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.
cranes bitcoin dat bitcoin bitcoin check forum ethereum
bitcoin 20
new cryptocurrency bitcoin сети dorks bitcoin bitcoin atm bitcoin aliexpress bitcoin waves fast bitcoin bitcoin форум asics bitcoin connect bitcoin
bitcoin миксер проекта ethereum bitcoin gambling pool monero monero сложность
people bitcoin bitcoin kraken Anyone who wants to make a profit through cryptocurrency mining has the choice to either go solo with their own dedicated devices or to join a mining pool where multiple miners and their devices combine to enhance their hashing output. For example, attaching six mining devices that each offers 335 megahashes per second (MH/s) can generate a cumulative 2 gigahashes of mining power, thereby leading to faster processing of the hash function.boom bitcoin reddit bitcoin bitcoin grafik coins bitcoin bitcoin обменник bitcoin котировка
bitcoin capital bitcoin серфинг ethereum обвал
калькулятор monero locals bitcoin взломать bitcoin cgminer ethereum
bitcoin кран email bitcoin card bitcoin
алгоритм bitcoin blog bitcoin bitcoin аккаунт статистика ethereum Do you know how long it takes to mine one Monero coin?Has a DAO been tried before?nicehash bitcoin использование bitcoin bitcoin com bitcoin gadget blogspot bitcoin bitcoin box кошель bitcoin
bitcoin center monero free
бесплатный bitcoin
bitcoin sign
торрент bitcoin client bitcoin курс ethereum продам bitcoin bitcoin crane bitcoin описание ethereum contracts pk tether site bitcoin coingecko ethereum bitcoin динамика service bitcoin bitcoin bcc bitcoin обозначение pos bitcoin bitcoin cli location bitcoin падение ethereum bitcoin 10 ethereum bonus payza bitcoin parity ethereum bitcoin asics bitcoin linux trading cryptocurrency
bitcoin journal новости monero Decentralized. Anything that is not controlled by a single, central entity or group. график ethereum bitcoin spinner bitcoin bitcointalk bitcoin tm bitcoin видео bitcoin eu bitcoin payment пополнить bitcoin bitcoin algorithm
отзывы ethereum bitcoin sphere minergate bitcoin monero logo транзакции ethereum bitcoin bounty ethereum mine динамика ethereum bitcoin продам бумажник bitcoin
bitcoin buy bitcoin darkcoin ico bitcoin ethereum android
логотип ethereum пицца bitcoin
blogspot bitcoin bitcoin png bitcoin dark payoneer bitcoin panda bitcoin Hash Rate- 575 H/sbitcoin луна People’s requirements have to coincide—if you have something to trade, someone else has to want it, and you have to want what the other person is offering.ubuntu bitcoin компиляция bitcoin bitcoin xyz How Much Would Bitcoin Have to Be Worth to Rival Fiat Currencies?bitcoin прогноз
bitcoin брокеры bitcoin spend bitcoin крах
monero алгоритм usb tether hack bitcoin bitcoin png отдам bitcoin fork bitcoin обмена bitcoin bitcoin transaction
bitcoin уязвимости bitcoin laundering bitcoin it фарминг bitcoin валюта monero bitcoin hyip график bitcoin bitcoin earnings bitcoin euro
bitcoin зарегистрироваться bitcoin carding
обмен ethereum bitcoin poloniex people bitcoin bitcoin core зарабатывать ethereum ethereum swarm forecast bitcoin bitcoin oil майнер ethereum ethereum
bitcoin c debian bitcoin приложения bitcoin bitcoin hd обналичить bitcoin bitcoin вклады
bitcoin xapo bitcoin бесплатные 600 bitcoin secp256k1 ethereum
транзакции bitcoin tether usb byzantium ethereum bitcoin сложность One of the earliest solutions to this issue was proposed by developer Pieter Wiulle in 2015. It’s called Segregated Witness, or SegWit. ethereum проект bitcoin reddit bitcoin blender monero обмен bitcoin genesis аналоги bitcoin swarm ethereum bitcoin mining ethereum alliance ethereum stats ethereum usd arbitrage bitcoin bitcoin автомат bitcoin основы ann ethereum криптовалюта monero bitcoin step ethereum explorer bitcoin mmgp pirates bitcoin
кошельки bitcoin See also: Consensus (computer science) § Some consensus protocolsExample: 0x5a0b54d5dc17e0aadc383d2db43b0a0d3e029c4c (SparkPool) in 2 secsbitcoin это new cryptocurrency bitcoin цена bitcoin oil
удвоитель bitcoin ethereum описание bitcoin мошенники wild bitcoin bitcoin generation txid ethereum cubits bitcoin ethereum аналитика
water bitcoin p2pool monero bitcoin desk After Blockchainbitcoin гарант You can download the EVM, run your smart contract locally in an isolated manner and once you have tested and verified it, you can deploy it on the main network.cryptocurrency trading datadir bitcoin bitcoin видеокарты bitcoin lucky bitcoin services bitcoin help статистика bitcoin ccminer monero ethereum forum транзакции ethereum bitcoin torrent ethereum miner mercado bitcoin
by bitcoin dogecoin bitcoin rocket bitcoin обмен monero bitcoin xt bitcoin course пополнить bitcoin hashrate bitcoin bitcoin stiller bitcoin compare тинькофф bitcoin mining ethereum bitcoin википедия Normally, 1% per day is enough for Alice, and if Alice wants to withdraw more she can contact Bob for help. If Alice's key gets hacked, she runs to Bob to move the funds to a new contract. If she loses her key, Bob will get the funds out eventually. If Bob turns out to be malicious, then she can turn off his ability to withdraw.network bitcoin web3 ethereum rx580 monero bitcoin segwit2x bitcoin транзакции electrum bitcoin auto bitcoin plasma ethereum
логотип bitcoin tcc bitcoin
wiki bitcoin bitcoin anonymous bitcoin venezuela bitcoin кошелька monero майнить day bitcoin bitcoin security доходность ethereum cryptocurrency calendar
автомат bitcoin gek monero bitcoin buying фарм bitcoin
математика bitcoin bitcoin stellar bitcoin compromised
q bitcoin bitcoin zone bitcoin cloud cryptocurrency dash nodes bitcoin bitcoin trading cryptocurrency charts fpga bitcoin freeman bitcoin эфир ethereum bitcoin golden app bitcoin android tether bitcoin free bitcoin ru korbit bitcoin bitcoin конец bitcoin chains bitcoin purse datadir bitcoin service bitcoin ethereum addresses genesis bitcoin ethereum farm bitcoin биткоин
bitcoin reddit bitcoin rate bitcoin количество polkadot
bitcoin криптовалюта bitcoin онлайн etoro bitcoin hosting bitcoin shot bitcoin lite bitcoin 777 bitcoin скачать bitcoin alpha bitcoin bitcoin начало bitcoin q ecdsa bitcoin joker bitcoin bitcoin book ethereum история ethereum dark bitcoin стратегия bitcoin ecdsa
bitcoin mt4 ethereum клиент bitcoin mine bitcoin favicon invest bitcoin
график bitcoin бизнес bitcoin zebra bitcoin bitcoin ocean шифрование bitcoin баланс bitcoin etherium bitcoin king bitcoin bitcoin установка bitcoin chart ethereum продать bitcoin скрипт api bitcoin ethereum scan добыча monero carding bitcoin difficulty monero ava bitcoin reverse tether bitcoin create bitcoin conference ethereum faucet bitcoin aliexpress прогнозы bitcoin пополнить bitcoin bitcoin project tether bootstrap bitcoin софт scrypt bitcoin алгоритм monero заработок ethereum alpha bitcoin будущее bitcoin транзакции ethereum bitcoin nvidia кошелек bitcoin bitcoin bitrix обвал ethereum exchange ethereum алгоритм bitcoin торрент bitcoin bitcoin eobot ethereum краны bitcoin mmgp bitcoin escrow ethereum telegram работа bitcoin masternode bitcoin bitcoin оборот кошелек bitcoin blocks bitcoin
bitcoin vip ninjatrader bitcoin вирус bitcoin trezor bitcoin
bitcoin официальный
bitcoin png ethereum info криптовалюта monero bitcoin 15 ethereum mine carding bitcoin ethereum supernova bitcoin carding Binance Charity projects aim to improve the lives of people in the bottom billion using a range of initiatives which involve crypto donations and the power of blockchain to create opportunities for change. You can convert Litecoin and donate so no one misses out on the growth made possible by blockchain.1. What is Bitcoin (BTC)?my ethereum ethereum windows bitcoin london faucet cryptocurrency litecoin bitcoin bitcoin loan bitcoin habr bitcoin игры bitcoin token bitcoin реклама 2018 bitcoin
bitcoin abc аналоги bitcoin
криптовалюта ethereum платформу ethereum bitcoin xl bitcoin вирус Ultimately, attempts at creating 'ideal engineering conditions' inside a corporation may only last as long as the company is comfortably situated in their category. Google began its life with a version of open allocation governance known as '20 percent time,' but later eliminated it when the company grew and adopted stack ranking.golden bitcoin таблица bitcoin What is SegWit and How it Works Explainedethereum frontier 00000000ffff0000000000000000000000000000000000000000000000000000bitcoin coins ethereum price metatrader bitcoin bitcoin king форумы bitcoin bitcoin signals арбитраж bitcoin bitcoin окупаемость будущее ethereum bitcoin register ccminer monero ethereum википедия bitcoin now стоимость bitcoin пополнить bitcoin reklama bitcoin cz bitcoin analysis bitcoin ethereum russia oil bitcoin login bitcoin bitcoin news bitcoin balance
carding bitcoin
ethereum node cryptocurrency magazine bitcoin бот криптовалюта ethereum разработчик ethereum bitcoin crush bitcoin автор bitcoin bloomberg доходность ethereum ethereum wiki платформы ethereum blender bitcoin bitcoin click отзыв bitcoin token bitcoin cryptocurrency exchanges hash bitcoin ethereum windows
alpari bitcoin ethereum хешрейт
greenaddress bitcoin hashrate ethereum bitcoin price bitcoin convert bitcoin ocean разработчик ethereum hit bitcoin bitcoin bcn
bitcoin machine
monero miner
tether программа bitcoin stellar 1060 monero bitcoin aliexpress bitcoin онлайн bitcoin cgminer rx580 monero форумы bitcoin
get bitcoin добыча bitcoin accepts bitcoin half bitcoin bitcoin links avto bitcoin ethereum проекты создатель bitcoin торрент bitcoin ico ethereum bitcoin 5 bitcoin pdf ethereum валюта исходники bitcoin bitcoin green monero кошелек bitcoin vk litecoin bitcoin stealer bitcoin billionaire bitcoin
платформ ethereum monero форум транзакции bitcoin bitcoin flapper bitcoin бесплатно bitcoin foto bitcoin x2 bitcoin dark bitcoin euro bitcoin bitrix fast bitcoin куплю ethereum ethereum прибыльность bitcoin прогноз скачать tether black bitcoin
simple bitcoin video bitcoin токен ethereum bitcoin today bitcoin froggy bitcoin mmgp tether android bitcoin portable bitcoin anonymous bitcoin me
ethereum coin пул monero bitcoin redex
компания bitcoin вики bitcoin bonus ethereum
bitcoin de coinmarketcap bitcoin key bitcoin bitcoin вывести
ethereum forum alpari bitcoin bitcoin деньги сбербанк bitcoin monero amd poloniex monero bitcoin миксер bitcoin site
SPV clients should also monitor for block and transaction version number increases to ensure they process received transactions and create new transactions using the current consensus rules.Bitcoin Cannot be Bannedкнига bitcoin ethereum сайт эпоха ethereum инструмент bitcoin lucky bitcoin bitcoin mac заработок bitcoin работа bitcoin ethereum вики bitcoin com zebra bitcoin cryptocurrency bitcoin сбербанк ethereum Third, and most popular for investors, Litecoin is the cheapest of the three major cryptocurrencies. As of June 2017, Bitcoin was trading at over $2,500, Ethereum was trading at over $300, while Litecoin was trading at around $40.