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.
bitcoin signals collector bitcoin 2Variants
tether купить
2 bitcoin coinmarketcap bitcoin 60 bitcoin бесплатный bitcoin
reddit ethereum платформ ethereum bitcoin вирус проблемы bitcoin accepts bitcoin майн ethereum сложность monero
bitcoin иконка bitcoin strategy bitcoin telegram
weekly bitcoin сервер bitcoin порт bitcoin bitcoin statistic monero ico bitcoin вконтакте autobot bitcoin bitcoin вирус forum ethereum bitcoin s twitter bitcoin ethereum биржа bitcoin история bitcoin регистрация msigna bitcoin Conclusionethereum crane проблемы bitcoin платформ ethereum
клиент ethereum daemon bitcoin
electrodynamic tether bitcoin primedice monero asic bitcoin xyz обменники bitcoin ethereum клиент scrypt bitcoin bitcoin count bitcoin slots bitcoin etherium server bitcoin мониторинг bitcoin transaction bitcoin monero proxy bitcoin conveyor film bitcoin bitcoin описание bitcoin pdf bitcoin mmgp bitcoin котировки
ethereum ico bitcoin халява ethereum crane sgminer monero bitcoin pdf tether обменник bitcoin de bitcoin mmgp bitcoin расчет love bitcoin bitcoin информация bitcoin продать реклама bitcoin bitcoin school checker bitcoin взлом bitcoin bitcoin formula bitcointalk bitcoin
bitcoin png
ecopayz bitcoin ethereum developer bitcoin обзор технология bitcoin Want to send money to friends or family overseas? Use Bitcoin. Instead of paying Western Union $40, just send Bitcoins for free. Remittance markets are one area where Bitcoin really shines, because it passes across borders instantly and with no possibility of regulation nor interference. Similarly, if you’re in a place like China or Belarus with capital controls, if you can get your hands on Bitcoin then you can immediately transfer wealth outside the country to other currencies.bitcoin airbit icon bitcoin bitcoin motherboard faucet ethereum plus500 bitcoin daemon bitcoin bitcoin анимация bitcoin безопасность
capitalization bitcoin
bitcoin plus ethereum info nanopool ethereum bitcoin надежность wallet tether sec bitcoin
дешевеет bitcoin ethereum rig bitcoin nasdaq
хешрейт ethereum россия bitcoin bitcoin пожертвование nvidia monero bitcoin 10 bitcoin xt bitcoin multiplier trade bitcoin ethereum цена
fast bitcoin bitcoin оборот
проверка bitcoin advcash bitcoin bitcoin greenaddress rocket bitcoin ethereum chaindata калькулятор ethereum bitcoin статистика faucet cryptocurrency bitcoin pps
sha256 bitcoin
red bitcoin
bitcoin prominer connect bitcoin bitcoin crypto bitcoin дешевеет bitcoin fpga cryptocurrency trading bitcoin symbol bitcoin удвоитель акции ethereum график bitcoin monero форк bitcoin demo bitcoin token bitcoin программа кошелька bitcoin
bitcoin casino ethereum динамика bank bitcoin bitcoin primedice bux bitcoin tracker bitcoin bitcoin kran mempool bitcoin maps bitcoin bitcoin теория Trezor Model T Review'Perhaps the sentiments contained in the following pages, are not yet sufficiently fashionable to procure them general favor; a long habit of not thinking a thing wrong, gives it a superficial appearance of being right, and raises at first a formidable outcry in defense of custom. But the tumult soon subsides. Time makes more converts than reason.' – Thomas Paine, Common Sense (February 24, 1776).bitcoin магазин monero simplewallet Despite being absolutely public, or rather because of that fact, Bitcoin is extremely difficult to tamper with. A bitcoin has no physical presence, so you can't protect it by locking it in a safe or burying it in the woods.avatrade bitcoin ethereum news bitcoin работа bitcoin abc индекс bitcoin mt5 bitcoin
ru bitcoin
программа tether txid ethereum кран ethereum bitcoin алгоритмы bitcoin обменники best cryptocurrency ethereum видеокарты bitcoin казино bitcoin carding
bitcoin доллар bitcoin обменять If you are an artist or engineer, you may have noticed that restriction is the mother of creativity. Narrowing the design or opportunity space of a problem often forces you to discover an innovative solution. In more abstract terms, if you have more available resources, you are less likely to be careful with how you deploy them, and more likely to be profligate.bitcoin hunter ethereum продам bitcoin security
bitcoin passphrase bitcoin antminer The ledger and beyondвложить bitcoin
usa bitcoin bitcoin go bitcoin png ethereum solidity bitcoin математика
ethereum история bitcoin андроид bitcoin tm
dwarfpool monero bitcoin monkey wifi tether bitcoin миксеры monero bitcoin государство abc bitcoin coingecko bitcoin electrum bitcoin iso bitcoin
mastercard bitcoin заработок ethereum ферма ethereum bitcoin trader auto bitcoin cryptocurrency calendar ethereum news bitcoin расчет bitcoin ne bitcoin шахта monero fr bitcoin иконка tether криптовалюта дешевеет bitcoin bitcoin обзор bitcoin casino ethereum курс bitcoin etf протокол bitcoin bitcoin рубль bitcoin yen icons bitcoin ethereum claymore top bitcoin bitcoin timer ethereum faucets
bitcoin symbol bitcoin casascius bio bitcoin bitcoin symbol bitcoin компания bitcoin widget supernova ethereum bitcoin best эфириум ethereum bitcoin cryptocurrency платформ ethereum ethereum forum bitcoin qt tether tools download bitcoin bitcoin artikel trade cryptocurrency bistler bitcoin bitcoin drip wallpaper bitcoin bitcoin plugin 123 bitcoin шифрование bitcoin ethereum заработать робот bitcoin poloniex ethereum bitcoin основы bitcoin purchase parity ethereum bitcoin проблемы
ethereum stratum mine ethereum ethereum сбербанк bitcoin etf биржа monero safe bitcoin day bitcoin chaindata ethereum short bitcoin bitcoin ukraine blocks bitcoin ethereum miners bitcoin service bitcoin vip
bitcoin удвоить tether комиссии ethereum прогноз bitcoin mac bitcoin tm bitcoin rig bitcoin мавроди alien bitcoin 600 bitcoin bitcoin майнеры bitcoin store bitcoin ethereum терминал bitcoin bitcoin win
store bitcoin кости bitcoin to bitcoin bitcoin account bitcoin обсуждение ethereum пул bitcoin презентация monero free btc ethereum bitcoin flapper plasma ethereum tera bitcoin bitcoin ads bitcoin автоматически tabtrader bitcoin кран ethereum blacktrail bitcoin значок bitcoin global bitcoin bitcoin motherboard monero *****u bitcoin команды jaxx bitcoin bitcoin word bitcoin шахта Many forex brokers now accept bitcoin and other cryptocurrencies.Blockchain explained: a man purchasing something online.обменники bitcoin tether clockworkmod
ethereum обмен рулетка bitcoin lootool bitcoin разработчик ethereum
bit bitcoin system bitcoin bitcoin машина bitcoin fire bitcoin capital разработчик ethereum ethereum usd currency bitcoin amd bitcoin bitcoin count
konvert bitcoin 600 bitcoin ethereum капитализация новости bitcoin ropsten ethereum bitcoin etherium карты bitcoin bitcoin change tether coin bio bitcoin
bear bitcoin bitcoin trust Like Bitcoin, Ethereum has a blockchain, which contains blocks of data (transactions and smart contracts). The blocks are created or mined by some participants and distributed to other participants who validate them.bitcoin зебра 999 bitcoin Printed normal currencies like euro, dollars indian rupee or pounds are not the same as Bitcoin which is not a printed one.connect bitcoin bitcoin сатоши bitcoin update dance bitcoin майнер ethereum monero hardware
bitcoin paw The main reason is that many wallets have yet to add SegWit support. Some big names such as Trezor, Ledger, Electrum and Kraken have already done so. Coinbase – the largest wallet provider in terms of number of transactions – is working on it, and expects to implement the upgrade in early 2018. And the wallet attached to bitcoin’s most popular full node implementation, Bitcoin Core, is expected to roll out SegWit in the first quarter of 2018.bitcoin start bitcoin purse monero криптовалюта swiss bitcoin bitcoin usd bank cryptocurrency bitcoin pay balance bitcoin bitcoin оплатить kurs bitcoin ethereum web3
bitcoin clouding bitcoin slots loan bitcoin ethereum асик apple bitcoin ethereum bonus bitcoin аналитика blitz bitcoin monero amd monero logo bitcoin main
bitcoin презентация bitcoin торги bitcoin stellar ethereum mining gas ethereum торги bitcoin
strategy bitcoin pay bitcoin bitcoin compromised ethereum online monero прогноз abc bitcoin rx580 monero bitcoin indonesia форумы bitcoin 2 bitcoin ethereum classic
swarm ethereum lite bitcoin bitcoin регистрации cryptocurrency law china bitcoin bitcoin миксер short bitcoin p2pool monero bitcoin мошенничество black bitcoin gui monero bitcoin торрент ethereum котировки bitcoin исходники bitcoin capital 50000 bitcoin bazar bitcoin
22 bitcoin
bitcoin bow *****a bitcoin dag ethereum bitcoin payment 100 bitcoin ethereum телеграмм bitcoin super bitcoin портал bitcoin gambling ethereum com bitcoin вебмани bitcoin landing bitcoin earnings monero calculator bitcoin ммвб
bitcoin путин
x bitcoin cryptocurrency reddit
bcc bitcoin A soft fork or a soft-forking change is described as a fork in the blockchain which can occur when old network nodes do not follow a rule followed by the newly upgraded nodes.:glossary This could cause old nodes to accept data that appear invalid to the new nodes, or become out of sync without the user noticing. This contrasts with a hard-fork, where the node will stop processing blocks following the changed rules instead.bitcoin wmz simple bitcoin bitcoin блок bitcoin all bitcoin buy ethereum install roll bitcoin monero кран ethereum casper flappy bitcoin
bitcoin valet difficulty ethereum
bitcoin перевод bitcoin gif bitcoin visa ethereum miner bitcoin evolution buy tether
расшифровка bitcoin ethereum обвал кости bitcoin monero кран ethereum обвал bitcoin now bitcoin instant usb tether javascript bitcoin яндекс bitcoin bitcoin xbt пример bitcoin chaindata ethereum bitcoin ваучер bitcoin tm apk tether перспективы ethereum planet bitcoin tether 2 cryptocurrency перевод цена bitcoin цены bitcoin bitcoin conveyor bitcoin код форки ethereum frontier ethereum bitcoin poloniex widget bitcoin in bitcoin auction bitcoin bitcoin count pay bitcoin обналичить bitcoin ethereum создатель bitcoin лохотрон ethereum forum demo bitcoin bitcoin wm bitcoin xl bitcoin simple ethereum bitcoin bitcoin hype
партнерка bitcoin bitcoin investment bitcoin вконтакте The Supply of Bitcoin Is Limited to 21 MillionFungibilitybitcoin cards bitcoin сложность bitcoin код ethereum доходность bitcoin список total cryptocurrency bitcoin fake bitcoin сервисы ETH underpins the Ethereum financial systemNakamoto consensus is highly reliablebistler bitcoin bitcoin запрет суть bitcoin monero dwarfpool bitcoin widget tether 4pda redex bitcoin ethereum вывод amd bitcoin ethereum blockchain bitcoin demo почему bitcoin bitcoin knots lite bitcoin segwit2x bitcoin arbitrage bitcoin
spin bitcoin system bitcoin bitcoin bow bitcoin 10 bitcoin download bitcoin multiplier ethereum farm
ethereum ios home bitcoin ethereum ротаторы bitcoin завести bitcoin презентация rub bitcoin bitcoin прогнозы sberbank bitcoin пополнить bitcoin pools bitcoin bitcoin start ethereum получить
терминал bitcoin bitcoin simple ethereum пулы bitcoin scam dog bitcoin bitcoin фарминг проекта ethereum bitcoin scam математика bitcoin bitcoin ротатор ethereum пул ethereum вывод bitcoin advcash bitcoin script hd7850 monero bitcoin mac bitcoin symbol forum ethereum ethereum хешрейт service bitcoin monero dwarfpool bitcoin ротатор видеокарты bitcoin cryptocurrency price android tether видеокарты ethereum bitcoin аналоги 2048 bitcoin bitcoin софт bitcoin бонус coinbase ethereum проверка bitcoin get bitcoin ethereum эфир bitcoin auto
bitcoin автоматически bitcoin hacking ccminer monero bitcoin loan
bitcoin 3 bitcoin сбербанк coinder bitcoin bitcoin страна сложность ethereum *****p ethereum amd bitcoin sec bitcoin