Skip to content

refactor: use l1/eth types in non-L1 callers#3704

Merged
brbrr merged 5 commits into
mainfrom
migrate/eth-types-on-non-l1-callers
Jun 10, 2026
Merged

refactor: use l1/eth types in non-L1 callers#3704
brbrr merged 5 commits into
mainfrom
migrate/eth-types-on-non-l1-callers

Conversation

@brbrr

@brbrr brbrr commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Switches the eth types usage from geth to our own defined types on non-l1 callers.

@brbrr brbrr self-assigned this Jun 4, 2026
@brbrr brbrr changed the base branch from main to add/l1-eth-types June 4, 2026 11:12
@brbrr brbrr force-pushed the migrate/eth-types-on-non-l1-callers branch from e0ffe04 to 3119134 Compare June 4, 2026 11:14
@codecov

codecov Bot commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.63%. Comparing base (a79a303) to head (93739db).
⚠️ Report is 13 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #3704    +/-   ##
========================================
  Coverage   76.62%   76.63%            
========================================
  Files         409      410     +1     
  Lines       37030    37174   +144     
========================================
+ Hits        28376    28490   +114     
- Misses       6666     6696    +30     
  Partials     1988     1988            

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@brbrr brbrr marked this pull request as ready for review June 4, 2026 12:17
Copilot AI review requested due to automatic review settings June 4, 2026 12:17
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Claude finished @brbrr's task in 3m 44s —— View job


PR Review: use l1/eth types in non-L1 callers

  • Read context & gather the diff
  • Review core / blockchain / rpc / adapters / l1 changes
  • Check new wire_parity_test.go files
  • Verify build & post feedback

This is a clean, well-scoped mechanical refactor swapping go-ethereum/common.{Address,Hash} for the in-repo l1/eth equivalents across non-L1 callers. Go compilation passes for all touched packages (the only local build failure is the cgo link step for cmd/juno, which needs prebuilt Rust artifacts — an environment issue, not from this PR). No blockers or important issues found.

A few things I specifically checked and confirmed are sound:

  • JSON wire parityMsgToL1/MsgFromL1 address fields change type, but eth.Address.MarshalText emits lowercase, non-checksummed 0x-hex, matching what geth's common.Address produced via encoding/json (geth uses MarshalText, not the EIP-55 String()). The new wire_parity_test.go files pin this byte-for-byte, and l1/eth/address_test.go proves parity against geth directly. 👍
  • eth.Address(coreContractAddress) conversion in l1/eth_subscriber.go — valid, both are [20]byte.
  • validate:"required" on the retyped fields — behavior is unchanged since both old and new types are fixed-size [20]byte arrays.
  • HexToAddress on user config (cmd/juno) — silently crops/pads malformed input, but that matches the prior geth behavior, so no regression.
  • Callers of L1HandlerTxnHash (rpc/v{8,9,10}/l1.go, mock) all updated consistently to pass msgHash.Bytes().

Findings

Nit

  • blockchain/blockchain.go:231L1HandlerTxnHash now takes []byte + a runtime length check, where the old *common.Hash enforced 32 bytes at compile time. Using eth.Hash would keep that invariant compile-time and remove the L1HandlerMsgHashLength branch. Non-blocking; current callers can't trip the check. (left inline)

Nice touch adding the wire-parity tests alongside the migration — that's exactly the safety net this kind of change needs.
· migrate/eth-types-on-non-l1-callers

Comment thread blockchain/blockchain.go Outdated

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

Refactors non-L1 call sites to use the project’s internal l1/eth address/hash types instead of geth’s common.Address/common.Hash, while adding parity tests to lock the JSON-RPC wire format for L1/L2 messaging types.

Changes:

  • Replace geth common.Address with l1/eth.Address across RPC v8/v9/v10 message DTOs and core message types.
  • Refactor L1HandlerTxnHash plumbing to key lookups by raw 32-byte msg-hash bytes (with explicit length validation).
  • Add “wire parity” tests for RPC v8/v9/v10 to pin JSON output/input shapes after the type migration.

Reviewed changes

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

