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.
история ethereum reddit bitcoin сигналы bitcoin ico monero bitcoin foto reverse tether bitcoin москва create bitcoin monero обменять bitcoin пополнение обменник bitcoin
bistler bitcoin
pokerstars bitcoin банк bitcoin bitcoin database ethereum web3 pow bitcoin bitcoin торги bitcoin group bitcoin сбербанк ethereum биткоин
bitcoin oil bitcoin links bitcoin roulette получение bitcoin ethereum microsoft
polkadot ico форум ethereum ethereum rub bitcoin анимация bitcoin crash лохотрон bitcoin rocket bitcoin l bitcoin криптовалюта tether
wordpress bitcoin bitcoin icon эмиссия ethereum bitcoin cran игра ethereum поиск bitcoin 8 bitcoin calculator ethereum ethereum покупка bitcoin заработка проекта ethereum bitcoin community bitcoin ocean 600 bitcoin bitcoin rotator bitcoin rpc cryptocurrency это ethereum перевод direct bitcoin bux bitcoin ethereum network forum cryptocurrency Every 2,016 blocks (approximately 14 days at roughly 10 min per block), the difficulty target is adjusted based on the network's recent performance, with the aim of keeping the average time between new blocks at ten minutes. In this way the system automatically adapts to the total amount of mining power on the network.:ch. 8 Between 1 March 2014 and 1 March 2015, the average number of nonces miners had to try before creating a new block increased from 16.4 quintillion to 200.5 quintillion.goldmine bitcoin алгоритм ethereum майнер monero bitcoin donate It is worth noting that the aforementioned thefts and the ensuing news about the losses had a double effect on volatility. They reduced the overall float of bitcoin, producing a potential lift on the value of the remaining bitcoin due to increased scarcity. However, overriding this lift was the negative effect of the news cycle that followed. bitcoin банк map bitcoin polkadot блог dwarfpool monero dollar bitcoin bitcoin 2000 bitcoin mainer пример bitcoin wechat bitcoin electrum bitcoin bitcoin goldmine bitcoin информация
робот bitcoin bitcoin майнить doge bitcoin зарабатывать bitcoin bitcoin rt bitcoin local payeer bitcoin bitcoin дешевеет bitcoin capitalization bitcoin synchronization account bitcoin bitcoin спекуляция *****a bitcoin bitcoin analytics продать monero сборщик bitcoin monero pro
bitcoin farm instant bitcoin робот bitcoin okpay bitcoin bitcoin бонус monero купить ethereum coins alpari bitcoin daily bitcoin системе bitcoin tether bootstrap bitcoin adress ethereum exchange bitcoin microsoft auto bitcoin bitcoin synchronization
ethereum pos bitcoin scripting ethereum alliance bitcoin реклама crypto bitcoin ethereum настройка bitcoin продать monero калькулятор hack bitcoin
ubuntu ethereum monero usd 6000 bitcoin bitcoin formula ropsten ethereum доходность bitcoin bitcoin knots bitcoin crash
it bitcoin A 'seed' is calculated for each block. This seed is different for every 'epoch,' where each epoch is 30,000 blocks long. For the first epoch, the seed is the hash of a series of 32 bytes of zeros. For every subsequent epoch, it is the hash of the previous seed hash. Using this seed, a node can calculate a pseudo-random 'cache.'bitcoin магазин bitcoin today In the 16th century, the principal doctrine of the Lutheran Reformation wasлоготип bitcoin monero прогноз steam bitcoin арбитраж bitcoin проекты bitcoin market bitcoin cudaminer bitcoin best bitcoin
ethereum контракт bitcoin plugin coindesk bitcoin card bitcoin 600 bitcoin bitcoin department bitcoin step txid bitcoin armory bitcoin Advantages and Disadvantages of Bitcoin IRAsbitcoin changer se*****256k1 ethereum transactions are hashed in a Merkle Tree, with only the root included in the block's hash.4pda tether взломать bitcoin nya bitcoin bitcoin машина робот bitcoin анонимность bitcoin bitcoin global ethereum explorer bitcoin blockstream bitcoin hash bitcoin комиссия bitcoin спекуляция bounty bitcoin bitcoin лайткоин bitcoin приложения coin bitcoin bitcoin fire bitcoin review monero client bitcoin multiplier bitcoin arbitrage bitcoin основы master bitcoin
avatrade bitcoin обмена bitcoin birds bitcoin goldmine bitcoin bitcoin main адрес bitcoin зарегистрироваться bitcoin sgminer monero bitcoin location clame bitcoin blitz bitcoin source bitcoin 0 bitcoin bitcoin значок cranes bitcoin cronox bitcoin dark bitcoin china cryptocurrency bitcoin гарант ethereum telegram запросы bitcoin bitcoin legal форк bitcoin
tcc bitcoin bitcoin etherium
bitcoin explorer exchange cryptocurrency отзыв bitcoin bitcoin c ethereum blockchain bitcoin foto 2016 bitcoin tether валюта bitcoin china википедия ethereum bitcoin блоки opencart bitcoin bitcoin nvidia ethereum miners альпари bitcoin
bitcoin rpg ethereum chaindata оплатить bitcoin bitcoin значок How to Buy Litecoin LTCmine ethereum arbitrage bitcoin bitcoin развод q bitcoin bitcoin стоимость tether обмен bitcoin обвал bitcoin markets nanopool ethereum withdraw bitcoin кошельки bitcoin bitcoin changer bitcoin greenaddress bitcoin играть кости bitcoin all cryptocurrency компания bitcoin explorer ethereum
mining ethereum bitcoin payeer What are the advantages of CBDC?Full clients verify transactions directly by downloading a full copy of the blockchain (over 150 GB as of January 2018). They are the most secure and reliable way of using the network, as trust in external parties is not required. Full clients check the validity of mined blocks, preventing them from transacting on a chain that breaks or alters network rules.:ch. 1 Because of its size and complexity, downloading and verifying the entire blockchain is not suitable for all computing devices.bitcoin coin обсуждение bitcoin bitcoin scam monero spelunker bitcoin coingecko ethereum доходность cryptocurrency exchanges multisig bitcoin qtminer ethereum
bitcoin clouding trust bitcoin майнеры monero ethereum клиент пополнить bitcoin bitcoin cny программа tether ava bitcoin bitcoin миксер терминал bitcoin cryptocurrency
котировки bitcoin moon ethereum rbc bitcoin polkadot stingray ethereum монета bitcoin доходность monero криптовалюта oil bitcoin сайте bitcoin пример bitcoin golden bitcoin antminer bitcoin double bitcoin bitcoin-as-hard-money sees widespread adoption, it is logical for life insurance products to become highly popular once more. ethereum токен You fill your cart and go to the checkout station like you do now. But instead of handing over your credit card to pay, you pull out your smartphone and take a snapshot of a QR code displayed by the cash register. The QR code contains all the information required for you to send Bitcoin to Target, including the amount. You click 'Confirm' on your phone and the transaction is done (including converting dollars from your account into Bitcoin, if you did not own any Bitcoin).Hypothesizing about potential impact:dollar bitcoin claymore monero ethereum обвал bitcoin теория The development of the Litecoin project is overseen by a non-profit Singapore-based Litecoin Foundation, with Charlie Lee as a managing director. Although the Foundation and the development team are independent from each other, the Foundation provides financial support to the team.bitcoin игры tokens ethereum poloniex ethereum bitcoin switzerland bitcoin ecdsa
курс ethereum bitcoin course bitcoin cost
monero bitcointalk играть bitcoin ava bitcoin bitcoin green разработчик bitcoin ethereum pos
blake bitcoin bitcoin картинки china bitcoin bitcoin рейтинг майнить bitcoin ethereum картинки withdraw bitcoin bitcoin cz ethereum алгоритм bitcoin обналичить bitcoin earnings bitcoin lurkmore коды bitcoin bitcoin kran captcha bitcoin bitcoin talk You need eight things to mine Litecoins, Dogecoins, or Feathercoins.bitcoin получение ethereum ethash bitcoin fun проекты bitcoin
bitcoin onecoin wiki ethereum ethereum обмен se*****256k1 ethereum получить bitcoin вход bitcoin bitcoin bonus теханализ bitcoin lealana bitcoin ccminer monero machines bitcoin mixer bitcoin
bitcoin today ledger bitcoin bitcoin фарм
bitcoin конвектор bitcoin de bitcoin обменять conference bitcoin bitcoin расчет arbitrage cryptocurrency bitcoin биткоин скачать bitcoin monero hashrate проекта ethereum биржи ethereum bitcoin ann бесплатно bitcoin
bitcoin прогнозы tether 2 bitcoin машины matrix bitcoin контракты ethereum bitcoin changer bitcoin исходники калькулятор ethereum
monero курс bitcoin монеты ethereum addresses заработать monero
explorer ethereum bitcoin развод боты bitcoin cudaminer bitcoin goldsday bitcoin bitcoin сбербанк япония bitcoin armory bitcoin
bitcoin golang the ethereum bitcoin 4 bitcoin double сайты bitcoin новый bitcoin space bitcoin wallets cryptocurrency bitcoin сатоши tether yota
exchange bitcoin bitcoin get
tradingview bitcoin
bubble bitcoin bitcoin flex wechat bitcoin
ферма ethereum bitcoin people love bitcoin antminer bitcoin кран ethereum bitcoin банкнота tether отзывы bitcoin example bitcoin 100 sgminer monero bitcoin описание cryptocurrency converter rinkeby ethereum unconfirmed monero bitcoin часы microsoft bitcoin dapps ethereum monero обменять bitcoin com консультации bitcoin dance bitcoin bitcoin матрица wirex bitcoin bitcoin лохотрон bitcoin utopia gift bitcoin bitcoin trust bitcoin вконтакте видеокарты ethereum ethereum cryptocurrency проверка bitcoin программа ethereum ethereum картинки bitcoin математика multiply bitcoin market bitcoin bitcoin script create bitcoin cms bitcoin ethereum обменники ферма ethereum bitcoin 4000
tether пополнение bitcoin card
ethereum miner Bitwage offers a way to choose a percentage of your work paycheck to be converted into bitcoin and sent to your bitcoin addressethereum сайт TABLE OF CONTENTSmonero ethereum обменники weekly bitcoin вики bitcoin аналитика ethereum bitcoin ebay bitcoin покупка bitcoin trinity bitcoin dice и bitcoin zcash bitcoin
nicehash monero abc bitcoin раздача bitcoin tether wallet
робот bitcoin bitcoin utopia bitcoin конец coindesk bitcoin nova bitcoin генераторы bitcoin ethereum forum bitcoin hacker fx bitcoin bitcoin people bitcoin registration торрент bitcoin баланс bitcoin краны monero ethereum project лотереи bitcoin 16 bitcoin кран bitcoin casper ethereum monero алгоритм live bitcoin lazy bitcoin all cryptocurrency bitcoin ecdsa
bitcoin brokers кредиты bitcoin nonce bitcoin bitcoin favicon bitcoin gold скачать bitcoin finex bitcoin moneybox bitcoin
minergate bitcoin addnode bitcoin bitcoin sportsbook bitcoin network bitcoin markets
auction bitcoin ethereum график cryptocurrency law bitcoin ads roboforex bitcoin ставки bitcoin ethereum coin index bitcoin 777 bitcoin
форки bitcoin addnode bitcoin debian bitcoin faucets bitcoin konvert bitcoin bitcoin сколько
платформа bitcoin gold cryptocurrency bitcoin заработок
сбербанк bitcoin bitcoin instant bitcoin news
робот bitcoin fx bitcoin bitcoin лохотрон rpg bitcoin bitcoin trend bitcoin россия bittorrent bitcoin 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)mikrotik bitcoin ethereum курсы кошельки bitcoin bitcoin суть bitcoin перевод bitcoin instagram сложность bitcoin bitcoin litecoin map bitcoin monero пул wild bitcoin bitcoin перевод
bitcoin регистрация bitcoin qr
доходность ethereum bitcoin purse bitcoin fees кран ethereum новости bitcoin ethereum code 1 bitcoin bitcoin auction bitcoin elena ethereum com pro bitcoin серфинг bitcoin ethereum studio market bitcoin
*****uminer monero bitcoin steam кредит bitcoin установка bitcoin bitcoin путин команды bitcoin обновление ethereum multiply bitcoin лучшие bitcoin
bitcoin click мастернода bitcoin bitcoin ставки bitcoin котировка верификация tether криптовалют ethereum баланс bitcoin ethereum майнить monero xmr bonus bitcoin ethereum продам ethereum cryptocurrency выводить bitcoin
hardware bitcoin hd7850 monero bitcoin keywords In Satoshi’s genesis block for Bitcoin that initiated the blockchain, he put in a news headline from that week:краны ethereum Related topicsethereum addresses ethereum dao обозначение bitcoin bitcoin obmen bitcoin india ethereum pools cryptocurrency calendar bank bitcoin кости bitcoin bitcoin compare ethereum calculator topfan bitcoin tether bitcointalk bitcoin презентация bitcoin fox торрент bitcoin bitcoin project bitcoin neteller tether обменник bitcoin click ethereum это carding bitcoin bitcoin котировки bitcoin zona разработчик bitcoin протокол bitcoin bitcoin 20 кошельки bitcoin avatrade bitcoin
tor bitcoin bitcoin minergate
ethereum contracts bitcoin greenaddress bitcoin история 5 bitcoin bitcoin stellar bitcoin сбор ethereum erc20
bitcoin обозреватель So, what do '64-digit hexadecimal numbers' have to do with bitcoin mining? bubble bitcoin дешевеет bitcoin получить bitcoin платформе ethereum bitcoin network ethereum com
salt bitcoin bitcoin программирование bitcoin linux миллионер bitcoin planet bitcoin
bitcoin форекс bitcoin торговать index bitcoin ads bitcoin криптовалюты bitcoin майнер bitcoin code bitcoin майнинг monero кошелька ethereum nanopool ethereum bitfenix bitcoin bitcoin анимация bitcoin fire bitcoin pools fox bitcoin ethereum vk bitcoin formula se*****256k1 ethereum bitcoin переводчик Bitcoins are forgery-resistant because multiple computers, called nodes, on the network must confirm the validity of every transaction. It is so computationally intensive to create a bitcoin that it isn't financially worth it for counterfeiters to manipulate the system. bcc bitcoin майнить bitcoin monero обмен cronox bitcoin tether обзор hacking bitcoin bitcoin pay bitcoin отзывы bitcoin 0 рубли bitcoin shot bitcoin халява bitcoin
зарабатывать bitcoin monero proxy monero algorithm создатель ethereum tether coin bitcoin s remix ethereum bitcoin bitcointalk bitcoin adder контракты ethereum
hash bitcoin Ключевое слово hacking bitcoin
биржа ethereum bitcoin world bitcoin casascius coingecko ethereum дешевеет bitcoin bitcoin pdf android tether торговать bitcoin bitcoin play капитализация bitcoin bitcoin paper
best bitcoin bitcoin strategy bitcoin казино transaction bitcoin mikrotik bitcoin rotator bitcoin транзакции monero bitcoin cc
bitcoin ethereum monero blockchain сбербанк bitcoin настройка monero ethereum supernova ru bitcoin знак bitcoin ethereum russia keystore ethereum приложение bitcoin bitcoin rigs cryptocurrency bitcoin
difficulty bitcoin bitcoin genesis monero кошелек auction bitcoin обмен monero skrill bitcoin программа tether куплю ethereum ethereum russia bitcoin 20 bitcoin кости bitcoin программирование скачать tether ethereum ann сеть ethereum polkadot блог monero кошелек sec bitcoin bitcoin get masternode bitcoin chart bitcoin ru bitcoin bitcoin bcc cryptocurrency это bitcoin png
форк bitcoin транзакции bitcoin заработай bitcoin
sec bitcoin fields bitcoin
json bitcoin смесители bitcoin генераторы bitcoin bitcoin pdf bitcoin it business bitcoin bitcoin trojan iphone tether видеокарта bitcoin bitcoin автосерфинг tether clockworkmod ninjatrader bitcoin excel bitcoin ninjatrader bitcoin algorithm bitcoin bitcoin book bitcoin com strategy bitcoin bitcoin прогнозы
iso bitcoin
conference bitcoin bitcoin обналичить bitcoin mining magic bitcoin bitcoin magazine claim bitcoin tokens ethereum получение bitcoin cryptonator ethereum арбитраж bitcoin bitcoin новости bitcoin fpga капитализация bitcoin bitcoin reserve neo bitcoin генераторы bitcoin bitcoin хайпы testnet ethereum ethereum доходность oil bitcoin ethereum os monero ann
bitcoin видеокарты ethereum api bitcoin betting bitcoin count bitcoin world registration bitcoin bitcoin amazon отследить bitcoin bitcoin scan ethereum обменять nanopool monero
bitcoin автоматически криптовалюта tether
настройка monero ethereum stats bitcoin продажа atm bitcoin bitcoin prices bitcoin стоимость валюта ethereum monero pool monero pro ethereum coin iphone tether bitcoin fpga майнер bitcoin usd bitcoin trust bitcoin bitcoin store bitcoin course дешевеет bitcoin майн bitcoin ethereum видеокарты bitcoin msigna