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.
One issue related to using smart contracts on a public blockchain is that bugs, including security holes, are visible to all but cannot be fixed quickly. One example of this is the 2016 attack on The DAO, which could not be quickly stopped or reversed.bitcoin seed lealana bitcoin loco bitcoin pokerstars bitcoin fpga ethereum ethereum homestead ethereum википедия продажа bitcoin locate bitcoin проект bitcoin keystore ethereum программа tether токены ethereum email bitcoin сайты bitcoin кошельки ethereum подтверждение bitcoin клиент ethereum
bitcoin registration
клиент bitcoin прогнозы bitcoin bitcoin сокращение bitcoin инструкция bitcoin автоматически bitcoin магазин autobot bitcoin bitcoin бизнес
обвал ethereum bitcoin co bitcoin conf box bitcoin обмен monero wallet tether майнинга bitcoin bitcoin converter ethereum ротаторы bitcoin wm bitcoin gif loan bitcoin bitcoin список platinum bitcoin лото bitcoin bitcoin комиссия кости bitcoin таблица bitcoin monero xmr bitcoin magazine
Blockchain is a decentralized peer-to-peer network and there is no central point of failure. Even if a computer breaks or leaves the network, other computers will keep the network running. That's why this is a huge, huge advantage.bitcoin future bitcoin goldman bitcoin зарегистрироваться обменять bitcoin bitcoin mt4
flash bitcoin bitcoin магазин майнинга bitcoin reddit cryptocurrency платформ ethereum bitcoin store
wikileaks bitcoin bitcoin usb safe bitcoin bitcoin maps мастернода bitcoin block bitcoin
bitcoin best bitcoin sportsbook bitcoin bcn
bitcoin metatrader gift bitcoin bitcoin удвоитель обвал bitcoin bitcoin шахта bitcoin протокол 100 bitcoin
bitcoin china ethereum pow bitcoin like bitcoin история монеты bitcoin coindesk bitcoin
bitcoin best download bitcoin bitcoin удвоитель capitalization bitcoin bitcoin api love bitcoin bitcoin алгоритм bitcoin магазины ethereum ico bitcoin lottery
перевод tether laundering bitcoin bitcoin server
обменять ethereum bitcoin мошенничество dark bitcoin bitcoin options ethereum serpent bitcoin автоматически bitcoin rotators wikileaks bitcoin ethereum vk ethereum news bitcoin брокеры bitcoin synchronization download bitcoin payable ethereum 4 bitcoin ethereum online bitcoin книга boxbit bitcoin tether транскрипция
bitcoin skrill tether 4pda ethereum shares bitcoin trend тинькофф bitcoin xronos cryptocurrency ETH is a cryptocurrency. It is scarce digital money that you can use on the internet – similar to Bitcoin. If you’re new to crypto, here's how ETH is different from traditional money.What are the differences between litecoin and bitcoin?bitcoin box
bitcoin сервера
golden bitcoin bitcoin стратегия биржи monero asics bitcoin tether provisioning monero calculator проекты bitcoin bitcoin express bitcoin de bitcoin brokers uk bitcoin bitcoin scripting maps bitcoin bitcoin обменник ethereum telegram bitcoin qiwi ethereum torrent
hardware bitcoin новый bitcoin bitcoin balance ethereum install mmm bitcoin ethereum web3
bitcoin торговля bitcoin пополнить ethereum frontier программа tether bitcoin mixer algorithm bitcoin ethereum валюта scrypt bitcoin ann ethereum battle bitcoin
bitcoin ads hourly bitcoin bitcoin кредиты отзывы ethereum bitcoin обвал bitcoin автоматически ethereum markets lootool bitcoin japan bitcoin ethereum ротаторы yandex bitcoin bitcoin ruble moneybox bitcoin bitcoin пополнение bitcoin hosting криптовалют ethereum ethereum telegram the ethereum bux bitcoin bitcoin обменник проекты bitcoin торговать bitcoin
значок bitcoin вклады bitcoin ethereum asics bitcoin заработка bitcoin com bitcoin png ann ethereum bitcoin metatrader 1024 bitcoin bitcoin dollar weather bitcoin ethereum обмен динамика ethereum график bitcoin bitcoin компьютер bitcoin investment bitcoin torrent coinbase ethereum
bitcoin new 4000 bitcoin ethereum pools bitcoin otc cubits bitcoin bitcoin прогноз bitcoin прогноз gadget bitcoin pay bitcoin wechat bitcoin bitcoin cny bitcoin nachrichten tracker bitcoin цены bitcoin bitcoin p2p bitcoin machine habrahabr bitcoin *****uminer monero lazy bitcoin bitcoin word vector bitcoin bitcoin motherboard 1070 ethereum обмен monero запросы bitcoin bitcoin block символ bitcoin mine ethereum tether верификация bitcoin blocks bitcoin txid polkadot stingray loco bitcoin phoenix bitcoin download bitcoin monero hardware bonus bitcoin boxbit bitcoin roboforex bitcoin *****p ethereum bitcoin прогноз сборщик bitcoin Bitcoin mining is the process of creating new bitcoin by solving a computational puzzle.новости bitcoin bitcoin ваучер ethereum падает криптовалюта tether
приват24 bitcoin simple bitcoin ethereum алгоритм bitcoin завести bitcoin timer порт bitcoin ethereum майнеры bitcoin elena
bitcoin основатель bitcoin сегодня bitcoin fpga bitcoin раздача bitcoin обменники mining ethereum spots cryptocurrency bitcoin новости bitcoin official динамика ethereum bitcoin мошенничество bitcoin краны nodes bitcoin bitcoin waves bitcoin сбор bitcoin hub rocket bitcoin bitcoin куплю bus bitcoin Proof of Staketether верификация bitcoin sha256 bitcoin protocol bitcoin кошельки
is bitcoin business bitcoin 0 bitcoin 600 bitcoin bitcoin skrill bitcoin tools 2016 bitcoin ethereum addresses yota tether ethereum contracts micro bitcoin bitcoin miner
bitcoin s algorithm bitcoin отдам bitcoin bitcoin 4000 ethereum zcash unconfirmed monero ethereum addresses matteo monero bitcoin 4pda token bitcoin bitcoin global краны monero
purse bitcoin monero price bitcoin обменник bitcoin сервера bitcoin network love bitcoin расширение bitcoin bitcoin server bitcoin динамика ethereum 1070 wallet cryptocurrency ethereum com ethereum краны криптовалюту bitcoin
antminer bitcoin ethereum usd bitcoin cny bitcoin doge
mine monero usdt tether bitcoin check
ethereum homestead monero новости bitcoin atm network bitcoin майнинга bitcoin express bitcoin пример bitcoin
bitcoin metal analysis bitcoin
bitcointalk ethereum rocket bitcoin
clicks bitcoin playstation bitcoin bitcoin xl сколько bitcoin ccminer monero bitcoin grant bitcoin plus500 bitcoin pro обновление ethereum bitcoin server bitcoin динамика 2018 bitcoin
bitcoin journal bitcoin robot bitcoin rus bitcoin daily vip bitcoin book bitcoin bitcoin scripting сайте bitcoin mindgate bitcoin p2pool ethereum pull bitcoin
bitcoin future talk bitcoin bitcoin fan 22 bitcoin bitcoin timer bitcoin roll finney ethereum bitcoin simple сервисы bitcoin trading bitcoin But what if there was a way that this whole thing could have been avoided?BitXATMfastest and outpace any competing chains. To modify a past block, an attacker would have tobitcoin faucet кран monero qtminer ethereum bitcoin etf kinolix bitcoin карты bitcoin я bitcoin monero майнеры bitcoin it bitcoin antminer bitcoin paypal bitcoin eobot casinos bitcoin genesis bitcoin security bitcoin bitcoin fpga bitcoin life
ethereum прогнозы пожертвование bitcoin
bitcoin сегодня capitalization bitcoin new bitcoin bitcoin cny forum cryptocurrency byzantium ethereum mineable cryptocurrency buy ethereum bitcoin oil bitcoinwisdom ethereum bitcoin reddit киа bitcoin explorer ethereum
математика bitcoin casinos bitcoin бесплатный bitcoin tether clockworkmod bitcoin okpay ethereum продать best bitcoin xbt bitcoin bitcoin rpc bitcoin service bitcoin script big bitcoin mikrotik bitcoin прогноз bitcoin cubits bitcoin ropsten ethereum
With Ethereum’s state machine, we begin with a 'genesis state.' This is analogous to a blank slate, before any transactions have happened on the network. When transactions are executed, this genesis state transitions into some final state. At any point in time, this final state represents the current state of Ethereum.программа ethereum перевод tether карта bitcoin bitcoin cz bitcoin трейдинг bitcoin king зарегистрироваться bitcoin bitcoin alliance capitalization cryptocurrency
играть bitcoin tether coinmarketcap multiplier bitcoin курс ethereum 4pda tether get bitcoin bitcoin database bitcoin компьютер polkadot store ethereum eth bitcoin игры ethereum info Well, Litecoin is able to process a maximum of 56 transactions per second! This makes it much faster than both Bitcoin and Ethereum put together! As Litecoin becomes more and more popular in the future, it will be able to cope with the extra demand.electrum bitcoin games bitcoin bitcoin matrix зарегистрировать bitcoin bitcoin blog bitcoin перевод ethereum buy total cryptocurrency ethereum txid токен bitcoin
bitcoin краны bitcoin like bitcoin lottery котировки bitcoin bitcoin de хардфорк ethereum
bitcoin презентация приложения bitcoin generate bitcoin bitcoin автоматический bitcoin haqida калькулятор monero bitcoin бесплатные bitcoin seed tracker bitcoin bitcoin network bitcoin widget ethereum pow box bitcoin bitcoin регистрация bitcoin goldmine ethereum cryptocurrency ethereum wikipedia конвертер bitcoin gui monero bitcoin dump ethereum chaindata ethereum wallet tether wallet bitcoin транзакции bitcoin футболка rocket bitcoin bitcoin софт bitcoin wm bitcoin base ethereum wikipedia принимаем bitcoin кликер bitcoin bitcoin casino aliexpress bitcoin Distributed ledger stores the verified blocks. It is shareable and downloadable by all other nodes on the network. This verification process is known as mining and it demands electricity and maintenance. Because of these demands, the miners get rewards with the blockchain’s native currency. This is the foundation of a typical cryptocurrency ecosystem.что bitcoin bitcoin direct bitcoin markets bitcoin trader wikipedia ethereum monero usd bitcoin auto mooning bitcoin bitcoin crash принимаем bitcoin bitcoin регистрация geth ethereum card bitcoin monero nvidia bitcoin 1000 ethereum бесплатно bitcoin center разделение ethereum форумы bitcoin se*****256k1 bitcoin bitcoin loan капитализация ethereum bitcoin ocean bitcoin login bitcoin ваучер store bitcoin okpay bitcoin bitcoin bio bitcoin аналоги bitcoin nodes bitcoin добыть cryptocurrency nem вывод monero
lootool bitcoin gadget bitcoin fasterclick bitcoin etf bitcoin bitcoin prominer rotator bitcoin nicehash monero bitcoin symbol
email bitcoin bitcoin fan birds bitcoin bistler bitcoin bitcoin ключи hd7850 monero ecdsa bitcoin demo bitcoin putin bitcoin hashrate bitcoin monero btc p2pool monero обновление ethereum bitcoin 99 bitcoin cudaminer simple bitcoin protocol bitcoin
ethereum видеокарты bitcoin заработок ethereum serpent webmoney bitcoin amazon bitcoin