Skip to content

Commit

Permalink
op-challenger: Update for move to eth package
Browse files Browse the repository at this point in the history
  • Loading branch information
ajsutton committed Jan 15, 2025
1 parent 99d1043 commit 35a1f86
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 24 deletions.
4 changes: 1 addition & 3 deletions op-challenger/game/fault/trace/super/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/types"
interopTypes "github.com/ethereum-optimism/optimism/op-program/client/interop/types"
"github.com/ethereum-optimism/optimism/op-service/eth"
supervisortypes "github.com/ethereum-optimism/optimism/op-supervisor/supervisor/types"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
Expand All @@ -27,8 +26,7 @@ const (
)

type RootProvider interface {
// TODO: Should we redefine SuperRootResponse so we don't depend on supervisor?
SuperRootAtTimestamp(timestamp uint64) (supervisortypes.SuperRootResponse, error)
SuperRootAtTimestamp(timestamp uint64) (eth.SuperRootResponse, error)
}

type SuperTraceProvider struct {
Expand Down
41 changes: 20 additions & 21 deletions op-challenger/game/fault/trace/super/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/ethereum-optimism/optimism/op-service/eth"
"github.com/ethereum-optimism/optimism/op-service/testlog"
"github.com/ethereum-optimism/optimism/op-service/testutils"
supervisortypes "github.com/ethereum-optimism/optimism/op-supervisor/supervisor/types"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
Expand All @@ -28,12 +27,12 @@ func TestGet(t *testing.T) {
t.Run("AtPostState", func(t *testing.T) {
provider, stubSupervisor := createProvider(t)
superRoot := eth.Bytes32{0xaa}
stubSupervisor.Add(supervisortypes.SuperRootResponse{
stubSupervisor.Add(eth.SuperRootResponse{
Timestamp: poststateTimestamp,
SuperRoot: superRoot,
Chains: []supervisortypes.ChainRootInfo{
Chains: []eth.ChainRootInfo{
{
ChainID: supervisortypes.ChainIDFromUInt64(1),
ChainID: eth.ChainIDFromUInt64(1),
Canonical: eth.Bytes32{0xbb},
Pending: []byte{0xcc},
},
Expand All @@ -47,12 +46,12 @@ func TestGet(t *testing.T) {
t.Run("AtNewTimestamp", func(t *testing.T) {
provider, stubSupervisor := createProvider(t)
superRoot := eth.Bytes32{0xaa}
stubSupervisor.Add(supervisortypes.SuperRootResponse{
stubSupervisor.Add(eth.SuperRootResponse{
Timestamp: prestateTimestamp + 1,
SuperRoot: superRoot,
Chains: []supervisortypes.ChainRootInfo{
Chains: []eth.ChainRootInfo{
{
ChainID: supervisortypes.ChainIDFromUInt64(1),
ChainID: eth.ChainIDFromUInt64(1),
Canonical: eth.Bytes32{0xbb},
Pending: []byte{0xcc},
},
Expand All @@ -77,33 +76,33 @@ func TestGet(t *testing.T) {
superRoot2 := eth.NewSuperV1(prestateTimestamp+1,
eth.ChainIDAndOutput{ChainID: 1, Output: eth.OutputRoot(outputA2)},
eth.ChainIDAndOutput{ChainID: 2, Output: eth.OutputRoot(outputB2)})
stubSupervisor.Add(supervisortypes.SuperRootResponse{
stubSupervisor.Add(eth.SuperRootResponse{
Timestamp: prestateTimestamp,
SuperRoot: eth.SuperRoot(superRoot1),
Chains: []supervisortypes.ChainRootInfo{
Chains: []eth.ChainRootInfo{
{
ChainID: supervisortypes.ChainIDFromUInt64(1),
ChainID: eth.ChainIDFromUInt64(1),
Canonical: eth.OutputRoot(outputA1),
Pending: outputA1.Marshal(),
},
{
ChainID: supervisortypes.ChainIDFromUInt64(2),
ChainID: eth.ChainIDFromUInt64(2),
Canonical: eth.OutputRoot(outputB1),
Pending: outputB1.Marshal(),
},
},
})
stubSupervisor.Add(supervisortypes.SuperRootResponse{
stubSupervisor.Add(eth.SuperRootResponse{
Timestamp: prestateTimestamp + 1,
SuperRoot: eth.SuperRoot(superRoot2),
Chains: []supervisortypes.ChainRootInfo{
Chains: []eth.ChainRootInfo{
{
ChainID: supervisortypes.ChainIDFromUInt64(1),
ChainID: eth.ChainIDFromUInt64(1),
Canonical: eth.OutputRoot(outputA2),
Pending: outputA2.Marshal(),
},
{
ChainID: supervisortypes.ChainIDFromUInt64(1),
ChainID: eth.ChainIDFromUInt64(1),
Canonical: eth.OutputRoot(outputB2),
Pending: outputB2.Marshal(),
},
Expand Down Expand Up @@ -225,26 +224,26 @@ func TestComputeStep(t *testing.T) {
func createProvider(t *testing.T) (*SuperTraceProvider, *stubRootProvider) {
logger := testlog.Logger(t, log.LvlInfo)
stubSupervisor := &stubRootProvider{
rootsByTimestamp: make(map[uint64]supervisortypes.SuperRootResponse),
rootsByTimestamp: make(map[uint64]eth.SuperRootResponse),
}
return NewSuperTraceProvider(logger, nil, stubSupervisor, eth.BlockID{}, gameDepth, prestateTimestamp, poststateTimestamp), stubSupervisor
}

type stubRootProvider struct {
rootsByTimestamp map[uint64]supervisortypes.SuperRootResponse
rootsByTimestamp map[uint64]eth.SuperRootResponse
}

func (s *stubRootProvider) Add(root supervisortypes.SuperRootResponse) {
func (s *stubRootProvider) Add(root eth.SuperRootResponse) {
if s.rootsByTimestamp == nil {
s.rootsByTimestamp = make(map[uint64]supervisortypes.SuperRootResponse)
s.rootsByTimestamp = make(map[uint64]eth.SuperRootResponse)
}
s.rootsByTimestamp[root.Timestamp] = root
}

func (s *stubRootProvider) SuperRootAtTimestamp(timestamp uint64) (supervisortypes.SuperRootResponse, error) {
func (s *stubRootProvider) SuperRootAtTimestamp(timestamp uint64) (eth.SuperRootResponse, error) {
root, ok := s.rootsByTimestamp[timestamp]
if !ok {
return supervisortypes.SuperRootResponse{}, ethereum.NotFound
return eth.SuperRootResponse{}, ethereum.NotFound
}
return root, nil
}

0 comments on commit 35a1f86

Please sign in to comment.