Skip to content

fix: support dynamic fields in event signatures - #1522

Merged
g-r-a-n-t merged 2 commits into
argotorg:masterfrom
cburgdorf:event_fix
Sep 16, 2026
Merged

g-r-a-n-t merged 2 commits into
argotorg:masterfrom
cburgdorf:event_fix

Conversation

@cburgdorf

@cburgdorf cburgdorf commented Jul 17, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Non-indexed DynArray<T> event fields cannot produce canonical Solidity
event signatures because the required SolCompat implementations are missing.
Evaluating the generated TOPIC0 can consequently trigger a compiler panic.

For example:

  #[event]
  struct ValuesChanged {
      values: DynArray<u256>,
  }

This should produce ValuesChanged(uint256[]). Imported aliases and nested
types such as DynArray<[u256; 2]> must also resolve to their canonical
Solidity names.

What changed

  • Add composable SolCompat implementations for dynamic and fixed-size arrays.
  • Generate event signature fragments through qualified SolCompat resolution,
    supporting imported aliases, nested arrays, and user-defined types named
    DynArray.
  • Diagnose unsupported indexed dynamic fields using their resolved semantic type.
  • Report generated TOPIC0 evaluation failures and runtime semantic-constant
    evaluation/reification failures instead of panicking.

Event payload encoding uses the existing implementation on master, which
already encodes non-empty event data as a tuple, including singleton fields.

Result

Non-indexed dynamic array event fields produce Solidity-compatible signatures
and payloads. For the example above:

  TOPIC0 = keccak256("ValuesChanged(uint256[])")
  data   = offset(0x20) | array length | array elements

Indexed dynamic fields remain unsupported and receive a targeted diagnostic.

Test coverage

  • Runtime log comparisons against expected Solidity topics and payloads,
    including singleton dynamic fields and fixed-size array elements.
  • Bytes, DynString, DynArray<u256>, and DynArray<Address> event fields.
  • Mixed dynamic and static payloads.
  • Imported aliases and user-defined generic types named DynArray.
  • Indexed dynamic-field diagnostics, including aliases and a shadowed type name.
  • Generated TOPIC0 compile-time evaluation failures.

Validation passed for the full 237-test type-check diagnostic suite, event HIR
tests, CLI event fixtures, runtime log comparisons, and existing event/ERC20
codegen snapshots.

@cburgdorf
cburgdorf marked this pull request as ready for review August 19, 2026 08:52
@cburgdorf

Copy link
Copy Markdown
Collaborator Author

@codex review

@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: 539cd703e2

ℹ️ 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 crates/hir/src/core/lower/event.rs Resolved
Comment thread crates/hir/src/core/lower/event.rs Resolved
Comment thread crates/hir/src/core/lower/event.rs Resolved
@cburgdorf

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: bc984b6764

ℹ️ 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".

@cburgdorf

Copy link
Copy Markdown
Collaborator Author

@sbillig This one is ready for human review

Build canonical Solidity type names for dynamic-array event fields while preserving correct topic and payload encoding.

Diagnose unsupported indexed dynamic fields from resolved core types, including aliases, without rejecting shadowed user types. Surface generated TOPIC0 CTFE failures and semantic-constant reification failures instead of panicking, with focused UI and execution regressions.
@cburgdorf

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 16, 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-16T11:06:14.794056Z 69e1627 Manual request
ℹ️ 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.

@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: 8673474594

ℹ️ 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 crates/hir/src/analysis/ty/abi_ty.rs Resolved
Recurse through fixed-array elements when detecting indexed dynamic event fields, including nested type aliases. Add diagnostic regressions for dynamic arrays and a static-array counterexample.
@cburgdorf

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 69e162773f

ℹ️ 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".

@cburgdorf

Copy link
Copy Markdown
Collaborator Author

@g-r-a-n-t @sbillig @micahscopes anyone cares to review this? I think we should take this for the upcoming release

