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 of the most successful investors in the world, Warren Buffet, summed up his investment strategy like this:транзакции bitcoin Something to note is the fact that all blockchains which are more decentralized in their administration suffer from so-called Theseus problems. This refers to the fact that unowned blockchains need to balance the persistence of a singular identity over time with the ability to malleate.bitcoin капитализация forum bitcoin ethereum code сети ethereum ютуб bitcoin go ethereum
продать ethereum
ad bitcoin комиссия bitcoin bitcoin script bitcoin in смесители bitcoin In many ways, the Bitcoin project is similar to forerunners like Mozilla. The fact that the Bitcoin system emits a form of currency is its distinguishing feature as a coordination system. This has prompted the observation that Bitcoin 'created a business model for open source software.' This analogy is useful in a broad sense, but the devil is in the details.bitcoin clicker программа tether
bitcoin suisse bitcoin froggy bitcoin сигналы key bitcoin кран bitcoin bitcoin vk testnet ethereum bitcoin кредит баланс bitcoin bitcoin рост avto bitcoin mac bitcoin panda bitcoin bitcoin установка gas ethereum ethereum перевод adc bitcoin bitcoin daily прогнозы ethereum crococoin bitcoin abi ethereum
bitcoin accelerator bitcoin коллектор
bitcoin вконтакте bitcoin сети ethereum пулы bitcoin проблемы bitcoin список space bitcoin buying bitcoin котировки ethereum space bitcoin bitcoin paw заработать monero the ethereum ethereum serpent bitcoin комиссия sberbank bitcoin ethereum course bitcoin preev ethereum википедия ethereum complexity история ethereum withdraw bitcoin bitcoin форки bitcoin bittorrent
monero usd bitcoin 5 arbitrage cryptocurrency bitcoin блокчейн wmx bitcoin иконка bitcoin ssl bitcoin торговать bitcoin ethereum clix
adbc bitcoin bitcoin программа bitcoin транзакции шифрование bitcoin bitcoin пул алгоритмы ethereum putin bitcoin сложность monero
bitcoin бизнес bitcoin анимация bitcoin eobot bitcoin qazanmaq
bitcoin server asrock bitcoin 4000 bitcoin planet bitcoin bitcoin рулетка up bitcoin
monero gpu tether mining raspberry bitcoin ethereum рост difficulty monero форк ethereum bitcoin cards tether верификация ethereum курс сайт ethereum kinolix bitcoin bitcoin market bitcoin 1000
кошелек ethereum калькулятор ethereum bitcoin script
bitcoin oil фермы bitcoin ферма ethereum
вклады bitcoin
proxy bitcoin bitcoin server bitcoin spinner monero вывод рулетка bitcoin ethereum котировки ethereum myetherwallet
conference bitcoin by bitcoin bitcoin office HRSChoosing one depends on your preferences for convenience and security. Usually these two concepts are at odds with one another: the more convenient, the worse the security (and vice versa).bitcoin зарегистрироваться dwarfpool monero bitfenix bitcoin bitcoin primedice monero gui bitcoin смесители видео bitcoin bitcoin торговля
ethereum wallet moneypolo bitcoin bitcoin work bitcoin crypto
bitcoin стратегия habrahabr bitcoin bitcoin legal
виджет bitcoin bitcoin пополнение
bitcoin login gas ethereum bitcoin parser ethereum news перевод ethereum bitcoin анимация bitcoin команды bitcoin запрет bitcoin ваучер ethereum проблемы клиент ethereum stats ethereum bitcoin x2 bitcoin goldman lamborghini bitcoin пулы ethereum
cran bitcoin bitcoin count More coherent approaches to treating puzzle solutions as cash are found in two essays that preceded bit-coin, describing ideas called b-money13 and bit gold43 respectively. These proposals offer timestamping services that sign off on the creation (through proof of work) of money, and once money is created, they sign off on transfers. If disagreement about the ledger occurs among the servers or nodes, however, there isn't a clear way to resolve it. Letting the majority decide seems to be implicit in both authors' writings, but because of the Sybil problem, these mechanisms are not very secure, unless there is a gatekeeper who controls entry into the network or Sybil resistance is itself achieved with proof of work.bitcoin банкнота обновление ethereum транзакции bitcoin agario bitcoin Why Blockchain Is Neededалгоритм ethereum ethereum habrahabr компиляция bitcoin forbot bitcoin покер bitcoin bitcoin flapper masternode bitcoin monero fork king bitcoin bitcoin timer monero dwarfpool registration bitcoin bitcoin debian monero алгоритм
bitcoin second суть bitcoin bear bitcoin view bitcoin bitcoin nedir Don’t forget, if you don’t want to invest lots of money into expensive hardware, you can just cloud mine instead!bitcoin переводчик bitcoin вирус mini bitcoin bitcoin роботы bitcoin server hourly bitcoin bitcoin delphi bitcoin войти bitcoin информация gemini bitcoin bitcoin download transferring bitcoin to a friendbitcoin логотип
bitcoin stellar accepts bitcoin bitcoin математика ethereum 1070 bitcoin download сбербанк bitcoin collector bitcoin bitcoin перевод bitcoin switzerland fpga ethereum ultimate bitcoin заработок ethereum
ethereum картинки hyip bitcoin bitcoin online buy tether ethereum charts
ethereum bitcointalk bitcoin example
bitcoin simple серфинг bitcoin bitcoin easy coingecko ethereum bitcoin bonus кошель bitcoin mikrotik bitcoin bitcoin vip блоки bitcoin bitcoin mixer скачать bitcoin alpari bitcoin monero minergate bitcoin cloud wei ethereum bitcoin автоматически bitcoin kz opencart bitcoin bitcoin nvidia tera bitcoin bitcoin ваучер bitcoin is Stablecoinsbitcoin get http bitcoin bitcoin data bitcoin virus tether кошелек bitcoin магазин kupit bitcoin The design must be a correct solution to the problem. It is slightly better to be simple than correct.стратегия bitcoin bitcoin проблемы bitcoin биржи bitcoin комментарии ethereum russia ethereum poloniex bitcoin xpub bus bitcoin bazar bitcoin пополнить bitcoin bitcoin hesaplama
bitcoin accelerator bitcoin department китай bitcoin шифрование bitcoin water bitcoin
основатель bitcoin
новости monero bitcoin download
bitcoin коды ethereum обвал minergate bitcoin оплатить bitcoin 1070 ethereum bitcoin вирус ethereum 4pda bitcoin chain bitcoin развод заработок bitcoin ethereum install bitcoin client токен bitcoin bitcoin multibit pro bitcoin курс ethereum simple bitcoin amd bitcoin фото bitcoin bitcoin drip bitcoin отслеживание aliexpress bitcoin tether coin bitcoin stellar ethereum котировки
часы bitcoin ethereum telegram
bitcoin com mac bitcoin bitcoin legal importprivkey bitcoin bitcoin экспресс
bitcoin tradingview loco bitcoin bitcoin uk For a more beginner-friendly introduction to Bitcoin, please visit Binance Academy’s guide to Bitcoin.bitcoin matrix
bitcoin ann ethereum online bitcoin legal bitcoin tools bitcoin golang bitcoin price bitcoin moneypolo
ethereum plasma bitcoin coindesk
microsoft ethereum stock bitcoin
usd bitcoin
бот bitcoin ethereum asic bitcoin free
bitcoin войти bitcoin спекуляция bitcoin cgminer bitcoin eobot bitcoin make dog bitcoin sec bitcoin bitcoin central bitcoin google видеокарта bitcoin bitcoin будущее wmz bitcoin finney ethereum Microsoft accepts bitcoin in its app stores, where you can download movies, games and app-based services. The leading game streaming platform Twitch also accepts payments in bitcoin and bitcoin cash for its subscriptions.There is a finite number of bitcoins available (estimated to be 21 million). With ethereum, issuance of ether is capped at 18 million per year, which equals 25% of the initial supply. So, while the absolute issuance is fixed, relative inflation decreases every year.coffee bitcoin make bitcoin clockworkmod tether bitcoin knots
фото bitcoin bitcointalk monero
bitcoin кошелька bitcoin исходники
bitcoin конвектор poloniex bitcoin casper ethereum nya bitcoin bitcoin trader Gas is a unit of account within the EVM used in the calculation of a transaction fee, which is the amount of ETH a transaction's sender must pay to the miner who includes the transaction in the blockchain.bitcoin миллионеры
bitcoin telegram trading bitcoin bitcoin xt bitcoin legal отследить bitcoin bitcoin matrix bitcoin пополнить live bitcoin bitcoin openssl карты bitcoin account bitcoin часы bitcoin box bitcoin bitcoin форекс bitcoin 50000 keystore ethereum bitcoin playstation ethereum ann hit bitcoin
bitcoin q escrow bitcoin ico monero ethereum обмен icon bitcoin bitcoin китай компания bitcoin bcc bitcoin ethereum investing ethereum ann bloomberg bitcoin рубли bitcoin банк bitcoin bitcoin location fast bitcoin сайте bitcoin bitcoin ann bitcoin 1070 abi ethereum search bitcoin bitcoin рублей bitcoin эмиссия bitcoin protocol 777 bitcoin ethereum сбербанк ads bitcoin bitcoin блокчейн
конвертер monero black bitcoin bitcoin hosting валюта tether
ecdsa bitcoin терминалы bitcoin That is a great many hashes.swarm ethereum multiply bitcoin bitcoin buying футболка bitcoin bitcoin account bitcoin настройка конвертер bitcoin ethereum casper bitcoin kurs сборщик bitcoin bitcoin транзакция bitcoin gold
bitcoin torrent вложения bitcoin Accounts that store ETH and have code (smart contracts) that can be run – these smart contracts are activated by a transaction sending ETH into it. Once the smart contract has been uploaded, it sits there waiting to be activated.фермы bitcoin bitcoin rt lightning bitcoin goldmine bitcoin bitcoin картинки bitcoin зебра bitcoin продажа
bitcoin icons bitcoinwisdom ethereum bitcoin рухнул bitcoin auto часы bitcoin rinkeby ethereum
bitcoin получение PoS is an alternative to PoW in which the Blockchain aims to achieve distributed consensus. The probability of validating a block relies upon the number of tokens you own. The more tokens you have, the more chances you get to validate a block. It was created as a solution to minimize the use of expensive resources spent in mining.блок bitcoin bitcoin 33 cryptocurrency dash wisdom bitcoin monero новости p2pool monero pps bitcoin bitcoin cudaminer bitcoin 2048 bitcoin income mt5 bitcoin оплата bitcoin новости monero bitcoin hesaplama сборщик bitcoin bitcoin timer
bitcoin help wikipedia bitcoin bitcoin стоимость bitcoin froggy ethereum пулы vip bitcoin настройка bitcoin top cryptocurrency описание ethereum ethereum programming view bitcoin alliance bitcoin claim bitcoin
sec bitcoin tether отзывы bitcoin project download bitcoin bitcoin video loans bitcoin flappy bitcoin asics bitcoin bitcoin математика chain bitcoin 6000 bitcoin etf bitcoin usdt tether ethereum addresses finney ethereum криптовалюту bitcoin bitcoin отзывы bitcoin в bitcoin group фермы bitcoin bitcoin переводчик fork ethereum bitcoin generate bitcoin lion bitcoin sportsbook
bitcoin pool bitcoin сети rigname ethereum ethereum курсы ethereum кран dogecoin bitcoin ethereum dag bitcoin traffic exchange bitcoin bitcoin бесплатные bitcoin проверить
60 bitcoin
kurs bitcoin java bitcoin кошелька ethereum
bitcoin synchronization fire bitcoin bitcoin charts
script bitcoin monero обмен bitcoin attack bitcoin кэш bitcoin рубль bitcoin презентация bitcoin кошелька
monero node polkadot cadaver bitcoin okpay get bitcoin
neo bitcoin ethereum обвал bitcoin sec twitter bitcoin dollar bitcoin bitcoin обозреватель bitcoin россия инструмент bitcoin rbc bitcoin добыча bitcoin ethereum zcash bitcoin лучшие bitcoin 2018 капитализация ethereum bitcoin перевод фонд ethereum tether отзывы
bitcoin транзакция p2p bitcoin перспективы ethereum Whatever your view on bitcoin, you can’t ignore the fact that the growth of cryptocurrencies has captured the imagination of an investment community tired of central bank manipulation of monetary assets.bitcoin spinner bitcoin окупаемость doge bitcoin
ethereum homestead продам ethereum bitcoin crash carding bitcoin
monero хардфорк
in bitcoin roll bitcoin nova bitcoin cryptocurrency calendar p2pool ethereum get bitcoin apk tether ethereum free widget bitcoin bitcoin раздача
exmo bitcoin By eliminating the centralized system, blockchain provides a transparent and secure way of recording transactions (without disclosing your private information to anyone)pps bitcoin рулетка bitcoin games bitcoin
bitcoin buying
ethereum рост ethereum ферма ethereum io cryptocurrency unconfirmed bitcoin дешевеет bitcoin bitcoin billionaire играть bitcoin cryptocurrency logo
blockchain ethereum best cryptocurrency bitcoin weekly bitcoin проверить