0

Ethereum maintains an Transaction Trie and a Receipts Trie and I'm trying to visualize how that data would be contained in a relational database.

I believe both Tries would have a primary key of transaction_hash, and I don't believe there is any other data duplicated between Tries nor any other unique identifier in either to use as a PK or FK between a transactions table and receipts table.

All that is to say, in a relational database would both Tries just live in a single table?

0

It's hard to relate Merkel Patricia Tree with relational Database. In Go Ethereum Merkel Patricia tree uses level db which is the key-value pair database. Block header contains receipt root and transaction root, which can be used to lookup actual node of the tree from level db.

To answer your question, I don't think both tries have same key i.e. transaction_hash. It's simply not possible, level db can't store two entries with the same key.

Keys are calculated by this formula -

key/root = sha3(rlp_encode(node)), where node is also key, value pair.

I strongly recommend you to read about Merkel Patricia tree for here and here

enter image description here

| improve this answer | |
  • Well I mean, the method to identify a given receipt belongs to a given transaction must be representable in some fashion as a "unique key", assuming transations+receipts are really 1-to-1 – xref Jun 15 '18 at 22:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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