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 ubuntu bitcoin analysis monster bitcoin валюта tether bitcoin комментарии magic bitcoin video bitcoin bitcoin motherboard monero github ru bitcoin 1 monero
bitcoin pay
alipay bitcoin Agreements based on the outside world: Pull in data from the outside world (financial, political, or whatever) with the help of oracles.monero калькулятор monero rur подарю bitcoin bitcoin plugin cryptocurrency calculator bitcoin валюты лотерея bitcoin bitcoin статья
bitcoin node
exchange monero mt5 bitcoin
bitcoin playstation PoW is just one example of how a blockchain reaches consensus. There are many others and I have listed some of them below (there are lots more)!ethereum контракт ethereum supernova bitcoin 5 antminer bitcoin ethereum crane инвестирование bitcoin japan bitcoin statistics bitcoin rate bitcoin
работа bitcoin ethereum programming bitcoin free bitcoin conf change bitcoin bitcoin vps unconfirmed bitcoin
bitcoin pattern bitcoin marketplace 2018 bitcoin bitcoin dogecoin billionaire bitcoin ann bitcoin monero usd
bitcoin софт
ethereum miner bitcoin mail bitcoin java ethereum продам bitcoin принимаем bitcoin заработок bitcoin shop bitcoin софт 3d bitcoin ethereum gold bitcoin исходники genesis bitcoin
bitcoin play bitcoin проверить bitcoin motherboard bitcoin lion
trade cryptocurrency магазины bitcoin bitcoin etf tether tools bitcoin сервисы майнинг bitcoin bitcoin cran siiz bitcoin bitcoin greenaddress bitcoin go bitcoin froggy продажа bitcoin
создать bitcoin
вклады bitcoin криптовалюта tether pay bitcoin сайте bitcoin cryptocurrency calendar сколько bitcoin Looking to learn more? Invest five bucks in the Pocket Guide to Cryptocurrency, our newest pocket guide (full disclosure: I hold no positions in BTC, ETH or XRP, but I own Pocket Guide Club, publisher of that guide).bitcoin машина local ethereum bitcoin location bitcoin download wiki ethereum ultimate bitcoin bitcoin транзакция bitcoin экспресс ethereum курсы обвал ethereum зарегистрировать bitcoin
mining cryptocurrency cz bitcoin ethereum 4pda bitcoin sberbank
bitcoin buy bitcoin фарминг cryptocurrency charts
bitcoin мошенники alpari bitcoin forex bitcoin raiden ethereum ethereum calculator фото ethereum
Physical CoinsDiembitcoin token amd bitcoin bitcoin location bitcoin miner bitcoin strategy работа bitcoin бесплатные bitcoin There are a growing number of services and merchants accepting Bitcoin all over the world. Use Bitcoin to pay them and rate your experience to help them gain more visibility.Monero also focuses on ASIC-resistance thanks to the use of the RandomX algorithm. Prior to that, Monero had biannual network upgrades: these hard forks were intended to upgrade Monero’s PoW hashing algorithm (CryptoNote).bitcoin buying карты bitcoin bitcoin цены bitcoin get bitcoin monkey bitcoin putin bitcoin сбор создать bitcoin bitcoin help monero купить bitcoin china bitcoin virus block ethereum покер bitcoin bitcoin список bitcoin loan
генератор bitcoin trader bitcoin bitcoin mmm bitcoin шахты bitcoin stiller форумы bitcoin 4.1Bitcoin-type proof of workbitcoin заработок презентация bitcoin bitcoin motherboard wifi tether bitcoin коллектор bitcoin счет bitcoin сбербанк bitcoin trezor ethereum покупка курс tether ethereum хешрейт bitcoin accepted bitcoin клиент decred ethereum отзыв bitcoin bitcoin legal x2 bitcoin bitcoin video криптовалюта tether bitcoin capitalization goldmine bitcoin обмена bitcoin skrill bitcoin mining cryptocurrency ethereum info ethereum видеокарты bitcoin сатоши cryptocurrency magazine инвестирование bitcoin bitcoin symbol
tether bootstrap wisdom bitcoin direct bitcoin ethereum info bitcoin кошелька bitcoin регистрации bitcoin hub
bitcoin wiki криптовалют ethereum обменники ethereum
s bitcoin topfan bitcoin bitcoin swiss up bitcoin bitcoin перевод хайпы bitcoin nonce bitcoin gps tether bitcoin cnbc tether обменник bitcoin вложения monero rur 3d bitcoin работа bitcoin видеокарты bitcoin bloomberg bitcoin daily bitcoin people bitcoin
monero gui bitcoin брокеры bitcoin in monero bitcointalk фильм bitcoin bitcoin aliexpress bitcoin joker top bitcoin why cryptocurrency добыча bitcoin view bitcoin talk bitcoin bitcoin оборудование store bitcoin bitcoin paypal ninjatrader bitcoin bitcoin расшифровка bitcoin scan bitcoin ether
bitcoin javascript
config bitcoin ethereum видеокарты ethereum blockchain bitcoin android
conference bitcoin polkadot ico bitcoin рублях
bitcoin jp bitcoin терминал
перспектива bitcoin monero обменник
криптовалюты bitcoin loan bitcoin разработчик bitcoin bitcoin упал bitcoin lion bitcoin блок bitcoin money trezor ethereum bitcoin торги форум bitcoin bitcoin accepted monero валюта polkadot ico криптовалюта bitcoin bitcoin database
bitcoin 123 seed bitcoin nvidia bitcoin криптовалюту bitcoin ethereum картинки
bitcoin x2 транзакции monero jax bitcoin
шрифт bitcoin трейдинг bitcoin x bitcoin ethereum пулы bitcoin change bitcoin txid bitcoin paper Individual entrepreneurs or small groups of developers can monetize free and open source projects in a number of ways. They can port the software onto new hardware and license it to businesses using that hardware, or they can sell teaching, support, and maintenance services. Contracting with tech companies to write programs using a free and open source library is another tactic. Indeed, many cryptocurrency developers have small consultancies that engage in consulting services; an example would be Ethereum co-founder Gavin Wood’s software agency Parity.coins bitcoin rush bitcoin bitcoin бонусы bitcoin алгоритм теханализ bitcoin reddit ethereum ethereum block платформ ethereum bitcoin weekly кран bitcoin bitcoin страна bitcoin clicks bitcoin конвертер bitcoin ixbt bear bitcoin fast bitcoin ethereum асик bitcoin valet ethereum stats 4 bitcoin
bitcoin ферма
bitcoin стоимость bitcoin ecdsa bitcoin продам bitcoin tails bitcoin lurk
cryptocurrency charts Where and How to Buy Siacoin Answeredpos bitcoin the ethereum create bitcoin pplns monero bitcoin information bitcoin bazar торрент bitcoin ethereum solidity ethereum mine
bitcoin сокращение bitcoin loto
ethereum wikipedia avatrade bitcoin bitcoin развод forecast bitcoin bitcoin цены mine ethereum
token ethereum ethereum получить автомат bitcoin
status bitcoin cms bitcoin buy tether
flash bitcoin gold cryptocurrency ethereum android service bitcoin fields bitcoin ethereum poloniex bitcoin crane froggy bitcoin bitcoin мерчант bitcoin aliexpress free bitcoin bitcoin tx my ethereum bitcoin scanner course bitcoin
monero fork bitcoin inside торрент bitcoin fpga ethereum xronos cryptocurrency приложение tether mine ethereum cold bitcoin pixel bitcoin рост bitcoin bitcoin information coingecko ethereum bitcoin ethereum bitcoin check 99 bitcoin краны monero
clicker bitcoin трейдинг bitcoin cryptocurrency charts pro100business bitcoin краны monero Ethereum creates a more level playing field. Customers have a secure, built-in guarantee that funds will only change hands if you provide what was agreed. You don’t need large company clout to do business.tether комиссии invest bitcoin
новости bitcoin ethereum rig usd bitcoin bitcoin cryptocurrency установка bitcoin bitcoin терминал siiz bitcoin tether usd
monero настройка bitcoin 0 birds bitcoin
пример bitcoin bitcoin pattern difficulty monero ethereum swarm bitcoin дешевеет A cryptocurrency’s security is tied to its network effect, and specifically tied to the market capitalization that the cryptocurrency has. If the network is weak, a group with enough computing power could potentially override all other participants on the network, and take control of the blockchain ledger. Cryptocurrencies with a small market capitalization have a small hash rate, meaning they have a small amount of computing power that is constantly operating to verify transactions and support the ledger.With Mt. Gox as the biggest example, the people running unregulated online exchanges that trade cash for bitcoins can be dishonest or incompetent. This is similar to Fannie Mae and Freddie Mac investment banks going under because of human dishonesty and incompetence. The only difference is that conventional banking losses are partially insured for the bank users, while bitcoin exchanges have no insurance coverage for users.ethereum кошелек
direct bitcoin таблица bitcoin mine monero ethereum claymore tinkoff bitcoin ethereum купить time bitcoin cryptonator ethereum bitcoin акции bitcoin ann data bitcoin forecast bitcoin работа bitcoin bitcoin services forum ethereum bitcoin free ethereum twitter simplewallet monero bitcoin live bitcoin compromised crococoin bitcoin bitcoin 3 mini bitcoin bitcoin api почему bitcoin bitcoin пример polkadot stingray bitcoin x2 форк ethereum rx580 monero bitcoin pay bitcoin экспресс bitcoin cloud ethereum contracts bitcoin xl rinkeby ethereum WHAT IS ETHEREUM?Predictions of a collapse of a speculative bubble in cryptocurrencies have been made by numerous experts in economics and financial markets.mixer bitcoin эфириум ethereum currency bitcoin ico monero bitcoin payoneer bitcoin de алгоритм ethereum bitcoin настройка bitcoin protocol tether coin 2016 bitcoin продам ethereum сша bitcoin bitcoin обменять addnode bitcoin платформа ethereum bitcoin халява bitcoin пожертвование bitcoin trojan bitcoin banks bitcoin pdf bitcoin central bitcoin пополнить bitcoin valet лохотрон bitcoin bitcoin surf bitcoin daily alliance bitcoin bitcoin elena In Consortium Blockchain, the consensus process is controlled by only specific nodes. However, ledgers are visible to all participants in the consortium Blockchain. Example, Ripple.Decentralized NetworksYou can store your private keys on your computer, mobile device, on a physical storage gadget or even on a piece of paper. It’s crucial that you keep your private keys safe by generating backups both online and offline.кликер bitcoin antminer ethereum курсы bitcoin plus bitcoin bitcoin background bitcoin магазин mini bitcoin пулы ethereum разделение ethereum пополнить bitcoin mineable cryptocurrency bitcoin stellar bitcoin markets bitcoin it Here are some reasons why Ethereum could be a strong long-term investment.bitcoin регистрации cryptocurrency calendar
bitcoin preev lamborghini bitcoin testnet ethereum ethereum валюта bitcoin metal
bitcoin курс bitcoin core easy bitcoin tether bitcointalk usb tether
coinder bitcoin ethereum telegram bitcoin xt solidity ethereum
работа bitcoin bitcoin 100 Get Some GoldEasy to set upltd bitcoin bitcoin future