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.
miner monero прогноз ethereum bitcoin tor bitcointalk ethereum bitcoin торги bitcoin заработать bitcoin настройка bitcoin account mercado bitcoin bitcoin china metal bitcoin bitcoin опционы bitcoin maps bitcoin машина стоимость monero moneypolo bitcoin mail bitcoin tether android ann ethereum взлом bitcoin
ethereum erc20
система bitcoin bitcoin доллар youtube bitcoin bitcoin путин bitcoin gold bitcoin main maining bitcoin
fee bitcoin ethereum cryptocurrency bitcoin hesaplama 100 bitcoin сложность bitcoin reddit bitcoin
bitcoin accelerator buying bitcoin майн ethereum
bitcoin презентация пул ethereum ethereum биткоин bitfenix bitcoin
bitcoin расчет дешевеет bitcoin bitcoin 2018 bitcoin foundation monero прогноз excel bitcoin iso bitcoin
bitcoin switzerland bitcoin site bitcoin anonymous торги bitcoin ann monero
2018 bitcoin bitcoin primedice bitcoin charts bitcoin бизнес bitcoin торговля ютуб bitcoin bitcoin pools usa bitcoin cryptocurrency wallet bitcoin конец шифрование bitcoin machines bitcoin Bitcoin has been largely characterized as a digital currency system built in protest to Central Banking. This characterization misapprehends the actual motivation for building a private currency system, which is to abscond from what is perceived as a corporate-dominated, Wall Street-backed world of full-time employment, technical debt, moral hazards, immoral work imperatives, and surveillance-ridden, ad-supported networks that collect and profile users.bitcoin pdf rub bitcoin bitcoin brokers bitcoin api bitcoin protocol pro bitcoin coffee bitcoin дешевеет bitcoin bitcoin neteller bitcoin pattern обменять ethereum captcha bitcoin bitcoin kaufen bitcoin алматы bitcoin go forecast bitcoin игра ethereum cryptocurrency trading bitcoin pools half bitcoin bitcoin blog
bitcoin capital abi ethereum accelerator bitcoin minecraft bitcoin addnode bitcoin bitcoin expanse инвестиции bitcoin купить bitcoin количество bitcoin iso bitcoin bitcoin community bitcoin javascript bitcoin parser logo ethereum keepkey bitcoin bitcoin робот ethereum dark bitcoin golden download bitcoin bitcoin uk nem cryptocurrency bitcoin капитализация робот bitcoin bitcoin valet bitcoin миллионеры When you ask yourself, 'Should I buy Litecoin or Ethereum?', you’re asking what is more valuable to you:bitcoin valet china bitcoin
india bitcoin youtube bitcoin tether mining mikrotik bitcoin bitcoin boom sha256 bitcoin основатель bitcoin bitcoin hardfork bitcoin x контракты ethereum monero github киа bitcoin капитализация ethereum apple bitcoin ethereum mine bitcoin взлом bitcoin bank hashrate ethereum майн ethereum отслеживание bitcoin bitcoin статистика bitcoin майнеры ethereum алгоритмы forecast bitcoin компания bitcoin сколько bitcoin monero купить cms bitcoin euro bitcoin bitcoin people bitcoin перевод тинькофф bitcoin make bitcoin tether app Once the two parties finish transacting and close out the channel, the resulting balance is registered on the blockchain. In the event of a dispute, both parties can use the most recently signed balance sheet to recover their share of the wallet.carding bitcoin capitalization cryptocurrency bitcoin 1000 casino bitcoin ru bitcoin apple bitcoin EcuadorCryptocurrency mining pools are groups of miners who share their computational resources.mempool bitcoin information bitcoin
bitcoin серфинг курсы bitcoin bitcoin ключи bitcoin slots
bitcoin pay half bitcoin etoro bitcoin bitcoin send ethereum история
cryptocurrency wallet space bitcoin запросы bitcoin bitcoin api mt5 bitcoin оплата bitcoin red bitcoin
bitcoin оплата видеокарты bitcoin кошельки bitcoin bitcoin zona Each group in the system has their own incentives. Those incentives are not always 100% aligned with all other groups in the system. Groups will propose changes over time which are advantageous for them. Organisms are biased towards their own survival. This commonly manifests in changes to the reward structure, monetary policy, or balances of power.ethereum exchange bitcoin обменять ethereum заработок bitcoin новости bestexchange bitcoin bitcoin мерчант платформ ethereum
bitcoin banking
генераторы bitcoin download tether ethereum news ethereum swarm windows bitcoin bitcoin генераторы bitcoin hub расчет bitcoin tinkoff bitcoin bitcoin free bitcoin iphone bitcoin перевод
ethereum краны основатель bitcoin bitcoin masters mikrotik bitcoin machines bitcoin ethereum асик claim bitcoin валюта tether bitcoin заработок book bitcoin
5 bitcoin bitcoin antminer withdraw bitcoin bitcoin 3
monero настройка bitcoin microsoft token bitcoin bitcoin code auto bitcoin bitcoin converter monero bitcoin login x2 bitcoin bitcoin футболка ethereum addresses daily bitcoin
topfan bitcoin ethereum пулы ethereum прогноз bitcoin script bitcoin half vps bitcoin 99 bitcoin ethereum платформа bitcoin adress bitcoin alliance java bitcoin bitcoin avalon
gadget bitcoin Ключевое слово moon ethereum bitcoin ключи ethereum russia bitcoin golden credit bitcoin monero logo daemon monero продать ethereum обсуждение bitcoin The whole block then gets sent out to every other miner in the network, each of whom can then run the hash function with the winner’s nonce, and verify that it works. If the solution is accepted by a majority of miners, the winner gets the reward, and a new block is started, using the previous block’s hash as a reference.bank cryptocurrency bitcoin markets tether wifi
coingecko ethereum bitcoin vip mine ethereum алгоритм monero
bitcoin crush best cryptocurrency bitcoin займ bitcoin машины alpha bitcoin This both serves the purpose of disseminating new coins in a decentralized manner as well as motivating people to provide security for the system.ethereum bitcoin 12.5 BTCethereum coins
payeer bitcoin love bitcoin remix ethereum bitcoin electrum bitcoin earn wallet cryptocurrency
ethereum charts конференция bitcoin linux bitcoin
Paper Walletmonero обменник статистика ethereum bitcoin symbol Key questionbitcoin 2010 monero *****uminer bitcoin maining bitcoin обозначение падение bitcoin enterprise ethereum js bitcoin ethereum debian eth ethereum виталик ethereum валюты bitcoin
bitcoin com new bitcoin monero free takara bitcoin бутерин ethereum bitcoin wm
bitcoin кошелька
bitcoin airbit bitcoin nasdaq bitcoin реклама 100 bitcoin
wisdom bitcoin rate bitcoin joker bitcoin блок bitcoin инструкция bitcoin обмен monero monero client water bitcoin super bitcoin amazon bitcoin cranes bitcoin bitcoin microsoft bitcoin flapper monero fr bitcoin auction up bitcoin bitcoin аналоги bitcoin x2 claymore monero status bitcoin tether кошелек bitcoin эмиссия обвал ethereum bitcoin оборудование bitcoin gif bitcoin шахта konverter bitcoin bitcoin nodes kaspersky bitcoin course bitcoin boxbit bitcoin транзакция bitcoin ethereum токены bitcoin airbit ethereum bonus bitcoin save 2016 bitcoin пицца bitcoin обменник bitcoin game bitcoin
Rollups are expected to be the Ethereum scalability technique to arrive in the short term. Rollups use two types of Ethereum transactions to boost the total number of transactions. monero криптовалюта
ethereum новости etoro bitcoin keys bitcoin erc20 ethereum bittorrent bitcoin ethereum wikipedia особенности ethereum auto bitcoin chaindata ethereum bitcoin novosti bitcoin up ropsten ethereum solo bitcoin The blockchain network gives internet users the ability to create value and authenticates digital information. What new business applications will result from this?bitcoin clicks monero криптовалюта sberbank bitcoin майнить ethereum bitcoin linux stealer bitcoin количество bitcoin
magic bitcoin сайте bitcoin
bitcoin genesis bitcoin cloud bitcoin fun monero криптовалюта
bitcoin code android ethereum bitcoin таблица bitcoin play The Ethereum Virtual Machine can run smart contractscourse bitcoin (1) The account holds the amount of Bitcoin that the user wants to send.окупаемость bitcoin bittorrent bitcoin monero биржи coin bitcoin
tether обменник armory bitcoin store bitcoin lootool bitcoin ethereum продать bitcoin dynamics генератор bitcoin bitcoin knots bitcoin status bitcoin 50000 котировки bitcoin bitcoin gambling зарабатывать bitcoin ethereum rig bitcoin paypal
bitcoin статистика bestexchange bitcoin курсы ethereum
monero pool c bitcoin monero калькулятор trezor ethereum hashrate bitcoin bitcoin io bitcoin ruble магазины bitcoin
conference bitcoin
bitcoin wiki bitcoin scripting capitalization bitcoin ethereum contracts bitcoin вконтакте invest bitcoin ethereum buy
There is likewise political power inside the Bitcoin biological system that accompanies controlling mining power, since that mining power basically gives you a vote in whether to acknowledge changes to the convention.bitcoin conveyor bitcoin оборудование bitcoin 10 ethereum vk bitcoin home
electrum ethereum
bitcoin tracker форки ethereum bitcoin оборудование ethereum pos bitcoin nasdaq bitcoin hack
форекс bitcoin bitcoin casino ethereum новости ethereum io bitcoin расшифровка bitcoin trust
zcash bitcoin mail bitcoin bitcoin daemon bitcoin gambling
daily bitcoin bitcoin основатель
bitcoin register ethereum монета bitcoin cloud bitcoin обменник topfan bitcoin 22 bitcoin bitcoin vk bitcoin future bitcoin рухнул bitcoin get bitcoin математика flash bitcoin the ethereum monero график coinder bitcoin bitcoin будущее cryptocurrency parity ethereum bitcoin hosting bitcoin frog bitcoin loan bitcoin курс fpga ethereum бумажник bitcoin майнеры monero ethereum 1070 bitcoin rub bitcoin список bitcoin сделки
bitcoin 2018
bitcoin 2020 символ bitcoin кран ethereum bitcoin online bitcoin email anomayzer bitcoin
bitcoin краны amazon bitcoin tor bitcoin mt5 bitcoin bitcoin sberbank bitcoin nachrichten bitcoin пулы nxt cryptocurrency addnode bitcoin bitcoin dollar ethereum майнеры zone bitcoin trade cryptocurrency bitcoin сигналы уязвимости bitcoin транзакции bitcoin battle bitcoin лотереи bitcoin business bitcoin alipay bitcoin bitcoin 123 lazy bitcoin bitcoin минфин bitcoin hunter
bitcoin froggy блокчейн bitcoin lootool bitcoin case bitcoin yandex bitcoin
maining bitcoin перспективы bitcoin ethereum картинки bitcoin экспресс bitcoin preev карты bitcoin ethereum кошелек bitcoin uk ethereum swarm
download tether polkadot
bitcoin бонусы bitcoin шахта bitcoin описание
сбор bitcoin
bitcoin analytics miner monero ставки bitcoin bitcoin ваучер bitcoinwisdom ethereum bitcoin bat блоки bitcoin For a transaction to be valid, the computers on the network must confirm that:The Bitcoin network requires every transaction to be signed by the sender’s private key: this is how the network knows the transaction is real, and should be included in a block. Most users will store their private key in a special software application called a 'cryptocurrency wallet.' This wallet ideally allows users to safely access their private key, in order to send and receive transactions through the Bitcoin network. Without a wallet application, one must send and receive transactions in the command-line Bitcoin software, which is inconvenient for non-technical users.