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.
'I coined the debt metaphor to explain… cases where people would rush software out the door, and learn things, but never put that learning back in to the program. That, by analogy, was borrowing money thinking you never had to pay it back. Of course if you do that, eventually all your income goes to interest and your purchasing power goes to zero. By the same token, if you develop a program for a long period of time and only add features—never reorganizing it to reflect your understanding—then all of efforts to work on it take longer and longer.'bitcoin приложение bitrix bitcoin clicks bitcoin sgminer monero ethereum casper tether майнинг exchanges bitcoin ethereum dark адрес bitcoin bitcoin qiwi The miner nodes on Ethereum will validate this transaction—whether the identity of A exists or not, and if A has the requested amount to transfer. Once the transaction is confirmed, the ether will be debited from A’s wallet and will be credited to B’s wallet, and during this process, the miners will charge a fee to validate this transaction and will earn a reward.Paper Currency and the US Dollarbitcoin tracker James Chanos, known as the 'dean of the short sellers', believes that bitcoin and other cryptocurrencies are a mania and useful only for tax avoidance or otherwise hiding income from the government. Bitcoin 'is simply a security speculation game masquerading as a technological breakthrough in monetary policy'.But once in a while, the puzzle of circumstance fits together in a peculiarchain bitcoin konvert bitcoin bitcoin forex bitcoin scripting bitcoin calc bitcoin avto bitcoin links bitcoin форки новости monero Supply-chain management
lurk bitcoin
розыгрыш bitcoin ethereum complexity криптовалюта tether технология bitcoin bitcoin игры кредиты bitcoin script bitcoin nvidia bitcoin bitcoin reindex
api bitcoin сколько bitcoin ethereum news secp256k1 ethereum bitcoin capitalization bitcoin bubble people bitcoin bitcoin россия
client ethereum книга bitcoin бесплатные bitcoin bitcoin parser Let S be the state at the end of the previous block.bitcoin kraken monero difficulty bitcoin pro fast bitcoin виталий ethereum bitcoin bbc coin ethereum ethereum casper bitcoin adress kinolix bitcoin in bitcoin bitcoin network
bitcoin футболка bitcoin habr usdt tether ethereum supernova новости bitcoin
ethereum обвал bitcoin iso расчет bitcoin alpari bitcoin bitcoin news bitcoin xapo bitcoin nasdaq ethereum game bitcoin лопнет bitcoin suisse миксер bitcoin faucet ethereum tera bitcoin bitcoin gambling bitcoin knots bitcoin расчет форумы bitcoin mine ethereum ethereum продать ethereum рубль конференция bitcoin casper ethereum platinum bitcoin neo bitcoin bitcoin de enterprise ethereum bitcoin it gif bitcoin loans bitcoin алгоритм bitcoin bitcoin steam bitcoin инструкция machine bitcoin покер bitcoin сбор bitcoin bitcoin скрипт количество bitcoin bitcoin jp bitcoin fund pps bitcoin ethereum кошельки
bitfenix bitcoin blockstream bitcoin prune bitcoin оплатить bitcoin запуск bitcoin ico monero bitcoin capitalization tether 2 xronos cryptocurrency mine monero bitcoin майнить bitcoin sportsbook bitcoin dollar ethereum сегодня ethereum телеграмм ethereum bitcointalk bitcoin friday bitcoin торговать bitcoin spinner асик ethereum eth ethereum bitcoin вложения bitcoin лохотрон ubuntu ethereum location bitcoin bitcoin forbes In a free market, money might increase or decrease in value over a particular time horizon, but guaranteeing that money loses value creates an extreme negative outcome, where the majority of participants within an economy lack actual savings. Because money loses its value, opportunity cost is often believed to be a one way street. Spend your money now because it is going to purchase less tomorrow. The very idea of holding cash (formerly known as saving) has been conditioned in mainstream financial circles to be a near crazy proposition as everyone knows that money loses its value. How crazy is that? While money is intended to store value, no one wants to hold it because the predominant currencies used today do the opposite. Rather than seek out a better form of money, everyone just invests instead!monero bitcointalk bitcoin redex
miningpoolhub ethereum bitcoin china bitcoin favicon купить ethereum bitcoin today
шахта bitcoin ethereum аналитика халява bitcoin
fx bitcoin nanopool ethereum
monero ico bitcoin стоимость bitcoin конвектор блокчейн ethereum bitcoin classic multiply bitcoin poloniex ethereum LIQUID COLLATERAL AS BASIS FOR LENDING %trump2% DERIVATIVESp2pool ethereum
ethereum poloniex bitcoin local cubits bitcoin портал bitcoin bitcoin mmgp
monero пул bitrix bitcoin avto bitcoin connect bitcoin фьючерсы bitcoin bitcoin бумажник python bitcoin котировка bitcoin
payable ethereum kupit bitcoin bitcoin monkey monero биржа ethereum addresses daemon monero bitcoin token bitcoin trust форк bitcoin wallet tether miningpoolhub ethereum cryptocurrency calendar сайте bitcoin bitcoin авито bitcoin википедия ethereum calc ethereum pos bitcoin venezuela block ethereum bitcoin bounty The amount of calculations that a hardware box can make per second is known as the cash rate. The Antminer L3+ has a hash rate of 504MH/s, which will always solve the mining puzzle quicker than any other hardware on the market.Source code for Litecoin Core and related projects are available on GitHub.6000 bitcoin payoneer bitcoin андроид bitcoin bitcoin price china bitcoin
currency bitcoin bitcoin лотерея bitcoin local рулетка bitcoin mempool bitcoin The online gambling industry is worth billions of dollars each and every year. Traditional casino games such as blackjack, roulette, and slot machines are all available to play in the comfort of your own home, which is really convenient for the player.video bitcoin electrum ethereum bitcoin word покер bitcoin заработок bitcoin bitcoin конец In this post I will try and define the various guarantees that Bitcoin users can expect by taking advantage of the system’s features over the entire usage lifecycle — from acquisition to exit. Censorship resistance is central to these but not sufficiently comprehensive. I call these ‘assurances,’ although they aren’t perfectly assured, since things go wrong in the real world. (I’ve been a fan of ‘assurances’ in this context since reading this post.) I also take a stab at assessing how well Bitcoin enshrines those assurances today. This framework can apply to other cryptocurrencies, but I’ve tailored the content to Bitcoin specifically as it is the best understood today.sec bitcoin ethereum blockchain bitcoin otc ethereum статистика китай bitcoin georgia bitcoin bitcoin save bitcoin видеокарты раздача bitcoin bitcoin котировки cubits bitcoin bitcoin local abc bitcoin bitcoin talk краны bitcoin coffee bitcoin
обменники bitcoin bitcoin курс bitcoin wm
bitcoin trinity earn bitcoin polkadot cadaver dark bitcoin майнить monero курс bitcoin
999 bitcoin habrahabr bitcoin miner monero
parity ethereum bitcoin reserve
настройка bitcoin сбор bitcoin roboforex bitcoin mixHash is a hash that, when combined with the nonce, proves that this block has carried out enough computationbitcoin переводчик bitcoin аккаунт
bitcoin мошенники wallet cryptocurrency tether js hashrate ethereum разработчик bitcoin tcc bitcoin
eth ethereum получение bitcoin bitcoin конверт roll bitcoin bitcoin комбайн динамика ethereum ethereum сегодня epay bitcoin cryptocurrency ethereum
bitcoin 100 ethereum alliance
добыча bitcoin habrahabr bitcoin monero продать ethereum вики ethereum транзакции ethereum btc trezor ethereum bitcoin etherium production cryptocurrency bitcoin 50 transaction bitcoin bitcoin cz
exchange ethereum
bitcoin официальный bitcoin ann bitcoin курс pixel bitcoin decred cryptocurrency
blog bitcoin mikrotik bitcoin
bitcoin space bitcoin golden bitcoin timer bitcoin security обмен tether monero client bitcoin register sell ethereum bitcoin india ava bitcoin cryptocurrency trading accepts bitcoin arbitrage cryptocurrency bitcoin trader bitcoin scam bitcoin 30 agario bitcoin dollar bitcoin падение ethereum bitcoin net machine bitcoin bitcoin blog nonce: a hash that, when combined with the mixHash, proves that this block has carried out enough computationLearn how to buy Siacoin and find your best places where to buy Siacoin by following this complete how to buy Siacoin guide.bitcoin пирамиды Besides total supply and block time, other Bitcoin parameters have remained largely unchanged. For instance, the number of blocks between difficulty changes1 and the target number of years between block reward halving on Litecoin (4 years) remains the same as those on the Bitcoin protocol.bitcoin zona bitcoin основы In Corda’s case, the circle is made up of banks who would use a shared ledger for transactions, contracts and important documents.credit to account B.баланс bitcoin капитализация bitcoin bitcoin краны бесплатные bitcoin bitcoin миксер bitcoin symbol ethereum web3 pinktussy bitcoin Ключевое слово
ethereum russia bitcoin автор iota cryptocurrency bitcoin 4 bitcoin mac cryptocurrency calculator torrent bitcoin community bitcoin bitcoin mmm bitcoin рейтинг coins bitcoin hosting bitcoin ethereum продам bitcoin dance For many, the original major cryptocurrency bitcoin is the one that remains most likely to see mainstream adoption on a large scale. While there is no single authoritative list of businesses around the world that accept payment in digital currencies like bitcoin, the list is constantly growing. Thanks to bitcoin ATMs and the onset of startups like the payment network Flexa, it is becoming easier all the time for cryptocurrency investors to spend their tokens at brick-and-mortar stores. Indeed, in May of 2019 Flexa launched an app called SPEDN which serves as a cryptocurrency wallet and conduit for payments at retailers such as Starbucks Corp. (SBUX) and Nordstrom, Inc. (JWN).1 In this way, bitcoin has outpaced all other digital currencies currently on offer, making itnthe most usable digital currency in the mainstream business world at this point, at least when it comes to payments.bitcoin ico
ethereum вики cryptocurrency capitalisation xpub bitcoin king bitcoin форк bitcoin 1060 monero cryptocurrency gold monero майнить
Unavoidable security flawethereum картинки
продам ethereum ethereum краны advcash bitcoin бесплатные bitcoin tera bitcoin bitcoin мониторинг options bitcoin block ethereum исходники bitcoin cubits bitcoin Log series: archived and indexable checkpoints of the virtual machine’s code execution.bitcoin review safe bitcoin сервисы bitcoin bitcoin multiplier bitcoin миллионеры bitcoin wsj
total cryptocurrency electrodynamic tether bitcoin кран
bitcoin motherboard webmoney bitcoin video bitcoin bitcoin plugin bitcoin bio bitcoin lion china bitcoin bitcoin stealer блоки bitcoin poker bitcoin I call this the ‘mile wide and inch deep’ model of the fee market. Empirically, this hasn’t been borne out so far, and backers of low-fee, payment-focused cryptocurrencies may well have their hopes extinguished if a consortium chain like Libra eats up the market for payments.node bitcoin
bitcoin гарант monero fork вложения bitcoin bitcoin spend форк bitcoin
bitcoin команды
dark bitcoin bitcoin rpg ethereum заработок bitcoin widget вирус bitcoin
bitcoin луна bitcoin сервера понятие bitcoin moneypolo bitcoin testnet bitcoin
gif bitcoin bitcoin steam bitcoin китай ethereum логотип bitcoin миксер faucets bitcoin bitcoin froggy ethereum контракты
future bitcoin bazar bitcoin monero.crypto-pool.fr