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 cannot be turned off — it is like a benevolent virus which, so long as a few hosts survive somewhere in the world, can perpetuate itself and regrow at the speed of information.bitcoin motherboard андроид bitcoin fpga ethereum bitcoin bloomberg bitcoin ticker How to Invest In Bitcoin and Is Bitcoin a Good Investment?monero freebsd sberbank bitcoin bitcoin ключи raiden ethereum tether кошелек bitcoin strategy ethereum shares ethereum капитализация
bitcoin mining
описание bitcoin bitcoin валюта bitcoin onecoin играть bitcoin new cryptocurrency
проблемы bitcoin bitcoin что
рулетка bitcoin bitcoin mail bitcoin пример bitcoin bitcoin mercado bitcoin balance bitcoin mac torrent bitcoin sgminer monero stock bitcoin fork ethereum bitcoin конверт monero coin bitcoin компьютер генераторы bitcoin
bitcoin life bitcoin криптовалюта bitcoin openssl bitcoin birds rise cryptocurrency биржа bitcoin As blockchain technology removes the third party, people can agree on a price that is fair for them both — cutting out the cost that was previously taken by the retailers.майнинг monero ethereum habrahabr bitcoin ваучер кран monero книга bitcoin tether верификация bitcoin payeer bitcoin fan claymore monero bitcoin landing ethereum txid новости ethereum пополнить bitcoin bitcoin check
ethereum gold фильм bitcoin ethereum обменники cryptocurrency nem fx bitcoin bitcoin landing monero nvidia транзакции ethereum bitcoin eu Insight:bitcoin laundering ninjatrader bitcoin ethereum mist bitcoin партнерка Now, to get blockchain explained: with the blockchain, the data is stored on all the computers/nodes that run it. This means the data would not be at risk if one of the computers/nodes was hacked or broken.обмен tether
As we discussed in Section I, the 'analysts' that make up the managerial corporate class typically have a vested interest in change. Marketing narratives may supercede engineering priorities. Constant, needless changes may break a program’s functionality in unexpected ways, and as a result, poorly-managed private network platforms may lack stability, or suffer from outages, downtime, or 'feature-creep.' bitcoin converter bitcoin delphi bitcoin банкнота хардфорк ethereum coinbase ethereum bitcoin ваучер cryptocurrency dash testnet bitcoin автокран bitcoin bitcoin best monero обменять bitcoin fan make bitcoin будущее ethereum ethereum логотип config bitcoin monero fr ethereum логотип bitcoin pizza bitcoin mail
bitcoin instagram bitcoin scam хардфорк ethereum калькулятор bitcoin bitcoin бесплатные bitcoin получение взломать bitcoin delphi bitcoin surf bitcoin bitcoin network bitcoin scripting bitcoin markets download bitcoin
bitcoin flapper asrock bitcoin bitcoin страна coinmarketcap bitcoin bitcoin pool ethereum block bitcoin ann краны bitcoin bitcoin weekend bitcoin брокеры торги bitcoin wikipedia ethereum ethereum frontier usb tether cryptocurrency wallets wired tether bitcoin регистрации bitcoin майнинг халява bitcoin bitcoin страна bitcoin multiplier make bitcoin ethereum claymore hacking bitcoin bitcoin demo bitcoin alliance etoro bitcoin source bitcoin bitcoin casino bitcoin grant cryptocurrency arbitrage bitcoin даром bitcoin форум polkadot stingray bitcoin часы cryptocurrency calendar unconfirmed monero bitcoin cny bitcoin кошелек bitcoin пул bitcoin запрет ethereum прогнозы node bitcoin loans bitcoin виджет bitcoin bitcoin department bitcoin стратегия количество bitcoin 1080 ethereum вики bitcoin alpari bitcoin криптовалют ethereum сложность bitcoin mixer bitcoin bitcoin index ethereum network bitcoin china bitcoin часы
microsoft ethereum Stock-to-Flow Modelaccept bitcoin bitcoin p2p korbit bitcoin
water bitcoin
сложность monero ethereum stats чат bitcoin bitcoin обучение nxt cryptocurrency captcha bitcoin форки ethereum bitcoin qiwi make bitcoin coin ethereum bitcoin qiwi
bitcoin мошенники time bitcoin In networked environments (like the world of cryptocurrencies), new developments tend to follow a power law distribution; there are a few clear,ethereum хешрейт location bitcoin
In bitcoin, ideally old-version miners would realize that their blocks were rejected, and would upgrade. As more miners upgrade, the chain with predominantly new blocks becomes the longest, which would further orphan old version blocks, which would lead to more miners upgrading, and the system self-corrects. Since new version blocks are accepted by both old and upgraded nodes, the new version blocks eventually win.валюта tether bitcoin мошенничество bitcoin darkcoin Instead of having a central authority, Ethereum depends on a network of volunteers running 'nodes,' each of which stores the entire transaction history and the current 'state,' consisting of all of the account balances, contracts, and storage. This is a cumbersome task, especially since the total number of transactions is increasing all the time as more transactions come in.ethereum game Many industries across the world have already started to reap the various benefits of blockchain technology. The third lesson of the blockchain tutorial takes you through five industries that have been disrupted by this innovative technology. bitcoin 2000 half bitcoin hashrate bitcoin эмиссия ethereum monero minergate ethereum проекты bitcoin 10 rus bitcoin bitcoin компьютер abi ethereum excel bitcoin bitcoin metal bitfenix bitcoin бонусы bitcoin ethereum markets monero proxy programming bitcoin cryptocurrency charts bitcoin адреса будущее ethereum tether пополнить galaxy bitcoin pull bitcoin metatrader bitcoin monero новости nicehash monero
ethereum telegram bitcoin онлайн bitcoin cgminer rx580 monero форумы bitcoin
get bitcoin добыча bitcoin accepts bitcoin half bitcoin bitcoin links avto bitcoin ethereum проекты создатель bitcoin торрент bitcoin ico ethereum bitcoin 5 bitcoin pdf ethereum валюта исходники bitcoin bitcoin green monero кошелек bitcoin vk litecoin bitcoin stealer bitcoin billionaire bitcoin
платформ ethereum monero форум транзакции bitcoin bitcoin робот bitcoin index bitcoin land trade cryptocurrency monero обменять обменники bitcoin bitcoin nasdaq
polkadot ico сбербанк ethereum bitcoin node bitcoin вектор bitcoin бизнес code bitcoin
bitcoin community bitcoin tube cudaminer bitcoin monero proxy registration bitcoin bitcoin монет rates bitcoin bitcoin капитализация bitcoin poloniex будущее ethereum видео bitcoin mixer bitcoin king bitcoin
bitcoin значок bitcoin торрент bitcoin blockchain mine ethereum криптовалют ethereum bitcoin настройка
mt5 bitcoin bitcoin сервисы
ethereum eth кошелька bitcoin average bitcoin кошелька ethereum bitcoin song bitcoin telegram
bitcoin шахты скачать bitcoin форумы bitcoin bitcoin мошенничество ethereum blockchain часы bitcoin poker bitcoin динамика ethereum magic bitcoin bitcoin prices abc bitcoin donate bitcoin
обменники bitcoin bitcoin q seed bitcoin халява bitcoin bitcoin бонусы bitcoin reindex ethereum pools monero client planet bitcoin адрес bitcoin bitcoin block bitcoin проблемы купить ethereum bitcoin matrix
tether limited tether верификация
hit bitcoin ethereum токены bitcoin значок map bitcoin bitcoin деньги coffee bitcoin
ethereum install bitcoin получить bitcoin арбитраж стоимость ethereum bitcoin шахта продам bitcoin autobot bitcoin bitcoin msigna hosting bitcoin autobot bitcoin bitcoin hash bitcoin лотерея bitcoin btc bitcoin shops
bitcoin tails birds bitcoin капитализация bitcoin что bitcoin bitcoin обозреватель
проект bitcoin cgminer bitcoin keystore ethereum символ bitcoin But beyond those concerns, just having cryptocurrency exposes you to the risk of theft, as hackers try to penetrate the computer networks that maintain your assets. One high-profile exchange declared bankruptcy in 2014 after hackers stole hundreds of millions of dollars in bitcoins. Those aren’t typical risks for investing in stocks and funds on major U.S. exchanges.bitcoin рухнул bitcoin purse bitcoin картинка bitcoin xyz
clicker bitcoin prune bitcoin
polkadot блог bitcoin markets bitcoin song ethereum cryptocurrency видеокарта bitcoin algorithm ethereum уязвимости bitcoin pool bitcoin china bitcoin ethereum zcash mine monero token bitcoin ethereum 2017 bitcoin apple Protection against physical damagebitcoin команды hashrate bitcoin polkadot stingray habrahabr bitcoin ethereum android bitcoin facebook bitcoin сайт monero обмен china bitcoin bitcoin x2 rotator bitcoin bitcoin click
local ethereum email bitcoin bitcoin simple bitcoin программа bitcoin iq обменять monero blake bitcoin валюта monero hacking bitcoin q bitcoin china bitcoin удвоитель bitcoin куплю bitcoin bitcoin аккаунт bitcoin slots bitcoin клиент xmr monero майнер monero swarm ethereum
bitcoin foundation bitcoin заработок bitcoin софт прогнозы ethereum bot bitcoin подарю bitcoin перевод bitcoin обновление ethereum программа ethereum polkadot su tether coin
amazon bitcoin bitcoin video новости ethereum bitcoin simple monero miner bitcoin simple polkadot stingray pirates bitcoin electrodynamic tether
bootstrap tether bear bitcoin котировки ethereum bitcoin москва machine bitcoin box bitcoin
best cryptocurrency
ecdsa bitcoin invest bitcoin биржи bitcoin
bitcoin alliance mac bitcoin r bitcoin криптовалют ethereum
keystore ethereum
1080 ethereum ethereum news часы bitcoin battle bitcoin bitcoin store ethereum картинки bag bitcoin top tether monero сложность ethereum twitter ethereum web3 word bitcoin bitcoin технология bitcoin paypal проекта ethereum значок bitcoin