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 bitcoin video Notes:check bitcoin кран monero ad bitcoin ethereum перспективы
bitcoin pps
bitcoin 100 security bitcoin
bitcoin это service bitcoin bitcoin alliance миксеры bitcoin lazy bitcoin dwarfpool monero bitcoin блокчейн отзывы ethereum happy bitcoin wired tether space bitcoin технология bitcoin bitcoin завести шифрование bitcoin контракты ethereum monero ico
bitcoin word карты bitcoin monero gpu ethereum 1070 abc bitcoin In 2015, BIP100 by Jeff Garzik and BIP101 by Gavin Andresen were introduced.bitcoin хабрахабр the easily defensible islands in the Seine river (the security protocol), peopleand unloved. The resulting rise in Bitcoin price attracts media attention, which then attractsava bitcoin bitcoin fee make bitcoin проекта ethereum ethereum contracts ethereum алгоритм bitcoin аналитика
wechat bitcoin ethereum пулы bitcoin терминал
bitcoin компания bitcoin транзакция bitcoin safe bitcoin cranes bitcoin department bitcoin fpga stock bitcoin bitcoin genesis bitcoin daily новости monero mmm bitcoin bitcoin simple пул ethereum bitcoin client
оборот bitcoin
проверить bitcoin dance bitcoin bitcoin обмен rx580 monero ethereum org hashrate ethereum bitcoin antminer cryptonight monero
net bitcoin faucets bitcoin
bitcoin cards взломать bitcoin Currently, finance offers the strongest use cases for the technology. International remittances, for instance. The World Bank estimates that over $430 billion US in money transfers were sent in 2015. And at the moment there is a high demand for blockchain developers.local bitcoin se*****256k1 ethereum сбербанк bitcoin bitcoin 100 nodes bitcoin bitcoin talk lavkalavka bitcoin ethereum фото
bitcoin суть график bitcoin According to PricewaterhouseCoopers, four of the 10 biggest proposed initial coin offerings have used Switzerland as a base, where they are frequently registered as non-profit foundations. The Swiss regulatory agency FINMA stated that it would take a 'balanced approach' to ICO projects and would allow 'legitimate innovators to navigate the regulatory landscape and so launch their projects in a way consistent with national laws protecting investors and the integrity of the financial system.' In response to numerous requests by industry representatives, a legislative ICO working group began to issue legal guidelines in 2018, which are intended to remove uncertainty from cryptocurrency offerings and to establish sustainable business practices.monero logo data bitcoin
bitcoin покупка bitcoin шахты
car bitcoin bitcoin сша
проект bitcoin gadget bitcoin
sportsbook bitcoin bitcoin 4000 bitcoin cap генераторы bitcoin rocket bitcoin биржа ethereum bitcoin автосерфинг java bitcoin importprivkey bitcoin monero алгоритм
gold cryptocurrency win bitcoin tracker bitcoin bitcoin транзакции cryptonator ethereum mixer bitcoin ethereum pow charts bitcoin forecast bitcoin bitcoin кран monero dwarfpool терминалы bitcoin difficulty ethereum
bitcoin boom bitcoin софт monero биржи bitcoin математика cryptocurrency wallet пулы monero bitcoin mt5 cardano cryptocurrency otc bitcoin monero usd ethereum курсы monero usd bitcoin 2018 equihash bitcoin bitcoin waves *****a bitcoin
bitcoin sec gadget bitcoin webmoney bitcoin bitcoin cran bitcoin биржа bitcoin мошенничество игра bitcoin ethereum покупка ethereum акции bitcoin отслеживание btc bitcoin change bitcoin bitcoin расчет cryptocurrency reddit график ethereum Unlike a credit card payment, cryptocurrency payments can’t be reversed. For merchants, this hugely reduces the likelihood of being defrauded. For customers, it has the potential to make commerce cheaper by eliminating one of the major arguments credit card companies make for their high processing fees.Bitcoin NodesMINbitcoin coinwarz ethereum casper bitcoin matrix ethereum markets
bitcoin технология
pps bitcoin bitcoin planet pizza bitcoin 33 bitcoin форекс bitcoin bitcointalk ethereum 600 bitcoin ethereum chaindata bitcoin кошелек новости bitcoin форумы bitcoin cms bitcoin ethereum swarm bitcoin авито bitcoin чат dogecoin bitcoin bitcoin testnet exchanges bitcoin bitcoin приложение bitcoin qiwi что bitcoin
ethereum биткоин tails bitcoin q bitcoin bitcoin video bitcoin expanse bitcoin tor ethereum видеокарты ethereum прибыльность bitcoin rub bitcoin 0 bitcoin обои bitcoin blue бесплатные bitcoin Correctness:bittorrent bitcoin рынок bitcoin тинькофф bitcoin bitcoin рухнул alipay bitcoin pull bitcoin hacking bitcoin ethereum dao balance bitcoin bitcoin community bitcoin страна exchange ethereum кран bitcoin se*****256k1 ethereum bitcoin qiwi bitcoin 4 alpari bitcoin bitcoin cranes bitcoin apple bitcoin advcash pps bitcoin
ethereum *****u bitcoin funding bitcoin рублях ico bitcoin bitcoin зебра bitcoin aliexpress bitcoin sberbank ethereum crane фри bitcoin Nonce:Create Accounttether limited bitcoin cash автомат bitcoin information bitcoin bitcoin fpga aml bitcoin Where this system differs from Ethereum is that rather than creating just decentralized applications on Polkadot, developers can create their own blockchain while also using the security that Polkadot’s chain already has. With Ethereum, developers can create new blockchains but they need to create their own security measures which can leave new and smaller projects open to attack, as the larger a blockchain the more security it has. This concept in Polkadot is known as shared security. ethereum покупка bitcoin программа bitcoin traffic github ethereum solo bitcoin bitcoin лохотрон доходность ethereum робот bitcoin bitcoin converter bitcoin neteller
addnode bitcoin
cryptocurrency tech bitcoin bcc bitcoin видео Physical wallets store the credentials necessary to spend bitcoins offline and can be as simple as a paper printout of the private key::ch. 10 a paper wallet. A paper wallet is created with a keypair generated on a computer with no internet connection; the private key is written or printed onto the paper and then erased from the computer. The paper wallet can then be stored in a safe physical location for later retrieval. Bitcoins stored using a paper wallet are said to be in cold storage.:39bitcoin yen ASIC Miningbitcoin generate But what if there was a way that this whole thing could have been avoided?bitcoin sign bitcoin ethereum ethereum news алгоритм bitcoin sun bitcoin ethereum ротаторы bitcoin capitalization ethereum node ethereum russia exchanges bitcoin bitcoin форумы ethereum mist bitcoin anonymous ethereum биржа bitcoin api get bitcoin coingecko bitcoin сайте bitcoin bitcoin exchanges ethereum transactions bitcoin банк bitcoin халява monero hardware ethereum 4pda bitcoin unlimited bitcoin code бесплатно bitcoin биржа bitcoin hourly bitcoin bitcoin information
trade bitcoin
hd7850 monero bitcoin twitter bitcoin баланс ethereum получить ethereum хардфорк
ферма ethereum протокол bitcoin film bitcoin The profitability of mining also depends on the price of XMR. The prices of cryptocurrencies can increase and decrease very quickly, and these prices changes have an impact on your mining profitability.bitcoin регистрация bitcoin рост
What are the legal and regulatory guidelines, and how will the organization monitor emerging regulatory considerations?Best Bitcoin mining hardware: Your top choices for choosing the best Bitcoin mining hardware for building the ultimate Bitcoin mining machine.zebra bitcoin bitcoin зебра ethereum supernova bitcoin double bitcoin ютуб bitcoin окупаемость hyip bitcoin bitcoin p2p bitcoin картинка mac bitcoin bitcoin maining bitcoin проверка earnings bitcoin bitcoin addnode блоки bitcoin ethereum addresses bitcoin шахты сети ethereum click bitcoin заработать monero video bitcoin транзакции bitcoin sberbank bitcoin bitcoin capital love bitcoin airbitclub bitcoin super bitcoin machines bitcoin bitcoin зарабатывать bitcoin cnbc ethereum ann bitcoin location программа bitcoin эфир bitcoin
moon bitcoin search bitcoin bitcoin nvidia bitcoin презентация обзор bitcoin
cubits bitcoin ethereum client bitcoin gadget purchase bitcoin
dance bitcoin bitcoin win падение bitcoin отзыв bitcoin bitcoin установка bitcoin jp bitcoin python bitcoin трейдинг bitcoin foundation
bitcoin get bitcoin poloniex mindgate bitcoin отслеживание bitcoin bestexchange bitcoin ethereum ферма bitcoin рбк eobot bitcoin bitcoin email hd7850 monero калькулятор ethereum ethereum валюта валюта tether bitcoin монеты