4

I was reading Event's documentation. I encountered this paragraph. Can someone explains it in simple words?

You can add the attribute indexed to up to three parameters which adds them to a special data structure known as “topics” instead of the data part of the log. A topic can only hold a single word (32 bytes) so if you use a reference type for an indexed argument, the Keccak-256 hash of the value is stored as a topic instead.

  1. How transactions are stored on ethereum? ( w.r.t data structure )

  2. How Events are stored in transactions?

  3. How indexed arguments are stored?

  4. How reference type indexed arguments are stored?

Naman Vyas
  • 99
  • 5
  • Note that this is implementation specific. There are multiple EVM clients (geth, Erigon, Avalanche, etc). Whatever internal database and data structures they use are an implementation details. For the answer you just read the client source code. For example, Erigon is using speed optimised data structures. – Mikko Ohtamaa Jul 02 '22 at 08:53

1 Answers1

3

I can only answer question 1,2

  1. Transactions are stored in a Patricia Merkle Tree, the so called Transaction Trie. The root of the Transaction Trie is stored in the block header, all transactions are appended in the block body. see: https://ethereum.org/en/developers/docs/data-structures-and-encoding/patricia-merkle-trie/

  2. Events are not stored in the transaction nor on the blockchain. They are stored within the transaction receipt. TX receipts are stored in the Receipts Trie by the node. Further the root of the receipts tree is stored onchain in the block header.

Ethereum Tries

IMG Source

Derawi
  • 430
  • 4
  • 12