@g-r-a-n-t
g-r-a-n-t self-requested a review September 16, 2026 15:37
@g-r-a-n-t
g-r-a-n-t merged commit b8c7928 into argotorg:master Sep 16, 2026
7 checks passed
micahscopes added a commit that referenced this pull request Sep 24, 2026
Whether a trait impl constant's body was checked depended on where the
impl came from. Raw impls were checked. The `#[event]` and `#[error]`
desugarings were checked with their body diagnostics suppressed, since
an error in a field's source type would otherwise cascade into the
generated body, and only the contextual CTFE diagnostic from #1522 was
reported. Generated `msg` impls were skipped entirely.

Record the choice on each constant instead. `AssocConstBodyCheckPolicy`
defaults to `BodyAnalysis`, the ordinary check of the value against its
expected type, and a generated origin alone no longer exempts a body.
Message selectors keep their dedicated checker (`MsgSelectorAnalysis`),
which reports their body errors before checking uniqueness. The
existing event, error and message ABI constants are marked
`ExpansionSourceCompatibility`, which keeps today's behavior: the body
is checked, its diagnostics are suppressed, and an event or error body
that type-checks still gets #1522's contextual CTFE diagnostic.

A fieldless event has no field errors to cascade from, so its `TOPIC0`
uses ordinary checking. No other diagnostics change.
micahscopes added a commit that referenced this pull request Sep 24, 2026
Whether a trait impl constant's body was checked depended on where the
impl came from. Raw impls were checked. The `#[event]` and `#[error]`
desugarings were checked with their body diagnostics suppressed, since
an error in a field's source type would otherwise cascade into the
generated body, and only the contextual CTFE diagnostic from #1522 was
reported. Generated `msg` impls were skipped entirely.

Record the choice on each constant instead. `AssocConstBodyCheckPolicy`
defaults to `BodyAnalysis`, the ordinary check of the value against its
expected type, and a generated origin alone no longer exempts a body.
Message selectors keep their dedicated checker (`MsgSelectorAnalysis`),
which reports their body errors before checking uniqueness. The
existing event, error and message ABI constants are marked
`ExpansionSourceCompatibility`, which keeps today's behavior: the body
is checked, its diagnostics are suppressed, and an event or error body
that type-checks still gets #1522's contextual CTFE diagnostic.

A fieldless event has no field errors to cascade from, so its `TOPIC0`
uses ordinary checking. No other diagnostics change.
micahscopes added a commit that referenced this pull request Sep 25, 2026
Whether a trait impl constant's body was checked depended on where the
impl came from. Raw impls were checked. The `#[event]` and `#[error]`
desugarings were checked with their body diagnostics suppressed, since
an error in a field's source type would otherwise cascade into the
generated body, and only the contextual CTFE diagnostic from #1522 was
reported. Generated `msg` impls were skipped entirely.

Record the choice on each constant instead. `AssocConstBodyCheckPolicy`
defaults to `BodyAnalysis`, the ordinary check of the value against its
expected type, and a generated origin alone no longer exempts a body.
Message selectors keep their dedicated checker (`MsgSelectorAnalysis`),
which reports their body errors before checking uniqueness. The
existing event, error and message ABI constants are marked
`ExpansionSourceCompatibility`, which keeps today's behavior: the body
is checked, its diagnostics are suppressed, and an event or error body
that type-checks still gets #1522's contextual CTFE diagnostic.

A fieldless event has no field errors to cascade from, so its `TOPIC0`
uses ordinary checking. No other diagnostics change.
micahscopes added a commit that referenced this pull request Sep 26, 2026
Whether a trait impl constant's body was checked depended on where the
impl came from. Raw impls were checked. The `#[event]` and `#[error]`
desugarings were checked with their body diagnostics suppressed, since
an error in a field's source type would otherwise cascade into the
generated body, and only the contextual CTFE diagnostic from #1522 was
reported. Generated `msg` impls were skipped entirely.

