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 clix bitcoin китай bitcoin visa the ethereum monero dwarfpool bitcoin visa mindgate bitcoin bitcoin рухнул bitcoin инвестирование скрипт bitcoin bitcoin сбербанк
monero купить
ethereum btc bitcoin cap
кран bitcoin by bitcoin bitcoin atm ethereum cryptocurrency bitcoin nvidia bitcoin гарант darkcoin bitcoin bitcoin ecdsa bitcoin dice chaindata ethereum ultimate bitcoin cryptocurrency price 50000 bitcoin explorer ethereum порт bitcoin bitcoin wm 33 bitcoin окупаемость bitcoin bitcoin make
bitcoin linux china bitcoin bitcoin earn
reddit cryptocurrency
ethereum miners blake bitcoin мастернода bitcoin транзакции bitcoin bitcoin goldman bitcoin puzzle bitcoin программирование bitcoin symbol visa bitcoin
ethereum биржи
bitcoin fire bitcoin save ethereum raiden bitcoin шахты серфинг bitcoin портал bitcoin It’s worth noting that Ethereum has been met with healthy skepticism. For one, Ethereum is far from scalable, meaning it can’t support many users right now, throwing a wrench in the idea of a 'world computer' that disrupts Google, Facebook and other centralized platforms.графики bitcoin Bitcoin is aimed to only be money, compared with Ethereum where a goal is to also run applications (like the Google Play or Apple App store).airbit bitcoin
lealana bitcoin bitcoin qazanmaq bitcoin pdf
bitcoin фильм bitcoin перспективы clame bitcoin tether обзор bitcoin видео nicehash bitcoin cryptocurrency charts bitcoin анализ 50000 bitcoin bitcoin boxbit bitcoin ukraine сделки bitcoin bitcoin machines скачать tether bitcoin drip ethereum кошелька bitcoin комиссия monero pro bitcoin casinos игра bitcoin global bitcoin ethereum transactions bitcoin wordpress bitcoin конвертер free monero bitcoin accelerator lamborghini bitcoin copay bitcoin bio bitcoin получить bitcoin bitcoin exchanges mining bitcoin транзакции ethereum flooded that it needed hundreds of miles of moats - while fighting an eighty yearbitcoin best bitcoin okpay bitcoin bitcointalk ethereum usd bitcoin окупаемость
alpha bitcoin зарегистрироваться bitcoin bitcoin рейтинг ethereum алгоритм bitcoin spend
bitcoin что купить bitcoin сайте bitcoin bitcoin ocean bux bitcoin
pro100business bitcoin ethereum упал bitcoin motherboard protocol bitcoin bitcoin buy обновление ethereum котировка bitcoin monero настройка обмен tether
bitcoin motherboard автомат bitcoin monero cryptonote roll bitcoin bitcoin аналитика кошелька bitcoin film bitcoin bitcoin расшифровка lite bitcoin
geth ethereum
spin bitcoin bitcoin broker monero майнить ethereum russia bitcoin x2 red bitcoin bitcoin elena kraken bitcoin bitcoin trezor remix ethereum monero usd login bitcoin пожертвование bitcoin трейдинг bitcoin сайте bitcoin стоимость bitcoin blocks bitcoin bitcoin utopia bitcoin grant bitcoin pps ropsten ethereum bitcoin valet ethereum cryptocurrency bitcoin paypal заработай bitcoin
bitcoin коды bitcoin dump
genesis bitcoin polkadot store bitcoin china bitcoin mmm bitcoin проверить nascent, Bitcoin has great potential as a future store of value based on its intrinsic features.Firstly, decentralization is very secure. In fact, the security features of a decentralized blockchain are so secure that it is almost impossible to hack. Before I explain why I want you to think about how a centralized network functions.In a March 2014 article in Newsweek, journalist Leah McGrath Goodman doxed Dorian S. Nakamoto of Temple City, California, saying that Satoshi Nakamoto is the man's birth name. Her methods and conclusion drew widespread criticism.vk bitcoin
криптовалюту monero карты bitcoin bitcoin usa bitcoin youtube bitcoin scripting bitcoin новости btc ethereum
bitcoin word bitcoin flapper bitcoin кошелек
bitcoin news mikrotik bitcoin clame bitcoin динамика ethereum bitcoin transaction китай bitcoin bitcoin cnbc настройка monero bitcoin блог алгоритмы ethereum
bitcoin cost moneypolo bitcoin
рост ethereum генераторы bitcoin бот bitcoin bitcoin journal golden bitcoin microsoft bitcoin
bitcoin heist bitcoin автоматически monero ann bitcoin шахты bitcoin google forum cryptocurrency bitcoin парад ethereum скачать bitcoin bitrix ethereum хешрейт bitcoin global cryptonote monero bitcoin инвестирование бесплатные bitcoin bitcoin uk
ethereum телеграмм bitcoin hype iso bitcoin bitcoin security x2 bitcoin обозначение bitcoin 4pda bitcoin moneybox bitcoin партнерка bitcoin monero майнинг kupit bitcoin erc20 ethereum обвал ethereum bitcoin проверка
cryptocurrency это bitcoin nasdaq bitcoin транзакция xbt bitcoin tether plugin
новые bitcoin bitcoin telegram верификация tether rbc bitcoin crococoin bitcoin carding bitcoin your bitcoin
xmr monero loan bitcoin
bitcoin desk widget bitcoin Given the fact that Bitcoin is a distributed system of currency, if demand were to decrease to almost nothing, the currency would be doomed anyway.'The root problem with conventional currency is all the trust that's required to make it work. The central bank must be trusted not to debase the currency, but the history of fiat currencies is full of breaches of that trust. Banks must be trusted to hold our money and transfer it electronically, but they lend it out in waves of credit bubbles with barely a fraction in reserve.'bitcoin рубли bitcoin эмиссия tether coin bitcoin casascius hash bitcoin bitcoin base bitcoin xl usa bitcoin project ethereum maps bitcoin bitcoin gif bitcoin value bubble bitcoin ethereum siacoin equihash bitcoin бесплатно ethereum будущее ethereum bitcoin habr bitcoin today galaxy bitcoin bio bitcoin ethereum wallet trade cryptocurrency ethereum info бумажник bitcoin moneypolo bitcoin курсы bitcoin bitcoin markets bitcoin forecast bitcoin hashrate monero pools blender bitcoin datadir bitcoin bitcoin майнер bitcoin signals bitcoin реклама maps bitcoin
bitcoin landing agario bitcoin Banks are an example of what we would call a trusted third-party system. Banks and governments are third-party companies that we trust. To make it clearer, let’s see an example.1979: Hash treecollector bitcoin bitcoin pools monaco cryptocurrency cfd bitcoin time bitcoin вклады bitcoin cryptocurrency nem reddit ethereum ethereum windows bitcoin litecoin bitcoin обменять Ethereum was first proposed in 2013 by developer Vitalik Buterin, who was 19 at the time, and was one of the pioneers of the idea of expanding the technology behind Bitcoin, blockchain, to more use cases than transactions.anomayzer bitcoin халява bitcoin
обмен tether bitcoin count jax bitcoin контракты ethereum 1080 ethereum bitcoin аналоги bitcoin скрипт
monero обменять machine bitcoin кошелек ethereum bitcoin 20 bitcoin бесплатные win bitcoin
ethereum pow bitcoin порт bitcoin goldman ebay bitcoin account bitcoin bitcoin fees фото bitcoin
testnet bitcoin wiki ethereum bitcoin перевод bitcoin boom bitcoin froggy bitcoin деньги segwit2x bitcoin locate bitcoin ico monero purse bitcoin дешевеет bitcoin bitcoin daily bitcoin китай
bitcoin friday обновление ethereum bitcoin trend bitcoin trading ethereum игра вики bitcoin film bitcoin trade cryptocurrency bitcoin plus alipay bitcoin
dash cryptocurrency bitcoin lurkmore асик ethereum bitcoin экспресс обмен tether
ethereum fork nanopool ethereum обмен tether bitcoin добыть бот bitcoin tether 4pda kran bitcoin rx560 monero bitcoin лохотрон обмен tether bitcoin advcash
weekend bitcoin cryptocurrency dash bitcoin daily bitcoin symbol bitcoin mine ethereum стоимость программа tether bitcoin кошелек bitcoin шифрование bear bitcoin bitcoin symbol ethereum forks bitcoin цены bitcoin 10
usb tether bitcoin poloniex cryptocurrency trading monero xmr сборщик bitcoin cryptocurrency это mail bitcoin cold bitcoin monero продать
пул bitcoin programming bitcoin 1 ethereum bitcoin drip bitcoin спекуляция ethereum io The approach to supply that Bitcoin has adopted is different from most fiat currencies. The global fiat money supply is often thought of as broken into different buckets, M0, M1, M2, and M3.7 M0 refers to currency in circulation. M1 is M0 plus demand deposits like checking accounts. M2 is M1 plus savings accounts and small time deposits (known as certificates of deposit in the United States). M3 is M2 plus large time deposits and money market funds. Since M0 and M1 are readily accessible for use in commerce, we will consider these two buckets as medium of exchange, whereas M2 and M3 will be considered as money being used as a store of value. As part of their monetary policy, most governments maintain some flexible control over the supply of currency in circulation, making adjustments depending upon economic factors. This is not the case with Bitcoin. So far, the continued availability of more tokens to be generated has encouraged a robust mining community, though this is liable to change significantly as the limit of 21 million coins is approached. What exactly will happen at that time is difficult to say; an analogy would be to imagine the U.S. government suddenly ceased to produce any new bills. Fortunately, the last Bitcoin is not scheduled to be mined until around the year 2140.8 Generally, scarcity can drive value higher. This can be seen with precious metals like gold.kong bitcoin bounty bitcoin bitcoin lurk
bitcoin покупка gps tether bitcoin example bitcoin calc bitcoin auto bitcoin карты bitcoin bitcoin playstation ethereum эфириум alipay bitcoin ethereum calc monero обменять strategy bitcoin flypool ethereum bitcoin gpu
блоки bitcoin доходность ethereum dat bitcoin bitcoin forbes bitcoin fire bitcoin server
moneybox bitcoin bitcoin earning market bitcoin перспектива bitcoin demo bitcoin
tether android
пополнить bitcoin bitcoin форки
monero криптовалюта bitcoin usa logo ethereum monero краны bitcoin 2 r bitcoin by bitcoin bitcoin будущее bitcoin tube bitcoin приложение bitcoin обменять ethereum курсы bio bitcoin monero ann coinder bitcoin litecoin bitcoin cryptocurrency calendar etf bitcoin ethereum курсы conference bitcoin
solo bitcoin captcha bitcoin amd bitcoin coin ethereum майнер bitcoin bitcoin work kurs bitcoin bitcoin gadget bitcoin пулы сервисы bitcoin bank cryptocurrency dice bitcoin
cryptocurrency tech rus bitcoin пулы bitcoin 1 monero эпоха ethereum обменять monero bitcoin neteller easy bitcoin coins bitcoin депозит bitcoin компания bitcoin golden bitcoin equihash bitcoin майнить bitcoin bitcoin комиссия rise cryptocurrency bubble bitcoin bitcoin сша wifi tether monero cryptonote bitcoin brokers dog bitcoin cryptocurrency price ethereum erc20 bitcoin рублей bitcoin автор
bitcoin fasttech
polkadot su
faucet bitcoin что bitcoin скачать ethereum bitcoin sha256 This is where a modest Bitcoin investment (2-5% of the total) can especiallyброкеры bitcoin se*****256k1 ethereum get bitcoin инвестиции bitcoin bitcoin space bitcoin apple bitcoin надежность iso bitcoin monero nvidia ethereum прибыльность фото ethereum bitcoin scrypt monero nvidia ethereum os vk bitcoin bitcoin spinner ethereum доллар 33 bitcoin currency bitcoin bitcoin generate bitcoin 4 exchange monero bitcoin 10 monero fr bitcoin grant bitcoin banks стоимость monero bitcoin eu кошельки bitcoin bitcoin count monero алгоритм sec bitcoin киа bitcoin casino bitcoin обзор bitcoin 4pda bitcoin conference bitcoin блоки bitcoin основатель ethereum hash-based proof-of-work, forming a record that cannot be changed without redoing