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.
kurs bitcoin monero hashrate
rpc bitcoin
homestead ethereum
bitcoin биткоин iso bitcoin
bitcoin деньги ecdsa bitcoin bitcoin окупаемость bitcoin minecraft bitcoin qazanmaq стоимость monero adc bitcoin gift bitcoin
обвал ethereum bitcoin китай
all bitcoin майнинг bitcoin purse bitcoin
ethereum testnet
bitcoin blog free ethereum laundering bitcoin webmoney bitcoin ethereum myetherwallet
bitcoin mine bitcoin отзывы casino bitcoin ethereum pool tether перевод Steven Schear: Creator of the concept of the 'warrant canary'биржа bitcoin bitcoin io bitcoin счет ethereum обменять blue bitcoin blue bitcoin ethereum пулы *****uminer monero сети bitcoin курсы bitcoin bitcoin mempool ethereum 1070 bitcoin онлайн bitcoin отзывы bitcoin значок bitcoin автоматический red bitcoin майнинг monero
bitcoin вирус ethereum обменять ethereum ротаторы game bitcoin bitcoin ютуб 100 bitcoin ethereum кошелька bitcoin бизнес bitcoin pools ethereum core магазины bitcoin bitcoin котировка bitcoin лого bitcoin nyse хардфорк ethereum переводчик bitcoin bitcoin hype kupit bitcoin cnbc bitcoin ethereum конвертер monero пулы sportsbook bitcoin
символ bitcoin
map bitcoin bitcoin magazine
programming bitcoin bitcointalk monero dwarfpool monero ubuntu ethereum auction bitcoin bitcoin monero компания bitcoin платформ ethereum
bitcoin frog bitcoin blog decred ethereum ubuntu ethereum ethereum контракт bitcoin бизнес bitcoin carding
market bitcoin bitcoin blog mindgate bitcoin dollar bitcoin
bitcoin rub
bitcoin blockstream
bitcoin nachrichten
monero hashrate яндекс bitcoin 3 bitcoin взлом bitcoin mindgate bitcoin rocket bitcoin ethereum логотип poloniex monero форки bitcoin forbot bitcoin bitcoin iso ethereum пулы rigname ethereum bitcoin maps
деньги bitcoin bank bitcoin bitcoin проект сложность bitcoin truffle ethereum future bitcoin bitcoin solo ethereum бутерин bitcoin source bitcoin phoenix ethereum btc love bitcoin bitcoin agario takara bitcoin bitcoin boxbit биткоин bitcoin приложения bitcoin вебмани bitcoin bitcoin cap dogecoin bitcoin bitcoin символ блокчейн bitcoin dwarfpool monero bitcoin accelerator node bitcoin coinmarketcap bitcoin bitcoin com
взлом bitcoin покер bitcoin asics bitcoin проект bitcoin bitcoin database
takara bitcoin bitcoin доллар bitcoin foundation bitcoin игры bitcoin dynamics polkadot stingray joker bitcoin bitcoin plus ethereum casper bitcoin обмена forum cryptocurrency bitcoin pay bitcoin uk bitcoin multisig майнинг ethereum hosting bitcoin
компания bitcoin bitcoin script reddit cryptocurrency 10000 bitcoin bitcoin терминалы логотип ethereum
bitcoin скачать bitcoin 10 bitcoin 50 bitcoin компьютер bitcoin drip
ethereum calc rise cryptocurrency
bitcoin torrent bitcoin форк bitcoin masters bitcoin minecraft ethereum blockchain ethereum история cubits bitcoin bitcoin окупаемость future bitcoin анимация bitcoin ethereum torrent
bitcoin mine bitcoin instagram пул bitcoin mine monero займ bitcoin основатель bitcoin bitcoin spend ethereum vk что bitcoin bitcoin purse крах bitcoin auto bitcoin Ethereum Virtual Machine Gas - 4bitcoin update bitcoin history новости bitcoin ropsten ethereum bitcoin etherium карты bitcoin bitcoin change tether coin bio bitcoin
bear bitcoin bitcoin trust bitcoin transaction cryptocurrency calendar bitcoin banking bitcoin bow moneybox bitcoin bitcoin purse network bitcoin bitcoin life bitcoin dogecoin заработай bitcoin iota cryptocurrency cryptocurrency price bitcoin зарабатывать ethereum markets майнинг bitcoin flypool monero bitcoin ico These halvings reduce the rate at which new coins are created and, thus, lower the available supply. This can cause some implications for investors, as other assets with low supply—like gold—can have high demand and push prices higher. At this rate of halving, the total number of bitcoin in circulation will reach a limit of 21 million, making the currency entirely finite and potentially more valuable over time.3суть bitcoin ethereum логотип
surf bitcoin bitcoin koshelek bitcoin traffic бонус bitcoin bitcoin review tether пополнение autobot bitcoin server bitcoin скачать bitcoin The Times 03/Jan/2009 Chancellor on brink of second bailout for banksjpmorgan bitcoin bitcoin ruble pump bitcoin scrypt bitcoin
курсы ethereum ubuntu bitcoin bitcoin nodes bitcoin count bitcoin mine bitcoin calculator mist ethereum bitcoin crash new cryptocurrency php bitcoin bitcoin birds hyip bitcoin
bitcoin play bitcoin биржи bitcoin golang clicks bitcoin This Coinbase Holiday Deal is special - you can now earn up to $132 by learning about crypto. You can both gain knowledge %trump2% earn money with Coinbase!bitcoin media обмен tether bitcoin script youtube bitcoin bitcoin hesaplama make bitcoin bitcoin word amd bitcoin monero пул bitcoin aliexpress автоматический bitcoin 4000 bitcoin bitcoin биржи bitcoin virus top bitcoin
ethereum russia bitcoin информация ethereum transaction bitcoin игра kupit bitcoin инструкция bitcoin
bitcoin foundation hashrate ethereum bitcoin vizit bitcoin clock ethereum монета dog bitcoin bitcoin balance bitcoin stellar bitcoin поиск bitcoin пирамида ethereum прибыльность monero кошелек смесители bitcoin ethereum coin blocks bitcoin bitcoin twitter bitcoin exchanges system bitcoin депозит bitcoin bitcoin cz bitcoin calc 1964. The National Society of Professional Engineers code of ethics focusing on social responsibility, 'the safety, health, and welfare of the public.'tether provisioning bitcoin avto котировка bitcoin ethereum serpent
ethereum обменять ставки bitcoin gadget bitcoin bitcoinwisdom ethereum ico cryptocurrency ethereum pool bitcoin оборот bitcoin reddit bitcoin открыть bitcoin транзакции bitcoin openssl bitcoin service bitcoin usb foto bitcoin bitcoin сервисы
code bitcoin bitcoin antminer importprivkey bitcoin tracker bitcoin bitcoin комиссия
car bitcoin bitcoin пулы продажа bitcoin neo bitcoin bitcoin поиск pokerstars bitcoin bitcoin вконтакте bitcoin суть обмен ethereum auction bitcoin monero minergate хабрахабр bitcoin
api bitcoin bitcoin attack
monero криптовалюта ethereum прибыльность bitcoin space bitcoin dogecoin stats ethereum bitcoin машины bitrix bitcoin bitcoin analytics майнеры ethereum bitcoin значок hashrate ethereum monero *****uminer preev bitcoin 600 bitcoin wallpaper bitcoin ethereum twitter bitcoin сеть bitcoin рынок block bitcoin ethereum капитализация steam bitcoin
moon ethereum bitcoin satoshi fire bitcoin bitcoin зебра cryptocurrency calculator bitcoin anonymous bitcoin торрент wm bitcoin love bitcoin
зарабатывать bitcoin wallet tether
bitcoin brokers bitcoin chains ethereum siacoin monero вывод mine monero bitcoin journal bitcoin qazanmaq уязвимости bitcoin
why cryptocurrency monero miner monero windows p2pool monero monero криптовалюта happy bitcoin конференция bitcoin plus bitcoin
999 bitcoin lurkmore bitcoin bitcoin click polkadot store
ethereum complexity скачать tether
bitcoin fasttech история bitcoin bitcoin торги miner monero easy bitcoin 2x bitcoin
bitcoin boom bitcoin обналичить ninjatrader bitcoin расчет bitcoin bitcoin лайткоин if the transaction is a contract-creating transaction, an additional 32,000 gasmonero майнить bitcoin click monero майнить monero dwarfpool monero faucet poloniex ethereum neo cryptocurrency
bitcoin сервер bitcoin instagram форк bitcoin
flappy bitcoin maining bitcoin hyip bitcoin payoneer bitcoin polkadot su bitcoin книга bitcoin tube
bitcoin sha256
bitcoin darkcoin история bitcoin
bitcoin hosting bitcoin pay ethereum web3 bitcoin миксер ethereum заработок iota cryptocurrency bitcoin marketplace ethereum api monero *****uminer tether майнить
ubuntu ethereum bitcoin london bitcoin otc ethereum vk bitcoin ваучер дешевеет bitcoin bitcoin установка 0 bitcoin cryptocurrency charts bitcoin картинка книга bitcoin
se*****256k1 ethereum настройка monero king bitcoin bitcoin cache bitcoin регистрация bitcoin withdraw настройка monero bitcoin страна партнерка bitcoin jax bitcoin raspberry bitcoin
bitcoin mmgp antminer bitcoin
global bitcoin bitcoin mail keystore ethereum куплю ethereum bitcoin sportsbook lealana bitcoin скачать bitcoin monero gpu
bitcoin etf ethereum core зарегистрировать bitcoin блок bitcoin ethereum exchange розыгрыш bitcoin decred ethereum bitcoin обучение autobot bitcoin local bitcoin bitcoin daily bitcoin автоматически cudaminer bitcoin bitcoin fund bitcoin минфин
master bitcoin bonus bitcoin bitcoin wmx вклады bitcoin ethereum эфириум монета ethereum bitcoin обучение Think for a moment about what a blockchain was originally designed to do – store a distributed record of transactions of a peer-to-peer electronic cash (Bitcoin). In this sense, a blockchain can thought of as a machine that tracks the current state of the entire network and the value (amounts of Bitcoin) that are scattered among various holders.bitcoin информация film bitcoin sgminer monero bitcoin символ сайты bitcoin ethereum новости phoenix bitcoin ethereum php мастернода bitcoin bitcoin china bitcoin qr bitcoin safe
chaindata ethereum краны ethereum monero rur bitcoin монет ethereum github
bitcoin com rigname ethereum monero pro bitcoin rt bitrix bitcoin bitcoin ферма токены ethereum Cypherpunks were a subculture of the hacker movement with a focus on cryptography and privacy. They had their own manifesto, written in 1993, and their own mailing list which operated from 1992 to 2013 and at one point numbered 2,000 members. A truncated version of the manifesto is reproduced below. In the final lines, it declares a need for a digital currency system as a way to gain privacy from institutional oversight:bitcoin poloniex 2016 bitcoin виталик ethereum bitcoin airbit tether addon reddit ethereum bitcoin elena bitcoin даром There are several types of Ethereum wallets made specifically for storing these private keys:1 ethereum blender bitcoin bitcoin аккаунт стоимость bitcoin accepts bitcoin bitcoin png лото bitcoin bitcoin plugin bitcoin earn
payoneer bitcoin gas ethereum bitcoin цена flash bitcoin bitcoin primedice cap bitcoin bitcoin simple bitcoin fork
claymore monero ethereum farm rx580 monero bonus bitcoin ethereum usd gift bitcoin bitcoin оборот status bitcoin p2pool monero ethereum обменять ethereum логотип asics bitcoin cryptocurrency calculator
bitcoin википедия