-
Notifications
You must be signed in to change notification settings - Fork 3.9k
op-sync-tester: eth namespace relay #17117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
nonsense
merged 16 commits into
develop
from
pcw109550/sync-tester-eth-namespace-harden
Aug 20, 2025
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
62b8bf7
op-sync-tester: eth namespace relay
pcw109550 1e73d11
simplify
pcw109550 bd6ded9
More synctester example configs
pcw109550 e1ac22a
better error handling fore eth_chainId
pcw109550 d88245a
safety guard
pcw109550 61f18c2
read only backend encapsulation
pcw109550 e241816
fix lint
pcw109550 6f877c2
rename
pcw109550 dc63df3
refactor sync tester init
pcw109550 1165798
mock rl backend and chainID test
pcw109550 9feeef0
refactor
pcw109550 c31af0e
GetBlockByHash tests
pcw109550 3440908
GetBlockByNumber tests
pcw109550 3a74be1
GetBlockReceipts tests
pcw109550 7f20649
consistency
pcw109550 cb2ea17
fix logic error
pcw109550 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,10 @@ | ||
| synctesters: | ||
| local: | ||
| chain_id: 2151908 | ||
| el_rpc: http://localhost:32988/ | ||
| el_rpc: http://localhost:62654/ | ||
| sepolia: | ||
| chain_id: 11155420 | ||
| el_rpc: https://sepolia.optimism.io | ||
| el_rpc: https://sepolia.optimism.io | ||
| mainnet: | ||
| chain_id: 10 | ||
| el_rpc: https://mainnet.optimism.io |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| package backend | ||
|
|
||
| import ( | ||
| "context" | ||
| "encoding/json" | ||
| "math/big" | ||
|
|
||
| "github.com/ethereum/go-ethereum/common" | ||
| "github.com/ethereum/go-ethereum/common/hexutil" | ||
| "github.com/ethereum/go-ethereum/core/types" | ||
| "github.com/ethereum/go-ethereum/ethclient" | ||
| "github.com/ethereum/go-ethereum/rpc" | ||
| ) | ||
|
|
||
| // ReadOnlyELBackend defines the minimal, read-only execution layer | ||
| // interface used by the sync tester and its mock backends. | ||
| // The interface exposes two flavors of block accessors: | ||
| // - JSON-returning methods (GetBlockByNumberJSON, GetBlockByHashJSON) | ||
| // which return the raw RPC payload exactly as delivered by the EL. | ||
| // These are useful for relaying the response from read-only exec layer directly | ||
| // - Typed methods (GetBlockByNumber, GetBlockByHash) which decode | ||
| // the RPC response into geth *types.Block for structured | ||
| // inspection in code. | ||
| // - Additional helpers include GetBlockReceipts and ChainId | ||
| // | ||
| // Implementation wraps ethclient.Client to forward RPC | ||
| // calls. For testing, a mock implementation can be provided to return | ||
| // deterministic values without requiring a live execution layer node. | ||
| type ReadOnlyELBackend interface { | ||
| GetBlockByNumberJSON(ctx context.Context, number rpc.BlockNumber, fullTx bool) (json.RawMessage, error) | ||
| GetBlockByHashJSON(ctx context.Context, hash common.Hash, fullTx bool) (json.RawMessage, error) | ||
| GetBlockByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Block, error) | ||
| GetBlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error) | ||
| GetBlockReceipts(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) ([]*types.Receipt, error) | ||
| ChainId(ctx context.Context) (hexutil.Big, error) | ||
| } | ||
|
|
||
| var _ ReadOnlyELBackend = (*ELReader)(nil) | ||
|
|
||
| type ELReader struct { | ||
| c *ethclient.Client | ||
| } | ||
|
|
||
| func NewELReader(c *ethclient.Client) *ELReader { | ||
| return &ELReader{c: c} | ||
| } | ||
|
|
||
| func (g *ELReader) GetBlockByNumberJSON(ctx context.Context, number rpc.BlockNumber, fullTx bool) (json.RawMessage, error) { | ||
| var raw json.RawMessage | ||
| if err := g.c.Client().CallContext(ctx, &raw, "eth_getBlockByNumber", number, fullTx); err != nil { | ||
| return nil, err | ||
| } | ||
| return raw, nil | ||
| } | ||
|
|
||
| func (g *ELReader) GetBlockByHashJSON(ctx context.Context, hash common.Hash, fullTx bool) (json.RawMessage, error) { | ||
| var raw json.RawMessage | ||
| if err := g.c.Client().CallContext(ctx, &raw, "eth_getBlockByHash", hash, fullTx); err != nil { | ||
| return nil, err | ||
| } | ||
| return raw, nil | ||
| } | ||
|
|
||
| func (g *ELReader) GetBlockByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Block, error) { | ||
| return g.c.BlockByNumber(ctx, big.NewInt(number.Int64())) | ||
| } | ||
pcw109550 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| func (g *ELReader) GetBlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error) { | ||
| return g.c.BlockByHash(ctx, hash) | ||
| } | ||
|
|
||
| func (g *ELReader) GetBlockReceipts(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) ([]*types.Receipt, error) { | ||
| return g.c.BlockReceipts(ctx, blockNrOrHash) | ||
| } | ||
|
|
||
| func (g *ELReader) ChainId(ctx context.Context) (hexutil.Big, error) { | ||
| chainID, err := g.c.ChainID(ctx) | ||
| if err != nil { | ||
| return hexutil.Big{}, err | ||
| } | ||
| return hexutil.Big(*chainID), nil | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.