Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decode RLP values in TrieDiff output #9

Open
Nashtare opened this issue May 10, 2024 · 3 comments
Open

Decode RLP values in TrieDiff output #9

Nashtare opened this issue May 10, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@Nashtare
Copy link
Contributor

Nashtare commented May 10, 2024

The trie diff tool will output something like this currently (added formatting for readability)

Point Diff {
    depth: 0,
    Path: (Branch(12) --> Branch(13) --> Branch(1) --> Branch(1) --> Branch(8) --> Branch(7) --> Branch(14) --> Branch(14) --> Branch(12)),
    Key: 0xcd1187eec,
    A info: (
        key: 0xcd1187eec83bc100b4e63e815deeba81810d9d6921d7ad3f4b987440c84ea666,
        Value: "f8440180a046436918d517d18028d2e44a47022f16d4f349d1c58284f1d3bda3305d18ea41a0516e38ed2cd77bcb4dfb71f1afe70b0516eeb781a30e5c770fbee39aa6eb809c",
        Node type: Leaf Trie,
        hash: 9b594f92cd023c5d8f9b3a9f513faa1abc709b824ede7d3712b28ea6ed6c3510
    ),
    B info: (
        key: 0xcd1187eec83bc100b4e63e815deeba81810d9d6921d7ad3f4b987440c84ea666,
        Value: "f8440180a0746b7a0278ae1126808f786cadf431f73a18b7deda4c7543ba82f0e75a73fa2ea0516e38ed2cd77bcb4dfb71f1afe70b0516eeb781a30e5c770fbee39aa6eb809c",
        Node type: Leaf Trie,
        hash: 44e8d85eb8b9becc4c45d91ea8e7c3110a77bba6628aba4362eba01bd390d5ad
    )
}

It would be nice if it was displaying the Decoded value along with the currently Encoded value, which in this case could look like:

Point Diff {
    depth: 0,
    Path: (Branch(12) --> Branch(13) --> Branch(1) --> Branch(1) --> Branch(8) --> Branch(7) --> Branch(14) --> Branch(14) --> Branch(12)),
    Key: 0xcd1187eec,
    A info: (
        key: 0xcd1187eec83bc100b4e63e815deeba81810d9d6921d7ad3f4b987440c84ea666,
        Encoded value: "f8440180a046436918d517d18028d2e44a47022f16d4f349d1c58284f1d3bda3305d18ea41a0516e38ed2cd77bcb4dfb71f1afe70b0516eeb781a30e5c770fbee39aa6eb809c",
        Decoded value: AccountRlp {
            nonce: 1,
            balance: 0,
            storage_root: 0x46436918d517d18028d2e44a47022f16d4f349d1c58284f1d3bda3305d18ea41,
            code_hash: 0x516e38ed2cd77bcb4dfb71f1afe70b0516eeb781a30e5c770fbee39aa6eb809c
        },
        Node type: Leaf Trie,
        hash: 9b594f92cd023c5d8f9b3a9f513faa1abc709b824ede7d3712b28ea6ed6c3510
    ),
    B info: (
        key: 0xcd1187eec83bc100b4e63e815deeba81810d9d6921d7ad3f4b987440c84ea666,
        Encoded Value: "f8440180a0746b7a0278ae1126808f786cadf431f73a18b7deda4c7543ba82f0e75a73fa2ea0516e38ed2cd77bcb4dfb71f1afe70b0516eeb781a30e5c770fbee39aa6eb809c",
        Decoded value: AccountRlp {
            nonce: 1,
            balance: 0,
            storage_root: 0x746b7a0278ae1126808f786cadf431f73a18b7deda4c7543ba82f0e75a73fa2e,
            code_hash: 0x516e38ed2cd77bcb4dfb71f1afe70b0516eeb781a30e5c770fbee39aa6eb809c
        },
        Node type: Leaf Trie,
        hash: 44e8d85eb8b9becc4c45d91ea8e7c3110a77bba6628aba4362eba01bd390d5ad
    )
}
@Nashtare Nashtare added the enhancement New feature or request label May 10, 2024
@BGluth
Copy link
Contributor

BGluth commented May 21, 2024

Hmm... So the idea would be to try and decode to AccountRlp or an rlped storage value and display that if it's successful right?

@Nashtare
Copy link
Contributor Author

Yeah. Could also be decoding the txn or the receipt if we need to debug those tries (though rarely happens). Does that seem worth it to you?

@BGluth
Copy link
Contributor

BGluth commented May 21, 2024

Yeah this seems like a nice-to-have and should be pretty trivial to implement (just four decode attempts). The only potential issue that I see is we could mis-decode some non-evm trie value into a storage trie slot, just since the value type is rlp(U256), but I don't think that this probably really matters that much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants