Skip to content

Add keccak_words, create2_address and a direct packed-encoding path - #1604

Merged
sbillig merged 1 commit into
masterfrom
feat/std-keccak-helpers
Sep 29, 2026
Merged

sbillig merged 1 commit into
masterfrom
feat/std-keccak-helpers

Conversation

@cburgdorf

Copy link
Copy Markdown
Collaborator

std::evm::keccak_words([..]) hashes a fixed list of words, the common keccak256(abi.encode(a, b, ...)) over word-sized values, and create2_address(deployer, salt, init_code_hash) computes CREATE2 addresses.

EncodePacked gains a provided write_packed method that stores a value directly at its packed width. The std implementations override it with a single word store or copy, tuples chain it, and keccak_packed / encode_packed use it instead of the Packed builder: keccak_packed((address, int24, int24, bytes32)) drops from about 2,140 to about 470 gas. Non-canonical Address and FixedBytes<N> values still revert. The custom-width sol:: integers implement EncodePacked.

@cburgdorf
cburgdorf force-pushed the feat/std-keccak-helpers branch from a175825 to c84bd2e Compare September 28, 2026 08:37
@cburgdorf
cburgdorf marked this pull request as ready for review September 28, 2026 10:03
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-29T15:26:52.037515Z 6fdd38d New commits
🔒 Security Review ✅ Completed 2026-09-29T15:28:12.008461Z 6fdd38d New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cburgdorf

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: c84bd2ef1b

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c84bd2ef1b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread ingots/std/src/evm/packed.fe Resolved
Comment thread ingots/std/src/evm/packed.fe Resolved
Comment thread ingots/std/src/evm/crypto.fe Resolved
`std::evm::keccak_words([..])` hashes a fixed list of words, the common
`keccak256(abi.encode(a, b, ...))` over word-sized values, and
`create2_address(deployer, salt, init_code_hash)` computes CREATE2
addresses.

`EncodePacked` gains a provided `write_packed` method that stores a value
directly at its packed width. The std implementations override it with a
single word store or copy, tuples chain it, and `keccak_packed` /
`encode_packed` use it instead of the `Packed` builder:
`keccak_packed((address, int24, int24, bytes32))` drops from about 2,140
to about 470 gas. Non-canonical `Address` and `FixedBytes<N>` values
still revert. The custom-width `sol::` integers implement `EncodePacked`.
@cburgdorf
cburgdorf force-pushed the feat/std-keccak-helpers branch from c84bd2e to 6fdd38d Compare September 29, 2026 15:21
@cburgdorf
cburgdorf requested a review from sbillig September 29, 2026 16:42
@sbillig
sbillig merged commit 2c2b6ba into master Sep 29, 2026
9 checks passed
@sbillig
sbillig deleted the feat/std-keccak-helpers branch September 29, 2026 19:50
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