std: add evm::packed — tightly packed byte encoding (abi.encodePacked…#1512
Conversation
|
@codex review |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
…ut class
A tuple/struct const region holding a String<N> literal of 16 bytes or
fewer crashed Sonatina emission ("global initializer immediate type
does not match global type") — the aggregate field type is always I256
while the immediate was typed from the literal's byte length.
gv_initializer_for_const now threads the layout's per-field
RuntimeClass down to immediate_for_const, which types FixedBytes
immediates from the declared class width.
As a side effect, string constants emit as direct .i256 immediates
instead of a small immediate plus zext (two sonatina_ir snapshots
updated). string_in_tuple is a minimal regression fixture.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b44de4c3eb
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f4b14b8793
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 372f37d4d1
ℹ️ 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".
… parity) Adds std::evm::packed with two layers: - A declarative tuple API: an EncodePacked trait with encode_packed / keccak_packed entry points, implemented for u8-u256, i8-i256 (two's complement), bool, Address, String<N> (effective len() bytes), [u8; N], FixedBytes<N>, Bytes, BytesView<MemoryInput>, and tuples of arity 1..=16, so `keccak_packed((token0, token1))` covers CREATE2 salts and EIP-712 digests with zero size bookkeeping. - An imperative Packed builder for runtime-shaped payloads, with byte-precise writes (full-word mstore fast path only when a whole word fits below the buffer limit, mstore8 fallback otherwise) and copy-on-grow doubling, plus keccak256/sha256/as_bytes terminals. Also adds crypto::eip712_digest built on the tuple API. Builds on the preceding codegen fix for String<N> literals in const tuple regions, which this module's tests exposed. The packed_encoding fixture's expected values are all precomputed with Foundry (cast abi-encode --packed / cast keccak), so the tests are not their own oracle.
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@sbillig ready to review now. There's a codegen fix in a separate commit |
std: add evm::packed — tightly packed byte encoding (abi.encodePacked parity)
Adds std::evm::packed with two layers:
keccak_packed entry points, implemented for u8-u256, i8-i256 (two's
complement), bool, Address, String (effective len() bytes),
[u8; N], FixedBytes, Bytes, BytesView, and tuples of
arity 1..=16, so
keccak_packed((token0, token1))covers CREATE2salts and EIP-712 digests with zero size bookkeeping.
byte-precise writes (full-word mstore fast path only when a whole
word fits below the buffer limit, mstore8 fallback otherwise) and
copy-on-grow doubling, plus keccak256/sha256/as_bytes terminals.
Also adds crypto::eip712_digest built on the tuple API.
Fixes a codegen bug this exposed: a tuple/struct const region holding
a String literal of 16 bytes or fewer crashed Sonatina emission
("global initializer immediate type does not match global type") —
the aggregate field type is always I256 while the immediate was typed
from the literal's byte length. gv_initializer_for_const now threads
the layout's per-field RuntimeClass down to immediate_for_const, which
types FixedBytes immediates from the declared class width. As a side
effect, string constants emit as direct .i256 immediates instead of a
small immediate plus zext (two sonatina_ir snapshots updated).
The packed_encoding fixture's expected values are all precomputed with
Foundry (cast abi-encode --packed / cast keccak), so the tests are not
their own oracle. string_in_tuple is a minimal regression fixture for
the codegen fix.