Skip to content

cl/merkle_tree: add EIP-7495 active fields mix-in#22528

Open
JackCC703 wants to merge 4 commits into
erigontech:mainfrom
JackCC703:eip-7495-active-fields
Open

cl/merkle_tree: add EIP-7495 active fields mix-in#22528
JackCC703 wants to merge 4 commits into
erigontech:mainfrom
JackCC703:eip-7495-active-fields

Conversation

@JackCC703

@JackCC703 JackCC703 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

add MixInActiveFields following the EIP-7495 active-fields mix-in definition
pack up to 256 active-field bits into one zero-padded SSZ chunk using little-endian bit order
add pinned reference vectors covering the EIP-7807 18-field configuration, sparse bits, the 256-bit boundary, invalid input, and input immutability

Motivation

This is a follow-up to #22446 and provides the active-fields mix-in primitive needed for future EIP-7495 ProgressiveContainer support, including EIP-7807 execution payloads.

The helper computes:

hash(root, pack_bits(active_fields))

Specification references

Testing

  • go test ./cl/merkle_tree -run '^TestMixInActiveFields' -count=1
  • go test ./cl/merkle_tree -count=1
  • make lint
  • make erigon integration

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds the EIP-7495 “active-fields mix-in” helper to the CL merkle tree utilities, enabling future ProgressiveContainer support (notably for EIP-7807 ExecutionPayload-style containers) by hashing root || pack_bits(active_fields).

Changes:

  • Implement MixInActiveFields(root, activeFields) that packs up to 256 active-field bits into a zero-padded 32-byte SSZ chunk using little-endian bit order.
  • Add pinned reference-vector tests covering EIP-7807’s 18-field configuration, sparse bit patterns, the 256-bit boundary, and invalid input length.
  • Add a sanity check that the produced hash matches a direct sha256(root||packed) computation.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
cl/merkle_tree/progressive.go Adds MixInActiveFields implementation and length validation (max 256 bits).
cl/merkle_tree/progressive_test.go Adds reference-vector and validation tests for the new mix-in helper.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@JackCC703

Copy link
Copy Markdown
Contributor Author

Hi @domiwei,
gentle ping when you have a chance.
This is a small follow-up to #22446 that adds the EIP-7495 active-fields mix-in needed for the next EIP-7807 step.
The change is limited to two files, with focused tests included. Would you mind taking a look?
Thanks!

@domiwei

domiwei commented Jul 23, 2026

Copy link
Copy Markdown
Member

Adversarial review found one blocking issue:

[P1] cl/merkle_tree/progressive.go:47 does not compile. It calls utils.Sha256, but the merge brought in #22489, which moved SHA-256 from cl/utils to common/crypto; this file now imports only common/crypto.

Reproduced at HEAD a14b0cf:

GOCACHE=/private/tmp/erigon-pr22528-gocache go test ./cl/merkle_tree -run "^TestMixInActiveFields" -count=1
cl/merkle_tree/progressive.go:47:9: undefined: utils

The call should be:

return crypto.Sha256(root[:], packed[:]), nil

After applying only that correction locally, the full cl/merkle_tree package tests, the focused race test, and an additional length 0-256 boundary test all pass.

Two non-blocking notes:

  • TestMixInActiveFieldsDoesNotModifyRoot is vacuous because root is a [32]byte passed by value. If input immutability is intended to be protected, snapshot and compare activeFields, which is the aliased slice input.
  • The six-line provenance comment in progressive_test.go:67-72 exceeds the repository comment policy; the pinned revision details can remain in the PR description while the source comment is condensed.

The EIP-7495 packing semantics, zero padding, 256-bit limit, and EIP-7807 18-field vector otherwise look correct.

@JackCC703

JackCC703 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Adversarial review found one blocking issue:

[P1] cl/merkle_tree/progressive.go:47 does not compile. It calls utils.Sha256, but the merge brought in #22489, which moved SHA-256 from cl/utils to common/crypto; this file now imports only common/crypto.

Reproduced at HEAD a14b0cf:

GOCACHE=/private/tmp/erigon-pr22528-gocache go test ./cl/merkle_tree -run "^TestMixInActiveFields" -count=1
cl/merkle_tree/progressive.go:47:9: undefined: utils

The call should be:

return crypto.Sha256(root[:], packed[:]), nil

After applying only that correction locally, the full cl/merkle_tree package tests, the focused race test, and an additional length 0-256 boundary test all pass.

Two non-blocking notes:

  • TestMixInActiveFieldsDoesNotModifyRoot is vacuous because root is a [32]byte passed by value. If input immutability is intended to be protected, snapshot and compare activeFields, which is the aliased slice input.
  • The six-line provenance comment in progressive_test.go:67-72 exceeds the repository comment policy; the pinned revision details can remain in the PR description while the source comment is condensed.

The EIP-7495 packing semantics, zero padding, 256-bit limit, and EIP-7807 18-field vector otherwise look correct.

Thanks for the detailed review! I fixed the SHA-256 call after the package move, replaced the vacuous root immutability test with an activeFields immutability check, and condensed the provenance comment.

Validated with:

  • go test ./cl/merkle_tree -run '^TestMixInActiveFields' -count=1
  • go test ./cl/merkle_tree -count=1
  • go test -race ./cl/merkle_tree -run '^TestMixInActiveFields' -count=1
  • make lint
  • make erigon integration

Could you please take another look when you have time? Thanks!

@JackCC703 JackCC703 closed this Jul 23, 2026
@JackCC703 JackCC703 reopened this Jul 23, 2026
@AskAlexSharov AskAlexSharov added this to the 3.7.0 milestone Jul 23, 2026
@domiwei

domiwei commented Jul 23, 2026

Copy link
Copy Markdown
Member

@JackCC703 could you check the CI failure? Thank you

@JackCC703

Copy link
Copy Markdown
Contributor Author

@JackCC703 could you check the CI failure? Thank you

Sure!

The root failing job is eest-spec-tests / eest-spec-zkevm-witness. The ci-gate failure is only a consequence of this job failing.

The logs show repeated BAL mismatch errors during the zkEVM witness tests. This PR only changes files under cl/merkle_tree, and the Caplin tests, lint, unit tests, race tests, and builds all pass.

The same zkEVM witness job is also failing in another unrelated PR run, so this appears to be a shared EEST/BAL or base-branch issue rather than something caused by the active-fields change.

Please let me know if you would like me to investigate anything else.

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.

4 participants