Skip to content

perf: return onERC1155Received selector without shifting#151

Open
wjmelements wants to merge 4 commits into
huff-language:mainfrom
wjmelements:receiver-no-shift
Open

perf: return onERC1155Received selector without shifting#151
wjmelements wants to merge 4 commits into
huff-language:mainfrom
wjmelements:receiver-no-shift

Conversation

@wjmelements

@wjmelements wjmelements commented Jul 6, 2026

Copy link
Copy Markdown

Reviewer @Maddiaa0
CC @kadenzipfel

Changes

  • don't shift
  • msize

Comment thread src/utils/ERC1155Receiver.huff Outdated
Comment on lines +10 to +11
0xf23a6e61 0x00 mstore // []
0x20 0x1c return // []

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I also want to try msize instead of 0x20

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

55b0d66

revert that commit if CI fails

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

msize uses less codesize and execution gas than push1

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd add the small note that unlike the original version this makes assumptions about surrounding memory (that 0x20..0x3c is zeroed)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I'd add the small note that unlike the original version this makes assumptions about surrounding memory (that 0x20..0x3c is zeroed)

252a35b

Comment thread src/utils/ERC1155Receiver.huff Outdated
@wjmelements

Copy link
Copy Markdown
Author

I have attached erc1155.tar.gz, which demonstrates (using a dio config) that if both approaches are allowed to use MSIZE, this approach is still 2 less execution gas and 2 less codesize.

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.

3 participants