Record the choice on each constant instead. `AssocConstBodyCheckPolicy`
defaults to `BodyAnalysis`, the ordinary check of the value against its
expected type, and a generated origin alone no longer exempts a body.
Message selectors keep their dedicated checker (`MsgSelectorAnalysis`),
which reports their body errors before checking uniqueness. The
existing event, error and message ABI constants are marked
`ExpansionSourceCompatibility`, which keeps today's behavior: the body
is checked, its diagnostics are suppressed, and an event or error body
that type-checks still gets #1522's contextual CTFE diagnostic.

A fieldless event has no field errors to cascade from, so its `TOPIC0`
uses ordinary checking. No other diagnostics change.
micahscopes added a commit that referenced this pull request Sep 27, 2026
Whether a trait impl constant's body was checked depended on where the
impl came from. Raw impls were checked. The `#[event]` and `#[error]`
desugarings were checked with their body diagnostics suppressed, since
an error in a field's source type would otherwise cascade into the
generated body, and only the contextual CTFE diagnostic from #1522 was
reported. Generated `msg` impls were skipped entirely.

Record the choice on each constant instead. `AssocConstBodyCheckPolicy`
defaults to `BodyAnalysis`, the ordinary check of the value against its
expected type, and a generated origin alone no longer exempts a body.
Message selectors keep their dedicated checker (`MsgSelectorAnalysis`),
which reports their body errors before checking uniqueness. The
existing event, error and message ABI constants are marked
`ExpansionSourceCompatibility`, which keeps today's behavior: the body
is checked, its diagnostics are suppressed, and an event or error body
that type-checks still gets #1522's contextual CTFE diagnostic.

A fieldless event has no field errors to cascade from, so its `TOPIC0`
uses ordinary checking. No other diagnostics change.
micahscopes added a commit that referenced this pull request Sep 29, 2026
Whether a trait impl constant's body was checked depended on where the
impl came from. Raw impls were checked. The `#[event]` and `#[error]`
desugarings were checked with their body diagnostics suppressed, since
an error in a field's source type would otherwise cascade into the
generated body, and only the contextual CTFE diagnostic from #1522 was
reported. Generated `msg` impls were skipped entirely.

Record the choice on each constant instead. `AssocConstBodyCheckPolicy`
defaults to `BodyAnalysis`, the ordinary check of the value against its
expected type, and a generated origin alone no longer exempts a body.
Message selectors keep their dedicated checker (`MsgSelectorAnalysis`),
which reports their body errors before checking uniqueness. The
existing event, error and message ABI constants are marked
`ExpansionSourceCompatibility`, which keeps today's behavior: the body
is checked, its diagnostics are suppressed, and an event or error body
that type-checks still gets #1522's contextual CTFE diagnostic.

A fieldless event has no field errors to cascade from, so its `TOPIC0`
uses ordinary checking. No other diagnostics change.
micahscopes added a commit that referenced this pull request Sep 30, 2026
Whether a trait impl constant's body was checked depended on where the
impl came from. Raw impls were checked. The `#[event]` and `#[error]`
desugarings were checked with their body diagnostics suppressed, since
an error in a field's source type would otherwise cascade into the
generated body, and only the contextual CTFE diagnostic from #1522 was
reported. Generated `msg` impls were skipped entirely.

Record the choice on each constant instead. `AssocConstBodyCheckPolicy`
defaults to `BodyAnalysis`, the ordinary check of the value against its
expected type, and a generated origin alone no longer exempts a body.
Message selectors keep their dedicated checker (`MsgSelectorAnalysis`),
which reports their body errors before checking uniqueness. The
existing event, error and message ABI constants are marked
`ExpansionSourceCompatibility`, which keeps today's behavior: the body
is checked, its diagnostics are suppressed, and an event or error body
that type-checks still gets #1522's contextual CTFE diagnostic.

A fieldless event has no field errors to cascade from, so its `TOPIC0`
uses ordinary checking. No other diagnostics change.
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