26

Reading through the Yellow paper, I can see that each block header includes the Keccak 256 hash of the root of the trie for transactions and transaction receipts. I am struggling to understand how and where they are created.

How are the Transactions Trie and the Transaction Receipts Trie related for a given block?

Is it the case that, as the world state is updated by going through the transactions, the transactions and transaction receipts are stored in their respective tries?

2 Answers 2

19

Transaction Tries and Transaction Receipt Tries are indeed independent data structures with distinct roots stored on the blockchain header and differ in both purpose and content.

Purpose:

  • Transaction Tries: records transaction request vectors

  • Transaction Receipt Tries: records the transaction outcome

Content:

Parameters used in composing a Transaction Trie [details in section 4.3 of the yellow paper]:

  • nonce,
  • gas price,
  • gas limit,
  • recipient,
  • transfer value,
  • transaction signature values, and
  • account initialization (if transaction is of contract creation type), or transaction data (if transaction is a message call)

Parameters used in composing a Transaction Receipt Trie [details in section 4.4.1 of the yellow paper]:

  • post-transaction state,
  • the cumulative gas used,
  • the set of logs created through execution of the transaction, and
  • the Bloom filter composed from information in those logs
5
  • 2
    Thanks zanzu, are the recepts always for the transactions in the same block? If so, are they stored in the same order?
    – Lee
    Commented Jun 13, 2016 at 15:16
  • 2
    @atomh33ls. Yes and yes. This is clear from the equations for the transactions root, Ht, and receipts root, Hr, in Eq 29, both of which are indexed on block transaction index, i.
    – zanzu
    Commented Jun 13, 2016 at 15:48
  • 1
    Ah yes thanks; I think you mean He for receipt root? The Ht and He components of Eq 28 are also relevant.
    – Lee
    Commented Jun 13, 2016 at 16:23
  • 2
    @atomh33ls. Yes, sorry, replace Hr with He in my above comment (it would have been too easy if receipts root would have been denoted by Hr! :o))
    – zanzu
    Commented Jun 13, 2016 at 16:28
  • 1
    What do you mean by transaction request vectors @zanzu
    – alper
    Commented Dec 10, 2017 at 16:12
5

In https://blog.ethereum.org/2015/11/15/merkling-in-ethereum Vitalik Buterin gave an example of using the different trees (transactions, receipt, state trees).

  • Has this transaction been included in a particular block?
  • Tell me all instances of an event of type X (eg. a crowdfunding contract reaching its goal) emitted by this address in the past 30 days
  • What is the current balance of my account?
  • Does this account exist?
  • Pretend to run this transaction on this contract. What would the output be?

The first is handled by the transaction tree; the third and fourth are handled by the state tree, and the second by the receipt tree. The first four are fairly straightforward to compute; the server simply finds the object, fetches the Merkle branch (the list of hashes going up from the object to the tree root) and replies back to the light client with the branch. The fifth is also handled by the state tree, but the way that it is computed is more complex. Here, we need to construct what can be called a Merkle state transition proof. Essentially, it is a proof which make the claim “if you run transaction T on the state with root S, the result will be a state with root S', with log L and output O” (“output” exists as a concept in Ethereum because every transaction is a function call; it is not theoretically necessary).

Receipts are basically for proving logs and events.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.