Skip to content
This repository has been archived by the owner on Oct 20, 2024. It is now read-only.

automate stack comments #205

Open
devtooligan opened this issue Aug 26, 2022 · 2 comments
Open

automate stack comments #205

devtooligan opened this issue Aug 26, 2022 · 2 comments

Comments

@devtooligan
Copy link
Contributor

devtooligan commented Aug 26, 2022

We would like a way for the stack comments to be automatically generated.

by stack comments we are referring to inline comments to the right representing the current known state of the stack:

0x20 // [length]
0x0  //  [offset, length]

One way we discussed was creating a new huff-fmt command that would got through Huff files and add stack annotations. Maybe someday it would be nice to have a editor extension that can add the comments.

As part of this work, we need to figure out how to assign labels or aliases for items on the stack.

For incoming/outgoing stack items, it has been suggest that maybe we define the aliases along with the takes(x) returns(x) at the macro(fn) definition level, so perhaps takes(2, [owner, spender]) returns (1, [returnValue]).

Alternatively, aliases could be defined in a comment at the beginning of the macro so:

#define macro MY_MACRO() = takes(2) returns(1) {
  // takes: [owner, spender]
  // returns: [returnValue]
  ...
}

It would also be great to be able to alias intermediate stack items so one idea is:

 0x04
 CALLDATALOAD // alias: Spender

would elicit:

 0x04                     // 0x04
 CALLDATALOAD // [Spender, 0x04]

For values with left padded zero's, one idea is to exclude the zeros so:

 0x123

would elicit:

 0x123   // [0x123]

It has also been suggested that the stack generating logic would work with constants so:

  0x123
  [SOME_SLOT]

would elicit:

  0x123                     // [0x123]
  [SOME_SLOT]      // [SOME_SLOT, 0x123]
@ameya-deshmukh
Copy link
Collaborator

@devtooligan this still open?

@devtooligan
Copy link
Contributor Author

@ameya-deshmukh yup

heres some additional discussion around this topic:
https://discord.com/channels/980519274600882306/980519275062251560/1082756897238695966

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants