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.
difficulty bitcoin обменять bitcoin testnet bitcoin ethereum падение сайте bitcoin адрес ethereum account bitcoin мавроди bitcoin bitcoin evolution tether майнинг bitcoin вложения ethereum котировки monero algorithm токен ethereum 123 bitcoin monero free bitcoin mmgp проекта ethereum обвал bitcoin bitcoin вектор bitcoin poker minergate monero bitcoin mt4 стоимость monero bye bitcoin captcha bitcoin bitcoin get bitcoin carding bitcoin de cgminer ethereum сети bitcoin эпоха ethereum
зарегистрироваться bitcoin
chain bitcoin joker bitcoin bitcoin free bitcoin hyip bitcoin info bitcoin миллионеры bitcoin database bitcoin теория india bitcoin ethereum api bitcoin icons usa bitcoin bitcoin торги технология bitcoin minergate bitcoin mercado bitcoin
токен ethereum bitcoin список автоматический bitcoin raiden ethereum
bitcoin трейдинг история ethereum bitcoin trend surf bitcoin Multisig is popular in Bitcoin today: about 1.65m BTC (about $6b) are held in known multisig wallets. This figure climbs to 3.9m BTC (-$14b) if we make a naive extrapolation about the ratio of multisig to non multisig in unspent p2sh scripts.bitcoin bonus monero майнинг But they had different ideas about how the Internet would develop in the future.bcn bitcoin The users who check the transaction to see whether it’s valid or not are known as miners. After this is done, the transaction and several others are added to the blockchain, where the details cannot be changed. Bitcoin vs. Ethereumrate bitcoin конвертер bitcoin bank bitcoin bitcoin alpari ethereum прибыльность bitcoin trezor bitcoin grafik новости bitcoin bitcoin пулы bcn bitcoin iso bitcoin *****a bitcoin 2 bitcoin
Walmart was facing an issue where people were returning goods citing quality issues. Now, in an organization of Walmart’s size and scope, it was quite a task to determine where bad products originated from within their supply chain. Their supply chain involved the following steps: bitcoin formula ethereum картинки
tether транскрипция wifi tether index bitcoin bazar bitcoin monero стоимость bitcoin cny курс monero bitcoin capitalization tether ico оборудование bitcoin datadir bitcoin trust bitcoin bitcoin journal poloniex ethereum bitcoin green bitcoin flapper fast bitcoin bitcoin vpn nicehash monero bitcoin freebitcoin create bitcoin bitcoin монета japan bitcoin xpub bitcoin bitcoin магазин ethereum course bitcoin 2010 bitcoin all 1000 bitcoin bitcoin eth
total cryptocurrency dog bitcoin bitcoin background protocol bitcoin parity ethereum bitcoin 2x yota tether monero benchmark виталий ethereum erc20 ethereum swiss bitcoin
bitcoin plus play bitcoin safe bitcoin coinmarketcap bitcoin lamborghini bitcoin 5.0ethereum markets bitcoin update Cryptocurrency Airdrops %trump2% Hard Forksethereum регистрация script bitcoin bitcoin продать matteo monero ethereum btc tether майнинг купить ethereum happy bitcoin bitcoin china gif bitcoin bitcoin казино bitcoin получение bitcoin account
tether usb ecdsa bitcoin
bitcoin converter bitcoin экспресс ethereum сайт таблица bitcoin
case bitcoin primedice bitcoin flash bitcoin bitcoin advcash nicehash bitcoin bitcoin crash
mercado bitcoin bitcoin frog bitcoin habr genesis bitcoin bitcoin greenaddress value bitcoin bitcoin tracker цена ethereum ethereum pool bitcoin swiss рулетка bitcoin
supernova ethereum truffle ethereum bitcoin игры bitcoin hashrate bitcoin брокеры segwit2x bitcoin bitcoin alpari bitcoin q bitcoin nodes monero client bitcoin казино ava bitcoin bitcoin деньги json bitcoin
bitcoin ютуб
bitcoin cryptocurrency китай bitcoin bitcoin пул 600 bitcoin bitcoin people bitcoin вклады download tether расчет bitcoin
bitcoin calculator ethereum пулы forum ethereum bitcoin friday ethereum russia
ethereum pool биржа bitcoin bitcoin основы bitcoin dice box bitcoin ico cryptocurrency goldsday bitcoin bitcoin пожертвование создать bitcoin mercado bitcoin bitcoin atm bitcoin scam bitcoin развод airbitclub bitcoin tether usdt
bitcoin landing ccminer monero chain bitcoin bitcoin xapo bitcoin ethereum proxy bitcoin bitcoin group unconfirmed monero bitcoin forbes bitcoin book It is the ultimate emergency fund: accessible whenever you want,monero minergate forecast bitcoin эмиссия ethereum bitcoin code
капитализация bitcoin ethereum linux collector bitcoin играть bitcoin asus bitcoin конвертер ethereum monero minergate hourly bitcoin
bitcoin кошельки server bitcoin p2pool bitcoin
bitcoin loans sgminer monero Like all powerful tools, it’s important for those interested in using Bitcoin to spend some time engaging in the due diligence of education. Similar to a bicycle, once you know how to use Bitcoin, it will feel very easy and comfortable. But also like a bicycle, one could spend years learning the physics that enable it to operate. Such deep knowledge is not necessary to the actual rider, and in the same way one can enjoy the world of Bitcoin with little more than a healthy curiosity and a bit of practice.Image for postbitcoin purse bitcoin hosting
обменник monero bitcoin компания monero amd bitcoin mainer
bitcoin captcha bitcoin mine bitcoin earnings coin bitcoin ethereum node bitcoin python bitcoin microsoft cryptocurrency gold tether download bitcoin трейдинг tinkoff bitcoin боты bitcoin sgminer monero monero биржи nvidia monero forum ethereum ethereum алгоритм
bazar bitcoin rpg bitcoin loans bitcoin теханализ bitcoin waves bitcoin casino bitcoin abi ethereum обвал ethereum bitcoin фарминг
bitcoin софт alliance bitcoin safe bitcoin
bitcoin rotator расширение bitcoin bitcoin обмена генераторы bitcoin bitcoin safe iobit bitcoin
pokerstars bitcoin monero продать kupit bitcoin bitcoin withdraw
cryptocurrency charts карты bitcoin
ethereum валюта
bitcoin usd bitcoin multiply masternode bitcoin wifi tether bitcoin расчет ethereum farm rus bitcoin bitcoin make hacker bitcoin monero amd bitcoin блог bitcoin price transactions bitcoin бизнес bitcoin bitcoin faucets bitcoin комбайн testnet bitcoin bitcoin config
ethereum web3 bitcoin 1000 bitcoin capitalization 1080 ethereum polkadot cadaver брокеры bitcoin tcc bitcoin local ethereum 60 bitcoin bitcoin стратегия книга bitcoin bitcoin stellar bitcoin landing фри bitcoin bitcoin официальный bitcoin forums cryptocurrency trade bitcoin xyz 2x bitcoin abi ethereum money bitcoin bitcoin информация coinder bitcoin bitcoin traffic рейтинг bitcoin
bitcoin уязвимости avatrade bitcoin Mining contractors provide mining services with performance specified by contract, often referred to as a 'Mining Contract.' They may, for example, rent out a specific level of mining capacity for a set price at a specific duration.master bitcoin bitcoin пулы ethereum course free bitcoin
ethereum stratum wiki ethereum lite bitcoin bitcoin instaforex your bitcoin ethereum homestead bitcoin puzzle neo cryptocurrency ninjatrader bitcoin bitcoin работать стоимость ethereum alpari bitcoin bitcoin skrill bitcoin euro bitcoin weekly trezor ethereum бесплатный bitcoin bitcoin 999 генераторы bitcoin bitcoin индекс blocks bitcoin nanopool ethereum bitcoin видеокарты hashrate ethereum
bitcoin технология my ethereum
торговля bitcoin p2p bitcoin bitcoin алгоритм daemon bitcoin история ethereum bitcoin maps ethereum serpent tp tether monero blockchain bitcoin pools ethereum сайт bitcoin iq
надежность bitcoin 1000 bitcoin взлом bitcoin обсуждение bitcoin lealana bitcoin цены bitcoin bitcoin валюта bitcoin atm cryptocurrency forum bitcoin шахты транзакция bitcoin programming bitcoin bitcoin торги bitcoin автомат
master bitcoin collector bitcoin
bitcointalk monero 1080 ethereum bitcoin golden mac bitcoin ethereum кошелек bitcoin jp pps bitcoin bitcoin eth ico monero обменник ethereum майнить bitcoin ethereum platform js bitcoin bitcoin аккаунт top cryptocurrency bitcoin laundering форк bitcoin daemon bitcoin
bitcoin банкнота
1060 monero bitcoin symbol bitcoin курс 600 bitcoin android tether ethereum php ad bitcoin puzzle bitcoin bitcoin transactions
agario bitcoin plus500 bitcoin bitcoin club bitcoin переводчик bitcoin переводчик bitcoin landing bitcoin подтверждение nonce bitcoin
карты bitcoin системе bitcoin сети bitcoin adbc bitcoin tether верификация super bitcoin bitcoin казахстан bitcoin check создатель ethereum ethereum chaindata bitcoin 20 bitcoin wikileaks
обновление ethereum обменять ethereum
bitcoin 1070 forum ethereum value bitcoin tether bootstrap clame bitcoin розыгрыш bitcoin bitcoin котировки инструкция bitcoin ethereum investing отдам bitcoin multiply bitcoin qiwi bitcoin bootstrap tether monero майнинг conference bitcoin doubler bitcoin bitcoin ocean bitcoin ключи
bitcoin 4pda банк bitcoin lurkmore bitcoin monero proxy фонд ethereum луна bitcoin продам ethereum bitcoin win bitcoin приложение технология bitcoin bitcoin инвестирование bitcoin foto Are there other major investors who are investing in it? It’s a good sign if other well-known investors want a piece of the currency.equihash bitcoin erc20 ethereum бесплатный bitcoin bitcoin nachrichten bitcoin fan FACEBOOKbitcoin motherboard bitcoin развод fenix bitcoin
nicehash bitcoin bitcoin компания monero amd
bitcoin instagram converter bitcoin cronox bitcoin bitcoin update purchase bitcoin
moto bitcoin акции ethereum monero майнинг bitcoin сатоши
индекс bitcoin обмен monero bitcoin tor monero hashrate wisdom bitcoin bitcoin usd neteller bitcoin
миксер bitcoin bitcoin стратегия
bitcoin казино bitcoin linux bitcoin bloomberg деньги bitcoin игра ethereum удвоить bitcoin bitcoin satoshi moneypolo bitcoin hd bitcoin monero кран microsoft ethereum новости monero all bitcoin monero стоимость кошель bitcoin ethereum кошелька php bitcoin ethereum история abi ethereum monero новости bitcoin майнер 999 bitcoin майнинг monero bitcoin funding
uk bitcoin bip bitcoin bitcoin girls фри bitcoin bitcoin курс bitcoin вконтакте bitcoin заработать bitcoin конверт yota tether bitcoin виджет cryptocurrency market 2x bitcoin bitcoin продам ethereum вики bitcoin puzzle
boom bitcoin пулы ethereum bitcoin cz знак bitcoin bitcoin brokers
bitcoin talk 60 bitcoin история bitcoin monero algorithm bitcoin рейтинг bitcoin ne bitcoin вклады ethereum siacoin
ethereum io nanopool monero moon ethereum
token ethereum ethereum токены ethereum заработок
терминалы bitcoin bitcoin aliexpress ethereum web3 трейдинг bitcoin bitcoin instagram
siiz bitcoin
tether wifi bitcoin оплатить сколько bitcoin bitcoin ммвб оборот bitcoin bitcoin greenaddress
bitcoin казахстан bitcoin пополнить
green bitcoin
p2p bitcoin bitcoin пицца
bitcoin видео moto bitcoin store bitcoin bitcoin хардфорк
bitcoin сбор network bitcoin цена ethereum bitcoin timer
bitcoin usd fire bitcoin carding bitcoin gambling bitcoin ethereum курсы
bitcoin бесплатные криптовалюту monero bitcoin nyse pow bitcoin bitcoin рейтинг bitcoin addnode algorithm bitcoin ethereum coins cryptocurrency top lite bitcoin froggy bitcoin что bitcoin конвертер ethereum адреса bitcoin трейдинг bitcoin bitcoin tor alpari bitcoin bitcoin playstation
bitcoin analysis ethereum farm монета ethereum platinum bitcoin bitcoin видеокарта
keepkey bitcoin
bitcoin список monero майнер moneybox bitcoin bitcoin котировка bitcoin ann bitcoin mining blockchain ethereum
регистрация bitcoin bitcoin multibit
ethereum russia joker bitcoin ads bitcoin bitcoin changer
bitcoin майнить bitcoin лотереи
bitcoin торги
цена ethereum
отзыв bitcoin bitcoin utopia webmoney bitcoin cryptocurrency charts ecdsa bitcoin bistler bitcoin Ключевое слово Bitcoin is not anonymousinformation bitcoin bitcoin компания ecopayz bitcoin pow bitcoin япония bitcoin difficulty ethereum ethereum chaindata wallet tether bitcoin куплю
connect bitcoin bitcoin википедия
flappy bitcoin daemon monero ethereum swarm фото ethereum yota tether bitcoin investing
bitcoin лохотрон monero ico mindgate bitcoin monero ann Merkle Treesbitcoin вход Keep your personal costs down, including electricity and hardware.Antpool, located in China, is one of the largest Litecoin mining pools available. They also have pools available for other cryptocurrencies, such as Bitcoin and Ethereum.bitcoin convert trade cryptocurrency
майн bitcoin monero algorithm bitcoin zone cryptocurrency calculator ethereum wiki bitcoin банкнота Modified 'rat poison' systems are being funded by Wall Street alliances and venture capital dollars from prominent firms like Andreessen-Horowitz, despite the two points above. $6.3B was raised in token offerings in Q1 2018 alone. Facebook and Google both have blockchain divisions. bitcoin org