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 майнинг protocol bitcoin account bitcoin collector bitcoin
обновление ethereum
bitcoin today monero btc вход bitcoin bitcoin сервисы monero rur bitcoin mempool bitcoin base bitcoin роботы ethereum github accepts bitcoin x2 bitcoin tor bitcoin monero hardware
создатель bitcoin
community bitcoin bitcoin office mine ethereum bitcoin home bitcoin компания cryptonight monero ethereum транзакции
gas ethereum bitcoin news bitcoin видеокарта electrum ethereum email bitcoin logo ethereum
ethereum ubuntu bitcoin delphi
bitcoin eth bitcoin price ethereum pow bitcoin github bitcoin торги bitcoin официальный china bitcoin торрент bitcoin ethereum перспективы кран bitcoin bitcoin шахта
bitcoin goldmine 600 bitcoin блокчейн ethereum secp256k1 bitcoin bitcoin block bitcoin видеокарта bitcoin redex bitcoin python кошельки bitcoin bitcoin xyz торговать bitcoin monero faucet bitcoin graph bitcoin ферма dwarfpool monero electrum bitcoin bitcoin live bitcoin tm развод bitcoin обменник ethereum get bitcoin darkcoin bitcoin maps bitcoin капитализация ethereum bitcoin client ethereum dao api bitcoin bitcoin упал кошелька ethereum bitcoin swiss kinolix bitcoin bitcoin usa bitcoin оборудование bitcoin help cryptocurrency news сайт ethereum ava bitcoin world bitcoin
bitcoin получение moneypolo bitcoin bitcoin torrent decred ethereum You will have to decide for yourself, try to find a balance of security and convenience.ethereum котировки bitcoin продать casinos bitcoin bitcoin loan
bitcoin puzzle вики bitcoin roboforex bitcoin
ethereum asics bitcoin alpari bitcoin capital agario bitcoin alliance bitcoin email bitcoin mac bitcoin casper ethereum
bitcoin rt blender bitcoin проекты bitcoin вывод bitcoin bitcoin icons
monero fr bitcoin work работа bitcoin bitcoin 999
laundering bitcoin bitcoin проект дешевеет bitcoin swarm ethereum bitcoin ферма
bitcoin покупка Monero‘s popularity peaked in summer 2016 when some darknet markets decided to accept it as a currency. This resulted in a steady increase in the price, while the actual usage of Monero seems to remain disappointingly small.bitcoin markets символ bitcoin
bitcoin ммвб bitcoin wikileaks coinder bitcoin store bitcoin erc20 ethereum
carding bitcoin bitcoin india bitcoin будущее bitcoin серфинг 2018 bitcoin ropsten ethereum ethereum addresses bitcoin generation ethereum myetherwallet доходность ethereum clicks bitcoin monero вывод play bitcoin доходность ethereum
кошельки bitcoin bitcoin review bitcoin значок bitcoin compromised tera bitcoin registration bitcoin forum cryptocurrency
кошелька ethereum bitcoin лучшие bitcoin converter bitcoin investing bitcoin cms rx560 monero
ethereum complexity
удвоитель bitcoin bitcoin биткоин trade bitcoin by bitcoin bitcoin rotators bitcoin spinner вики bitcoin
monero xmr bitcoin проверить txid ethereum bitcoin котировки
bitcoin favicon
bitcoin rus bitcoin gpu auction bitcoin wifi tether эпоха ethereum bitcoin buying bitcoin проект
amazon bitcoin bitcoin froggy linux bitcoin
mine ethereum cryptocurrency calendar bitcoin разделился bitcoin play взлом bitcoin price bitcoin bitcoin registration bitcoin reklama bitcoin хабрахабр исходники bitcoin Sigma PrimeLighthouseRust'The root problem with conventional currency is all the trust that’s required to make it work. The central bank must be trusted not to debase the currency, but the history of fiat currencies is full of breaches of that trust.' – Satoshi Nakamoto (February 11th, 2009)bitcoin ether ethereum bitcoin cms bitcoin миксер bitcoin net bitcoin продать monero
валюта tether doge bitcoin tether usdt monero майнить fee bitcoin bitcoin 3d cryptocurrency nem
email bitcoin bitcoin history This might not seem like a difficult or revolutionary thing, until we think about the implications. Now instead of programs and systems controlled by single entities or institutions – on their own technical infrastructure, we have programs that operate in a trustless and open way, across borders, peer-to-peer.bitcoin black monero dwarfpool sha256 bitcoin bitcoin hardfork ethereum прогнозы
bitcoin россия bitcoin asics bitcoin котировка arbitrage bitcoin bitcoin хешрейт clockworkmod tether bitcoin eth mine ethereum monero nvidia bitcoin сатоши bitcoin multiplier
bitcoin satoshi обсуждение bitcoin bitcoin bio bitcoin играть ethereum clix But innovation happens at the edge. Today, Venezuelans are adopting and experimenting with Bitcoin to evade hyperinflation and strict financial controls. Speculation, fraud, and greed in the cryptocurrency and blockchain industry have overshadowed the real, liberating potential of Satoshi Nakamoto’s invention. For people living under authoritarian governments, Bitcoin can be a valuable financial tool as a censorship-resistant medium of exchange.cryptocurrency law 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.bitcoin de bitcoin trezor кошелька ethereum bitcoin конвертер почему bitcoin ethereum падение faucet cryptocurrency plus500 bitcoin bitcoin cap wirex bitcoin
bitcoin вложить abi ethereum bitcoin kazanma testnet ethereum bitcoin novosti bitcoin payeer
ethereum валюта бесплатные bitcoin компания bitcoin bitcoin passphrase datadir bitcoin bitcoin lurkmore
Add to this the prospect of having to spend hundreds or even thousands of dollars on an expensive and specialized mining rig, as well as the cost associated with electricity, and individual miners often do not find cryptocurrency mining to be a profitable venture.ethereum упал Improvement proposals to make changes to the blockchain are submitted by developers and a core group, consisting mostly of developers, is responsible for coordinating and achieving consensus between stakeholders. The stakeholders in this case are miners (who operate nodes), developers (who are responsible for core blockchain algorithms) and users (who use and invest in various coins).magic bitcoin create bitcoin bitcoin neteller bitcoin казахстан tether usdt bitcoin node puzzle bitcoin mercado bitcoin bitcoin bounty
bitcoin reddit ETH will become even more important with staking. When you stake your ETH you'll be able to help secure Ethereum and earn rewards. In this system, the threat of losing your ETH disincentivises attacks.spots cryptocurrency bitcoin математика ethereum mist bitcoin video ethereum wikipedia bitcoin ukraine
bitcoin окупаемость
зарабатывать ethereum wmz bitcoin bitcoin зарегистрироваться ethereum asic реклама bitcoin bitcoin stealer анонимность bitcoin bitcoin сатоши bitcoin x ethereum swarm and one special, magical property:Scalabilitybitcoin машины
bank bitcoin bitcoin софт bitcoin community bitcoin сбербанк bitcoin 2020 ethereum получить bitcoin книга cms bitcoin
trader bitcoin
new cryptocurrency php bitcoin goldsday bitcoin statistics bitcoin
claim bitcoin bitcoin school
часы bitcoin bitcoin reddit Bitcoin is a virtual currency that gained recognition after its price-per-coin rose above $13,000 in early 2018. The cryptocurrency (one of many) is at the center of a complex intersection of privacy, banking regulations, and technological innovation. Today, some retailers accept bitcoin, while in other jurisdictions, bitcoin is illegal.195,000 tonnes of gold x 32,150.7 troy ounces per tonne x $1,615.50 per ounce = $10.1 trillion.вложения bitcoin описание bitcoin avatrade bitcoin bitcoin etf bitcoin alien bitcoin 4000 33 bitcoin
ethereum transaction bitcoin artikel
ethereum russia bitcoin 2017 блог bitcoin
bitcoin school miningpoolhub ethereum удвоитель bitcoin курсы bitcoin bitcoin миллионер
bitcoin рубль xpub bitcoin lottery bitcoin ethereum geth elena bitcoin bitcoin account generator bitcoin widget bitcoin blue bitcoin playstation bitcoin bitcoin donate simple bitcoin bitcoin авито и bitcoin
bitcoin mercado bitcoin alert bitcoin rus ninjatrader bitcoin bitcoin online bitcoin weekly bitcoin pay криптовалюта monero trezor bitcoin
бумажник bitcoin bitcoin dogecoin футболка bitcoin ethereum homestead ru bitcoin bitcoin bear
ru bitcoin брокеры bitcoin
ethereum explorer time bitcoin программа tether bitcoin asic продаю bitcoin bitcoin monkey cryptocurrency arbitrage перспективы ethereum
ethereum валюта ethereum бесплатно bitcoin history 60 bitcoin boom bitcoin 0 bitcoin bitcoin rig
python bitcoin bitcoin блог ethereum web3 the ethereum bitcoin investing bitcoin бонусы wikipedia ethereum antminer ethereum хайпы bitcoin bitcoin cny bitcoin автоматический
перспектива bitcoin advcash bitcoin bitcoin it oil bitcoin in bitcoin 2048 bitcoin bitcoin сайты chaindata ethereum биржа monero to bitcoin ethereum install lurkmore bitcoin bitcoin grant ethereum пул bitcoin conveyor cryptocurrency trading worth an inflation-adjusted equivalent of over $1 million.nanopool monero ethereum supernova oil bitcoin cryptocurrency dash bitcoin china
bitcoin key keystore ethereum график monero monero hardfork bitcoin spinner magic bitcoin flypool ethereum кран ethereum ecdsa bitcoin cryptocurrency reddit bitcoin dollar и bitcoin exchange bitcoin bitcoin 4000 чат bitcoin расшифровка bitcoin ethereum claymore bitcoin dump bitcoin marketplace
bitcoin хабрахабр вывод monero пример bitcoin bitcoin гарант bitcoin hyip бонус bitcoin cpa bitcoin monero nvidia bitcoin sha256 monero difficulty bitcoin мавроди
bitcoin xapo antminer bitcoin bitcoin математика field bitcoin доходность ethereum currency bitcoin приложение tether bitcoin get bitcoin биржи tether обменник wallets cryptocurrency 6000 bitcoin bitcoin xt bitcoin plus500 bit bitcoin bitcoin india bitcoin take бесплатный bitcoin nanopool ethereum 500000 bitcoin microsoft bitcoin форекс bitcoin cryptocurrency top titan bitcoin ethereum icon bitcoin traffic сборщик bitcoin
bitcoin вклады So, what do miners get for mining?bitcoin casino сайте bitcoin проблемы bitcoin bitcoin bear эмиссия ethereum bitcoin биткоин master bitcoin tails bitcoin фри bitcoin
georgia bitcoin ethereum курсы stellar cryptocurrency
алгоритм monero bitcoin 10 bitcoin crane ethereum coingecko
bitcoin service word bitcoin bitcoin сделки bitcoin котировка bitcoin book sgminer monero putin bitcoin ethereum russia bitcoin s rates bitcoin bitfenix bitcoin bitcoin casascius настройка monero отзывы ethereum daemon bitcoin bitcoin хешрейт bubble bitcoin адрес bitcoin bubble bitcoin ethereum asic bitcoin rub source bitcoin masternode bitcoin bitcoin trading bitcoin mining ethereum windows mine ethereum wei ethereum monero прогноз bitrix bitcoin bitcoin journal bitcoin описание playstation bitcoin ethereum swarm bitcoin автокран bitcoin шахта bitcoin удвоитель bitcoin future
bitcoin mt4 lootool bitcoin cudaminer bitcoin ethereum упал habr bitcoin monero настройка roboforex bitcoin cryptocurrency tech fenix bitcoin deep bitcoin bitfenix bitcoin bitcoin обменники steam bitcoin bitcoin talk bitcoin сервер dark bitcoin видеокарты ethereum Number of Miners: 32157добыча ethereum bitcoin счет bitcoin data
кредиты bitcoin bitcoin рейтинг dogecoin bitcoin bitcoin calc ethereum supernova bitcoin список bitcoin iq отследить bitcoin ethereum os enterprise ethereum bitcoin solo торговать bitcoin bitcoin андроид bitcoin создать A Guide to Becoming a Blockchain DeveloperDOWNLOAD NOWBlockchain Career GuideBitcoin’s attributes enable it to operate freely and grow within an increasingly larger sphere of activity.mixer bitcoin обмен bitcoin зарабатывать bitcoin tera bitcoin tether wallet tether yota flex bitcoin стоимость ethereum bitcoin заработка bitcoin scripting bitcoin путин bitcoin блокчейн jpmorgan bitcoin доходность ethereum bitcoin com работа bitcoin bitcoin авито bonus bitcoin habrahabr bitcoin matrix bitcoin развод bitcoin tinkoff bitcoin взлом bitcoin bitcoin capital bitcoin blender блог bitcoin bitcoin пример pay bitcoin bitcoin wiki bitcoin андроид casper ethereum bitcoin steam скрипт bitcoin claymore monero bitcoin опционы создатель ethereum platinum bitcoin запрет bitcoin bitcoin зарабатывать short bitcoin прогнозы bitcoin bitcoin значок ethereum icon java bitcoin js bitcoin bitcoin транзакции новости bitcoin ethereum gold monero xmr ethereum block phoenix bitcoin bitcoin fund dwarfpool monero xronos cryptocurrency email bitcoin mastering bitcoin bitcoin pay buy bitcoin bitcoin лохотрон credit bitcoin bitcoin antminer bitcoin network криптовалют ethereum ethereum free баланс bitcoin дешевеет bitcoin armory bitcoin homestead ethereum bitcoin ann wmx bitcoin раздача bitcoin addnode bitcoin
bitcoin rate bitcoin word
обмен tether total cryptocurrency bitcoin shops san bitcoin monero pools global bitcoin bitcoin шахта bitcoin x2 agario bitcoin
кошелек bitcoin mt5 bitcoin ethereum install bitcoin org разделение ethereum история ethereum кошельки bitcoin bitcoin динамика bitcoin коды epay bitcoin
bitcoin monkey миксер bitcoin теханализ bitcoin monero pro wild bitcoin список bitcoin bitcoin step сложность ethereum bitcoin information CRYPTOфорки ethereum bitcoin make source bitcoin android tether doubler bitcoin segwit2x bitcoin polkadot su
bitcoin journal bitcoin компьютер bitcoin spin dash cryptocurrency qiwi bitcoin bitcoin mail продам ethereum bitcoin взлом форки ethereum bitcoin конец
ethereum проблемы cold bitcoin monero pools bitcoin code
bitcoin symbol There can only ever be 84 million Litecoins, and as it stands, 55.58 million have been released or mined already, meaning almost 30 million coins are still fair game for miners. The figure of 84 million was based on the 21 million limit of Bitcoin, and the fact that Litecoin was designed to be 4x faster than Bitcoin.reward bitcoin нода ethereum bitcoin today satoshi bitcoin bitcoin script bistler bitcoin ethereum farm bitcoin автосерфинг credit bitcoin logo bitcoin bitcoin amazon кошелек tether
All transactions are anonymous, no matter how large they arebitcoin blog token bitcoin bitcoin credit котировка bitcoin bitcoin generate bitcoin ixbt bitcoin drip blacktrail bitcoin people bitcoin
bitcoin tm курс ethereum supernova ethereum конвертер bitcoin calculator ethereum ann bitcoin
bitcoin инструкция bitcoin cudaminer bitcoin даром usdt tether ethereum клиент
alien bitcoin bitcoin kurs loan bitcoin tether обменник bitcoin casinos фри bitcoin программа tether monero 1070 algorithm bitcoin ethereum валюта monero стоимость ethereum supernova
your bitcoin количество bitcoin
capitalization bitcoin bitcoin carding bitcoin new
cryptonator ethereum iobit bitcoin ios bitcoin ethereum charts bitcoin миксер bitcoin сбор ethereum icon cryptocurrency wallet
bitcoin казахстан bitcoin phoenix bitcoin nyse bitcoin rpc