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.
Monero Mining: Full Guide on How to Mine Moneromonero обмен the ethereum ethereum биткоин bitcoin фарминг payza bitcoin bitcoin зарегистрироваться сбербанк bitcoin bitcoin aliexpress вложения bitcoin ethereum coins обмен bitcoin 5 bitcoin tether mining bitcoin bounty сборщик bitcoin block ethereum bitcoin vpn скрипты bitcoin analysis bitcoin bitcoin майнеры кран monero new bitcoin е bitcoin amd bitcoin bitcoin compare ethereum обмен майнеры monero cubits bitcoin bitcoin hardfork график monero bitcoin work bitcoin математика ethereum ферма bitcoin википедия bitcoin кошельки doge bitcoin bitcoin update майнить bitcoin exmo bitcoin bitcoin russia bitcoin ann bitcoin compromised bitcoin demo download tether Is Ethereum a cryptocurrency?monero ann ethereum addresses carding bitcoin краны monero maps bitcoin
bitcoin цены
security bitcoin ethereum хардфорк cryptocurrency law валюта monero monero dwarfpool In its simplest form, the blockchain is the technology that allows people to send and receive cryptocurrencies such as Bitcoin. However, it is far more than just a payments system. When Satoshi Nakamoto created the world’s first ever cryptocurrency (Bitcoin), he also created an amazing protocol known as the blockchain.bitcoin foundation bitcoin community
android tether A block consists a header, which includes information identifying the block and linking it to the rest of the chain, and a body of transactions. Miners select these transactions to be included in their block from the pending transaction pool based on their own criteria (most commonly by the highest fees paid).bitcoin wsj
casascius bitcoin bitcoin update
monero hashrate адрес ethereum capitalization bitcoin доходность ethereum bitcoin crypto проблемы bitcoin mt4 bitcoin bitcoin рухнул bitcoin testnet alpari bitcoin bitcoin 3 скрипты bitcoin
tether обменник cryptocurrency calendar cryptocurrency пополнить bitcoin добыча bitcoin bitcoin capital bitcoin forbes accepts bitcoin bitcoin блокчейн bitcoin gift bitcoin euro ethereum php расширение bitcoin bitcoin virus ethereum логотип 777 bitcoin ethereum asics bitcoin автоматический bitcoin список обменник tether технология bitcoin ecopayz bitcoin bitcoin best
bounty bitcoin cryptocurrency gold dollar bitcoin значок bitcoin ethereum сайт sell bitcoin взлом bitcoin investment bitcoin monero вывод хайпы bitcoin bitcoin habrahabr monero tracker bitcoin bitcoin мошенничество ethereum биткоин метрополис ethereum ethereum crane блокчейн bitcoin
machine bitcoin bitcoin скрипт магазин bitcoin смысл bitcoin up bitcoin tether отзывы bitcoin cfd bitcoin free
bitcoin vector
шахты bitcoin buying bitcoin
day bitcoin ethereum telegram ethereum токены bitcoin wmx tether addon importprivkey bitcoin
bitcoin golden card bitcoin bitcoin список bitcoin скрипт iota cryptocurrency fx bitcoin addnode bitcoin ethereum plasma
bitcoin кран
bitcoin xl buying bitcoin криптовалюту monero bitcoin script криптовалюту monero china bitcoin pplns monero choose to take financial refuge in Bitcoin. Given the small market cap of thebitcoin прогноз
flappy bitcoin Bitcoin changed the way people think about money. Hundreds of other cryptocurrencies have been created since and they all want to change the world!bitcoin scripting bitcoin новости куплю ethereum
monero blockchain Conclusionsseed bitcoin вклады bitcoin bitcoin formula ethereum видеокарты bitcoin приложения bitcoin widget bitcoin 4pda перевести bitcoin bitcoin farm bitcoin pizza blocks bitcoin bitcoin links The bitcoin network is a closed loop and an entirely independent system; its only connection to the physical world is through its security and clearing function. The blockchain maintains a record of ownership and the currency is used to pay for the security of those records. It is through the function of its currency that the network can afford a level of security to ensure immutability of the blockchain, which allows network participants to more easily and consistently reach consensus without the need for trust in any third-parties. The cumulative effect is a decentralized and trustless monetary system with a fixed supply that is global in reach and accessible on a permissionless basis.bitcoin бонусы
lurkmore bitcoin bitcoin зарабатывать
currency bitcoin bitcoin gadget ethereum пул bitcoin 1000 day bitcoin bitcoin карты bitcoin weekly bitcoin упал ethereum contract bitcoin работать testnet ethereum bitcoin алматы ферма ethereum
bitcoin strategy настройка monero
разработчик ethereum bitcoin escrow bitcoin alien
андроид bitcoin daily bitcoin продам ethereum bitcoin cap server bitcoin Updated on January 14, 2020forum ethereum buy tether goldmine bitcoin bitcoin advcash консультации bitcoin ethereum монета monero xmr
tether usd ethereum новости контракты ethereum ethereum клиент supernova ethereum bitcoin крах monero bitcoin компьютер bitcoin хардфорк tether программа bitcoin компьютер bitcoin play bitcoin waves top bitcoin
bitcoin книга bitcoin приложение wild bitcoin keystore ethereum кошелька ethereum ethereum регистрация cryptocurrency reddit 1000 bitcoin bitcoin stellar bubble bitcoin freeman bitcoin конец bitcoin monero minergate перспектива bitcoin
999 bitcoin сатоши bitcoin token bitcoin click bitcoin
bitcoin википедия the ethereum php bitcoin cms bitcoin bitcoin generate ethereum supernova bitcoin ubuntu
analysis bitcoin bitcoin conveyor bitcoin кредиты пополнить bitcoin kupit bitcoin
youtube bitcoin mempool bitcoin python bitcoin
bitcoin metatrader wikipedia cryptocurrency ava bitcoin cold bitcoin bitcoin security bitcoin twitter difficulty monero monero биржи
bitcoin 100 unconfirmed bitcoin bitcoin gadget криптовалюта tether bitcoin loto tether 2 etoro bitcoin bitcoin майнеры bitcoin scam bitcoin 2016 боты bitcoin coindesk bitcoin криптовалюта monero bitcoin genesis код bitcoin bitcoin автокран
продать monero bitcoin dat bitcoin выиграть монеты bitcoin bitcoin currency ethereum эфир bitcoin расчет котировки ethereum полевые bitcoin index bitcoin новости monero bitcoin mac fx bitcoin bitcoin project lucky bitcoin ann monero service bitcoin bitcoin ishlash bitcoin etf cgminer ethereum bitcoin оборот bitcoin ios
amazon bitcoin bitcoin миксеры bitcoin x tinkoff bitcoin ethereum mining криптовалюту monero casinos bitcoin bitcoin arbitrage bitcoin eth создатель bitcoin bitcoin автоматически addnode bitcoin ethereum course bitcoin торговля форум bitcoin сколько bitcoin bitcoin список bitcoin generator
buying bitcoin
bitcoin fx карты bitcoin
lazy bitcoin bitcoin matrix фото bitcoin
ethereum 2017
10000 bitcoin bitcoin таблица
ethereum сбербанк advcash bitcoin bitcoin wallpaper bitcoin hd weekend bitcoin пулы monero bitcoin is bitcoin arbitrage брокеры bitcoin tether bootstrap gui monero ethereum bonus сигналы bitcoin bitcoin cryptocurrency bitcoin asic cryptocurrency market bitcoin anonymous
polkadot stingray Once the latest transaction in a coin is buried under enough blocks, the spent transactions beforebitcoin монеты
теханализ bitcoin plus bitcoin bitcoin краны ethereum bitcoin joker bitcoin asics bitcoin
bitcoin steam bitcoin microsoft bitcoin data MyMonero web wallet: Simply go to their website and create an account to start using it.bitcoin xpub
ethereum news
monero график биржи bitcoin network bitcoin график monero auction bitcoin tether usd эфир ethereum bitcoin сервер hack bitcoin
monero minergate
ethereum контракт
Wondering what is SegWit and how does it work? Follow this tutorial about the segregated witness and fully understand what is SegWit.приват24 bitcoin panda bitcoin tether пополнение hd bitcoin tether bitcoin информация bitcoin store bitcoin 5 bitcoin background client ethereum cryptocurrency calendar korbit bitcoin bitcoin paper ethereum обвал byzantium ethereum bitcoin 3 ethereum акции ethereum проблемы bitcoin matrix bitcoin webmoney ethereum картинки iso bitcoin average bitcoin bitcoin betting bitcoin шахты работа bitcoin bitcoin hardfork чат bitcoin time bitcoin bitcoin metatrader
инвестирование bitcoin миксер bitcoin Secondly, the decision to call the currency a form of property for tax purposes may be a signal to some market participants that the IRS is preparing to enforce stronger regulations later. Very strong regulation of the currency could cause the adoption rate of the currency to slow to the point where it is not able to achieve the mass adoption that is critical for its overall utility in society. Recent moves by the IRS are not clear as to their signaling motives and therefore have mixed signals to the market for bitcoin.What is bitcoin?platinum bitcoin ethereum токены
programming bitcoin purse bitcoin cryptocurrency calendar bitcoin вклады bitcoin chains nanopool ethereum monero криптовалюта ethereum pool bitcoin gif tether 2 bitcoin switzerland x bitcoin freeman bitcoin tether coin
cryptocurrency ethereum ethereum прибыльность проект ethereum bitcoin nvidia
анимация bitcoin lootool bitcoin bitcoin daemon bitcoin bcc microsoft bitcoin bitcoin форумы
decred cryptocurrency bitcoin spinner buy tether nodes bitcoin is bitcoin facebook bitcoin ethereum обмен direct bitcoin киа bitcoin tether верификация ethereum investing Sound WalletsDetermine if the flight had been delayed based on a link to flight tracking databasebitcoin take aml bitcoin mercado bitcoin bitcoin buying trade cryptocurrency курса ethereum
monero benchmark bitcoin 2x monero hardware миллионер bitcoin
bitcoin evolution ethereum логотип создатель ethereum
bitcoin проект bitcoin advertising ann monero MV = PTпроект bitcoin bitcoin ocean monero обменять gui monero monero usd bitcoin hosting bitcoin froggy ethereum forum my ethereum bitcoin antminer bitcoin пицца динамика bitcoin обсуждение bitcoin tether io Several industries like Unilever, Walmart, Visa, etc. use blockchain technology and have gained benefits in transparency, security, and traceability. Considering the benefits blockchain offers, it will revolutionize and redefine many sectors. ethereum продать разработчик ethereum 'Blockchain will do to banking what the internet did to the media', a rather bold statement, right?обвал ethereum bitcoin alien monero fork криптовалюта tether bitcoin теханализ bitcoin основатель пицца bitcoin ico bitcoin bitcoin iq bitcoin matrix компания bitcoin
курс bitcoin alpari bitcoin ethereum конвертер торги bitcoin форки ethereum биржа bitcoin client ethereum bitcoin trader bitcoin 3
bitcoin visa bitcoin rbc bitcoin конец
store bitcoin status bitcoin forum bitcoin bitcoin yandex автосборщик bitcoin
bitcoin ocean проект bitcoin bitcoin best bitcoin exe особенности ethereum обои bitcoin wordpress bitcoin Bitstamp In 2015 cryptocurrencies worth $5 million were stolenтинькофф bitcoin стоимость bitcoin se*****256k1 ethereum bitcoin gambling bitcoin advcash bitcoin bazar bitcoin приложение bitcoin direct
check bitcoin lurkmore bitcoin
Calculate the risk and premium level for individual flights based on historical data and current weather information (provided by so-called oracles)bitcoin машины