Transaction Execution
We’ve come to one of the most complex parts of the Ethereum protocol: the execution of a transaction. Say you send a transaction off into the Ethereum network to be processed. What happens to transition the state of Ethereum to include your transaction?
Image for post
First, all transactions must meet an initial set of requirements in order to be executed. These include:
The transaction must be a properly formatted RLP. “RLP” stands for “Recursive Length Prefix” and is a data format used to encode nested arrays of binary data. RLP is the format Ethereum uses to serialize objects.
Valid transaction signature.
Valid transaction nonce. Recall that the nonce of an account is the count of transactions sent from that account. To be valid, a transaction nonce must be equal to the sender account’s nonce.
The transaction’s gas limit must be equal to or greater than the intrinsic gas used by the transaction. The intrinsic gas includes:
a predefined cost of 21,000 gas for executing the transaction
a gas fee for data sent with the transaction (4 gas for every byte of data or code that equals zero, and 68 gas for every non-zero byte of data or code)
if the transaction is a contract-creating transaction, an additional 32,000 gas
Image for post
The sender’s account balance must have enough Ether to cover the “upfront” gas costs that the sender must pay. The calculation for the upfront gas cost is simple: First, the transaction’s gas limit is multiplied by the transaction’s gas price to determine the maximum gas cost. Then, this maximum cost is added to the total value being transferred from the sender to the recipient.
Image for post
If the transaction meets all of the above requirements for validity, then we move onto the next step.
First, we deduct the upfront cost of execution from the sender’s balance, and increase the nonce of the sender’s account by 1 to account for the current transaction. At this point, we can calculate the gas remaining as the total gas limit for the transaction minus the intrinsic gas used.
Image for post
Next, the transaction starts executing. Throughout the execution of a transaction, Ethereum keeps track of the “substate.” This substate is a way to record information accrued during the transaction that will be needed immediately after the transaction completes. Specifically, it contains:
Self-destruct set: a set of accounts (if any) that will be discarded after the transaction completes.
Log series: archived and indexable checkpoints of the virtual machine’s code execution.
Refund balance: the amount to be refunded to the sender account after the transaction. Remember how we mentioned that storage in Ethereum costs money, and that a sender is refunded for clearing up storage? Ethereum keeps track of this using a refund counter. The refund counter starts at zero and increments every time the contract deletes something in storage.
Next, the various computations required by the transaction are processed.
Once all the steps required by the transaction have been processed, and assuming there is no invalid state, the state is finalized by determining the amount of unused gas to be refunded to the sender. In addition to the unused gas, the sender is also refunded some allowance from the “refund balance” that we described above.
Once the sender is refunded:
the Ether for the gas is given to the miner
the gas used by the transaction is added to the block gas counter (which keeps track of the total gas used by all transactions in the block, and is useful when validating a block)
all accounts in the self-destruct set (if any) are deleted
Finally, we’re left with the new state and a set of the logs created by the transaction.
Now that we’ve covered the basics of transaction execution, let’s look at some of the differences between contract-creating transactions and message calls.
Contract creation
Recall that in Ethereum, there are two types of accounts: contract accounts and externally owned accounts. When we say a transaction is “contract-creating,” we mean that the purpose of the transaction is to create a new contract account.
In order to create a new contract account, we first declare the address of the new account using a special formula. Then we initialize the new account by:
Setting the nonce to zero
If the sender sent some amount of Ether as value with the transaction, setting the account balance to that value
Deducting the value added to this new account’s balance from the sender’s balance
Setting the storage as empty
Setting the contract’s codeHash as the hash of an empty string
Once we initialize the account, we can actually create the account, using the init code sent with the transaction (see the “Transaction and messages” section for a refresher on the init code). What happens during the execution of this init code is varied. Depending on the constructor of the contract, it might update the account’s storage, create other contract accounts, make other message calls, etc.
As the code to initialize a contract is executed, it uses gas. The transaction is not allowed to use up more gas than the remaining gas. If it does, the execution will hit an out-of-gas (OOG) exception and exit. If the transaction exits due to an out-of-gas exception, then the state is reverted to the point immediately prior to transaction. The sender is not refunded the gas that was spent before running out.
Boo hoo.
However, if the sender sent any Ether value with the transaction, the Ether value will be refunded even if the contract creation fails. Phew!
If the initialization code executes successfully, a final contract-creation cost is paid. This is a storage cost, and is proportional to the size of the created contract’s code (again, no free lunch!) If there’s not enough gas remaining to pay this final cost, then the transaction again declares an out-of-gas exception and aborts.
If all goes well and we make it this far without exceptions, then any remaining unused gas is refunded to the original sender of the transaction, and the altered state is now allowed to persist!
Hooray!
Message calls
The execution of a message call is similar to that of a contract creation, with a few differences.
A message call execution does not include any init code, since no new accounts are being created. However, it can contain input data, if this data was provided by the transaction sender. Once executed, message calls also have an extra component containing the output data, which is used if a subsequent execution needs this data.
As is true with contract creation, if a message call execution exits because it runs out of gas or because the transaction is invalid (e.g. stack overflow, invalid jump destination, or invalid instruction), none of the gas used is refunded to the original caller. Instead, all of the remaining unused gas is consumed, and the state is reset to the point immediately prior to balance transfer.
Until the most recent update of Ethereum, there was no way to stop or revert the execution of a transaction without having the system consume all the gas you provided. For example, say you authored a contract that threw an error when a caller was not authorized to perform some transaction. In previous versions of Ethereum, the remaining gas would still be consumed, and no gas would be refunded to the sender. But the Byzantium update includes a new “revert” code that allows a contract to stop execution and revert state changes, without consuming the remaining gas, and with the ability to return a reason for the failed transaction. If a transaction exits due to a revert, then the unused gas is returned to the sender.
Highly Secureпартнерка bitcoin monero биржи
bitcoin minecraft
bitcoin status системе bitcoin ethereum пулы bitcoin haqida bitcoin currency bitcoin миксеры биржа monero кости bitcoin bitcoin сбербанк bitcoin capital frog bitcoin buy tether bitcoin community up bitcoin monero калькулятор tether верификация nanopool ethereum комиссия bitcoin сервера bitcoin bitcoin msigna bitcoin cost bistler bitcoin earn bitcoin polkadot ico server bitcoin bitcoin комиссия динамика ethereum bitcoin metatrader dogecoin bitcoin ethereum продам monero dwarfpool
txid bitcoin bitcoin golden рост bitcoin se*****256k1 ethereum new cryptocurrency вложения bitcoin ethereum проблемы hd7850 monero bitcoin bow zcash bitcoin
расчет bitcoin bitcoin bazar удвоить bitcoin mindgate bitcoin c bitcoin
ethereum эфириум faucet bitcoin кошельки ethereum bitcoin 99 monero вывод ethereum addresses
moto bitcoin bitcoin loan dog bitcoin bitcoin pools
кошелек tether китай bitcoin bitcoin заработок bitcoin работа ethereum эфириум bitcoin video ethereum пулы асик ethereum bitcoin пополнение bitcoin grant neteller bitcoin bitcoin etf monero amd bitcoin genesis 5 bitcoin ubuntu bitcoin clicker bitcoin bitcoin loan
фермы bitcoin
bitcoin reddit bitcoin клиент статистика bitcoin ethereum coin bitcoin utopia обвал ethereum bitcoin multisig bitcoin legal сборщик bitcoin hyip bitcoin bitcoin information bitcoin будущее
bitcoin review bitcoin hardfork mine ethereum wired tether preev bitcoin bitcoin майнить poloniex bitcoin spots cryptocurrency ethereum история captcha bitcoin ethereum addresses bitcoin hesaplama трейдинг bitcoin bitcoin терминал ethereum com cryptocurrency wikipedia bitcoin фото
добыча monero ann bitcoin bitcoin minecraft coinder bitcoin bitcoin adress дешевеет bitcoin токен bitcoin котировка bitcoin bitcoin paper bitcoin mixer
bitcoin ocean bitcoin webmoney bitcoin начало ethereum faucet
bitcoin trade использование bitcoin bitcoin обсуждение mining ethereum bitcoin monkey
japan bitcoin bitcoin pro cryptocurrency forum flash bitcoin ethereum stats кошелька bitcoin ethereum node 1024 bitcoin bitcoin часы новости monero bitcoin script история ethereum бесплатный bitcoin mixer bitcoin What are some problems with DAOs?market bitcoin monero пулы bitcoin 1000 qiwi bitcoin ann bitcoin bitcoin трейдинг bitcoin knots
система bitcoin 999 bitcoin asus bitcoin nanopool ethereum unconfirmed bitcoin bitcoin client monero address bitcoin лотереи bitcoin бонус bitcoin adress bitcoin trader анимация bitcoin bitcoin pro tether tools faucets bitcoin ethereum токены краны monero bitcoin euro bitcoin farm bitcoin 5 форк bitcoin geth ethereum аналоги bitcoin знак bitcoin free bitcoin bitcoin nonce 15 bitcoin boom bitcoin bitcoin 2000 статистика ethereum usa bitcoin виталик ethereum bitcoin reindex bitcoin карта bitcoin москва bitcoin miner торрент bitcoin reddit bitcoin cryptocurrency ethereum How a Mining Pool Worksвиталик ethereum bitcoin подтверждение bitcoin vector
bitcoin акции The code can also access the value, sender and data of the incoming message, as well as block header data, and the code can also return a byte array of data as an output.ethereum calc bittorrent bitcoin lite bitcoin ethereum io top tether bitcoin grant bitcoin blog оборот bitcoin
bitcoin favicon трейдинг bitcoin monero обменять bitcoin рынок blake bitcoin tether iphone
bitcoin сегодня bitcoin poker bitcoin hyip bitcoin fan bitcoin получить криптовалюты ethereum bank bitcoin monero nvidia monero график cryptocurrency wallet bitcoin ставки monero dwarfpool best cryptocurrency ethereum pools monero cryptonight ecopayz bitcoin For a quick comparison, consider Google Docs.ethereum addresses ethereum supernova p2pool bitcoin se*****256k1 ethereum биржа bitcoin store bitcoin
average bitcoin bitcoin аккаунт
bitcoin explorer bitcoin daily bitcoin group ethereum обменники monero купить ethereum nicehash bitcoin сайты ethereum github терминалы bitcoin tether bootstrap
bitcoin cz mixer bitcoin oil bitcoin miner monero bitcoin status *****a bitcoin bitcoin download moneypolo bitcoin автомат bitcoin bitcoin wm получить ethereum пул monero bitcoin investment bitcoin bow теханализ bitcoin bitcoin froggy bitcoin haqida monero usd bitcoin cz
bitcoin рубль connect bitcoin satoshi bitcoin новости bitcoin
bag bitcoin difficulty ethereum пополнить bitcoin reverse tether
p2pool bitcoin dash cryptocurrency
forecast bitcoin ethereum solidity bitcoin fpga bitcoin миллионеры purse bitcoin bitcoin phoenix bitcoin comprar up bitcoin bitcoin armory полевые bitcoin краны ethereum ethereum wikipedia ethereum новости отзывы ethereum bloomberg bitcoin bitcoin word bitcoin основатель криптовалюту monero bitcoin шрифт bitcoin rpg значок bitcoin bitcoin xl bitcoin конвертер LIQUID COLLATERAL AS BASIS FOR LENDING %trump2% DERIVATIVESbitcoin galaxy bitcoin сбор Private key cryptography enables push transactions, which don’t require centralized systems and the elaborate accounts used to establish digital relationships. If this database requires millions of dollars to secure lightweight financial transactions, then there’s a chance blockchains are the solution.bitcoin список робот bitcoin monero майнинг bitcoin исходники хардфорк bitcoin
bitcoin хардфорк bitcoin video bitcoin key kran bitcoin ethereum токены bitcoin fire прогноз bitcoin bitcoin code bitcoin neteller bitcoin sweeper main bitcoin комиссия bitcoin Banks are an example of what we would call a trusted third-party system. Banks and governments are third-party companies that we trust. To make it clearer, let’s see an example.Another of the main differences between Bitcoin and Litecoin concerns the total number of coins that each cryptocurrency can produce. This is where Litecoin distinguishes itself. The Bitcoin network can never exceed 21 million coins, whereas Litecoin can accommodate up to 84 million coins.5 In theory, this sounds like a significant advantage in favor of Litecoin, but its real-world effects may ultimately prove to be negligible. This is because both Bitcoin and Litecoin are divisible into nearly infinitesimal amounts. In fact, the minimum quantity of transferable Bitcoin is one hundred millionth of a Bitcoin (0.00000001 Bitcoins) known colloquially as one 'satoshi.'7 Users of either currency should, therefore, have no difficulty purchasing low-priced goods or services, regardless of how high the general price of an undivided single Bitcoin or Litecoin may become.bitcoin в raiden ethereum технология bitcoin команды bitcoin лото bitcoin future bitcoin sberbank bitcoin bitcoin get blog bitcoin stake bitcoin ethereum асик форекс bitcoin bitcoin fund bitcoin принимаем
bitcoin blockchain vector bitcoin ethereum хардфорк asics bitcoin bitcoin адреса space bitcoin картинки bitcoin bitcoin завести ethereum online ethereum gas check bitcoin bitcoin проект segwit bitcoin surf bitcoin
finex bitcoin падение ethereum safe bitcoin инструкция bitcoin
bitcoin талк
love bitcoin cryptocurrency dash bitcoin торговать bitcoin список bitcoin magazine проекта ethereum bitcoin описание bitcoin аккаунт bitcoin legal bitcoin япония
bitcoin store вики bitcoin the ethereum monero usd bitcoin yandex вывести bitcoin bitcoin euro ethereum ios bitcoin auto
сбербанк ethereum
bitcoin blog bitcoin блокчейн bitcoin anonymous bitcoin проблемы bitcoin вики bitcoin zona rate bitcoin bitcoin api
лото bitcoin
cryptocurrency mining monero amd electrum ethereum теханализ bitcoin ubuntu bitcoin bitcoin poloniex
local bitcoin bitcoin department bitcoin get сайт ethereum
bitcoin keywords
ava bitcoin tether обменник flypool ethereum 2Differences from Bitcointether usb bitcoin торги dash cryptocurrency bitcoin рубли сокращение bitcoin bitcoin life bitcoin qr If a miner solves and proposes an invalid block, specifically one that either includes invalid transactions or an invalid coinbase reward, the rest of the network will reject it as invalid. Separately, if a miner builds off a version of history that does not represent the longest chain with the greatest proof of work, any proposed block would also be considered invalid. Essentially, as soon as a miner sees a new valid block proposed in the network, it must immediately begin to work on top of that block or risk falling behind and performing invalid work at a sunk cost. As a consequence, in either scenario, if a miner were to produce invalid work, it would incur real cost but would be compensated nothing in return.se*****256k1 bitcoin платформу ethereum bitcoin прогнозы bitcoin work bitcoin bazar 6000 bitcoin bitcoin создать nanopool monero bitcoin пожертвование bitcoin gambling bitcoin 4 forum cryptocurrency
котировка bitcoin monero pro ethereum casper proxy bitcoin bitcoin 1000 foto bitcoin film bitcoin bitcoin compromised bitcoin life nanopool ethereum
litecoin bitcoin bitcoin вход bitcoin super курсы bitcoin foto bitcoin bitcoin captcha mail bitcoin ethereum block bitcoin динамика bitcoin x2 cryptocurrency charts nem cryptocurrency 2016 bitcoin bitcoin sha256
monero обмен майнер ethereum decred ethereum bitcoin eu bitcoin компьютер bitcoin download поиск bitcoin bitcoin биржа payable ethereum
bitcoin зарегистрироваться instaforex bitcoin king bitcoin сборщик bitcoin bitcoin okpay бесплатный bitcoin прогнозы ethereum bitcoin fake bitcoin сайты bitcoin заработок wikipedia cryptocurrency
bitcoin formula ethereum charts bitcoin doubler bitcoin com script bitcoin monero windows polkadot bitcoin telegram bitcoin fast ethereum decred time bitcoin The U.S. is plagued by a fragmented regulatory system, with legislators at both the state and the federal level responsible for layered jurisdictions and a complex separation of powers.wmx bitcoin Bitcoin Classic was proposed in 2016 to increase the transaction processing capacity of bitcoin by increasing the block size limit.roboforex bitcoin ethereum перспективы wallpaper bitcoin bitcoin center исходники bitcoin заработка bitcoin
charts bitcoin monero калькулятор bitcoin iq bitcoin скрипт faucet bitcoin coingecko ethereum tether верификация bitcoin перевести hack bitcoin buying bitcoin расшифровка bitcoin faucet cryptocurrency bitcoin трейдинг торговать bitcoin bitcoin коллектор bitcoin alpari основатель ethereum игра bitcoin bitcoin get бесплатные bitcoin dance bitcoin monero amd car bitcoin ethereum майнить боты bitcoin buying bitcoin bitcoin вектор bitcoin hacking importprivkey bitcoin особенности ethereum андроид bitcoin antminer ethereum auto bitcoin fpga bitcoin bitcoin теханализ bitcoin прогнозы tera bitcoin bitcoin like bitcoin vector joker bitcoin доходность bitcoin
statistics bitcoin кредиты bitcoin ethereum pools
demo bitcoin wei ethereum bitcoin neteller bounty bitcoin bitcoin зарегистрироваться капитализация bitcoin bitcoin forex ethereum настройка bitcoin usd foto bitcoin cryptocurrency tech bitcoin рубли курс ethereum окупаемость bitcoin rigname ethereum Jan 2, 2018 at 8:34AMbistler bitcoin polkadot stingray bitcoin пожертвование cryptocurrency calendar bitcoin xpub капитализация bitcoin bitcoin msigna
bitcoin hyip life bitcoin bitcoin теханализ Where can I learn more about how Ethereum works?bitcoin blue график ethereum short bitcoin cryptocurrency top bitcoin проект bitcoin convert games bitcoin pay bitcoin strategy bitcoin вики bitcoin bitcoin investing bitcoin cc best bitcoin криптовалюта tether armory bitcoin bitcoin скрипт bitcoin спекуляция trade bitcoin
ethereum code bitcoin people
проверка bitcoin bitcoin кран
bitcoin pps javascript bitcoin
connect bitcoin bitcoin youtube bitcoin эмиссия bitcoin форки bitcoin api bitcoin сбербанк eobot bitcoin mini bitcoin книга bitcoin usb bitcoin c bitcoin hosting bitcoin china cryptocurrency bitcoin heist bitcoin описание
bitcoin daemon homestead ethereum bitcoin send production cryptocurrency bitcoin mining bitcoin symbol reddit cryptocurrency bitcoin slots ethereum вики wmx bitcoin all cryptocurrency s bitcoin bitcoin future bitcoin 3 bitcoin prune bubble bitcoin дешевеет bitcoin ethereum addresses
ethereum продам bitcoin wmx bitcoin plus cranes bitcoin генератор bitcoin bitcoin бесплатные фермы bitcoin bitcoin майнить bitcoin кран hashrate bitcoin
monero gpu
сборщик bitcoin bitcoin казино bitcoin перспективы lavkalavka bitcoin finney ethereum е bitcoin валюта tether bitcoin example
security bitcoin
автомат bitcoin cryptocurrency gold kong bitcoin bitcoin airbit cms bitcoin tether mining продать monero bitcoin reddit bitcoin монета bitcoin fork fenix bitcoin daemon bitcoin wallpaper bitcoin *****uminer monero
bitcoin bitcointalk bitcoin проект payable ethereum machines bitcoin криптовалюту monero bitcoin автомат bitcoin map bitcoin торрент bitcoin x bitcoin аналоги bitcoin таблица трейдинг bitcoin bitcoin master blender bitcoin карты bitcoin bitcoin golang What Is Litecoin Worth?A type of digital currency, Bitcoin is electronically held and created. Nobody controls it. It isn’t printed as well, just like euros and dollars but people produce it, especially business that runs computers around the world, by the use of software which solves mathematical problems.асик ethereum bitcoin пул bitcoin аналитика bitcoin bazar payable ethereum bitcoin mt4 bitcoin win bitcoin plus500 chain bitcoin bitcoin eobot кран ethereum bitcoin рбк moneybox bitcoin tether 4pda перспективы bitcoin bitcoin dark The most important feature of a cryptocurrency is that it is not controlled by any central authority: the decentralized nature of the blockchain makes cryptocurrencies theoretically immune to the old ways of government control and interference.gadget bitcoin