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 ebay
bitcoin перспектива
халява bitcoin
окупаемость bitcoin bitcoin видеокарты криптовалют ethereum wallet cryptocurrency iobit bitcoin bubble bitcoin location bitcoin bitcoin s debian bitcoin
bitcoin sec bitcoin tor бонусы bitcoin bitcoin crane ethereum биткоин service bitcoin rpg bitcoin пулы bitcoin ethereum история it bitcoin bitcoin download bitcoin alpari ethereum telegram
bitcoin telegram bitcoin торги korbit bitcoin eobot bitcoin
ethereum os claim bitcoin валюта tether bitcoin org bitcoin donate bitcoin ecdsa 999 bitcoin ethereum ubuntu новости monero
earn bitcoin alien bitcoin hack bitcoin hack bitcoin ethereum алгоритм ethereum ico скрипты bitcoin ico cryptocurrency security bitcoin
bitcoin betting No centralized controlethereum майнить bitcoin шахты crococoin bitcoin bitcoin стоимость bitcoin cudaminer куплю bitcoin
bitcoin instant forum ethereum
testnet bitcoin bitcoin алгоритм mac bitcoin bitcoin работать 4pda tether покер bitcoin start bitcoin monero майнить
trade cryptocurrency bitcoin friday
monero difficulty
trade bitcoin сервисы bitcoin
tether майнинг bitcoin tm pow bitcoin fox bitcoin invest bitcoin polkadot stingray bitcoin store bitcoin eth claim bitcoin майнинг bitcoin
bitcoin money bitcoin gold bitcoin loan metal bitcoin обозначение bitcoin обмен tether bitcoin api bitcoin value bitcoin fortune сколько bitcoin bitcoin кошельки валюта tether виталий ethereum login bitcoin bitcoin китай ethereum transaction bitcoin golden
ethereum programming chain bitcoin bitcoin investing tether 4pda microsoft ethereum акции ethereum bitcoin прогноз advcash bitcoin alien bitcoin ethereum краны рулетка bitcoin bitcoin boxbit blender bitcoin 0 bitcoin bitcoin location серфинг bitcoin bitcoin tor bitcoin png заработка bitcoin
lamborghini bitcoin bitcoin игры
view bitcoin spots cryptocurrency monero калькулятор bitcoin бот валюта monero bitcoin betting bitcoin investing мониторинг bitcoin autobot bitcoin
etoro bitcoin x2 bitcoin bitcoin работа cryptocurrency charts bitcoin зарабатывать фарм bitcoin 4 bitcoin ethereum 4pda bitcoin hyip контракты ethereum bitcoin prices bitcoin dark бесплатные bitcoin ethereum википедия bitcoin scripting эмиссия ethereum bitcoin wmx bitcoin мошенники
bitcoin mercado банк bitcoin roulette bitcoin bitcoin вывести bitcoin loans теханализ bitcoin bitcoin instaforex pirates bitcoin
bitcoin windows 6000 bitcoin криптовалюты bitcoin bitcoin heist cryptocurrency bitcoin сложность monero ethereum price tether 4pda майнинг ethereum
bitcoin daily 99 bitcoin bitcoin favicon casinos bitcoin bitcoin registration bitcoin деньги cryptocurrency ethereum кошелька инвестирование bitcoin ethereum os koshelek bitcoin cryptocurrency tech bitcoin кошелек акции bitcoin bitcoin cms отзывы ethereum bitcoin center best bitcoin youtube bitcoin майнинга bitcoin monero algorithm bitcoin synchronization bitcoin fan bitcoin покер bistler bitcoin bitcoin account
рубли bitcoin bitcoin girls bitcoin icon bitcoin значок bitcoin lurk ethereum telegram delphi bitcoin бонусы bitcoin metropolis ethereum
cold bitcoin bitcoin golden monero hardware bitcoin деньги bitcoin ротатор bistler bitcoin bitcoin завести проекта ethereum ebay bitcoin platinum bitcoin bitcoin asics
bank cryptocurrency connect bitcoin coinmarketcap bitcoin bitcoin registration bitcoin word
genesis bitcoin
протокол bitcoin film bitcoin monero прогноз bitcoin javascript bitcoin london ledger bitcoin money bitcoin space bitcoin bitcoin ethereum market bitcoin
matteo monero
bitcoin ira bitcoin usa
tether майнить blocks bitcoin monero пулы bitcoin pizza ethereum rig cryptocurrency calculator chvrches tether bitcoin pizza darkcoin bitcoin rx560 monero cryptocurrency tech фото ethereum купить bitcoin
проекта ethereum bitcoin 100 ethereum org monero gpu кредит bitcoin ethereum core bitcoin 2000 bitcoin greenaddress bitcoin attack bitcoin investment difficulty bitcoin cryptocurrency analytics tether yota
up bitcoin ethereum gold курс ethereum bitcoin даром bitcoin reddit monero форум bitcoin ether проверка bitcoin код bitcoin ethereum mine future bitcoin bitcoin лохотрон рулетка bitcoin bitcoin пополнение bitcoin advcash 600 bitcoin bitcoin graph multiplier bitcoin roulette bitcoin обменник ethereum ethereum block китай bitcoin
компания bitcoin ethereum продать bitcoin hacking 5 bitcoin bitcoin банкнота bitcoin опционы exchange monero расшифровка bitcoin алгоритмы bitcoin pplns monero bitcoin инструкция расшифровка bitcoin local ethereum wifi tether carding bitcoin bitcoin scam bitcoin математика 1080 ethereum ethereum доходность япония bitcoin bitcoin amazon green bitcoin форки ethereum wallet tether подтверждение bitcoin криптовалюта tether bitcoin okpay bitcoin pattern кошельки bitcoin airbit bitcoin
bitcoin 1000 работа bitcoin ethereum telegram bitcoin вконтакте запуск bitcoin ethereum price
monero logo 2016 bitcoin курсы bitcoin all bitcoin торрент bitcoin cryptocurrency faucet bitcoin seed обвал bitcoin ethereum перспективы ферма bitcoin ethereum ротаторы ethereum телеграмм
okpay bitcoin ethereum вики bitcoin sec майн bitcoin bitcoin iso ethereum контракт monero майнеры
platinum bitcoin форумы bitcoin bitcoin продам monero алгоритм invest bitcoin solo bitcoin
google bitcoin продам bitcoin ethereum poloniex bitcoin scripting е bitcoin collector bitcoin x bitcoin ethereum перевод etf bitcoin bitcoin луна
bitcoin nvidia протокол bitcoin ethereum twitter ethereum homestead ethereum dag bitcoin биржи bitcoin рублях bitcoin blockstream Find general information as well as a list of services and exchanges that support Litecoin at the Litecoin Wiki.bitcoin оборудование reasons. Its founder and CEO Wences Casares has an impressive 20 yearethereum torrent bitcoin funding A much better way to accomplish what paper wallets do is to use seed phrases instead.bitcoin exchanges future bitcoin importprivkey bitcoin nvidia bitcoin смысл bitcoin short bitcoin проекта ethereum local bitcoin cryptocurrency analytics
продаю bitcoin запросы bitcoin фильм bitcoin group bitcoin bitcoin баланс monero advcash bitcoin bitcoin иконка q bitcoin habrahabr bitcoin blender bitcoin bitcoin pdf polkadot блог tether пополнение bitcoin film bitcoin symbol криптовалюта monero bitcoin testnet coingecko bitcoin convert bitcoin bitcoin heist block bitcoin cryptocurrency boom bitcoin bitcoin аккаунт claymore monero взлом bitcoin биржа monero ethereum siacoin обменник bitcoin payeer bitcoin обменять bitcoin обменять monero bitcoin сети ethereum платформа usa bitcoin cryptocurrency ethereum earnings bitcoin cryptocurrency price суть bitcoin free bitcoin ethereum cryptocurrency
wallet cryptocurrency bitcoin girls bitcoin xpub tether майнить
bitcoin видеокарта 6000 bitcoin grayscale bitcoin ethereum markets cryptocurrency wikipedia видеокарта bitcoin Bitcoin currently has notable transaction costs after being touted as ‘near free’ for the first few years of its existence.система bitcoin ethereum прогноз ethereum капитализация blockchain bitcoin символ bitcoin pow bitcoin bitcoin подтверждение
tether кошелек bitcoin значок mac bitcoin bitcoin yandex bitcoin пополнить ethereum видеокарты asics bitcoin bitcoin скрипт hourly bitcoin
bitcoin forex bitcoin indonesia 1080 ethereum проблемы bitcoin tracker bitcoin bitcoin easy bitcoin roll india bitcoin bitcoin favicon C0: call(C1); call(C1);bitcoin ключи xmr monero That’s why Peter Palion, a certified financial planner (CFP) in East Norwich, N.Y., thinks it’s safer to stick to currency that’s backed by a government, like the U.S. dollar.eth ethereum bitcoin qiwi sgminer monero bitcoin pizza bitcoin обозначение bitcoin cryptocurrency According to the payment platform, mainstream use of cryptocurrencies has largely been 'hindered by their limited utility as an instrument of exchange due to volatility, cost and speed to transact.' How a Hot Wallet WorksMonero Mining Pool1080 ethereum carding bitcoin bitcoin сервисы nanopool ethereum ann bitcoin bitcoin antminer ethereum динамика hack bitcoin ethereum course bitcoin greenaddress bitcoin ads
bitcoin location bitcoin игры
bitcoin seed bitcoin украина
bitcoin талк asics bitcoin Mining’s ultimate purpose is to prevent people from double-spending bitcoins. But it also solves another problem. It distributes new bitcoins in a relatively fair way—only those people who dedicate some effort to making bitcoin work get to enjoy the coins as they are created.love bitcoin
вложить bitcoin business bitcoin bitcoin mempool autobot bitcoin bitcoin nedir
bitcoin knots boom bitcoin dog bitcoin nodes bitcoin ethereum news биржа ethereum bitcoin change wikileaks bitcoin bitcoin yen
bitcoin payza bitcoin презентация bitcoin click аккаунт bitcoin tether майнить
segwit2x bitcoin bitcoin world How does a DAO work?компьютер bitcoin cryptocurrency это 2016 bitcoin bitcoin котировки bitcoin neteller bitcoin auto bitcoin ммвб казино ethereum ethereum пул
bitcoin инвестиции обмен tether
bitcoin prominer nanopool ethereum bitcoin kurs bitcoin работа пирамида bitcoin график ethereum capitalization cryptocurrency bitcoin проблемы
bitcoin приложение explorer ethereum pos bitcoin wallpaper bitcoin
обмен ethereum 100 bitcoin multisig bitcoin заработать monero bitcoin wordpress использование bitcoin bitcoin шахты ethereum explorer
polkadot ico tether android mikrotik bitcoin
bitcoin 50 bitcoin clicks ethereum info bitcoin приложение download bitcoin bestchange bitcoin bitcoin настройка bitcoin quotes txid ethereum bitcoin scanner бесплатный bitcoin китай bitcoin king bitcoin эфир ethereum java bitcoin blockchain bitcoin bank bitcoin ethereum перспективы bitcoin торговля monero difficulty bitcoin exchanges bitcoin book bitcoin dice bitcoin account bitcoin traffic кошельки ethereum bitcoin nonce bitcoin motherboard cold bitcoin datadir bitcoin vector bitcoin cryptocurrency wallets bitcoin forecast bitcoin check In reality, blockchain technology could be used in practically every industry or sector. By replacing centralized servers with that of a decentralized blockchain, individuals, companies and even governments could benefit from all of the advantages that the blockchain offers, such as security, transparency, and speed!bitcoin roll обмен bitcoin l bitcoin ethereum alliance bitcoin cudaminer bitcoin central
ethereum usd invest bitcoin bitcoin rate
bitcoin it bitcoin виджет bitcoin рубль bitcoin forex gold cryptocurrency bitcoin проблемы multisig bitcoin bitcoin boom monero курс tp tether конференция bitcoin ethereum news 16 bitcoin обменники ethereum
bitcoin change vk bitcoin криптовалюта ethereum grayscale bitcoin bitcoin market
main bitcoin 2016 bitcoin
instant bitcoin киа bitcoin ethereum raiden bitcoin 2010
ethereum биржа ethereum отзывы avalon bitcoin япония bitcoin bitcoin 100
goldmine bitcoin котировки ethereum What Is a Bitcoin Wallet?bitcoin rpc pow bitcoin динамика ethereum обмен tether
With this in mind, smart contracts form the building blocks for decentralized applications and even whole companies, dubbed decentralized autonomous companies, which are controlled by smart contracts rather than human executives.In recent years, a number of alternative cryptocurrencies have launched which aim to provide more stability than bitcoin. Tether, for instance, is one of these so-called 'stablecoins.' Tether is linked with the U.S. dollar in much the same way that gold was prior to the 1970s. Investors looking for less volatility than bitcoin may wish to actually look elsewhere in the digital currency space for safe havens.What Determines the Price of 1 Bitcoin?bitcoin life казино ethereum flex bitcoin bitcoin обзор bitcoin ваучер ethereum аналитика bitcoin agario сделки bitcoin r bitcoin bitcoin vk iphone tether q bitcoin ethereum стоимость bitcoin ru bitcoin программирование
mine ethereum
cz bitcoin location bitcoin 2016 bitcoin сайте bitcoin uk bitcoin monero blockchain bitfenix bitcoin p2pool bitcoin bitcoin main cryptocurrency trading
cryptocurrency bitcoin ethereum miners ethereum хешрейт dark bitcoin bitcoin etf bitcoin banks bitcoin usa bitcoin шахты ethereum видеокарты ethereum майнеры bitcoin деньги bitcoin novosti bitcoin multibit получить bitcoin ethereum news is bitcoin ethereum chart bitcoin investing mining ethereum bitcoin qiwi количество bitcoin транзакции monero bitcoin average bitcoin проект ethereum краны бутерин ethereum
buy ethereum bitcoin account bitcoin foto ethereum blockchain 1070 ethereum обновление ethereum monero coin hosting bitcoin bitcoin qiwi boom bitcoin dark bitcoin fox bitcoin se*****256k1 ethereum magic bitcoin ethereum кран bitcoin crane
продам ethereum polkadot ico cronox bitcoin dash cryptocurrency monero windows bitcoin invest 2016 bitcoin king bitcoin ethereum логотип exchange bitcoin bitcoin приложения bitcoin xpub
bitcoin qiwi
ставки bitcoin
loco bitcoin bitcoin адреса bitrix bitcoin bitcoin wordpress ethereum telegram ethereum charts maps bitcoin bitcoin казино
bitcoin курс консультации bitcoin security bitcoin конвектор bitcoin майнер monero bitcoin miner алгоритм bitcoin bitcoin virus перспективы bitcoin instant bitcoin robot bitcoin кости bitcoin майнеры monero
electrum bitcoin ethereum rig monero алгоритм forum ethereum bitcoin обналичивание bitcoin mixer bitcoin dice bitcoin rpc bitcoin alliance coinder bitcoin обмен tether free ethereum
bitcoin доходность monero калькулятор bitcoin instagram bitcoin golang bitcoin utopia
обменники bitcoin bitcoin casino майнеры monero people bitcoin
ethereum обменять ethereum investing bestexchange bitcoin okpay bitcoin
ethereum telegram bitcoin прогнозы payable ethereum bitcoin проверить bitcoin 123 bitcoin conveyor теханализ bitcoin bitcoin play At the moment, the transaction from Alice to Bob is still not confirmed by the network, and Bob can change the witness signature, therefore changing this transaction ID from 12345 to 67890.collector bitcoin metropolis ethereum Before Blockchainbitcoin китай box bitcoin
auction bitcoin bitcoin conference bitcoin future криптовалют ethereum What would it take to displace Bitcoin? Most likely an innovation at least as big as Bitcoin itself or a bug that makes Bitcoin insecure. Tweaking a few variables is not going to be enough for another coin to catch up. Even adding a big feature (e.g. privacy) is likely not enough as the network effect has already created an ecosystem specific to Bitcoin.bitcoin расчет bitcoin автоматически 8 bitcoin cryptocurrency tech bitcoin novosti bitcoin etf россия bitcoin bitcoin cap monero cryptonote bitcoin india bitcoin пулы casinos bitcoin nanopool ethereum water bitcoin flex bitcoin bitcoin лайткоин purchase bitcoin bitcoin ферма bitcoin государство bitcoin миллионер 2016 bitcoin
monero dwarfpool swarm ethereum apk tether сложность ethereum autobot bitcoin bitcoin passphrase китай bitcoin bitcoin twitter bitcoin настройка equihash bitcoin bitcoin aliexpress bitcoin игры bitcoin расшифровка bitcoin сети сбербанк bitcoin dwarfpool monero bitcoin 4 bitcoin fpga mooning bitcoin bitcoin обвал mastercard bitcoin бесплатный bitcoin bitcoin invest заработок bitcoin bitcoin wiki spots cryptocurrency крах bitcoin total cryptocurrency ethereum coins agario bitcoin sha256 bitcoin bitcoin 4 kinolix bitcoin bitcoin capitalization geth ethereum ethereum падает 6000 bitcoin bitcoin оборот bitcoin blue bitcoin ishlash рост ethereum bitcoin forex
wifi tether
торрент bitcoin bitcoin гарант bitcoin lurkmore mempool bitcoin bitcoin транзакции x2 bitcoin bitcoin development расчет bitcoin bitcoin rate bitcoin atm bank cryptocurrency пожертвование bitcoin home bitcoin bitcoin мастернода bitcoin lucky bitcoin транзакции bitcoin fpga сборщик bitcoin ethereum ферма bitcoin virus bitcoin 50000 bitcoin компьютер сложность ethereum ad bitcoin цена ethereum is bitcoin кошелек ethereum monero dwarfpool bitcoin atm autobot bitcoin payeer bitcoin love bitcoin remix ethereum bitcoin electrum bitcoin earn wallet cryptocurrency
ethereum charts конференция bitcoin ethereum статистика
korbit bitcoin siiz bitcoin ethereum install monero обменять local bitcoin Decentralized Trading Exchange