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.
explorer ethereum sec bitcoin bitcoin видеокарта electrum bitcoin bitcoin genesis курса ethereum технология bitcoin bitcoin курсы bitcoin clouding bitcoin ico биткоин bitcoin youtube bitcoin dwarfpool monero lucky bitcoin bitcoin кредиты purchase bitcoin bitcoin исходники avto bitcoin
bitcoin проверить
The plan was for investors in The DAO to receive tokens proportional to how much ether they invested in the project. With those tokens they could vote for which projects to fund. For selecting projects to invest in, it relied on the 'wisdom of crowds,' the idea that decisions made by a large group of people voting often leads to better outcomes than a single director, or even multiple directors making the decision.прогнозы bitcoin bitcoin download monero биржи wisdom bitcoin bitcoin куплю moneybox bitcoin dash cryptocurrency bitcoin 2020
ethereum markets bitcoin обсуждение bitcoin футболка bitcoin исходники For example, with Bitcoin, the huge hack that recently stole 70 million consumers’ credit card information from the Target department store chain would not have been possible. Here’s how that would work:unconfirmed bitcoin erc20 ethereum monero btc автосборщик bitcoin bitcoin surf
bitcoin tube bitcoin advcash nicehash bitcoin cryptocurrency ico bitcoin математика
капитализация bitcoin ethereum io получить ethereum bitcoin brokers bitcoin play coindesk bitcoin ethereum chaindata ethereum swarm bitcoin vpn bitcoin crypto doubler bitcoin bitcoin мошенники ethereum кошельки monero mining prune bitcoin monero coin акции ethereum metropolis ethereum bitcoin blocks bitcoin котировки tether gps bitcoin playstation ethereum сайт bounty bitcoin location bitcoin
bitcoin protocol bitcoin unlimited bitcoin москва bitcoin rotator bitcoin news ethereum algorithm ethereum twitter casascius bitcoin keystore ethereum bitcoin государство
putin bitcoin
tether верификация bitcoin приложения bitcoin вирус monero freebsd окупаемость bitcoin bitcoin eth кошель bitcoin abi ethereum
de bitcoin bitcoin fake daily bitcoin poloniex ethereum
bitcoin statistic faucet bitcoin платформы ethereum хабрахабр bitcoin avatrade bitcoin хайпы bitcoin bitcoin презентация
bitcoin freebitcoin bitcoin блок
казино ethereum рост ethereum cold bitcoin ethereum web3 bitcoin pizza ethereum картинки ethereum coin bitcoin pdf lamborghini bitcoin bitcoin прогноз mining bitcoin monero краны bitcoin code bitcoin пополнение lootool bitcoin nonce bitcoin сети bitcoin проверка bitcoin bitcoin elena цены bitcoin bitcoin swiss rx580 monero системе bitcoin конвертер bitcoin tether кошелек bitcoin cap minergate bitcoin bitcoin icon форекс bitcoin bitcoin уязвимости брокеры bitcoin куплю ethereum
скрипты bitcoin сервисы bitcoin ethereum биржа
plus500 bitcoin tether обменник bitfenix bitcoin blogspot bitcoin kurs bitcoin Cryptocurrency Tradingblog bitcoin xpub bitcoin bitcoin nvidia Whether you have an online or a bricks-and-mortar store, if you accept bitcoin, you need to publicize the fact. You can find a ‘bitcoin accepted here’ sign at the bitcoin wiki.bitcoin торги account bitcoin bitcoin currency bitcoin clicks
bitcoin status 1 bitcoin надежность bitcoin ethereum продать bitcoin moneybox форки bitcoin
*****a bitcoin сборщик bitcoin hack bitcoin ethereum картинки основатель ethereum bitcoin airbitclub usa bitcoin
bitcoin okpay bestexchange bitcoin analysis bitcoin инструкция bitcoin polkadot stingray bitcoin money coinbase ethereum bitcoin xpub monero калькулятор обменники bitcoin bitcoin fpga escrow bitcoin ethereum pool bitcoin io робот bitcoin flappy bitcoin курс ethereum monero xeon 33 bitcoin bitcoin yen
hack bitcoin location bitcoin
bitcoin conveyor alliance bitcoin captcha bitcoin ethereum обменять сложность monero alpha bitcoin bitcoin torrent ethereum вики bitcoin автосерфинг new bitcoin bitcoin xt ethereum сайт monero rur all cryptocurrency bitcoin talk автомат bitcoin
прогноз ethereum bitcoin ico bitcoin бизнес ethereum статистика bitcoin icons конвектор bitcoin bitcoin trust hashrate bitcoin bitcoin миксер кошельки bitcoin порт bitcoin bitcoin платформа bitcoin switzerland ethereum прогноз
multisig bitcoin bitcoin skrill будущее ethereum раздача bitcoin bitcoin darkcoin bitcoin торговать coinmarketcap bitcoin monero miner gas ethereum habrahabr bitcoin bitcoin wiki bitcoin xpub bitcoin birds nicehash bitcoin new bitcoin bitcoin payoneer bitcoin xl bitcoin atm
cryptocurrency nem carding bitcoin скрипты bitcoin
bitcoin доходность ethereum game claim bitcoin bitcoin converter bitcoin blue торговать bitcoin
checker bitcoin сложность monero падение ethereum
monero spelunker
bitcoin evolution bitcoin security green bitcoin блоки bitcoin майн ethereum
bitcoin reddit bitcoin путин график bitcoin кошелек ethereum moneybox bitcoin zebra bitcoin bitcoin ethereum bitcoin fasttech
bitcoin bonus bitcoin ммвб bitcoin таблица pos ethereum ethereum telegram биржа monero up bitcoin bitcoin conveyor
ethereum org bip bitcoin electrum bitcoin casinos bitcoin rbc bitcoin ethereum erc20 payable ethereum bitcoin цены bitcoin crane биржи monero
bitcoin обсуждение
daemon monero asics bitcoin bitcoin desk ethereum miners jax bitcoin bitcoin иконка bitcoin talk bitcoin 2020 bitcoin scrypt bitcoin marketplace bittorrent bitcoin location bitcoin nanopool ethereum monero майнить bitcoin torrent bitcoin trader курс ethereum новые bitcoin рост bitcoin cryptocurrency top matrix bitcoin nicehash bitcoin bitcoin paper vps bitcoin ethereum investing decred ethereum alpari bitcoin cryptonight monero capitalization cryptocurrency
скрипты bitcoin polkadot stingray bubble bitcoin прогнозы bitcoin исходники bitcoin bitcoin usd
bitcoin qt bitcoin transaction bitcoin миллионеры транзакции ethereum bitcoin steam bitcoin бесплатные bitcoin switzerland майнить bitcoin reverse tether bitcoin куплю cryptocurrency tech bitcoin ne se*****256k1 bitcoin bitcoin россия
bitcoin background code bitcoin кошель bitcoin fx bitcoin bitcointalk monero фото bitcoin bitcoin hyip bitcoin заработать dogecoin bitcoin верификация tether
monero difficulty ethereum калькулятор elysium bitcoin dance bitcoin korbit bitcoin bitcoin сигналы etherium bitcoin обменник bitcoin future bitcoin the ethereum blacktrail bitcoin
bitcoin exchange хардфорк bitcoin эпоха ethereum bitcoin de
bitcoin home bitcoin login tether обзор bitcoin space ethereum *****u bitcoin drip bitcoin матрица ethereum биткоин разработчик bitcoin kinolix bitcoin
bitcoin game обмен tether bitcoin scripting
bitcoin компьютер bitcoin hunter bitcoin котировки теханализ bitcoin 4 bitcoin bitcoin вложить ethereum получить koshelek bitcoin the ethereum
настройка bitcoin ethereum bitcoin пополнить bitcoin monero difficulty index bitcoin bitcoin knots тинькофф bitcoin ethereum обозначение bitcoin markets bitcoin бонусы What makes Cyptocurrencies special?In order to mine Ethereum, you need specialized computers that can perform the computations necessary to create new tokens on the blockchain in a timely manner as well as a significant amount of electricity, which is required to run the equipment continuously. All of this adds up to significant upfront costs.арестован bitcoin swiss bitcoin bitcoin hesaplama автосборщик bitcoin 5 bitcoin суть bitcoin cardano cryptocurrency
gek monero
ethereum акции bitcoin пицца
bitcoin окупаемость спекуляция bitcoin testnet ethereum korbit bitcoin бесплатный bitcoin терминал bitcoin
bitcoin mining сервисы bitcoin bitcoin доходность armory bitcoin ethereum пулы bitcoin рубль bitcoin получить ethereum metropolis bitcoin dice bitcoin s bitcoin комиссия
total cryptocurrency stealer bitcoin
nubits cryptocurrency bitcoin exe siiz bitcoin ethereum calc bitcoin курсы locate bitcoin bitcoin wordpress casper ethereum loan bitcoin bitcoin отзывы ethereum coin bitcoin переводчик
котировки bitcoin monero новости tether курс ethereum habrahabr bitcoin сша продать ethereum bitcoin games форк ethereum
4000 bitcoin bitcoin casino future bitcoin теханализ bitcoin
bitcoin base trade cryptocurrency bitcoin кэш bitcoin x ethereum rub hosting bitcoin
bitcoin carding bitcoin index bitcoin virus
earning bitcoin bitcoin rbc блокчейна ethereum abc bitcoin
bitcoin zona 777 bitcoin bitcoin баланс monero *****uminer пулы monero
bitcoin earnings bitcoin calc bitcoin club bitcoin mempool bitcoin blue адрес bitcoin новый bitcoin bitcoin хабрахабр
Antminer L3+: The Antminer L3+ is by far the most powerful Litecoin mining hardware that you can buy. Not only is it also the quickest, but it is also made by a well-known manufacturer called BitMain. No other Litecoin mining hardware will compete with this.antminer bitcoin planet bitcoin bitcoin zona l bitcoin The anonymity of bitcoinsegwit2x bitcoin
It’s like if someone identifies a new element, and people begin discovering uses for that element, and it experiences a period of rapid growth and high price volatility, until it has been around for sufficient time that it eventually settles in to a normal volatility band.lite bitcoin хардфорк bitcoin bitcoin eth bitcoin multisig
ethereum contracts best cryptocurrency icon bitcoin escrow bitcoin bitcoin friday mmm bitcoin usb bitcoin bitcoin страна pay bitcoin
ethereum прибыльность king bitcoin bitcoin script пополнить bitcoin 2048 bitcoin приват24 bitcoin ethereum форк payoneer bitcoin bitcoin казахстан linux bitcoin валюта monero
bitcoin farm bitcoin pools bitcoin capitalization bitcoin transaction
20 bitcoin bitcoin foto ethereum crane ethereum foundation moneybox bitcoin bitcoin png xpub bitcoin сайте bitcoin pokerstars bitcoin криптовалюту monero bitcoin форумы bitcoinwisdom ethereum bitcoin yandex top cryptocurrency монета ethereum bitcoin india price bitcoin doge bitcoin bitcoin аккаунт bitcoin circle bitcoin торрент bitcoin carding bitcoin bux оплата bitcoin bitcoin фермы bitcoin monkey shot bitcoin bitcoin платформа tether майнинг россия bitcoin account bitcoin zcash bitcoin курс bitcoin electrum bitcoin bitcoin значок добыча bitcoin
bitcoin synchronization bitcoin сигналы monero wallet home bitcoin up bitcoin bitcoin оборот
bitcoin generation iso bitcoin bitcoin торговля bitcoin пополнить bitcoin фарм bitcoin roll bitcoin earn tether coin miner monero checker bitcoin bitcoin фирмы bitcoin double вывод ethereum bitcoin россия keystore ethereum bitcoin курсы se*****256k1 bitcoin bitcoin китай ann monero bitcoin clock 9000 bitcoin mine ethereum autobot bitcoin Monero Mining: Full Guide on How to Mine Moneroсколько bitcoin bitcoin курс bitcoin miner отследить bitcoin xpub bitcoin ethereum shares автомат bitcoin bitcoin bubble
bitcoin gadget bitcoin логотип
bitcoin abc куплю ethereum ethereum casino bitcoin freebitcoin Past, present, and future of ASIC manufacturingbitcoin chain bitcoin freebie