Show a summary per file
File Description
rpc/v9/wire_parity_test.go Adds v9 JSON wire-shape parity tests for MsgToL1 / MsgFromL1.
rpc/v9/transaction.go Switches MsgToL1.To from geth common.Address to eth.Address.
rpc/v9/l1.go Updates L1HandlerTxnHash call sites to pass raw bytes via msgHash.Bytes().
rpc/v9/l1_test.go Updates mocks/expectations for new L1HandlerTxnHash([]byte) signature.
rpc/v9/estimate_fee.go Switches MsgFromL1.From to eth.Address and uses From.Bytes() for calldata.
rpc/v8/wire_parity_test.go Adds v8 JSON wire-shape parity tests for MsgToL1 / MsgFromL1.
rpc/v8/transaction.go Switches MsgToL1.To from geth common.Address to eth.Address.
rpc/v8/l1.go Updates L1HandlerTxnHash call sites to pass raw bytes via msgHash.Bytes().
rpc/v8/l1_test.go Updates mocks/expectations for new L1HandlerTxnHash([]byte) signature.
rpc/v8/estimate_fee.go Switches MsgFromL1.From to eth.Address and uses From.Bytes() for calldata.
rpc/v10/wire_parity_test.go Adds v10 JSON wire-shape parity tests for MsgToL1 / MsgFromL1.
rpc/v10/transaction_types.go Switches MsgToL1.To from geth common.Address to eth.Address.
rpc/v10/l1.go Updates L1HandlerTxnHash call sites to pass raw bytes via msgHash.Bytes().
rpc/v10/l1_test.go Updates mocks/expectations for new L1HandlerTxnHash([]byte) signature.
rpc/v10/estimate_fee.go Switches MsgFromL1.From to eth.Address and uses From.Bytes() for calldata.
mocks/mock_blockchain.go Regenerates blockchain.Reader mock for L1HandlerTxnHash([]byte).
migration/deprecated/migration_pkg_test.go Switches test msg-hash type construction to eth.HexToHash and uses .Bytes().
l1/l1_test.go Updates NewEthSubscriber construction to pass eth.Address{}.
l1/eth_subscriber.go Updates NewEthSubscriber signature to accept eth.Address and bridges to geth common.Address for the filterer.
core/transaction.go Migrates core L1/L2 message address fields to eth.Address.
cmd/juno/juno.go Parses core contract address into eth.Address for network config.
cmd/juno/juno_test.go Updates tests to use eth.HexToAddress for core contract address defaults.
blockchain/networks/network.go Changes Network.CoreContractAddress type to eth.Address and updates defaults.
blockchain/networks/network_test.go Updates tests to assert eth.Address core contract addresses.
blockchain/blockchain.go Changes Reader.L1HandlerTxnHash to accept []byte and validates 32-byte length before DB lookup.
blockchain/blockchain_test.go Updates L1 handler msg-hash lookup test and adds negative tests for non-32-byte inputs.
adapters/vm2core/vm2core.go Switches VM→core L1 address adaptation to eth.HexToAddress.
adapters/vm2core/vm2core_test.go Updates expectations to use eth.Address conversions.
adapters/testutils/core_test_utils.go Updates random L1 address generator to return eth.Address.
adapters/sn2core/sn2core.go Switches Starknet→core L1 address adaptation to eth.HexToAddress.
adapters/p2p2core/felt.go Switches P2P receipt Ethereum address adaptation to return eth.Address.
Files not reviewed (1)
  • mocks/mock_blockchain.go: Language not supported

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

Comment thread rpc/v10/wire_parity_test.go Outdated
Base automatically changed from add/l1-eth-types to main June 8, 2026 13:07
@brbrr brbrr force-pushed the migrate/eth-types-on-non-l1-callers branch from 3119134 to c718afc Compare June 8, 2026 13:14
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Claude finished @brbrr's task in 4m 35s —— View job


PR Review: use l1/eth types in non-L1 callers

  • Read context & gather the diff
  • Review core / blockchain / rpc / adapters / l1 changes
  • Verify build / vet on touched packages
  • Post review feedback

The migration itself is clean and well-scoped, but it does not compile against the current main — this looks like it regressed after the PR was retargeted/rebased.

