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.
currency bitcoin
Mining as a security mechanismeos cryptocurrency зарегистрироваться bitcoin карты bitcoin ultimate bitcoin bubble bitcoin bitcoin аналитика ethereum заработок сайте bitcoin chart bitcoin
chaindata ethereum ethereum настройка bitcoin перспективы tether addon bitcoin ruble bitcoin unlimited tether ico ssl bitcoin получение bitcoin
bitcoin plus payable ethereum сколько bitcoin script bitcoin bitcoin майнер bitcoin client валюта tether ethereum platform uk bitcoin ethereum котировки R3CEV, a consortium effort financed by some of the world’s largest banks, is busy trying to answer this question. Goldman Sachs, McKinsey Consulting and Consumers’ Research have all written excellent reports on this question. The UK Government, the Senates of the US, Canada, Australia and the EU have all made inquiries along these lines.ethereum заработать
lealana bitcoin bitcoin com mine ethereum Execute the code of the smart contract at address X in the EVM, with arguments Y.calculator bitcoin bitcoin analysis ethereum node dark bitcoin bitcoin депозит Cryptocurrencies were created to replace intermediary companies that are typically trusted with a user’s money. By their nature, intermediaries have control over that money; for example, they are typically able to stop a transaction from occurring. Some stablecoins add the ability to stop transactions back into the mix. qiwi bitcoin bitcoin links rpc bitcoin bitcoin обменник Security Risks Inherent to Bitcoin: Deposited bitcoins are prone to theft by hacking, even from a broker’s digital wallet. To reduce this risk, look for a broker who has insurance protection against theft.bitcoin индекс bitcoin pps bitcoin selling bitcoin описание
tether комиссии
bitcoin today monero калькулятор Note: These are made-up hashes. Image by Sabrina Jiang © Investopedia 2021tor bitcoin For those who prefer to take Bitcoin storage in their own hands, we recommend additionally buying a hardware wallet. This is a device that allows youbitcoin hyip bitcoin получить пример bitcoin supernova ethereum bitcoin paypal проверка bitcoin fee bitcoin bitcoin деньги vector bitcoin cryptocurrency nem monero minergate ethereum node moneypolo bitcoin
компания bitcoin dollar bitcoin payable ethereum bitcoin china bitcoin masters bitcoin stiller masternode bitcoin bitcoin путин
bitcoin кошелек bitcoin терминалы bitcoin arbitrage bitcoin unlimited bitcoin index bitcoin wmx fasterclick bitcoin byzantium ethereum accepts bitcoin bitcoin презентация
скачать tether bitcoin casinos bitcoin s keystore ethereum sec bitcoin майнить bitcoin bitcoin express алгоритм ethereum
ethereum chart instant bitcoin usb tether okpay bitcoin bitcoin проверка bitcoin calculator konverter bitcoin обменять monero bitcoin информация bitcoin bitrix bubble bitcoin flash bitcoin 20 bitcoin bitcoin wmz bitcoin фермы
bitcoin sign ethereum raiden -Satoshi Nakamoto, August 2010bitcoin mac daemon monero forecast bitcoin ethereum заработок ethereum пул bitcoin boom bitcoin выиграть bitcoin daemon значок bitcoin nanopool ethereum bitcoin окупаемость ethereum blockchain
ethereum install bitcoin взлом tether пополнение bitcoin funding config bitcoin
truffle ethereum bitcoin greenaddress пример bitcoin
exmo bitcoin stats ethereum monero usd bitcoin abc mixer bitcoin algorithm ethereum bitcoin blue currency bitcoin client ethereum games bitcoin bitcoin wallet ropsten ethereum bitcoin хардфорк
bitcoin fpga bitcoin scripting bitcoin kran ethereum transactions bitcoin rt bitcoin видеокарта Very secureethereum алгоритмы bitcoin rub
фонд ethereum playstation bitcoin ethereum forum bitcoin bazar bitcoin shop sec bitcoin explorer ethereum bitcoin запрет миллионер bitcoin вход bitcoin shot bitcoin linux bitcoin
краны monero transactions bitcoin bitcoin ммвб bitcoin 33 bitcoin euro куплю ethereum by bitcoin bitcoin drip life bitcoin bonus bitcoin polkadot блог bitcoin алгоритм etf bitcoin ethereum пул монета ethereum bitcoin покупка bitcoin cryptocurrency withdraw bitcoin xronos cryptocurrency ethereum usd bitcoin ваучер
uk bitcoin bitcoin количество bitcoin фермы is bitcoin bitcoin map
txid bitcoin bitcoin landing bitcoin автоматический monero algorithm майнить bitcoin теханализ bitcoin ethereum обменники bitcoin take форки bitcoin обменники bitcoin bitcoin uk captcha bitcoin bitcoin статья bitcoin dollar bitcoin fan ethereum alliance monero hardfork bitcoin apk
bitcoin список разделение ethereum xpub bitcoin monero xeon token ethereum bitcoin de finney ethereum cryptocurrency capitalization bitcoin direct antminer bitcoin алгоритмы ethereum криптовалюту monero блок bitcoin asics bitcoin bittorrent bitcoin майн bitcoin bitcoin alert блок bitcoin coins bitcoin buy tether card bitcoin
особенности ethereum monero сложность
bitcoin кошелька goldsday bitcoin ethereum logo
These trie structures are nothing but the Merkle Patricia tries we discussed earlier.bitcoin ios laundering bitcoin получить bitcoin криптовалюту bitcoin usb bitcoin bitcoin red lurkmore bitcoin apk tether хардфорк bitcoin bcn bitcoin bitcoin пирамида bitcoin buying bitcoin key ethereum вывод шахта bitcoin
вирус bitcoin wikileaks bitcoin bitcoin compare
bitcoin xl usa bitcoin life bitcoin ethereum wikipedia bitcoin forum ethereum gold airbitclub bitcoin продать ethereum вики bitcoin bitcoin kaufen bitcoin weekly ethereum игра ethereum poloniex ethereum pow bitcoin что счет bitcoin bitcoin мошенники download bitcoin moneybox bitcoin bitcoin easy torrent bitcoin The focus of mining is to accomplish three things:ethereum addresses ethereum обменники asrock bitcoin bitcoin aliexpress взлом bitcoin network bitcoin fast bitcoin bitcoin расчет facebook bitcoin monero ico monero miner 22 bitcoin
bitcoin xl bitcoin click 100 bitcoin weather bitcoin wiki ethereum monero курс ethereum platform
ann ethereum заработка bitcoin hashrate ethereum bitcoin cz options bitcoin bitcoin арбитраж calculator bitcoin обновление ethereum bitcoin rpg bitcoin home bitcoin prominer работа bitcoin bitcoin abc bitcoin счет
flappy bitcoin bitcoin hash monero benchmark get bitcoin bitcoin investing bitcoin sportsbook bitcoin protocol bitcoin оплатить ethereum майнить
bitcoin wsj system bitcoin ethereum биржа ethereum кошельки ethereum проект обозначение bitcoin
вывод ethereum preev bitcoin bitcoin hacker карты bitcoin bitcoin бот bitcoin алгоритмы обзор bitcoin cryptocurrency ico bitcoin split telegram bitcoin bitcoin links
магазин bitcoin основатель bitcoin bitcoin change
bitcoin count bitcoin casascius ru bitcoin bear bitcoin ethereum myetherwallet bitcoin talk
bitcoin client ethereum raiden cc bitcoin bitcoin анимация avatrade bitcoin register bitcoin bitcoin хешрейт ethereum blockchain bitcoin options bitcoin casascius bitcoin forbes monero xeon simple bitcoin 1000 bitcoin bitcoin сеть buying bitcoin bitcoin вход контракты ethereum алгоритмы ethereum lootool bitcoin bitcoin rub green bitcoin monero майнеры bitcoin timer кошельки bitcoin bitcoin faucet сложность ethereum bitcoin weekly bitcoin okpay tether программа bitcoin статья utxo bitcoin статистика ethereum создатель bitcoin bitcoin novosti production cryptocurrency хардфорк bitcoin
qr bitcoin auto bitcoin терминал bitcoin ethereum claymore bitcoin it bitcoin com bitcoin фарм
cryptonight monero short bitcoin баланс bitcoin bitcoin кошелек
bitcoin evolution love bitcoin bitcoin hack эпоха ethereum alpha bitcoin Blockchain technology can also potentially prevent the sale of illegal arms on the black market. By creating a global database that cannot be altered once recorded, Blockchain technology could be used to track weapons from their manufacture to their sale. The database could primarily record every transaction and purchase.курс bitcoin
криптовалюта monero приложение tether air bitcoin This is a great option for beginners as you will not have to buy expensive hardware that costs you lots of electricity!bitcoin бесплатно bitcoin airbit redex bitcoin bitcoin money
bitcoin zone bitcoin landing
ethereum ethash locate bitcoin ethereum web3 flash bitcoin monero прогноз
bitcoin cgminer ethereum io bitcoin отзывы ethereum кошельки bitcoin bitrix hashrate ethereum bitcoin bonus seed bitcoin bitcoin блокчейн block bitcoin In the financial world the applications are more obvious and the revolutionary changes more imminent. Blockchains will change the way stock exchanges work, loans are bundled, and insurances contracted. They will eliminate bank accounts and practically all services offered by banks. Almost every financial institution will go bankrupt or be forced to change fundamentally, once the advantages of a safe ledger technology without transaction fees are widely understood and implemented. After all, the financial system is built on taking a small cut of your money for the privilege of facilitating a transaction. Instead of paying high transaction fees to the banks and taking several days for payments to settle and clear, they can just transact between each other on blockchain-based exchanges with ease and at no time. Bankers will become mere advisers, not gatekeepers of money. Stockbrokers will no longer be able to earn commissions and the buy/sell spread will disappear.How Does a Blockchain Work?Rollups are seen as a short-term way to push Ethereum scaling to new heights, and are expected to be rolled out over the next couple of years. This could help businesses and apps on the platform that have bumped into high fees when the blockchain gets congested.bitcoin динамика bitcoin update bitcoin код bitcoin api
ethereum android ethereum пулы системе bitcoin
ethereum charts bitcoin airbitclub ethereum transactions bitcoin dynamics bitcoin hesaplama ccminer monero
android tether настройка bitcoin bitcoin работа bitcointalk ethereum tether io world bitcoin bitcoin friday bitcoin cryptocurrency
асик ethereum bitcoin магазин accepts bitcoin bitcoin lurk bitcoin вложения bitcoin tools json bitcoin bitcoin вклады
bitcoin hub bitcoin mixer
bitcoin пул ethereum проблемы ethereum clix
metropolis ethereum bitcoin конвертер
bitcoin evolution
bitcoin mmgp hd bitcoin nxt cryptocurrency index bitcoin bitcoin коллектор bitcoin lurk happy bitcoin bitcoin account bitcoin зарабатывать See also: Bitcoin scalability problem and List of bitcoin forksторрент bitcoin cryptocurrency wallet
бесплатные bitcoin bitcoin ethereum bitcoin dollar
bitcoin purchase ферма ethereum abi ethereum bitcoin net kurs bitcoin bitcoin neteller api bitcoin bitcoin транзакция
bitcoin 9000 tails bitcoin цены bitcoin monero hashrate
bitcoin save ethereum com tinkoff bitcoin monero прогноз настройка monero bitcoin nvidia
network bitcoin click bitcoin 99 bitcoin bitcoin bitrix bitcoin 2x bitcoin sportsbook avatrade bitcoin
blockchain ethereum geth ethereum bitcoin проект bitcoin страна пулы bitcoin bitcoin хешрейт сайте bitcoin bitcoin double tradingview bitcoin hyip bitcoin клиент bitcoin bitcoin бот cryptonight monero
bitcoin reserve bitcoin c bitcoin landing bitcoin nedir ethereum io bitcoin блок bitcoin casino биржи monero bitcoin strategy avalon bitcoin favicon bitcoin удвоить bitcoin buying bitcoin bitcoin freebitcoin tether комиссии golden bitcoin datadir bitcoin keys bitcoin bitcoin конверт bitcoin microsoft tether курс bitcoin биткоин siiz bitcoin
bitcoin майнер blogspot bitcoin майнинг ethereum index bitcoin
bitcoin status bitcoin сети