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.
100 bitcoin bitcoin greenaddress download bitcoin
bistler bitcoin
ethereum stratum bitcoin минфин bitcoin delphi ethereum homestead ethereum supernova bitcoin сборщик reklama bitcoin blake bitcoin lazy bitcoin ethereum перевод 6000 bitcoin
claymore monero airbit bitcoin sec bitcoin waves bitcoin
monero algorithm bitcoin теханализ
пулы monero андроид bitcoin github ethereum bitcoin регистрация bitcoin uk ethereum bitcointalk ethereum продать mastering bitcoin алгоритмы ethereum краны monero взлом bitcoin bitcoin scripting робот bitcoin bitcoin conference суть bitcoin script bitcoin ethereum dao bitcoin free bitcoin картинки rx470 monero настройка ethereum bitcoin лохотрон ethereum pools книга bitcoin
asics bitcoin bitcoin segwit2x monero fr ethereum курсы котировки ethereum ethereum статистика bitcoin робот bitcoin суть bitcoin cnbc bitcoin это oil bitcoin приложение tether bitcoin 0
POTENTIAL CONTENDERS DON’T LIVE UP TO THEIR PROMISESцена ethereum short bitcoin account bitcoin tether 4pda биржа ethereum
segwit bitcoin кошелька bitcoin bitcoin fox казино ethereum rigname ethereum 6000 bitcoin ethereum faucet antminer bitcoin Bare-bones user interfaceethereum crane bitcoin покупка flappy bitcoin monero spelunker bitcoin статистика bitcoin миксеры supernova ethereum доходность ethereum ethereum pools x2 bitcoin bitcoin qiwi казино ethereum boxbit bitcoin
оборот bitcoin опционы bitcoin
monero gpu bitcoin people bitcoin статистика bitcoin мониторинг casper ethereum difficulty ethereum кран bitcoin hash bitcoin рост bitcoin monero майнить bitcoin aliexpress bitcoin oil fenix bitcoin cryptocurrency ethereum bitcoin habrahabr tether addon bitcoin ether minergate bitcoin bitcoin протокол bitcoin биткоин tether yota bitcoin reddit space bitcoin tinkoff bitcoin tether coinmarketcap
bitcoin приложения
ethereum токены checker bitcoin bitcoin click скачать bitcoin bitcoin банк tails bitcoin bitcoin collector обменник bitcoin
алгоритм ethereum
lealana bitcoin check bitcoin tor bitcoin bitcoin converter testnet bitcoin bitcoin conf reddit bitcoin ethereum wallet ropsten ethereum gas ethereum hyip bitcoin auction bitcoin
hub bitcoin bitcoin комиссия вики bitcoin reklama bitcoin cold bitcoin bitcoin автосерфинг bitcoin ставки collector bitcoin rpg bitcoin mindgate bitcoin tether майнинг nonce bitcoin ethereum обмен скачать bitcoin перевод ethereum difficulty ethereum обновление ethereum ethereum news titan bitcoin bitcoin motherboard bot bitcoin hardware bitcoin часы bitcoin short bitcoin tether кошелек
bitcoin favicon bitcoin nachrichten продам bitcoin кредит bitcoin bitcoin de bitcoin broker usb tether
zebra bitcoin tether io создатель ethereum ethereum wallet технология bitcoin bitcoin алгоритм ethereum nicehash bitcoin eobot
half bitcoin bitcoin forum bitcoin x2 wikileaks bitcoin майнер monero монет bitcoin аккаунт bitcoin bitcoin обзор bitcoin crane bitcoin mac bitcoin payeer reward bitcoin
bitcoin avto tether верификация ethereum описание my bitcoin up bitcoin майнинга bitcoin tether обменник bitcoin кэш bitcoin clicks ethereum code покер bitcoin bitcoin value byzantium ethereum
bitcoin рост bitcoin nodes
bitcoin mining doge bitcoin bitcoin analysis trade cryptocurrency rotator bitcoin ethereum online fork bitcoin bitcoin electrum bitcoin ann bitcoin com ethereum доходность платформу ethereum bitcoin javascript
wild bitcoin bitcoin reddit cardano cryptocurrency
q bitcoin проверка bitcoin сатоши bitcoin котировка bitcoin
node bitcoin
технология bitcoin bitcoin баланс joker bitcoin аккаунт bitcoin
pay bitcoin покер bitcoin bitcoin отзывы bitcoin icons bitcoin информация
bitcoin neteller bitcoin block cryptocurrency prices dwarfpool monero vizit bitcoin torrent bitcoin
bitcoin cards прогнозы ethereum миксеры bitcoin bitcoin cash bitcoin вектор
mining bitcoin money bitcoin code bitcoin bitcoin conf tether yota bitcoin торги bitcoin development cryptonator ethereum приложения bitcoin debian bitcoin bitcoin forum bitcoin brokers claymore ethereum bitcoin fasttech bitcoin курс fpga ethereum bitcoin plus bitcoin statistics bitcoin уязвимости токен ethereum
bitcoin торги bitcoin xpub adbc bitcoin bitcoin database flypool ethereum bitcoin node ccminer monero bitcoin регистрации инструкция bitcoin server bitcoin bitcoin keywords bitcoin iq
bitcoin ocean
2016 bitcoin tether wifi difficulty monero краны monero форки ethereum sberbank bitcoin bitcoin сайты
ethereum asic
bitcoin froggy live bitcoin
bitcoin purchase ethereum биржа
bitcoin withdrawal
знак bitcoin local bitcoin habr bitcoin putin bitcoin bitcoin математика
500000 bitcoin bitcointalk monero обмена bitcoin bitcoin тинькофф калькулятор ethereum bitcoin waves
bitcoin trader bitcoin перевод токен bitcoin all bitcoin
bitcoin make майнить ethereum Modularity: the parts of the Ethereum protocol should be designed to be as modular and separable as possible. Over the course of development, our goal is to create a program where if one was to make a small protocol modification in one place, the application stack would continue to function without any further modification. Innovations such as Ethash (see the Yellow Paper Appendix or wiki article), modified Patricia trees (Yellow Paper, wiki) and RLP (YP, wiki) should be, and are, implemented as separate, feature-complete libraries. This is so that even though they are used in Ethereum, even if Ethereum does not require certain features, such features are still usable in other protocols as well. Ethereum development should be maximally done so as to benefit the entire cryptocurrency ecosystem, not just itself.bitcoin robot обменники bitcoin Without the money, there is no security and without the security, the value of the currency and the integrity of the chain both break down. It is for this reason that a blockchain is only useful within the application of money, and money does not magically grow on trees. Yep, it is that simple. A blockchain is only good for one thing, removing the need for a trusted third-party which only works in the context of money. A blockchain cannot enforce anything that exists outside the network. While a blockchain would seem to be able to track ownership outside the network, it can only enforce ownership of the currency that is native to its network. Bitcoin tracks ownership and enforces ownership. If a blockchain cannot do both, any records it keeps will be inherently insecure and ultimately subject to change. In this sense, immutability is not an inherent trait of a blockchain but instead, an emergent property. And if a blockchain is not immutable, its currency will never be viable as a form of money because transfer and final settlement will never be reliably possible. Without reliable final settlement, a monetary system is not functional and will not attract liquidity.master bitcoin
bitcoin greenaddress bitcoin online продажа bitcoin secp256k1 bitcoin bitcoin в double bitcoin cryptocurrency charts dwarfpool monero bitcoin ethereum bitcoin count bitcoin графики 100 bitcoin bitcoin machine дешевеет bitcoin monero hashrate coinmarketcap bitcoin bitcoin china
проблемы bitcoin bitcoin rub принимаем bitcoin
bitcoin testnet запросы bitcoin ico ethereum bitcoin widget bitcoin carding bitcoin bitminer bitcoin ru r bitcoin bitcoin новости
bitcoin all arbitrage cryptocurrency monero benchmark android tether криптовалют ethereum сложность monero bitcoin 99 карты bitcoin 2Variantsbitcoin script bitcoin скачать курс bitcoin mine ethereum bitcoin suisse
график monero bitcoin карты bitcoin код bitcoin darkcoin bitcoin mt4 oil bitcoin exchange ethereum salt bitcoin технология bitcoin биржа bitcoin bitcoin картинки addnode bitcoin кран monero
bitcoin abc пул bitcoin форк bitcoin download bitcoin
bitcoin foundation bitcoin ключи bitcoin widget mining bitcoin ethereum node neo cryptocurrency shot bitcoin bitcoin wmx galaxy bitcoin ethereum майнить mindgate bitcoin курс bitcoin новости bitcoin ethereum майнеры bitcoin register
clockworkmod tether обновление ethereum bitcoin bitminer арестован bitcoin PROMOTEDethereum twitter sha256 bitcoin
ethereum windows криптовалюту monero blog bitcoin
bitcoin настройка electrum ethereum mercado bitcoin знак bitcoin bcc bitcoin reddit ethereum msigna bitcoin bitcoin motherboard finney ethereum bitcoin википедия ethereum курс анонимность bitcoin cran bitcoin mac bitcoin bitcoin инструкция seed bitcoin box bitcoin bitcoin удвоить рынок bitcoin bitcoin loto bitcoin transaction дешевеет bitcoin
bitcoin icons coinbase ethereum
bitcoin bear multisig bitcoin
bitcoin hub bitcoin блокчейн pool bitcoin bitcoin iso кликер bitcoin bitcoin central
bitcoin bio 1024 bitcoin okpay bitcoin сайт ethereum monero dwarfpool casinos bitcoin bitcoin greenaddress bitcoin chains ninjatrader bitcoin cryptocurrency calendar bitcoin de сборщик bitcoin 500000 bitcoin bitcoin приложение bitcoin register
In addition to the basic function of storing the keys, a cryptocurrency wallet may also have one or more of the following characteristics.