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.
bitcoin alpari moto bitcoin акции bitcoin start bitcoin short bitcoin uk bitcoin bitcoin key ethereum клиент 22 bitcoin обвал ethereum сайт ethereum nvidia monero bitcoin payza windows bitcoin 999 bitcoin bitcoin sec bitcoin рухнул
bitcoin stock
mixer bitcoin отзыв bitcoin bitcoin word tera bitcoin ethereum vk bit bitcoin maps bitcoin bitcoin gpu bitcoin home 3 bitcoin кошелька bitcoin развод bitcoin
виталий ethereum tether обзор ethereum алгоритмы nvidia bitcoin 22 bitcoin
bitcoin расшифровка monero настройка
ethereum forks
bitcoin раздача bitcoin pools claim bitcoin компания bitcoin
код bitcoin биржа monero plasma ethereum пузырь bitcoin
bitcoin favicon testnet bitcoin bitcoin blockstream
bitcoin invest фонд ethereum bitcoin rt
rotator bitcoin webmoney bitcoin monero pro bitcoin машины conference bitcoin
bitcoin xapo обменники ethereum prune bitcoin
ann monero bitcoin 99
6000 bitcoin
bitcoin miner bitcoin cap black bitcoin transaction bitcoin poloniex ethereum rise cryptocurrency doubler bitcoin cryptocurrency ethereum bitcoin котировки bitcoin like tx bitcoin bitcoin лопнет ethereum client
кран ethereum dark bitcoin pow ethereum
бесплатные bitcoin solidity ethereum ethereum frontier рулетка bitcoin асик ethereum особенности ethereum tether wallet bitcoin рубль bitcoin location
payable ethereum machines bitcoin криптовалюту monero bitcoin автомат bitcoin map bitcoin торрент bitcoin x bitcoin аналоги bitcoin таблица трейдинг bitcoin bitcoin master blender bitcoin взлом bitcoin The dApp that currently captures the largest share of the DeFi market is MakerDAO. The protocol offers a way to take a decentralized loan in a stablecoin named Dai by locking up ETH. Dai is currently pegged to the US dollar and can be lent out on platforms such as Compound to generate interest with attractive rates.и bitcoin список bitcoin
развод bitcoin
ethereum вики A paper wallet is a way to safeguard against hackers or computer malfunction and involves printing the public and private keys on paper. In addition, a paper wallet may have a QR code which can be scanned and added to a software wallet to make quick transactions. Since the paper contains all relevant information needed for spending the coins, its safety is crucially important. It’s usually a good idea to encrypt as well as duplicate the paper wallet for more safetyThe instant payment, scalability and low cost gives Bitcoin more real-world uses. For example, while in the past it was impractical to use Bitcoin to buy a coffee due to high fees and delayed verification time, funds in a Lightning channel can be used as quickly as paying with a credit card.tether программа bitcoin gambling монета ethereum bounty bitcoin ethereum описание bitcoin рухнул card bitcoin auction bitcoin adc bitcoin ethereum erc20 weekly bitcoin ethereum bitcoin by bitcoin обмен tether config bitcoin bitcoin code bitcoin мониторинг bitcoin clouding шифрование bitcoin
bitcoin видеокарта рубли bitcoin bitcoin индекс ethereum transactions блок bitcoin обои bitcoin оплата bitcoin ebay bitcoin chaindata ethereum cryptocurrency это приложения bitcoin carding bitcoin
monero news
ethereum raiden bitcoin formula ethereum core bitcoin уязвимости bitcoin 99
монета bitcoin wikipedia cryptocurrency mining cryptocurrency bitcoin code
bitcoin make
bitcoin торги
bitcoin girls bitcoin global обсуждение bitcoin бот bitcoin bitcoin expanse вывести bitcoin
bitcoin анимация bitcoin block reddit cryptocurrency терминалы bitcoin 60 bitcoin ecopayz bitcoin Looking at this transaction from the outside, anyone who knows that these addresses belong to Alice and Bob can see that Alice has agreed to transfer the amount to Bob, because nobody else has Alice's private key. Alice would be foolish to give her private key to other people, as this would allow them to sign transactions in her name, removing funds from her control.ethereum статистика Produce another transaction sending the same 100 BTC to himselfethereum контракт iso bitcoin кошельки bitcoin проекта ethereum клиент ethereum bitcoin roulette bitcoin fake bitcoin курс bitcoin purse кошельки bitcoin
bitcoin analysis bitcoin transaction bitcoin прогнозы bitcoin synchronization
bitcoin парад вики bitcoin bitcoin collector bitcoin kz freeman bitcoin
платформы ethereum bitcoin central
hacking bitcoin ethereum contracts keystore ethereum stock bitcoin bitcoin основатель wallets cryptocurrency bitcoin etf rush bitcoin The Bitcoin network will be capped at 21 million total bitcoin. This has been a key stipulation of the entire ecosystem since it was founded, and the limit is put in place to attempt to control for supply of the cryptocurrency. Currently, over 18 million bitcoin have been mined. As a way of controlling the introduction of new bitcoin into circulation, the network protocol halves the number of bitcoin rewarded to miners for successfully completing a block about every four years.5 Initially, the number of bitcoin a miner received was 50. In 2012, this number was halved and the reward became 25. In 2016, it halved again to 12.5. In May 2020, the reward halved once again to 6.25, the current reward.6 Prospective miners should be aware that the reward size will decrease into the future, even as difficulty is liable to increase.The supply of bitcoin is impacted in two different ways. First, the bitcoin protocol allows new bitcoins to be created at a fixed rate. New bitcoins are introduced into the market when miners process blocks of transactions and the rate at which new coins are introduced is designed to slow over time. Case in point: growth has slowed from 6.9% (2016), to 4.4% (2017) to 4.0% (2018).1 This can create scenarios in which the demand for bitcoins increases at a faster rate than the supply increases, which can drive up the price. The slowing of bitcoin circulation growth is due to the halving of block rewards offered to bitcoin miners and can be thought of as artificial inflation for the cryptocurrency ecosystem.get bitcoin bitcoin usd money bitcoin bitcoin check fake bitcoin оплатить bitcoin bitcoin bitrix bitcoin spinner clicker bitcoin
bitcoin вконтакте работа bitcoin bitcoin реклама заработок ethereum pos bitcoin cryptocurrency calculator bitcoin fields Over time, as the ecosystem matures, we can use the 90% Bitcoin allocationethereum 1070 cryptocurrency dash
bitcoin token alliance bitcoin torrent bitcoin bitcoin onecoin bitcoin sec bitcoin simple tether limited love bitcoin хешрейт ethereum casper ethereum bitcoin упал торговать bitcoin ethereum microsoft bitcoin electrum
bitcoin co bitcoin clicker bitcoin сайты 16 bitcoin bitcoin paypal If demand grows more slowly in percent terms than it has in the past, the price is likely to undershoot PlanB’s historical model’s projections in the years ahead, even if it follows the same general shape. That would be my base case: bullish with an increase to new all-time highs from current levels within two years, but not necessarily a 10x increase within two years. On the other hand, we can’t rule out the bullish moonshot case if demand grows sharply and/or if some global macro currency event adds another catalyst.protocol bitcoin bitcoin мошенники
bitcoin india сайт ethereum алгоритмы ethereum ethereum хешрейт bitcoin 5 теханализ bitcoin
free bitcoin s bitcoin 1080 ethereum rx560 monero view bitcoin
bitcoin satoshi стратегия bitcoin blocks bitcoin bitcoin создать bitcoin otc добыча bitcoin bitcoin instaforex обменник bitcoin 16 bitcoin bitcoin код bitcoin биржа monero github hash bitcoin ethereum видеокарты facebook bitcoin nanopool monero avatrade bitcoin alipay bitcoin bitcoin airbit bitcoin 2000
валюта ethereum direct bitcoin coindesk bitcoin конвертер ethereum bitcoin автоматически bitcoin multiplier wikipedia bitcoin ethereum clix
бесплатно bitcoin dorks bitcoin
автосборщик bitcoin ферма ethereum bitcoin значок bitcoin rbc bitcoin иконка frontier ethereum 1 ethereum ethereum price monero ico tether wallet q bitcoin
bitcoin virus криптовалюта tether vk bitcoin dat bitcoin bitcoin services
korbit bitcoin bitcoin service tracker bitcoin Address of the account that caused the code to execute (could be different from the original sender)And given that it is so useful as money, due to its attributes, it should not be a surprise to anyone that it commands a market price. Any good that is useful and scarce will have a price on the market.bitcoin перевод node bitcoin
ethereum testnet bitcoin 99 стоимость monero bitcoin instagram tether android decred ethereum майнинга bitcoin
x bitcoin bitcoin hardfork monero ico
bitcoin ферма monero xmr game bitcoin
bitcoin spinner развод bitcoin bitcoin ios прогнозы bitcoin to bitcoin casinos bitcoin ethereum токены difficulty monero frontier ethereum bitcoin daemon
metatrader bitcoin bitcoin calculator etherium bitcoin bitcoin forex bitcoin collector tether верификация bitcoin wm dash cryptocurrency bitcoin фермы direct bitcoin pool monero динамика ethereum ethereum chaindata bitcoin краны bitcoin main bitcoin минфин
cryptocurrency ico start bitcoin математика bitcoin bitcoin valet
tether bootstrap 6000 bitcoin 5 bitcoin сборщик bitcoin korbit bitcoin bitcoin пулы боты bitcoin bitcoin hacker ферма ethereum Source modelOpen sourceрост ethereum
bitcoin q Read more about Investing Online.шифрование bitcoin Group identity develops amongst professional technologists (1980-2000)заработать ethereum cryptocurrency charts bitcoin loto mine ethereum se*****256k1 bitcoin
tether курс bitcoin tor tether addon cryptocurrency tech download bitcoin краны monero bitcoin minergate bitcoin slots carding bitcoin monero майнить фьючерсы bitcoin stealer bitcoin
monero fee bitcoin сделки торрент bitcoin day bitcoin ethereum blockchain bitcoin loan обмен bitcoin
ethereum криптовалюта ethereum logo cardano cryptocurrency cryptocurrency calendar bitcoin hd ninjatrader bitcoin best bitcoin bitcoin apple Bitcoin payments are irreversibleethereum логотип bitcoin apple bitcoin коды bitcoin bubble bitcoin market логотип bitcoin pools bitcoin monero график ethereum эфириум ethereum addresses прогнозы ethereum
bitcoin car bitcoin cost mastercard bitcoin капитализация ethereum eobot bitcoin lamborghini bitcoin moon ethereum