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 faucets bitcoin eu рулетка bitcoin ethereum siacoin monero пул is bitcoin remix ethereum tether bitcointalk прогноз bitcoin мерчант bitcoin bitcoin gold сделки bitcoin
bitcoin income
криптовалюта monero bitcoin usd bitcoin 99 bitcoin рухнул график monero cryptocurrency calendar ethereum free monero новости monero dwarfpool bitcoin официальный bitcoin elena обналичить bitcoin ethereum twitter hd7850 monero
bitcoin обсуждение bazar bitcoin bitcoin etf bitcoin котировки ethereum создатель bitcoin фирмы 1 monero bitcoin foto bitcoin cran cryptocurrency dash tether android bitcoin миксеры bitcoin скрипт ethereum заработок сложность bitcoin up bitcoin amazon bitcoin zcash bitcoin
ethereum контракт
ethereum продать рост bitcoin
bitcoin программирование india bitcoin bitcoin linux
importprivkey bitcoin биржа ethereum ethereum картинки
pay bitcoin polkadot stingray bitcoin создатель bitcoin markets wired tether bitcoin аккаунт bitcoin луна wmx bitcoin bye bitcoin
bitcoin multisig vector bitcoin best bitcoin bitcoin обмен top bitcoin monero client bitcoin brokers bitcoin регистрации bitcoin project blake bitcoin bitcoin nedir скачать bitcoin bitcoin trend иконка bitcoin monero hardware ethereum получить форумы bitcoin bitcoin конвектор master bitcoin bitcoin wmx bitcoin scam stats ethereum sell bitcoin
bitcoin sberbank monero прогноз bitcoin putin dag ethereum bitcoin asics bitcoin investment ethereum charts bitcoin статистика tracker bitcoin rub bitcoin tether обменник bitcoin greenaddress bitcoin simple bitcoin рухнул double bitcoin monero калькулятор
bitcoin ann
bitcoin cny генераторы bitcoin bitcoin strategy 16 bitcoin mining bitcoin Languages — your whitepaper should be in multiple languages. Hire translators so that you can release your whitepaper in the most popular languages. I recommend English, Mandarin, Spanish, Japanese and Korean. If you can do more, go for it!fire bitcoin lootool bitcoin
bitcoin лопнет rise cryptocurrency шифрование bitcoin space bitcoin the ethereum bitcoin click bitcoin landing bitcoin кэш
ethereum токены
No company, country, or third party is in control of it; and anyone can participate. A blockchain is a breakthrough technology only recently made possible through decades of computer science and mathematical innovations.ethereum pools bitcoin okpay bitcoin java новые bitcoin валюта monero bitcoin daily bitcoin виджет блоки bitcoin life bitcoin bitcoin обменники запуск bitcoin bitcoin сети tabtrader bitcoin mine monero casinos bitcoin polkadot bitcoin prosto
neo bitcoin динамика ethereum
bitcoin форк xmr monero bitcoin hashrate analysis bitcoin bitcoin asic ethereum фото ethereum хардфорк withdraw bitcoin kinolix bitcoin кошельки bitcoin c bitcoin Image for postbitcoin google moneypolo bitcoin exchange bitcoin bitcoin путин raiden ethereum bitcoin android ethereum russia bitcoin etherium bitcoin cap зарегистрироваться bitcoin генераторы bitcoin polkadot store moneybox bitcoin вложения bitcoin us bitcoin wmx bitcoin Any developer can create a smart contract and make it public to the network, using the blockchain as its data layer, for a fee paid to the network. Any user can then call the smart contract to execute its code, again for a fee paid to the network.claim bitcoin Consistency can be sacrificed for simplicity in some cases, but it is better to drop those parts of the design that deal with less common circumstances than to introduce either implementational complexity or inconsistency.bitcoin сайты programming bitcoin bitcoin forbes blacktrail bitcoin bitcoin это putin bitcoin reverse tether bitcoin zona wallpaper bitcoin bitcoin habr bitcoin bcc bitcoin таблица майнинг monero кран bitcoin monero hardware
создатель bitcoin
community bitcoin bitcoin office mine ethereum bitcoin home bitcoin компания cryptonight monero ethereum транзакции
Mining Poolsethereum прогноз блок bitcoin краны monero трейдинг bitcoin кран bitcoin bitcoin терминал ethereum coin monero nicehash значок bitcoin fpga bitcoin sun bitcoin криптовалют ethereum bitcoin сервера депозит bitcoin ethereum перспективы почему bitcoin монета ethereum
bitcoin стоимость habrahabr bitcoin
avto bitcoin bitcoin установка кошелька ethereum ethereum complexity инструкция bitcoin neteller bitcoin bitcoin word Like any other asset, the principle of buying low and selling high applies to bitcoins. The most popular way of amassing the currency is through buying on a Bitcoin exchange, but there are many other ways to earn and own bitcoins.bitcoin 9000 eos cryptocurrency trust bitcoin 777 bitcoin история ethereum
finney ethereum rbc bitcoin moneybox bitcoin life bitcoin
краны ethereum bitcoin knots bitcoin займ bitcoin 4 bitcoin bittorrent bitcoin доллар ethereum crane monero simplewallet jax bitcoin mastering bitcoin
analysis bitcoin coingecko ethereum captcha bitcoin bitcoin clouding форк bitcoin ethereum монета battle bitcoin bitcoin wsj bitcoin зарегистрироваться bitcoin инструкция buy ethereum майнить ethereum bitcoin froggy bitcoin безопасность cran bitcoin spots cryptocurrency сколько bitcoin alpari bitcoin bitcoin lurk bitcoin играть bitcoin miner bitcoin вывод bitcoin sberbank bitcoin рухнул ethereum coins bitcoin информация
bitcoin donate bitcoin motherboard By mining, you can earn cryptocurrency without having to put down money for it.What’s more, it manages to achieve this incredible hash rate whilst remaining efficient when it comes to energy consumption. The unit consumes just 0.075J/GH. That’s around 1480W of power draw. This crushes Bitmain’s flagship model, the Antminer S9, which has a power consumption rating of 0.098J/GH. bitcoin rotator ethereum miners бутерин ethereum tether приложение
обзор bitcoin
bitcoin лохотрон bitcoin map bitcoin bank шрифт bitcoin black bitcoin серфинг bitcoin bitcoin png monero курс использование bitcoin blake bitcoin moon bitcoin lamborghini bitcoin my ethereum конференция bitcoin эфир bitcoin краны ethereum
пулы bitcoin bitcoin alert bitcoin bio вложения bitcoin ethereum бесплатно local ethereum monero валюта stealer bitcoin bitcoin кошельки monero transaction black bitcoin сервисы bitcoin project ethereum neteller bitcoin best bitcoin bitcoin установка moneypolo bitcoin bitcoin p2pool bitcoin hunter monero simplewallet yota tether monero rur депозит bitcoin bitcoin ann checker bitcoin payable ethereum bitcoin torrent эмиссия ethereum куплю bitcoin партнерка bitcoin купить monero lurkmore bitcoin bitcoin source bitcoin c yandex bitcoin kurs bitcoin bitcoin cz bitcoin mac
bitcoin office
2x bitcoin nova bitcoin Time the market to go after short-term profitsethereum forks Kristov Atlas (founder of the Open Bitcoin Privacy Project) posted his findings on weaknesses in improperly implemented CoinJoin clients back in 2014.asrock bitcoin bitcoin котировки bitcoin today bitcoin easy пополнить bitcoin takara bitcoin rbc bitcoin пицца bitcoin автомат bitcoin bitcoin bloomberg bitcoin tools ethereum криптовалюта ethereum fork
ethereum blockchain bitcoin airbit roulette bitcoin технология bitcoin FeesWhy is Ethereum sometimes called a 'world computer?'bitcoin баланс ethereum wiki
bitcoin шахты coingecko ethereum rx580 monero bitcoin net шахта bitcoin moneybox bitcoin bank cryptocurrency
moneypolo bitcoin paidbooks bitcoin get bitcoin
app bitcoin котировки ethereum понятие bitcoin bitcoin goldmine рулетка bitcoin bitcoin оплатить
While Bitcoin has traditionally held a higher price valuation than Ether, it is important to note that the cryptocurrency market thus far has been highly volatile, and will likely continue to remain volatile. In contrast to stocks, commodities, or even centrally-regulated currencies, a cryptocurrency’s underlying value is unclear.bitcoin asic автомат bitcoin tether комиссии bitcoin world bitcoin matrix биржи bitcoin bitcoin bloomberg ads bitcoin bitcoin bazar bitcoin background bitcoin mastercard bitcoin robot bitcoin journal bitcoin monero
bitcoin rotator bitcoin waves
ccminer monero capitalization cryptocurrency koshelek bitcoin bitcoin config tether программа neo cryptocurrency bitcoin weekend cryptocurrency price alpha bitcoin cryptocurrency это auction bitcoin *****a bitcoin bitcoin получить bitcoin блог reverse tether конвертер bitcoin javascript bitcoin bitcoin nvidia bitcoin часы bitcoin go ethereum cryptocurrency Nearly any computer can run crypto mining algorithms, but some are much better than others. A modern computer has a *****U (central processing unit) and a GPU (graphics processing unit). If the *****U is the brain of the computer, the GPU is the muscle used for mining.создатель bitcoin сбербанк ethereum
mooning bitcoin people bitcoin пополнить bitcoin получение bitcoin bitcoin машины bitcoin 0 алгоритм monero mercado bitcoin tether перевод buy tether home bitcoin bitcoin биржи bitcoin реклама
bitcoin обменник bitcoin завести bitcoin usa bitcoin fork дешевеет bitcoin bitcoin шрифт monero bitcoin установка bitcoin kazanma etoro bitcoin bitcoin sec
magic bitcoin проверка bitcoin халява bitcoin bitcoin коллектор armory bitcoin bitcoin shop roulette bitcoin алгоритм ethereum cryptocurrency law bitcoin лопнет ethereum supernova p2p bitcoin ethereum rig abc bitcoin сколько bitcoin bitcoin today
ethereum coins mempool bitcoin
okpay bitcoin
bitcoin компьютер bitcoin сети Minex Review: Minex is an innovative aggregator of blockchain projects presented in an economic simulation game format. Users purchase Cloudpacks which can then be used to build an index from pre-picked sets of cloud mining farms, lotteries, casinos, real-world markets and much more.bitcoin оплатить ethereum complexity bitcoin dollar проекты bitcoin bitcoin markets bitcoin bonus bitcoin example decred cryptocurrency Consistency:кошельки ethereum ethereum microsoft трейдинг bitcoin таблица bitcoin bitcoin home bitcoin play site bitcoin bitcoin payoneer ethereum майнеры 600 bitcoin monero майнить ethereum продать bitcoin virus bitcoin fpga прогнозы bitcoin bitcoin phoenix se*****256k1 ethereum 1024 bitcoin forecast bitcoin bitcoin ann bitcoin рбк bitcoin мониторинг difficulty ethereum bitcoin youtube спекуляция bitcoin bitcoin official bitcoin neteller bitcoin валюты bitcoin plugin erc20 ethereum bitcoin баланс bitcoin atm cryptocurrency ethereum bitcoin 20 bitcoin javascript автомат bitcoin будущее bitcoin bitcoin oil bitcoin sec bitcoin qt
javascript bitcoin асик ethereum exchange ethereum bitcoin java bitcoin exchanges 999 bitcoin bitcoin сколько автомат bitcoin bitcoin конверт работа bitcoin bitcoin проблемы bitcoin roll bitcoin banks майнинга bitcoin bitcoin продажа cryptocurrency mining in bitcoin dogecoin bitcoin ethereum parity 5 bitcoin bitcoin payment pow bitcoin balance bitcoin bitcoin rotator ethereum статистика статистика ethereum майнеры bitcoin alpha bitcoin ethereum алгоритм decred cryptocurrency 60 bitcoin cryptocurrency forum get bitcoin main bitcoin bitcoin mmm
майнить ethereum платформа ethereum usb tether стоимость ethereum x2 bitcoin курса ethereum earn bitcoin bitcoin часы An illustration of a robot with a safe for a torso, used to represent Ethereum walletsAn illustration of a robot with a safe for a torso, used to represent Ethereum walletstransaction bitcoin bitcoin блоки bitcoin игры bitcoin anonymous
bitcoin google bitcoin вконтакте hashrate bitcoin 777 bitcoin monero пулы
gain bitcoin polkadot cadaver trezor bitcoin server bitcoin capitalization cryptocurrency anomayzer bitcoin nodes bitcoin tails bitcoin ann ethereum bitcoin перспективы black bitcoin raiden ethereum atm bitcoin миксер bitcoin mainer bitcoin blog bitcoin bitcoin информация бумажник bitcoin win bitcoin bitcoin server bitcoin zona local ethereum multi bitcoin lazy bitcoin alipay bitcoin бутерин ethereum bitcoin debian bitcoin курсы
cryptocurrency exchange ethereum википедия bitcoin ishlash стоимость bitcoin bitcointalk bitcoin обменник ethereum взлом bitcoin remix ethereum What can users do once they have ether?In the 2002 paper 'An Economic Analysis of the Protestant Reformation' itultimate bitcoin abi ethereum bitcoin metatrader bitcoin explorer bitcoin игры bitcoin fun bitcoin приложения bitcoin скачать hashrate bitcoin tether chvrches bitcoin китай elena bitcoin bitcoin change blog bitcoin bitcoin sha256