refactor: use l1/eth types in non-L1 callers#3704
Conversation
e0ffe04 to
3119134
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3704 +/- ##
==========================================
- Coverage 76.62% 76.61% -0.02%
==========================================
Files 409 409
Lines 37030 37030
==========================================
- Hits 28376 28370 -6
- Misses 6666 6672 +6
Partials 1988 1988 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Claude finished @brbrr's task in 3m 44s —— View job PR Review: use l1/eth types in non-L1 callers
This is a clean, well-scoped mechanical refactor swapping A few things I specifically checked and confirmed are sound:
FindingsNit
Nice touch adding the wire-parity tests alongside the migration — that's exactly the safety net this kind of change needs. |
| } | ||
|
|
||
| func (b *Blockchain) L1HandlerTxnHash(msgHash *common.Hash) (felt.Felt, error) { | ||
| func (b *Blockchain) L1HandlerTxnHash(msgHash []byte) (felt.Felt, error) { |
There was a problem hiding this comment.
Nit (design): the previous *common.Hash parameter guaranteed a 32-byte hash at compile time. Switching to []byte moves that guarantee to a runtime length check, which all current callers (rpc/v{8,9,10}/l1.go passing msgHash.Bytes()) can never trip. Since this PR introduces the l1/eth types, using eth.Hash here would keep the invariant compile-time-enforced and drop the need for L1HandlerMsgHashLength + the error branch entirely:
func (b *Blockchain) L1HandlerTxnHash(msgHash *eth.Hash) (felt.Felt, error) {
b.listener.OnRead("L1HandlerTxnHash")
return core.GetL1HandlerTxnHashByMsgHash(b.database, msgHash.Bytes())
}Not blocking — the []byte + validation approach is safe given the callers convert from a fixed-size common.Hash. Just flagging that the typed variant is stronger and fits the PR's direction.
There was a problem hiding this comment.
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.Addresswithl1/eth.Addressacross RPC v8/v9/v10 message DTOs and core message types. - Refactor
L1HandlerTxnHashplumbing 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.
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| // See rpc/v8/wire_parity_test.go for rationale. Same JSON shape as v8/v9. |
There was a problem hiding this comment.
if v8 is going to deprecated meaning v8 will eventually be deleted, shouldn't the rationale go in the latest rpc version?
3119134 to
c718afc
Compare
|
Claude finished @brbrr's task in 4m 35s —— View job PR Review: use l1/eth types in non-L1 callers
The migration itself is clean and well-scoped, but it does not compile against the current Blocker
Nits (non-blocking)
Things I confirmed are sound
Once the constructor names are fixed, |
| L2ChainID: "SN_MAIN", | ||
| L1ChainID: big.NewInt(1), | ||
| CoreContractAddress: common.HexToAddress("0xc662c410C0ECf747543f5bA90660f6ABeBD9C8c4"), | ||
| CoreContractAddress: eth.HexToAddress("0xc662c410C0ECf747543f5bA90660f6ABeBD9C8c4"), |
There was a problem hiding this comment.
Blocker — does not compile. eth.HexToAddress is undefined. The merged l1/eth package (#3700) names its constructors AddressFromString / AddressFromBytes / HashFromString / HashFromBytes, not the geth-style HexToAddress / BytesToAddress / HexToHash this PR uses.
$ go build ./blockchain/networks/
blockchain/networks/network.go:80:28: undefined: eth.HexToAddress
...
This breaks 31 call sites across the PR. The mapping is mechanical:
eth.HexToAddress(s)→eth.AddressFromString(s)—network.go,network_test.go,sn2core.go,vm2core.go/_test.go,cmd/juno/juno.go/_test.go,rpc/v{8,9,10}/wire_parity_test.goeth.HexToHash(s)→eth.HashFromString(s)—blockchain_test.go,migration/deprecated/migration_pkg_test.goeth.BytesToAddress(b)→eth.AddressFromBytes(b)—adapters/p2p2core/felt.go
Likely the PR was written against the original add/l1-eth-types base (which used geth-style names) and the rename to *FromString/*FromBytes landed in #3700 before this was retargeted onto main.
| CoreContractAddress: eth.HexToAddress("0xc662c410C0ECf747543f5bA90660f6ABeBD9C8c4"), | |
| CoreContractAddress: eth.AddressFromString("0xc662c410C0ECf747543f5bA90660f6ABeBD9C8c4"), |
c718afc to
5da18df
Compare
|
Claude finished @brbrr's task in 3m 59s —— View job PR Re-review: use l1/eth types in non-L1 callers
This is now clean — no blockers, no important issues. Good to merge. ✅ Verification
Things I confirmed are sound
Previously-raised items, now addressed
Clean, well-scoped mechanical migration with a solid test safety net. |

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