Skip to content

Clarification on MPT Proof Structure and Node Encoding #220

@t-sorger

Description

@t-sorger

Hi,

I am working with the trie-db crate and have been generating Merkle-Patricia Trie (MPT) proofs using the generate_proof function. I encountered a proof output that looks like this:

proof = [
    [128, 109, 246, 128, 40, 4, 143, 29, 173, 116, 217, 15, 202, 4, 160, 160, 243, 45, 95, 110, 28, 10, 153, 210, 113, 15, 3, 179, 233, 147, 5, 230, 153, 209, 209, 115, 128, 113, 191, 84, 118, 196, 215, 54, 25, 245, 52, 166, 200, 120, 122, 192, 104, 97, 253, 158, 24, 160, 177, 164, 114, 199, 9, 134, 60, 181, 222, 73, 243, 128, 136, 241, 139, 11, 150, 112, 108, 214, 87, 218, 133, 54, 61, 148, 207, 31, 88, 253, 222, 179, 177, 188, 198, 2, 133, 37, 168, 62, 129, 114, 253, 70, 128, 7, 163, 189, 250, 136, 142, 195, 195, 218, 59, 238, 243, 80, 253, 40, 152, 129, 165, 178, 131, 84, 196, 240, 8, 153, 237, 215, 189, 219, 47, 245, 58, 128, 11, 205, 1, 140, 183, 171, 19, 47, 147, 84, 153, 120, 73, 28, 170, 198, 246, 78, 95, 231, 36, 245, 98, 230, 117, 179, 163, 83, 179, 251, 184, 64, 0, 128, 48, 211, 8, 232, 219, 71, 172, 102, 249, 135, 136, 147, 93, 36, 70, 176, 85, 77, 95, 80, 246, 11, 121, 225, 79, 70, 115, 223, 48, 221, 117, 129, 128, 11, 242, 134, 219, 251, 72, 136, 31, 143, 118, 204, 30, 82, 119, 15, 192, 71, 77, 87, 3, 107, 161, 162, 237, 75, 19, 210, 7, 42, 15, 242, 195, 128, 9, 254, 94, 221, 144, 61, 92, 14, 157, 39, 103, 206, 173, 229, 219, 72, 95, 128, 151, 203, 214, 134, 216, 182, 96, 86, 108, 200, 86, 214, 110, 19, 128, 36, 255, 147, 74, 29, 85, 43, 167, 7, 132, 117, 60, 77, 200, 129, 26, 110, 25, 31, 16, 153, 7, 223, 150, 157, 184, 196, 37, 103, 57, 62, 105, 128, 175, 47, 204, 105, 72, 112, 255, 4, 235, 59, 5, 241, 155, 67, 73, 40, 194, 149, 151, 243, 142, 118, 139, 128, 140, 86, 180, 199, 167, 216, 121, 56],
    [128, 9, 0, 0, 128, 36, 25, 119, 113, 142, 246, 194, 73, 178, 154, 190, 114, 81, 232, 29, 114, 221, 10, 219, 104, 242, 170, 181, 114, 11, 19, 82, 255, 88, 163, 179, 197],
    [129, 5, 8, 32, 128, 152, 165, 197, 189, 19, 246, 122, 169, 52, 148, 27, 239, 143, 45, 182, 20, 157, 237, 67, 252, 163, 157, 162, 215, 192, 118, 168, 126, 248, 132, 182, 89, 0],
    [124, 101, 29, 221, 150, 105, 99, 28, 218, 101, 196, 107, 225, 80, 95, 11, 189, 109, 181, 202, 69, 33, 248, 233, 106, 239, 33, 148, 86, 180, 20, 0]
]

I understand that each Vec<u8> probably represents an encoded trie node, but I'm having trouble interpreting the structure and meaning of each node in the proof. I'm trying to understand:

  • The type of each node (e.g., branch, extension, leaf).
  • How these nodes collectively represent a proof of inclusion or exclusion for a particular key.

Could you please provide guidance or documentation on how to decode and interpret these proof nodes/values?

Thank you for your help!

(Mention to be pinged: @algomaster99, @javierron)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions