2

Suppose I have a very simple block with one transaction whose hash is:

0xce70a6b3ae683183e9c4d7c5a22ed5e2cf1f82a38fa67acaa24124b42b258b4a

And when I run eth.getBlock I get the following transaction root:

0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421

Assuming I have the keccak256 function, how would I verify this root is correct? I.e. how do I build and encode the transactions trie?

2

You would have to rebuild the trie. It uses the same patricia trie format as seen throughout Ethereum. The best example is in the wiki

Items in the patricia trie come in path->value pairs, and for the transaction trie specifically the path is rlp(transactionIndex). transactionIndexbeing its index within the block it's mined (the ordering decided by a miner). The value is the raw signed transaction.

My js library has functions for both generating the proof and verifying it. It uses the merkle-patricia-tree node module to build the trie.

2

According to https://github.com/ethereum/wiki/wiki/Patricia-Tree#transactions-trie you should rlpEncode(transactionIndex). So my guess is you'd need to see if that tx hash was present in any of the indexes of the TX trie.

Maybe take a peek at Zac Mitton's https://github.com/zmitton/eth-proof. More specifically https://github.com/zmitton/eth-proof/blob/master/buildProof.js#L147

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.