Skip to content

Conversation

DJViau
Copy link
Contributor

@DJViau DJViau commented Mar 6, 2023

This PR changes the labels on pretty-calldata from decimal integers to hex labels, like one finds in the debugger.

For example,

 [0]:  0000000000000000000000000000000000000000000000000000000000000020
 [1]:  0000000000000000000000000000000000000000000000000000000000000002
 [2]:  0000000000000000000000000000000000000000000000000000000000000040
 [3]:  0000000000000000000000000000000000000000000000000000000000000140
 [4]:  000000000000000000000000da5a5adc64c8013d334a0da9e711b364af7a4c2d
 [5]:  0000000000000000000000000000000000000000000000000000000000000000
 [6]:  0000000000000000000000000000000000000000000000000000000000000000
 [7]:  0000000000000000000000000000000000000000000000000000000000000080
 [8]:  0000000000000000000000000000000000000000000000000000000000000044
 [9]:  40c10f19000000000000000000000000e05fcc23807536bee418f142d19fa0d2
 [10]: 1bb0cff700000000000000000000000000000000000000000000000000000000
 ...

becomes

 [000]: 0000000000000000000000000000000000000000000000000000000000000020
 [020]: 0000000000000000000000000000000000000000000000000000000000000002
 [040]: 0000000000000000000000000000000000000000000000000000000000000040
 [060]: 0000000000000000000000000000000000000000000000000000000000000140
 [080]: 000000000000000000000000da5a5adc64c8013d334a0da9e711b364af7a4c2d
 [0a0]: 0000000000000000000000000000000000000000000000000000000000000000
 [0c0]: 0000000000000000000000000000000000000000000000000000000000000000
 [0e0]: 0000000000000000000000000000000000000000000000000000000000000080
 [100]: 0000000000000000000000000000000000000000000000000000000000000044
 [120]: 40c10f19000000000000000000000000e05fcc23807536bee418f142d19fa0d2
 [140]: 1bb0cff700000000000000000000000000000000000000000000000000000000
 ...

Motivation

The integer labels require mental energy to convert to hex, which is how my team typically thinks of these. Converting to hex saves time and mental energy.

Solution

I updated the display method for PossibleSigs.

NOTE: This is my first time writing rust and my first time making this type of contribution. I read the contribution guidelines and attempted to follow their instructions, but I found some of the cargo checks hard to parse. I skipped opening an issue since the change is tiny and cosmetic. Please let me know what I need to do to properly comply with the letter and spirit of the contribution rules.

EDIT: This change also makes it easier to look up offsets.

@mattsse
Copy link
Member

mattsse commented Mar 6, 2023

I don't have strong feelings about this.

wdyt @brockelmore ?

@mattsse mattsse added the A-debugger Area: debugger label Mar 6, 2023
@emo-eth
Copy link
Contributor

emo-eth commented Mar 6, 2023

imo much easier for parsing out calldata offsets in calls with structs or dynamic parameters

@DJViau
Copy link
Contributor Author

DJViau commented Mar 6, 2023

re: the label @mattsse assigned: this changes the behavior of cast pretty-calldata so that it behaves the same way the debugger does, so this should probably get the C-cast label in addition or instead.

@mattsse mattsse added the C-cast Command: cast label Mar 7, 2023
Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

sgtm

@mattsse mattsse merged commit 40d0a1b into foundry-rs:master Mar 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-debugger Area: debugger C-cast Command: cast

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants