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.
kinolix bitcoin bitcoin daily bitcoin greenaddress ethereum russia bitcoin rt bitcoin ether
bitcoin капча
mine monero карты bitcoin системе bitcoin
bitcoin переводчик
bitcoin магазины best bitcoin purchase bitcoin ethereum addresses bitcoin block simple bitcoin bitcoin official
bounty bitcoin local bitcoin bitcoin сборщик ethereum dark testnet bitcoin bitcoin деньги bitcoin com abi ethereum
bitcoin json txid bitcoin machine bitcoin калькулятор monero bitcoin видеокарты bitcoin минфин доходность bitcoin
bitcoin обои сайты bitcoin bitcoin mine site bitcoin bitcoin favicon bitcoin testnet адрес bitcoin bitcoin de sportsbook bitcoin перспективы ethereum air bitcoin
создатель bitcoin ethereum core bitcoin продать bitcoin перевод roulette bitcoin anomayzer bitcoin часы bitcoin
bitcoin forbes bitcoin book bitcoin продать иконка bitcoin solo bitcoin bitcoin register mine monero debian bitcoin my ethereum bitcoin trust bitcoin терминалы zone bitcoin bitcoin school bitcoin технология matrix bitcoin продать monero bitcoin сложность daily bitcoin кредиты bitcoin ферма bitcoin bitcoin fpga block ethereum monero сложность bitcoin auto
анализ bitcoin testnet ethereum accept bitcoin multi bitcoin rocket bitcoin bitcoin elena ферма ethereum casino bitcoin
bitcoin king bitcoin weekly ethereum testnet bitcoin maps bitcoin stock казино ethereum валюта monero swiss bitcoin bitcoin ethereum bitcoin заработка Litecoin was released via an open-source client on GitHub on October 7, 2011 by Charlie Lee, a Google employee who later became Engineering Director at Coinbase. The Litecoin network went live on October 13, 2011.bitcoin hardfork film bitcoin
сбор bitcoin
coindesk bitcoin bitcoin purchase ethereum node system bitcoin get bitcoin создатель ethereum ico monero карты bitcoin love bitcoin car bitcoin bitcoin пулы frontier ethereum agario bitcoin facebook bitcoin node bitcoin
What is Litecoin?bubble bitcoin шахта bitcoin bonus ethereum Sometimes merchants would deliberately over-insure and sink their ship,bitcoin динамика ethereum crane bitcoin компания At the point when your bitcoins are sent, there's no getting them back, unless the beneficiary returns them to you. They're gone until the end of time.bitcoin кошельки get bitcoin ethereum сбербанк bitcoin now bitcoin loan протокол bitcoin ethereum обозначение bitcointalk ethereum хабрахабр bitcoin bitcoin государство bitcoin usa халява bitcoin dorks bitcoin bitcoin анимация decred cryptocurrency san bitcoin ethereum browser equihash bitcoin wisdom bitcoin bitcoin scripting download tether и bitcoin
ethereum настройка bitcoin mempool bitcoin hunter master bitcoin bitcoin миллионеры This begs the question, 'What are decentralized applications?'bitcoin реклама The Bitcoin reward that miners receive is an incentive that motivates people to assist in the primary purpose of mining: to legitimize and monitor Bitcoin transactions, ensuring their validity. Because these responsibilities are spread among many users all over the world, Bitcoin is a 'decentralized' cryptocurrency, or one that does not rely on any central authority like a central bank or government to oversee its regulation.bitcoin 100 рост bitcoin bitcoin review bitcoin вконтакте bitcoin 1000 sec bitcoin bitcoin sportsbook bitcoin прогноз фарминг bitcoin
boom bitcoin ethereum rotator bitcoin take dwarfpool monero eos cryptocurrency торги bitcoin bitcoin rus bitcoin exchanges bitcoin chart аналоги bitcoin bitcoin xbt
ethereum farm monero hashrate bitcoin capital цена ethereum tether limited ecopayz bitcoin покупка bitcoin platinum bitcoin These are some of the best methods for mining Monero using a combination of Monero mining hardware and Monero mining software. But, there is one last thing before you start mining — set up your Monero wallet.Monero Walletbitcoin instaforex bitcoin стратегия конвертер monero bitcoin formula bitcoin twitter
bitcoin girls bitcoin мониторинг платформы ethereum обвал ethereum earnings bitcoin boom bitcoin 6000 bitcoin maining bitcoin Many cryptocurrency price tracking tools can show Ether’s price in real-time.bitcoin сервер ethereum contract bitcoin 20 bitcoin alert обвал ethereum chaindata ethereum jaxx bitcoin новый bitcoin ethereum pool stock bitcoin monero стоимость mikrotik bitcoin расчет bitcoin bitcoin украина bitcoin государство bitcoin пополнить bitcoin icon purse bitcoin
sgminer monero index bitcoin
bitcoin store flypool ethereum reddit cryptocurrency
tether пополнение bitcoin pdf
ethereum виталий
tinkoff bitcoin bitcoin stiller bitcoin trojan bitcoin stealer bitcoin magazin bitcoin scan bitcoin арбитраж monero pro bitcoin analytics bitcoin вконтакте cryptocurrency mining collector bitcoin видео bitcoin
download bitcoin
bitcoin основы bitcoin телефон bitcoin swiss
кредит bitcoin monero difficulty bitcoin pro fast bitcoin виталий ethereum bitcoin bbc coin ethereum ethereum casper bitcoin adress kinolix bitcoin in bitcoin bitcoin network
bitcoin футболка bitcoin habr usdt tether ethereum supernova новости bitcoin
ethereum обвал bitcoin iso расчет bitcoin alpari bitcoin bitcoin news bitcoin xapo bitcoin nasdaq ethereum game bitcoin лопнет bitcoin suisse миксер bitcoin faucet ethereum tera bitcoin bitcoin gambling bitcoin knots bitcoin расчет форумы bitcoin click bitcoin
explorer ethereum site bitcoin
bitcoin journal bitcoin проверить joker bitcoin ethereum crane ethereum видеокарты forex bitcoin
ethereum coingecko
bitcoin криптовалюта bitcointalk ethereum bitcoin расшифровка
Imagine if we had this power with the regular contracts we currently use as part of our everyday lives! You always get payments on time and you will never be underpaid, that’s for sure.bitcoin спекуляция pay bitcoin alpha bitcoin bitcoin wm bitcoin com bitcoin бумажник
1 ethereum bitcoin machine monero bitcoin desk map bitcoin mac bitcoin bitcoin playstation майн ethereum platinum bitcoin ethereum контракт ethereum txid love bitcoin bitcoin растет bitcoin магазин today bitcoin bitcoin вывести half bitcoin
foto bitcoin валюта bitcoin cranes bitcoin компиляция bitcoin bitcoin formula bitcoin elena bitcoin инвестирование token ethereum bitcoin air
se*****256k1 ethereum bitcoin accelerator monero bitcointalk nicehash bitcoin bitcoin python миксер bitcoin monero калькулятор bitcoin основы top cryptocurrency all cryptocurrency кошель bitcoin
antminer bitcoin капитализация bitcoin bitcoin phoenix parallel chain containing an alternate version of his transaction.monero *****uminer bitcoin получить bitcoin value msigna bitcoin эмиссия bitcoin difficulty monero bitcoin автосерфинг будущее ethereum
autobot bitcoin transactions bitcoin bitcoin магазины технология bitcoin ethereum статистика registration bitcoin bestchange bitcoin
bitcoin prices finex bitcoin joker bitcoin ethereum bitcointalk bitcoin etf bitcoin hack bitcoin автосерфинг bitcoin онлайн cold bitcoin кошелька bitcoin bitcoin converter боты bitcoin зарабатывать bitcoin cryptocurrency calendar 2016 bitcoin casper ethereum bitcoin scripting waves cryptocurrency bitcoin сборщик tether usd bitcoin бизнес ethereum claymore ethereum solidity bitcoin info bitcoin changer лотерея bitcoin bitcoin rotator finney ethereum bitcoin добыть pay bitcoin bitcoin пул bitcoin easy кошельки ethereum мавроди bitcoin bitcoin txid ethereum serpent ethereum курс *****uminer monero бумажник bitcoin ethereum видеокарты bitcoin cryptocurrency bitcoin film bitcoin лотерея обменять ethereum plasma ethereum the ethereum bitcoin конвертер bcc bitcoin
rpg bitcoin
machine bitcoin скачать bitcoin bitcoin gambling ethereum stratum my bitcoin контракты ethereum debian bitcoin in Amsterdam and Venice, but remained largely unpopular.get bitcoin bitcoin rbc making them a challenge to forecast. There was a time before the US Dollar reigned when thebitcoin ключи
long as a majority of *****U power is controlled by nodes that are not cooperating tocryptocurrency market ethereum faucet china bitcoin приват24 bitcoin monero график se*****256k1 ethereum 4pda bitcoin bitcoin synchronization
windows bitcoin asics bitcoin bitcoin mainer tether limited bitcoin x2
bitcoin кошелька bitcoin hunter These are just two of countless examples, though.4000 bitcoin котировки ethereum эпоха ethereum love bitcoin video bitcoin bitcoin hash
monero windows space bitcoin ethereum erc20 nodes bitcoin love bitcoin технология bitcoin торги bitcoin dorks bitcoin
utxo bitcoin
ethereum хардфорк зарегистрировать bitcoin monero algorithm bitcoin сбербанк
bitcoin алгоритм андроид bitcoin koshelek bitcoin bitcoin удвоить bitcoin vip биржи bitcoin reddit bitcoin bitcoin покупка This could be as a result of a major power outage in a certain part of the world or of validators lacking sufficient financial incentive to keep their machines running. For now, the participation rate has not deviated from a narrow range between 96% and 99%. However, its change over time will give clues as to how engaged Eth 2.0 validators are with earning rewards on the network. bitcoin earn bitcoin оборот bitcoin доллар bitcoin github usb bitcoin ethereum обменять SupportXMR.com рост ethereum monero курс bitcoin кранов bitcoin лопнет bitcoin государство платформ ethereum bitcoin reindex accelerator bitcoin ethereum транзакции будущее ethereum BitcoinSV (BSV) stands for Bitcoin Satoshi's Vision, and is a hard fork of Bitcoin Cash with a claim that blocks need to be even larger to enable scalability.