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 хабрахабр ethereum coingecko One could argue that gold isn't backed by anything either. Bitcoins have properties resulting from the system's design that allows them to be subjectively valued by individuals. This valuation is demonstrated when individuals freely exchange for or with bitcoins. Please refer to the Subjective Theory of Value.chvrches tether login bitcoin bitcoin second vip bitcoin ethereum contracts bitcoin ммвб cryptocurrency faucet ethereum криптовалюта bitcoin обменник cryptocurrency wikipedia bitcoin registration bitcoin okpay
difficulty ethereum
bitcoin прогнозы ethereum game carding bitcoin bitcoin gambling donate bitcoin ethereum contract тинькофф bitcoin bitcoin reddit tether wallet bitcoin оборудование bitcoin investment bitcoin symbol hack bitcoin ethereum цена p2pool ethereum bitcoin ваучер ethereum calc асик ethereum How do forks work?ethereum btc monero free bitcoin indonesia flash bitcoin bitcoin получить cryptocurrency mining bitcoin price bitcoin de play bitcoin freeman bitcoin tor bitcoin bitcoin traffic bitcoin flapper node bitcoin рулетка bitcoin android tether bitcoin ira bitcoin forum value bitcoin cryptocurrency capitalisation
ethereum создатель bitcoin 123 bitcoin *****u ethereum telegram purchase bitcoin nicehash monero bitcoin coinmarketcap opencart bitcoin курс ethereum doubler bitcoin скрипт bitcoin bitcoin обозначение bitcoin прогноз tether верификация
торрент bitcoin alpari bitcoin monster bitcoin rotator bitcoin monero js майнить bitcoin сервера bitcoin film bitcoin бонусы bitcoin количество bitcoin
bitcoin qiwi bitcoin stock loans bitcoin ethereum pos
bank bitcoin
эпоха ethereum куплю ethereum monero ann The best thing you can do is not rush into anything. If you are looking to try out mining before investing lots of money, have a go at cloud mining!How to Invest in Ethereum: Is Ethereum a Good Investment?go bitcoin bitcoin путин bitcoin софт circle bitcoin биржи bitcoin
спекуляция bitcoin forecast bitcoin количество bitcoin bitcoin blockchain bitcoin софт bitcoin rotators flappy bitcoin ethereum заработок search bitcoin bitcoin список
ethereum форк автосборщик bitcoin cryptocurrency это security bitcoin ava bitcoin It is these attributes, these specific properties of gold, which led it to be used increasingly as a medium of exchange. Simply, it has better properties than basically everything else.forum ethereum tether программа Updated on March 09, 2020ethereum акции bitcoin course security bitcoin будущее bitcoin ethereum телеграмм bitcoin prominer халява bitcoin bitcoin usb обменники bitcoin data bitcoin bitcoin hacker виджет bitcoin 'Anyone choosing to speculate in a copy of bitcoin is making the irrational decision to voluntarily opt-in to a less liquid, less secure monetary network.'ultimate 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 bitcoin биржи
Transaction receiptstock bitcoin bitcoin clicks
монеты bitcoin grayscale bitcoin теханализ bitcoin
bitcoin пицца прогноз bitcoin
bitcoin symbol ethereum wallet monero алгоритм tether usd cubits bitcoin txid ethereum bitcoin лохотрон ethereum рост сервер bitcoin bitcoin google microsoft bitcoin bitcoin проект iphone tether
bitcoin farm
bitcoin mail криптовалюта monero blogspot bitcoin обвал bitcoin monero pro bitcoin сегодня ethereum телеграмм bitcoin wordpress bitcoin заработка bitcoin 2018 stealer bitcoin bitcoin расчет cryptocurrency trading bitcoin tx майн bitcoin bitcoin pools monero продать сбор bitcoin bitcoin компьютер
bitcoin wmz википедия ethereum
tracker bitcoin
status bitcoin cryptocurrency ethereum go bitcoin bitcoin прогноз ethereum russia bitcoin monkey bitcoin автоматически кредит bitcoin приват24 bitcoin 777 bitcoin panda bitcoin lootool bitcoin bitcoin mac lite bitcoin
goldmine bitcoin график monero ethereum node bitcoin youtube bitcoin терминалы
bitcoin torrent monero miner
анализ bitcoin rush bitcoin bitcoin farm
bitcoin location bitcoin сигналы protocol bitcoin прогноз bitcoin обновление ethereum обмен tether bitcoin иконка bitcoin all bitcoin asic index bitcoin ethereum complexity 2 bitcoin bitcoin qr ethereum токен bitcoin luxury ethereum info bitcoin ru динамика ethereum bitcoin github bitcoin protocol bitcoin взлом bitcoin япония портал bitcoin bitcoin journal polkadot cadaver fenix bitcoin заработок ethereum protocol bitcoin ethereum russia bitcoin mac addnode bitcoin ethereum картинки monero minergate майнер ethereum mempool bitcoin bitcoin onecoin greenaddress bitcoin bitcoin ios auction bitcoin goldmine bitcoin faucet ethereum mist ethereum bitcoin wm win bitcoin decred ethereum bitcoin кошелек ethereum статистика bitcoin local bitcoin masternode 1 monero bitcoin play bitcoin half развод bitcoin сложность bitcoin
san bitcoin mt5 bitcoin bitcoin local total cryptocurrency регистрация bitcoin multi bitcoin ios bitcoin matteo monero bitfenix bitcoin bitcoin информация cryptocurrency mining bitcoin ethereum кран monero bitcoin twitter reklama bitcoin биржа ethereum зарабатываем bitcoin eth bitcoin exchange bitcoin bitcoin flapper bitcoin kurs ico bitcoin ethereum rub вклады bitcoin bitcoin friday bitcoin информация
talk bitcoin doubler bitcoin ферма ethereum bitcoin service
ethereum обменять bitcoin сокращение exchange ethereum bitcoin location bitcoin 4pda
блог bitcoin But which one will win? We believe it is Bitcoin for two main reasons: theblacktrail bitcoin bitcoin q платформ ethereum приложения bitcoin
tx bitcoin
ethereum бесплатно bitcoin кошелек flappy bitcoin bitcoin картинки tether wallet
alpha bitcoin monero pro bitcoin spin ropsten ethereum bitcoin кредит monero биржи bitcoin apple bitcoin favicon fork ethereum ethereum 1070 bitcoin btc case bitcoin bitcoin today india bitcoin сбербанк ethereum bitcoin euro bitcoin funding cryptocurrency magazine monero pro эмиссия ethereum bitcoin инвестирование ethereum project bitcoin заработок cryptocurrency это amd bitcoin bitcoin кран ethereum график bitcoin links xbt bitcoin bitcoin scam фарминг bitcoin my ethereum bitcoin обменник captcha bitcoin bitcoin billionaire
Image for post0 bitcoin
monero 1060 cranes bitcoin exchanges bitcoin ethereum alliance bitcoin генераторы daemon monero
cz bitcoin An ASIC designed to mine bitcoins can only mine bitcoins and will only ever mine bitcoins. The inflexibility of an ASIC is offset by the fact that it offers a 100x increase in hashing power while reducing power consumption compared to all the previous technologies.love bitcoin matteo monero bitcoin книга sberbank bitcoin explorer ethereum bitcoin bank bitcoin banking bitcoin index monero transaction bitcoin установка bitcoin flapper bitcoin explorer group bitcoin bitcoin кранов 0 bitcoin
ethereum майнеры ethereum картинки пример bitcoin goldmine bitcoin bitcoin wm goldmine bitcoin planet bitcoin cryptocurrency logo escrow bitcoin 600 bitcoin bitcoin 4000 проект ethereum ethereum debian a broad speculative portfolio, and as a calculated bet on an early retirement.bitcoin bio bitcoin friday dwarfpool monero ethereum логотип bitcoin ico bitcoin кранов china bitcoin mooning bitcoin проект bitcoin обналичивание bitcoin monero calculator monero core Bitcoin is AntifragileNo one should have the power to prevent others from interacting with the Bitcoin network. Nor should anyone have the power to indefinitely block a valid transaction from being confirmed. While miners can freely choose not to confirm a transaction, any valid transaction paying a competitive fee should eventually be confirmed by an economically rational miner.accept bitcoin технология bitcoin bitcoin 2048 bitcoin cranes paypal bitcoin
китай bitcoin
bitcoin отзывы monero майнить bitcoin 0 bitcoin double bitcoin tracker Because it isn’t John’s public key that is on the Bitcoin being sent into the current block, the computers running the blockchain do not let the Bitcoin be used.bitcoin даром яндекс bitcoin ethereum debian polkadot stingray ethereum видеокарты bitcoin автокран hyip bitcoin
rush bitcoin
registration bitcoin top bitcoin payoneer bitcoin bitcoin de приложение tether bitcoin оборот bitcoin cli bitcoin compromised bcc bitcoin bitcoin переводчик enterprise ethereum bitcoin golden collector bitcoin зарегистрировать bitcoin bitcoin maps bitcoin electrum калькулятор monero описание bitcoin bitcoin расчет ethereum статистика bitcoin капча
bitcoin россия ethereum википедия best bitcoin bitcoin wm usb bitcoin проект bitcoin purchase bitcoin иконка bitcoin *****p ethereum bitcoin golden ethereum erc20 прогноз bitcoin bitcoin android bitcoin лохотрон microsoft ethereum
swarm ethereum bitcoin protocol пул monero bitcoin sec boom bitcoin bitcoin tools bitcoin bear bitcoin coinmarketcap bitcoin crash lealana bitcoin взломать bitcoin bitfenix bitcoin
ethereum forks ethereum studio
описание bitcoin bitcoin переводчик roboforex bitcoin
bitcoin это master bitcoin
bitcoin хешрейт gps tether график ethereum ethereum акции blue bitcoin blake bitcoin wordpress bitcoin cryptocurrency bitcoin путин monero btc bitcoin сервисы ethereum poloniex bitcoin google bitcoin заработать прогноз bitcoin bitcoin dogecoin coinwarz bitcoin bitcoin service торрент bitcoin bitcoin dice wild bitcoin вывод bitcoin ethereum купить
bitcoin государство wirex bitcoin bitcoin neteller bitcoin keywords bitcoin разделился bitcoin allstars ethereum обвал bitcoin rigs ru bitcoin продам bitcoin сколько bitcoin bitcoin иконка monero кран trezor ethereum ethereum homestead bitcoin 0 bitcoin easy компьютер bitcoin
click bitcoin poloniex monero advcash bitcoin reddit cryptocurrency bitcoin paypal monero ico
bitcoin puzzle dollar bitcoin bitcoin валюты bitcoin roulette bitcoin book keys bitcoin
satoshi bitcoin 2016 bitcoin инвестиции bitcoin
bitcoin wordpress bitcoin primedice форк bitcoin calculator ethereum bitcoin space иконка bitcoin bitcoin png neo bitcoin лото bitcoin *****p ethereum bitcoin лого купить ethereum лото bitcoin ethereum claymore ethereum алгоритм
neo cryptocurrency antminer bitcoin block bitcoin bitcoin rub инструкция bitcoin
сколько bitcoin cryptocurrency capitalisation bitcoin strategy wiki bitcoin bitcoin datadir бесплатный bitcoin bitcoin sha256 вывод ethereum cold bitcoin cryptocurrency ethereum
ethereum получить bitcoin код get bitcoin bitcoin now bitcoin qr This prohibitive hardware requirement is one of the biggest security measures that deter people from trying to manipulate the bitcoin system.Bitcoin is a digital currency, a decentralized system which records transactions in a distributed ledger called a blockchain.case bitcoin bitcoin favicon ethereum контракты блокчейн ethereum love bitcoin micro bitcoin autobot bitcoin download bitcoin знак bitcoin bitcoin начало sec bitcoin халява bitcoin ethereum faucet bitcoin торговля
кошелька ethereum matrix bitcoin bitcoin pps bitcoin withdrawal подарю bitcoin monero cryptonote
bitcoin play вход bitcoin captcha bitcoin bus bitcoin master bitcoin bitcoin blog bitcoin poloniex bitcoin metatrader компания bitcoin arbitrage cryptocurrency bitcoin spinner moto bitcoin
4000 bitcoin difficulty monero bitcoin gambling claim bitcoin monero miner ethereum blockchain mist ethereum отслеживание bitcoin rx560 monero yota tether бесплатный bitcoin nanopool ethereum monster bitcoin bitcoin телефон 8 bitcoin
l bitcoin робот bitcoin использование bitcoin hd7850 monero bitcoin airbitclub bitcoin мониторинг bitcoin loan RSA (Rivest-Shamir-Adleman)Security Breaches Cause Volatilitybitcoin world cryptocurrency wallet обсуждение bitcoin car bitcoin bitcoin puzzle calculator bitcoin bitcoin разделился fox bitcoin bitcoin charts ethereum testnet dogecoin bitcoin bitcoin монета блокчейн bitcoin обновление ethereum escrow bitcoin bitcoin алгоритм loco bitcoin bitcoin установка casinos bitcoin up bitcoin community bitcoin community bitcoin cryptocurrency magazine planet bitcoin
bitcoin rpg monero новости взломать bitcoin bitcoin blockstream
bitcoin payment bitcoin favicon bio bitcoin nem cryptocurrency monero обменять 6000 bitcoin сколько bitcoin bitcoin fork A cryptocurrency wallet stores the public and private 'keys' or 'addresses' which can be used to receive or spend the cryptocurrency. With the private key, it is possible to write in the public ledger, effectively spending the associated cryptocurrency. With the public key, it is possible for others to send currency to the wallet.