Blocker

  • Build broken: undefined eth.HexToAddress / eth.HexToHash / eth.BytesToAddress (inline). The merged l1/eth package (feat(l1): Add L1 Eth types #3700) named its constructors AddressFromString / AddressFromBytes / HashFromString / HashFromBytes, but this PR uses the geth-style names at 31 call sites. Verified:

    $ go build ./blockchain/networks/
    blockchain/networks/network.go:80:28: undefined: eth.HexToAddress
    ...
    

    The fix is a mechanical rename:

    this PR uses should be files
    eth.HexToAddress eth.AddressFromString network.go/_test.go, sn2core.go, vm2core.go/_test.go, cmd/juno/juno.go/_test.go, rpc/v{8,9,10}/wire_parity_test.go
    eth.HexToHash eth.HashFromString blockchain_test.go, migration/deprecated/migration_pkg_test.go
    eth.BytesToAddress eth.AddressFromBytes adapters/p2p2core/felt.go

    Earlier CI on this PR passed because the original base (add/l1-eth-types) still exposed the geth-style names; the rename landed in feat(l1): Add L1 Eth types #3700 on main.

Nits (non-blocking)

  • blockchain/blockchain.go:231L1HandlerTxnHash([]byte) trades a compile-time 32-byte guarantee (*common.Hash) for a runtime length check. Using eth.Hash would keep the invariant compile-time and drop L1HandlerMsgHashLength + the error branch (already flagged in the prior review). The added negative tests are a nice safety net for the []byte approach if you keep it.
  • @rodrodros raised a fair point on wire_parity_test.go placement — if v8 is slated for deletion, the documenting rationale is better anchored in the latest RPC version (v10). Worth a follow-up, not a blocker.

Things I confirmed are sound

  • JSON wire parity for MsgToL1/MsgFromL1: eth.Address.MarshalText emits lowercase non-checksummed 0x-hex, matching geth's encoding/json output. The new parity tests pin this byte-for-byte. 👍
  • common.Address(coreContractAddress) bridge in l1/eth_subscriber.go — valid [20]byte conversion.
  • validate:"required" on retyped fields — unchanged behavior (both are fixed-size arrays).

Once the constructor names are fixed, go build ./... / go vet ./... should pass and this is good to go.
· migrate/eth-types-on-non-l1-callers

Comment thread blockchain/networks/network.go Outdated
@brbrr brbrr force-pushed the migrate/eth-types-on-non-l1-callers branch from c718afc to 5da18df Compare June 8, 2026 13:54
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

PR Re-review: use l1/eth types in non-L1 callers

  • Gather diff & check prior blocker status
  • Verify build / vet on touched packages
  • Re-check correctness (wire parity, conversions, length checks)
  • Post review feedback

The previous blocker (undefined eth.HexToAddress/HexToHash/BytesToAddress) appears resolved — all call sites now use the *FromString/*FromBytes constructors. Verifying the build now.

View job run

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Claude finished @brbrr's task in 3m 59s —— View job


PR Re-review: use l1/eth types in non-L1 callers

  • Gather diff & check prior blocker status
  • Verify build / vet on touched packages
  • Re-check correctness (wire parity, conversions, length checks)
  • Post review feedback

This is now clean — no blockers, no important issues. Good to merge.

Verification

  • Build passesgo build ./blockchain/... ./adapters/... ./core/... ./rpc/... ./l1/... ./migration/... succeeds. The previous blocker (undefined eth.HexToAddress/HexToHash/BytesToAddress) is fully resolved — all 31 call sites now use eth.AddressFromString / eth.AddressFromBytes / eth.HashFromString.
  • go vet passes on all touched packages.
  • go test is blocked in this sandbox, but compilation + vet are green and CI/Codecov are passing on the head commit.

Things I confirmed are sound

  • Conversion semantics match geth. eth.AddressFromStringAddressFromBytesSetBytes crops from the left for oversized input and left-pads with zeros for undersized — identical to geth's HexToAddress/BytesToAddress. So sn2core, vm2core, p2p2core, network.go, and cmd/juno config parsing keep their prior behavior (including the silent crop/pad on malformed config, which is a pre-existing trait, not a regression).
  • JSON wire parity for MsgToL1/MsgFromL1: eth.Address.MarshalText emits lowercase non-checksummed 0x-hex, matching geth's encoding/json output. The new wire_parity_test.go files (v8/v9/v10) pin this byte-for-byte, including the omitempty nil-From case. 👍
  • common.Address(coreContractAddress) bridge in l1/eth_subscriber.go — valid [20]byte conversion to feed the geth filterer.
  • validate:"required" on the retyped fields — unchanged behavior (both are fixed-size arrays).

Previously-raised items, now addressed

  • @rodrodros (wire-parity rationale placement) — commit 217ddd2f3 moved the documenting rationale to the v10 file, the latest RPC version.
  • L1HandlerTxnHash([]byte) nit — moot now: blockchain/blockchain.go, blockchain_test.go, the rpc l1.go/l1_test.go files, and the mock are no longer part of this PR, so the compile-time-vs-runtime-length-check tradeoff no longer applies here.

Clean, well-scoped mechanical migration with a solid test safety net.
· migrate/eth-types-on-non-l1-callers

@brbrr brbrr temporarily deployed to Development June 8, 2026 14:14 — with GitHub Actions Inactive

@RafaelGranza RafaelGranza 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.

LGTM.
One small nit

Comment thread rpc/v10/wire_parity_test.go Outdated
@brbrr brbrr temporarily deployed to Development June 9, 2026 17:59 — with GitHub Actions Inactive

@rodrodros rodrodros 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.

lgtm as well

@brbrr brbrr enabled auto-merge (squash) June 10, 2026 09:34
@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Claude finished @brbrr's task in 3m 5s —— View job


PR Review: use l1/eth types in non-L1 callers

  • Read the diff (22 files)
  • Review type migration correctness (conversions, wire parity)
  • Verify build/vet on touched packages
  • Post review feedback

This is clean — no blockers, no important issues, no nits. ✅ A tidy, well-scoped mechanical migration from go-ethereum/common.{Address,Hash} to the in-repo l1/eth equivalents across non-L1 callers.

Verification

  • go build ./adapters/... ./core/... ./blockchain/... ./l1/... ./rpc/... ./migration/... — passes.
  • go vet ./rpc/v{8,9,10}/... ./adapters/... ./blockchain/networks/... ./migration/deprecated/... ./l1/... — passes (new *_test.go files compile).

Things I confirmed are sound

  • Constructor names — all call sites use eth.AddressFromString / eth.AddressFromBytes / eth.HashFromString. The earlier blocker (geth-style HexToAddress/HexToHash/BytesToAddress that didn't exist in the merged l1/eth) is fully resolved.
  • Conversion semantics match gethAddressFromStringAddressFromBytesSetBytes left-crops oversized input and left-pads undersized, identical to geth's HexToAddress/BytesToAddress. So sn2core, vm2core, p2p2core, network.go, and cmd/juno config parsing keep prior behavior (including the pre-existing silent crop/pad on malformed config — not a regression).
  • JSON wire parityeth.Address/eth.Hash define MarshalText/UnmarshalText emitting lowercase non-checksummed 0x-hex, mirroring geth's encoding/json output. The new wire_parity_test.go files (v8/v9/v10) pin MsgToL1/MsgFromL1 byte-for-byte, including the omitempty nil-From case. 👍
  • common.Address(coreContractAddress) bridge in l1/eth_subscriber.go — valid [20]byte conversion to feed the geth filterer.
  • validate:"required" on the retyped fields — unchanged behavior (both old and new are fixed-size arrays).

Previously-raised items, all addressed

  • @rodrodros (wire-parity rationale placement) — 217ddd2f3 anchored the rationale in the v10 file (latest RPC version), with v8/v9 referencing it.
  • @RafaelGranza (_test package for the parity tests) — 93739db95 switched them to rpcv{8,9,10}_test external packages.
  • L1HandlerTxnHash([]byte) nit — moot; blockchain.go and the rpc l1.go files are no longer part of this PR.

Already approved by @RafaelGranza and @rodrodros — concur, good to merge.
· migrate/eth-types-on-non-l1-callers

@brbrr brbrr merged commit 4eccf08 into main Jun 10, 2026
17 of 18 checks passed
@brbrr brbrr deleted the migrate/eth-types-on-non-l1-callers branch June 10, 2026 09:46
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