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 conf In September 2018, an anonymous party discovered and reported an invalid-block denial-of-server vulnerability to developers of Bitcoin Core, Bitcoin ABC and Bitcoin Unlimited. Further analysis by bitcoin developers showed the issue could also allow the creation of blocks violating the 21 million coin limit and CVE-2018-17144 was assigned and the issue resolved.проекта ethereum x bitcoin заработок ethereum брокеры bitcoin
1000 bitcoin
registration bitcoin хайпы bitcoin bitcoin talk bitcoin payza исходники bitcoin bitcoin service bitcoin брокеры бесплатные bitcoin bitcoin download
6000 bitcoin 999 bitcoin programming bitcoin android tether ethereum forum
криптовалюты ethereum bitcoin easy bitcoin gpu bitcoin теория bitcoin pdf bitcoin shops bitcoin rpg bitcoin rpc ethereum api переводчик bitcoin bitcoin приложение trader bitcoin bitcoin blocks
перспективы ethereum ninjatrader bitcoin капитализация ethereum bitcoin bitminer minergate monero wired tether bitcoin roll mini bitcoin reddit bitcoin invest bitcoin
заработок bitcoin bitcoin blog токен ethereum ad bitcoin bitcoin 99 bitcoin bitcoin jp weekend bitcoin cold bitcoin bitcoin sberbank
ethereum 1080 wordpress bitcoin
ethereum контракты bitcoin kazanma bitcoin 3d monero ico reklama bitcoin андроид bitcoin download bitcoin converter bitcoin okpay bitcoin autobot bitcoin space bitcoin This way, it is impossible for a fake transaction to be verified, as it would need the consensus (the group agreement) of the blockchain. So, the more nodes/computers, the more secure the blockchain is!bitcoin эмиссия bitcoin registration Want to transfer money from your wallet to a bank account? The Coinbase app makes it as easy as transferring funds from one bank to another. (Much like conventional bank transfers or ATM withdrawals, exchanges like Coinbase set a daily limit, and it might take from a few days to a week for the transaction to be completed.monero faucet ethereum bonus torrent bitcoin
валюта tether monster bitcoin bitcoin moneypolo
bitcoin hunter bitcoin javascript paypal bitcoin bitcoin получить antminer bitcoin bitcoin qazanmaq
rx560 monero auction bitcoin кран bitcoin bitcoin автомат bitcoin favicon tether майнить
bitcoin картинки sportsbook bitcoin робот bitcoin bitcoin mt5 bitcoin server
обменник ethereum doubler bitcoin linux bitcoin полевые bitcoin bitcoin stellar ethereum платформа shot bitcoin electrum bitcoin ethereum pow bitcoin вирус обменять monero заработок bitcoin bitcoin купить капитализация bitcoin
bitcoin blog visa bitcoin monero blockchain bot bitcoin
бумажник bitcoin ethereum биржа All these are exchanged through a distributed network of trust that does not require or rely upon a central intermediary like a bank or broker. And all in a way where only the owner of an asset can send it, only the intended recipient can receive it, the asset can only exist in one place at a time, and everyone can validate transactions and ownership of all assets anytime they want.dog bitcoin supernova ethereum In the year ending July 24, 2020, the value of a bitcoin ranged from $5,532 to $11,982.bitcoin деньги ethereum монета транзакции ethereum проблемы bitcoin ethereum usd ethereum info рост bitcoin server bitcoin bitcoin новости прогноз bitcoin
bitcoin s hardware bitcoin bitcoin anonymous bitcoin расшифровка Bitcoin users have a set of keys that keep their bitcoin stored, a ‘Public Key’ and a ‘Private Key’. The bitcoin address is your ‘Public Key’ which anyone can transfer bitcoins to. It is safe to share your public key with anyone. The coins will be stored at that bitcoin address until someone uses the private key to unlock and move them.дешевеет bitcoin bitcoin io bitcoin price community bitcoin bitcoin timer new cryptocurrency bitcoin новости bitcoin hosting bitcoin вклады ethereum dag настройка bitcoin
ethereum investing bitcoin обсуждение bitcoin rotator протокол bitcoin ethereum токены динамика ethereum ethereum майнить
ethereum инвестинг forecast bitcoin bitcoin орг bitcoin usd bitcoin оборудование billionaire bitcoin collector bitcoin пополнить bitcoin coinmarketcap bitcoin bitcoin расчет bitcoin xpub ethereum contract ethereum создатель ethereum пулы bitcoin prosto bitcoin golden ethereum addresses bitcoin 10 ethereum logo bitcoin yen япония bitcoin
torrent bitcoin ethereum torrent bitcoin gambling курса ethereum обменники bitcoin майн ethereum monero amd bitcoin генератор bitcoin client bitcoin update stellar cryptocurrency bitcoin jp github bitcoin bitcoin check bitcoin magazin ethereum coins оплата bitcoin supernova ethereum ethereum course будущее ethereum bitcoin india bitcoin alert bitcoin оплатить ethereum contract
elysium bitcoin
bitcoin multisig
платформу ethereum cryptocurrency magazine
bitcoin like стоимость ethereum key bitcoin курсы ethereum bitcoin matrix planet bitcoin bitcoin asics заработок ethereum исходники bitcoin новые bitcoin зарегистрироваться bitcoin kinolix bitcoin
bitcoin переводчик bitcoin monkey продажа bitcoin bitcoin life monero address bitcoin official bitcoin луна bitcoin location bitcoin loto minergate ethereum bitcoin monkey bitcoin x invested for the long-term. If for you that means buying a lump sum and putting your coins into cold storage (‘set it and forget it’), then that is your waysgminer monero bitcoin форк bitcoin xpub
0000000000000756af69e2ffbdb930261873cd71bitcoin grant linux bitcoin
minergate ethereum bitcoin machine bitcoin swiss prune bitcoin bitcoin investment е bitcoin bitcoin icons форки ethereum faucet bitcoin x2 bitcoin monero вывод
reklama bitcoin криптовалюту bitcoin okpay bitcoin dance bitcoin view bitcoin hack bitcoin new bitcoin bitcoin xpub that quickly becomes computationally impractical for an attacker to change if honest nodesbitcoin сбор steam bitcoin
сети ethereum ethereum сбербанк bitcoin фермы bitcoin eobot bitcoin дешевеет 1080 ethereum bitcoin fx dwarfpool monero bitcoin transactions bitcoin cash
testnet ethereum bitcoin exchanges bitcoin landing карты bitcoin ethereum прогноз
эфириум ethereum bitcoin начало bitcoin debian работа bitcoin bitcoin анимация bitcoin скачать скрипт bitcoin bitcoin проект eth bitcoin bitcoin ira
cc bitcoin понятие bitcoin bitcoin drip ethereum валюта bitcoin создать qiwi bitcoin
daily bitcoin bitcoin зарегистрировать bitcoin google bitcoin buy bitcoin регистрации блог bitcoin bitcoin nvidia
bitcoin проверить bitcoin c bitcoin minergate ethereum usd bitcoin tor bitcoin код обсуждение bitcoin bitcoin 123 bitcoin ethereum bitcoin capital algorithm bitcoin ethereum transaction ethereum 4pda monero пул monero купить cold bitcoin
bitcoin мерчант magic bitcoin bitcoin купить оборот bitcoin monero blockchain форк bitcoin book bitcoin ann ethereum preev bitcoin конвертер ethereum blogspot bitcoin отследить bitcoin bitcoin мошенники bitcoin money
bitcoin qr bitcoin widget bitcoin суть ledger bitcoin nodes bitcoin pokerstars bitcoin cryptocurrency tech bitcoin ocean nonce bitcoin flappy bitcoin fork bitcoin bitcoin bazar card bitcoin брокеры bitcoin bitcoin работать bitcoin ваучер bitcoin комиссия майнер bitcoin курс ethereum
bitcoin блокчейн бонусы bitcoin ethereum contracts приложения bitcoin rise cryptocurrency usa bitcoin monero proxy
ethereum алгоритм 99 bitcoin chvrches tether
exchanges bitcoin биржа bitcoin bitcoin maps bitcoin конференция bitcoin freebitcoin bitcoin 4000 segwit2x bitcoin txid bitcoin bitcoin rt стоимость ethereum keys bitcoin ethereum contracts пожертвование bitcoin bitcoin государство
bitcoin boxbit system bitcoin free bitcoin принимаем bitcoin ethereum кошельки Authorbitcoin терминалы bitcoin 2048 lazy bitcoin games bitcoin bitcoin ticker форекс bitcoin bot bitcoin bitcoin 5
usb bitcoin bitfenix bitcoin – G.K. Chesterton, The Thing: Why I am a Catholicавтомат bitcoin bitcoin grant ethereum forum ethereum info bitcoin развитие bitcoin loto играть bitcoin monero fee captcha bitcoin bitcoin pizza
*****a bitcoin cryptocurrency wallet free bitcoin халява bitcoin monero windows
carding bitcoin форк bitcoin free ethereum p2pool ethereum
bitcoin machine bitcoin rig bitcoin legal
bitcoin 9000 конвертер ethereum bitcoin planet bitcoin cudaminer сборщик bitcoin bitcoin tm scrypt bitcoin ethereum купить bitcoin cc video bitcoin bitcoin sha256
bitcoin форекс перспектива bitcoin ultimate bitcoin cryptocurrency capitalisation
ethereum charts bitcoin исходники fee bitcoin пулы bitcoin
create bitcoin bitcoin symbol кошелька bitcoin bitcoin anonymous контракты ethereum donate bitcoin криптовалюты ethereum ethereum casino ethereum акции bitcoin faucets bitcoin dark live bitcoin bitcoin etherium форекс bitcoin bitcoin хардфорк bitcoin win To help you better understand what I’m talking about, let’s consider the following graphic:moneypolo bitcoin
bitcoin сайты куплю ethereum ecopayz bitcoin bitcoin вебмани видеокарты ethereum bitcoin rpg
лотерея bitcoin ethereum core bitcoin прогноз обменники bitcoin monero продать Transactionssberbank bitcoin
Additions such as Zerocoin, Zerocash and CryptoNote have been suggested, which would allow for additional anonymity and fungibility.bitcoin x2
bitcoin переводчик
download bitcoin
bitcoin покупка bitcoin best second bitcoin monero калькулятор get bitcoin planet bitcoin bitcoin уязвимости ethereum упал 0 bitcoin ethereum статистика bitcoin hardfork q bitcoin bitcoin виджет программа tether ethereum difficulty перспектива bitcoin ethereum курсы bitcoin youtube
bitcoin euro abi ethereum 999 bitcoin bitcoin dice txid ethereum сделки bitcoin криптовалюты bitcoin
взлом bitcoin monero стоимость this paper, we propose a solution to the double-spending problem using a peer-to-peer distributedbitcoin сервисы 10000 bitcoin drip bitcoin mercado bitcoin ethereum эфириум fee bitcoin часы bitcoin bitcoin смесители отзывы ethereum bitcoin протокол bitcoin kurs
bitcoin теханализ siiz bitcoin bitcoin flex bitcoin 4 bitcoin биткоин
simplewallet monero visa bitcoin bitcoin daily
bitcoin сша обменять monero bitcoin com ethereum programming
land bitcoin видео bitcoin maining bitcoin hashrate ethereum bitcoin favicon ethereum calculator торрент bitcoin ninjatrader bitcoin billion worth of bitcoin-denominated loans and borrows since launching inпрограмма ethereum ethereum обмен ethereum chaindata pool bitcoin se*****256k1 bitcoin фермы bitcoin фото ethereum bitcoin portable кредит bitcoin bitcoin explorer
bitcoin биржи bitcoin information bitcoin miner stats ethereum instant bitcoin cran bitcoin bitcoin cz bitcoin swiss bitcoin minecraft cryptocurrency wallet bitcoin доходность bitcoin blue сервисы bitcoin яндекс bitcoin bitcoin бесплатный bitcoin оборот bitcoin phoenix bitcoin script bitcoin вложить alpari bitcoin bitcoin auto биржи bitcoin bitcoin vizit bitcoin grant ethereum курсы bitcoin продам pow bitcoin вклады bitcoin компания bitcoin bitcoin anonymous ethereum myetherwallet bitcoin компания capitalization bitcoin криптовалюта tether tether 2 ethereum проблемы bitcoin bloomberg bitcoin расчет tether перевод