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

cmd/rlpdump: add support for text to rlp #23745

Merged
merged 2 commits into from
Oct 18, 2021
Merged

Conversation

holiman
Copy link
Contributor

@holiman holiman commented Oct 15, 2021

This PR adds support for the rlpdump tool to go from text format to RLP. This is often a bit cumbersome: modifying RLP means that the lengths needs to be recalculated. Right now, I often create some golang testcase which defines some struct and then call rlp.EncodeToBytes on it, which is a bit PITA.

Using a moderately complext struct:

[user@work rlpdump]$ ./rlpdump -hex 0xd8c1c0d5d4cccb84746573742a2a808213378667617a6f6e6b 
[
  [
    [],
  ],
  [
    [
      [
        [
          "test",
          "*",
          "*",
          "",
          1337,
        ],
      ],
      "gazonk",
    ],
  ],
]

Examples:

[user@work rlpdump]$ ./rlpdump -hex 0xd8c1c0d5d4cccb84746573742a2a808213378667617a6f6e6b | ./rlpdump -reverse 
0xd8c1c0d5d4cccb84746573742a2a808213378667617a6f6e6b
[user@work rlpdump]$ ./rlpdump -hex 0xd8c1c0d5d4cccb84746573742a2a808213378667617a6f6e6b > foo.test && ./rlpdump -reverse foo.test
0xd8c1c0d5d4cccb84746573742a2a808213378667617a6f6e6b

It doesn't handle 'bad input' well, and can panic, but that's not really important for this tool, IMO.

@holiman
Copy link
Contributor Author

holiman commented Oct 15, 2021

cc @marioevz you might find this useful too, when messing with e.g. transactions.

@holiman
Copy link
Contributor Author

holiman commented Oct 18, 2021

@MariusVanDerWijden PTAL?

Copy link
Member

@MariusVanDerWijden MariusVanDerWijden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

@holiman holiman merged commit b8dc1e2 into ethereum:master Oct 18, 2021
@holiman holiman added this to the 1.10.11 milestone Oct 18, 2021
sidhujag pushed a commit to syscoin/go-ethereum that referenced this pull request Oct 18, 2021
This PR adds support for the rlpdump tool to go from text format to RLP.
yongjun925 pushed a commit to DODOEX/go-ethereum that referenced this pull request Dec 3, 2022
This PR adds support for the rlpdump tool to go from text format to RLP.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants