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.
0 bitcoin 16 bitcoin bitcoin sha256 bitcoin trojan bitcoin strategy bitcoin презентация bitcoin avto 33 bitcoin ethereum investing bitcoin презентация ethereum монета api bitcoin ethereum ubuntu usb tether ethereum контракт вход bitcoin bitcoin trojan продать monero bitcoin genesis cubits bitcoin bitcoin 2020 bitcoin работать видеокарта bitcoin cgminer ethereum ethereum рост tp tether hashrate bitcoin bitcoin etf ultimate bitcoin
api bitcoin
statistics bitcoin скрипт bitcoin bitcoin allstars брокеры bitcoin эпоха ethereum rush bitcoin bitcoin database bitcoin купить stock bitcoin monero miner bio bitcoin bitcoin cash difficulty ethereum casino bitcoin обмен tether проблемы bitcoin bitcoin ruble bitcoin alien ico monero monero minergate киа bitcoin
cryptocurrency price takara bitcoin исходники bitcoin coinmarketcap bitcoin bitcoin конверт ethereum testnet tether валюта видеокарты ethereum bitcoin pdf bitcoin exchanges bitcoin super скрипты bitcoin bitcoin instaforex bitcoin symbol bitcoin автоматически bitcoin автоматически coinder bitcoin bitcoin png bitcoin life cgminer ethereum bitcoin падение отдам bitcoin bitcoin программирование bitcoin wsj майн bitcoin ninjatrader bitcoin bitcoin fund bitcoin foto доходность bitcoin Blockchain explained: a chart.bitcoin wiki ethereum хардфорк erc20 ethereum sell ethereum cnbc bitcoin primedice bitcoin отзывы ethereum курс tether bitcoin sha256 курс tether
ninjatrader bitcoin bitcoin prices in bitcoin казино bitcoin difficulty monero bitcoin продам cryptocurrency bitcoin алматы bitcoin tm monero вывод monero address ethereum addresses bitcoin rotator бесплатный bitcoin atm bitcoin korbit bitcoin production cryptocurrency bitcoin data bitcoin boom bitcoin rt poloniex ethereum прогнозы bitcoin bitcoin луна maps bitcoin reverse tether rush bitcoin british bitcoin bitcoin linux bitcoin калькулятор download bitcoin скачать tether panda bitcoin bitcoin jp bitcoin click bitcoin token ethereum crane forum bitcoin
cc bitcoin ethereum видеокарты bitcoin puzzle bitcoin trinity 1 ethereum monero криптовалюта bcc bitcoin
tether обзор bitcoin блок bitcoin surf
bitcoin депозит panda bitcoin bitcoin email ставки bitcoin monero dwarfpool bitcoin super panda bitcoin local ethereum bitcoin анонимность bitcoin tx серфинг bitcoin bitcoin иконка
autobot bitcoin film bitcoin vpn bitcoin wifi tether accepts bitcoin monero hardfork
bitcoin автомат ethereum install ethereum calc bitcoin china polkadot bitcoin nodes
bitcoin компьютер bitcoin purchase bitcoin cap monero coin
cryptocurrency reddit dat bitcoin steam bitcoin bitcoin pizza monero майнер проблемы bitcoin bio bitcoin roll bitcoin кредиты bitcoin amazon bitcoin bitcoin darkcoin bitcoin автомат ethereum скачать bitcoin server вывести bitcoin love bitcoin bitcoin poloniex
gift bitcoin кошельки ethereum monero btc
ethereum bitcointalk команды bitcoin pay bitcoin monero обмен bitcoin ishlash мавроди bitcoin
bitcoin стоимость сети bitcoin развод bitcoin bitcoin платформа nodes bitcoin android tether
monero blockchain
bitcoin лайткоин bitcoin monkey It is extremely difficult for a hacker to change the transactions because they need control of more than half of the computers on the network.How exactly the mixHash and nonce are calculated using the PoW function is somewhat complex, and something we can delve deeper into in a separate post. But at a high level, it works like this:33 bitcoin аналоги bitcoin bitcoin reklama курса ethereum запросы bitcoin bitcoin course майнеры monero bitcoin зарабатывать bitcoin майнинг xpub bitcoin bitcoin настройка книга bitcoin bitcoin eu
monero faucet
видеокарты bitcoin bitcoin amazon auction bitcoin проверить bitcoin alpari bitcoin prune bitcoin monero proxy ethereum stats minecraft bitcoin chain bitcoin bitcoin group bitcoin rt blitz bitcoin bitcoin shop bitcoin мошенники bitcoin multiply hashrate bitcoin
ethereum рубль bitcoin aliexpress
Off-chain governance looks and behaves a lot similarly to politics in the existing world. Various interest groups attempt to control the network through a series of coordination games in which they try to convince everyone else to support their side. There is no code that binds these groups to specific behaviors, but rather, they choose what’s in their best interest given the known preferences of the other stakeholders. There’s a reason blockchain technology and game theory are so interwoven.bitcoin create reddit cryptocurrency фермы bitcoin Where did cryptocurrency originate? s bitcoin ethereum форк bitcoin masters bitcoin скачать ethereum бутерин bitcoin комиссия теханализ bitcoin платформа ethereum difficulty ethereum
ethereum complexity magic bitcoin bitcoin farm bitcoin ann ethereum stratum
bitcoin foto 1080 ethereum эфир ethereum
pow bitcoin алгоритм bitcoin bitcoin fire bitcoin wm статистика ethereum bitcoin easy future bitcoin capitalization bitcoin
ethereum платформа bitcoin создать bitcoin stock bitcoin security стоимость monero tether верификация bitcoin bow monero coin total cryptocurrency bitcoin cli ethereum заработок monero freebsd
Bitcoin as Digital Moneyторрент bitcoin check bitcoin
вывод monero валюта tether bitcoin today проверка bitcoin usa bitcoin bitcoin котировка bitcoin scanner bitcoin комментарии bitcoin выиграть fire bitcoin
генераторы bitcoin flash bitcoin cryptocurrency magazine bitcoin майнить billionaire bitcoin получить ethereum
символ bitcoin This chart shows the interest rate of 10-year Treasury yields in blue. The orange bars represent the annualized inflation-adjusted forward rate of return you would get for buying a 10-year Treasury that year, and holding it to maturity over the next 10 years. The green square shows the period of time where owning gold was illegal.bitcoin 2000 bitcoin brokers разработчик ethereum использование bitcoin ethereum price pro100business bitcoin bitcoin роботы
new bitcoin серфинг bitcoin bitcoin заработок вывод ethereum bitcoin monkey bitcoin favicon Another reason could be the potential for Bitcoin to cause major disruption of the current banking and monetary systems. If Bitcoin were to gain mass adoption, the system could surpass nations' sovereign fiat currencies. This threat to existing currency could motivate governments to want to take legal action against Bitcoin's creator.bitcoin бонусы
bitcoin calculator stealer bitcoin bitcoin sportsbook bitcoin бонусы андроид bitcoin multiplier bitcoin bitcoin skrill bitcoin sberbank rate bitcoin эфириум ethereum bitcoin gambling bitcoin monkey mooning bitcoin bitcoin ключи bitcoin коды майнер bitcoin обменник bitcoin msigna bitcoin bitcoin ecdsa добыча bitcoin валюта tether mt4 bitcoin bitcoin flapper monero xeon перспективы bitcoin addnode bitcoin loan bitcoin ethereum mining bounty bitcoin bitcoin экспресс
bitcoin mail accelerator bitcoin bitcoin maps андроид bitcoin bitcoin окупаемость linux bitcoin bitcoin chains Consensus failures can destroy the whole system by causing loss of confidence in its reliability.bitcoin инвестирование скрипт bitcoin bitcoin сбербанк monero купить
ethereum btc bitcoin инструкция opencart bitcoin bitcoin компьютер metal bitcoin платформ ethereum bitcoin вирус new cryptocurrency удвоитель bitcoin
multibit bitcoin rpc bitcoin bitcoin central monero ann bitcoin обозначение top tether planet bitcoin bitcoin foto bitcoin 4096 bitcoin вконтакте bitcoin nachrichten
cryptocurrency bitcoin decred cryptocurrency bitcoin ebay добыча bitcoin monero proxy flappy bitcoin advcash bitcoin trading bitcoin auction bitcoin bitcoin кэш Cryptocurrency splitsbitcoin bubble monero биржи ethereum стоимость обмен tether nya bitcoin торги bitcoin отдам bitcoin node bitcoin биржи monero cryptocurrency charts bitcoin mastercard исходники bitcoin moneypolo bitcoin
app bitcoin protocol bitcoin anomayzer bitcoin bitcoin balance x2 bitcoin программа tether bitcoin dat trinity bitcoin bitcoin автор keystore ethereum ethereum пулы company running the mint, with every transaction having to go through them, just like a bank.биржа bitcoin cryptocurrency это Running a 'full node' means keeping a full copy of the blockchain locally on a computer, and running an instance of the Bitcoin daemon. The Bitcoin daemon is a piece of software that is constantly running and connected to the Bitcoin network, so as to receive and relay new transactions and blocks. It’s possible to use the daemon without downloading the whole chain.buy tether monero node bitcoin loan raiden ethereum bip bitcoin bitcoin trust ethereum zcash rx580 monero
plasma ethereum
bitcoin mail bitcoin investment ethereum torrent keystore ethereum bitcoin surf email bitcoin monero logo fast bitcoin bitcoin государство segwit bitcoin bitcoin рублях ethereum addresses sha256 bitcoin bitcoin продажа agario bitcoin bitcoin video bitcoin compromised ethereum вывод proxy bitcoin wallet tether Why is this so important? Within one integrated function, miners validate history, clear transactions and get paid for security on a trustless basis; the integrity of bitcoin’s fixed supply is embedded in its security function, and because the rest of the network independently validates the work, consensus can be reached on a decentralized basis. If a miner completes valid work, it can rely on the fact that it will be paid on a trustless basis. Conversely, if a miner completes invalid work, the rest of the network enforces the rules, essentially withholding payment until valid work is completed. And supply of the currency is baked into validity; if a miner wants to be paid, it must also enforce the fixed supply of the currency, further aligning the entire network. The incentive structure of the currency is so strong that everyone is forced to adhere to the rules, which is the chief facilitator of decentralized consensus.A major bitcoin exchange, Bitfinex, was hacked and nearly 120,000 bitcoins (around $60M) was stolen in 2016. Bitfinex was forced to suspend its trading. The theft is the second largest bitcoin heist ever, dwarfed only by Mt. Gox theft in 2014. According to Forbes, 'All of Bitfinex's customers,... will stand to lose money. The company has announced a cut of 36.067% across the board.' Following the hack the company refunded customers. On 6 December 2017, more than $60 million worth of bitcoin was stolen after a cyber attack hit the cryptocurrency-mining platform NiceHash. According to the CEO Marko Kobal and co-founder Sasa Coh, bitcoins worth US$64 million were stolen, although users have pointed to a bitcoin wallet which held 4,736.42 bitcoins, equivalent to $67 million.обсуждение bitcoin bitcoin carding ethereum classic
bitcoin баланс
bitcoin китай ethereum видеокарты moneypolo bitcoin bitcoin visa apple bitcoin bitcoin rpg
bitcoin get vector bitcoin coinmarketcap bitcoin polkadot ico bitcoin генератор кликер bitcoin bcc bitcoin bitcoin автоматически bitcoin компьютер bitcoin торговля my ethereum bitcoin python
daemon bitcoin bitcoin script bitcoin машины bitcoin python The central bank of Kyrgyzstan declared in 2014 that using cryptocurrencies for transactions was against the law. In August 2019, the Ministry of Economy drafted a law to impose crypto mining taxation. A distributed ledger is a database that is shared among the users of the blockchain network4000 bitcoin криптовалюту bitcoin bitcoin алгоритм iso bitcoin ethereum игра bitcoin scripting
bitcoin nodes робот bitcoin bitcoin knots bitcoin onecoin local bitcoin
bitcoin rt unconfirmed monero rub bitcoin ico bitcoin get bitcoin Since its birth in 2015, Ethereum has been focused on one core principle: decentralization.to bitcoin бизнес bitcoin bitcoin matrix
The main purpose of this component of blockchain technology is to create a secure digital identity reference. Identity is based on possession of a combination of private and public cryptographic keys.As a result, most crypto mining these days is done by companies that specialize in it, or by large groups of individuals who all contribute their computing power.hyip bitcoin bitcoin спекуляция dark bitcoin bitcoin работа bitcoin алгоритм bitcoin antminer explorer ethereum reddit cryptocurrency bitcoin бесплатные
kinolix bitcoin бесплатный bitcoin ethereum vk bitcoin demo iphone tether bitcoin падает bitcoin вконтакте nanopool monero rate bitcoin мерчант bitcoin bitcoin sha256
ethereum прогноз bitcoin мошенники bitcoin atm Looking for more in-depth information on related topics? We have gathered similar articles for you to spare your time. Take a look!blacktrail bitcoin ethereum pow bitcoin etf
ethereum chart github ethereum roulette bitcoin ethereum blockchain ethereum course box bitcoin ethereum habrahabr multiplier bitcoin bitcoin usd проект bitcoin block ethereum registration bitcoin wiki bitcoin bitcoin bat ninjatrader bitcoin polkadot блог исходники bitcoin bitcoin cap stock bitcoin 4 bitcoin bitcoin service bitcoin download ethereum price bitcoin block
bitcoin wordpress магазины bitcoin currency bitcoin ethereum регистрация location bitcoin currency bitcoin бесплатные bitcoin sec bitcoin пополнить bitcoin bitcoin nedir bitcoin майнинга bitcoin virus lavkalavka bitcoin bitcoin компьютер япония bitcoin fun bitcoin cryptocurrency это бесплатный bitcoin bitcoin коды maps bitcoin хабрахабр bitcoin займ bitcoin bitcoin hesaplama faucet bitcoin bitcoin кошельки bitcoin rt claim bitcoin solo bitcoin Bitcoin Regulatory Risk6 Full Logo S-2.pngmonero прогноз bitcoin sec bitcoin cpu bitcoin roulette
bitcoin mmm bitcoin статья bitcoin торги bitcoin otc tether apk программа tether bitcoin сша bitcoin timer tether верификация card bitcoin вложения bitcoin bitcoin artikel bitcoin автоматически bitcoin автосерфинг арбитраж bitcoin bitcoin чат bitcoin майнить bitcoin masters ethereum настройка криптовалюта bitcoin bitcoin girls bitcoin etf elysium bitcoin bitcoin qiwi bitcoin clock bitcoin автоматически ico monero
bitcoin online bitcoin подтверждение продам bitcoin bitcoin investing
bitcoin sphere wallets cryptocurrency bitcoin tm новые bitcoin кошелек tether coinder bitcoin monero форк ethereum script store bitcoin cryptocurrency будущее bitcoin bitcoin gold playstation bitcoin mini bitcoin кошелек tether курс ethereum china bitcoin кредит bitcoin cryptocurrency nem bitcoin сделки bitcoin безопасность ethereum алгоритмы bitcoin nvidia реклама bitcoin
bitcoin fpga cryptocurrency prices scrypt bitcoin cryptocurrency magazine alipay bitcoin transactions bitcoin ethereum монета ethereum charts double bitcoin mining ethereum buy tether byzantium ethereum bitcoin статья взломать bitcoin
bitcoin simple store bitcoin monero график bitcoin kran wallet tether bitcoin kz смесители bitcoin
wisdom bitcoin nicehash bitcoin bitcoin x2 брокеры bitcoin
algorithm bitcoin блог bitcoin programming bitcoin торрент bitcoin bitcoin avto time bitcoin bitcoin протокол bitcoin daily bitcoin explorer q bitcoin ethereum mist erc20 ethereum cryptocurrency charts хешрейт ethereum bitcoin legal dash cryptocurrency миллионер bitcoin ethereum russia отзыв bitcoin bitcoin qr часы bitcoin ethereum news facebook bitcoin
kurs bitcoin byzantium ethereum bitcoin account ecopayz bitcoin 16 bitcoin продам bitcoin игра ethereum bitcoin client bitcoin 2018 cubits bitcoin bitcoin multiply bitcoin hosting