diff --git a/op-challenger/game/fault/contracts/disputegame.go b/op-challenger/game/fault/contracts/disputegame.go index 5d873482c07a86b276b3b9c2afc4c6a7a0c6d61a..fd51e51cf0ca269b495f093863f4c0a6daa0ded0 100644 --- a/op-challenger/game/fault/contracts/disputegame.go +++ b/op-challenger/game/fault/contracts/disputegame.go @@ -29,7 +29,7 @@ const ( methodVM = "VM" ) -type DisputeGameContract struct { +type disputeGameContract struct { multiCaller *batching.MultiCaller contract *batching.BoundContract } @@ -55,7 +55,7 @@ func asProposal(p contractProposal) Proposal { } } -func (f *DisputeGameContract) GetGameDuration(ctx context.Context) (uint64, error) { +func (f *disputeGameContract) GetGameDuration(ctx context.Context) (uint64, error) { result, err := f.multiCaller.SingleCall(ctx, batching.BlockLatest, f.contract.Call(methodGameDuration)) if err != nil { return 0, fmt.Errorf("failed to fetch game duration: %w", err) @@ -63,7 +63,7 @@ func (f *DisputeGameContract) GetGameDuration(ctx context.Context) (uint64, erro return result.GetUint64(0), nil } -func (f *DisputeGameContract) GetMaxGameDepth(ctx context.Context) (uint64, error) { +func (f *disputeGameContract) GetMaxGameDepth(ctx context.Context) (uint64, error) { result, err := f.multiCaller.SingleCall(ctx, batching.BlockLatest, f.contract.Call(methodMaxGameDepth)) if err != nil { return 0, fmt.Errorf("failed to fetch max game depth: %w", err) @@ -71,7 +71,7 @@ func (f *DisputeGameContract) GetMaxGameDepth(ctx context.Context) (uint64, erro return result.GetBigInt(0).Uint64(), nil } -func (f *DisputeGameContract) GetAbsolutePrestateHash(ctx context.Context) (common.Hash, error) { +func (f *disputeGameContract) GetAbsolutePrestateHash(ctx context.Context) (common.Hash, error) { result, err := f.multiCaller.SingleCall(ctx, batching.BlockLatest, f.contract.Call(methodAbsolutePrestate)) if err != nil { return common.Hash{}, fmt.Errorf("failed to fetch absolute prestate hash: %w", err) @@ -79,7 +79,7 @@ func (f *DisputeGameContract) GetAbsolutePrestateHash(ctx context.Context) (comm return result.GetHash(0), nil } -func (f *DisputeGameContract) GetL1Head(ctx context.Context) (common.Hash, error) { +func (f *disputeGameContract) GetL1Head(ctx context.Context) (common.Hash, error) { result, err := f.multiCaller.SingleCall(ctx, batching.BlockLatest, f.contract.Call(methodL1Head)) if err != nil { return common.Hash{}, fmt.Errorf("failed to fetch L1 head: %w", err) @@ -87,7 +87,7 @@ func (f *DisputeGameContract) GetL1Head(ctx context.Context) (common.Hash, error return result.GetHash(0), nil } -func (f *DisputeGameContract) GetStatus(ctx context.Context) (gameTypes.GameStatus, error) { +func (f *disputeGameContract) GetStatus(ctx context.Context) (gameTypes.GameStatus, error) { result, err := f.multiCaller.SingleCall(ctx, batching.BlockLatest, f.contract.Call(methodStatus)) if err != nil { return 0, fmt.Errorf("failed to fetch status: %w", err) @@ -95,7 +95,7 @@ func (f *DisputeGameContract) GetStatus(ctx context.Context) (gameTypes.GameStat return gameTypes.GameStatusFromUint8(result.GetUint8(0)) } -func (f *DisputeGameContract) GetClaimCount(ctx context.Context) (uint64, error) { +func (f *disputeGameContract) GetClaimCount(ctx context.Context) (uint64, error) { result, err := f.multiCaller.SingleCall(ctx, batching.BlockLatest, f.contract.Call(methodClaimCount)) if err != nil { return 0, fmt.Errorf("failed to fetch claim count: %w", err) @@ -103,7 +103,7 @@ func (f *DisputeGameContract) GetClaimCount(ctx context.Context) (uint64, error) return result.GetBigInt(0).Uint64(), nil } -func (f *DisputeGameContract) GetClaim(ctx context.Context, idx uint64) (types.Claim, error) { +func (f *disputeGameContract) GetClaim(ctx context.Context, idx uint64) (types.Claim, error) { result, err := f.multiCaller.SingleCall(ctx, batching.BlockLatest, f.contract.Call(methodClaim, new(big.Int).SetUint64(idx))) if err != nil { return types.Claim{}, fmt.Errorf("failed to fetch claim %v: %w", idx, err) @@ -111,7 +111,7 @@ func (f *DisputeGameContract) GetClaim(ctx context.Context, idx uint64) (types.C return f.decodeClaim(result, int(idx)), nil } -func (f *DisputeGameContract) GetAllClaims(ctx context.Context) ([]types.Claim, error) { +func (f *disputeGameContract) GetAllClaims(ctx context.Context) ([]types.Claim, error) { count, err := f.GetClaimCount(ctx) if err != nil { return nil, fmt.Errorf("failed to load claim count: %w", err) @@ -134,7 +134,7 @@ func (f *DisputeGameContract) GetAllClaims(ctx context.Context) ([]types.Claim, return claims, nil } -func (f *DisputeGameContract) vm(ctx context.Context) (*VMContract, error) { +func (f *disputeGameContract) vm(ctx context.Context) (*VMContract, error) { result, err := f.multiCaller.SingleCall(ctx, batching.BlockLatest, f.contract.Call(methodVM)) if err != nil { return nil, fmt.Errorf("failed to fetch VM addr: %w", err) @@ -143,22 +143,22 @@ func (f *DisputeGameContract) vm(ctx context.Context) (*VMContract, error) { return NewVMContract(vmAddr, f.multiCaller) } -func (f *DisputeGameContract) AttackTx(parentContractIndex uint64, pivot common.Hash) (txmgr.TxCandidate, error) { +func (f *disputeGameContract) AttackTx(parentContractIndex uint64, pivot common.Hash) (txmgr.TxCandidate, error) { call := f.contract.Call(methodAttack, new(big.Int).SetUint64(parentContractIndex), pivot) return call.ToTxCandidate() } -func (f *DisputeGameContract) DefendTx(parentContractIndex uint64, pivot common.Hash) (txmgr.TxCandidate, error) { +func (f *disputeGameContract) DefendTx(parentContractIndex uint64, pivot common.Hash) (txmgr.TxCandidate, error) { call := f.contract.Call(methodDefend, new(big.Int).SetUint64(parentContractIndex), pivot) return call.ToTxCandidate() } -func (f *DisputeGameContract) StepTx(claimIdx uint64, isAttack bool, stateData []byte, proof []byte) (txmgr.TxCandidate, error) { +func (f *disputeGameContract) StepTx(claimIdx uint64, isAttack bool, stateData []byte, proof []byte) (txmgr.TxCandidate, error) { call := f.contract.Call(methodStep, new(big.Int).SetUint64(claimIdx), isAttack, stateData, proof) return call.ToTxCandidate() } -func (f *DisputeGameContract) CallResolveClaim(ctx context.Context, claimIdx uint64) error { +func (f *disputeGameContract) CallResolveClaim(ctx context.Context, claimIdx uint64) error { call := f.resolveClaimCall(claimIdx) _, err := f.multiCaller.SingleCall(ctx, batching.BlockLatest, call) if err != nil { @@ -167,16 +167,16 @@ func (f *DisputeGameContract) CallResolveClaim(ctx context.Context, claimIdx uin return nil } -func (f *DisputeGameContract) ResolveClaimTx(claimIdx uint64) (txmgr.TxCandidate, error) { +func (f *disputeGameContract) ResolveClaimTx(claimIdx uint64) (txmgr.TxCandidate, error) { call := f.resolveClaimCall(claimIdx) return call.ToTxCandidate() } -func (f *DisputeGameContract) resolveClaimCall(claimIdx uint64) *batching.ContractCall { +func (f *disputeGameContract) resolveClaimCall(claimIdx uint64) *batching.ContractCall { return f.contract.Call(methodResolveClaim, new(big.Int).SetUint64(claimIdx)) } -func (f *DisputeGameContract) CallResolve(ctx context.Context) (gameTypes.GameStatus, error) { +func (f *disputeGameContract) CallResolve(ctx context.Context) (gameTypes.GameStatus, error) { call := f.resolveCall() result, err := f.multiCaller.SingleCall(ctx, batching.BlockLatest, call) if err != nil { @@ -185,16 +185,16 @@ func (f *DisputeGameContract) CallResolve(ctx context.Context) (gameTypes.GameSt return gameTypes.GameStatusFromUint8(result.GetUint8(0)) } -func (f *DisputeGameContract) ResolveTx() (txmgr.TxCandidate, error) { +func (f *disputeGameContract) ResolveTx() (txmgr.TxCandidate, error) { call := f.resolveCall() return call.ToTxCandidate() } -func (f *DisputeGameContract) resolveCall() *batching.ContractCall { +func (f *disputeGameContract) resolveCall() *batching.ContractCall { return f.contract.Call(methodResolve) } -func (f *DisputeGameContract) decodeClaim(result *batching.CallResult, contractIndex int) types.Claim { +func (f *disputeGameContract) decodeClaim(result *batching.CallResult, contractIndex int) types.Claim { parentIndex := result.GetUint32(0) countered := result.GetBool(1) claim := result.GetHash(2) diff --git a/op-challenger/game/fault/contracts/disputegame_test.go b/op-challenger/game/fault/contracts/disputegame_test.go index 02cf1373c340a3ca1be72d62ef7fd80c482fd983..5d0f4891dde0b576e5a1d5720ebe03a173b51c67 100644 --- a/op-challenger/game/fault/contracts/disputegame_test.go +++ b/op-challenger/game/fault/contracts/disputegame_test.go @@ -20,7 +20,7 @@ var ( oracleAddr = common.HexToAddress("0x44442842371dFC380576ebb09Ae16Cb6B6ca4444") ) -type disputeGameSetupFunc func(t *testing.T) (*batchingTest.AbiBasedRpc, *DisputeGameContract) +type disputeGameSetupFunc func(t *testing.T) (*batchingTest.AbiBasedRpc, *disputeGameContract) func runCommonDisputeGameTests(t *testing.T, setup disputeGameSetupFunc) { tests := []struct { @@ -52,19 +52,19 @@ func runSimpleGettersTest(t *testing.T, setup disputeGameSetupFunc) { args []interface{} result interface{} expected interface{} // Defaults to expecting the same as result - call func(game *DisputeGameContract) (any, error) + call func(game *disputeGameContract) (any, error) }{ { method: methodStatus, result: types.GameStatusChallengerWon, - call: func(game *DisputeGameContract) (any, error) { + call: func(game *disputeGameContract) (any, error) { return game.GetStatus(context.Background()) }, }, { method: methodGameDuration, result: uint64(5566), - call: func(game *DisputeGameContract) (any, error) { + call: func(game *disputeGameContract) (any, error) { return game.GetGameDuration(context.Background()) }, }, @@ -72,14 +72,14 @@ func runSimpleGettersTest(t *testing.T, setup disputeGameSetupFunc) { method: methodMaxGameDepth, result: big.NewInt(128), expected: uint64(128), - call: func(game *DisputeGameContract) (any, error) { + call: func(game *disputeGameContract) (any, error) { return game.GetMaxGameDepth(context.Background()) }, }, { method: methodAbsolutePrestate, result: common.Hash{0xab}, - call: func(game *DisputeGameContract) (any, error) { + call: func(game *disputeGameContract) (any, error) { return game.GetAbsolutePrestateHash(context.Background()) }, }, @@ -87,21 +87,21 @@ func runSimpleGettersTest(t *testing.T, setup disputeGameSetupFunc) { method: methodClaimCount, result: big.NewInt(9876), expected: uint64(9876), - call: func(game *DisputeGameContract) (any, error) { + call: func(game *disputeGameContract) (any, error) { return game.GetClaimCount(context.Background()) }, }, { method: methodL1Head, result: common.Hash{0xdd, 0xbb}, - call: func(game *DisputeGameContract) (any, error) { + call: func(game *disputeGameContract) (any, error) { return game.GetL1Head(context.Background()) }, }, { method: methodResolve, result: types.GameStatusInProgress, - call: func(game *DisputeGameContract) (any, error) { + call: func(game *disputeGameContract) (any, error) { return game.CallResolve(context.Background()) }, }, diff --git a/op-challenger/game/fault/contracts/faultdisputegame.go b/op-challenger/game/fault/contracts/faultdisputegame.go index 7b7a3edd11b7b856bbbd3d59a91bf9aeb2bbfa08..ebcaf60ed2c0754915140685618c315fa053954e 100644 --- a/op-challenger/game/fault/contracts/faultdisputegame.go +++ b/op-challenger/game/fault/contracts/faultdisputegame.go @@ -17,7 +17,7 @@ const ( ) type FaultDisputeGameContract struct { - DisputeGameContract + disputeGameContract } func NewFaultDisputeGameContract(addr common.Address, caller *batching.MultiCaller) (*FaultDisputeGameContract, error) { @@ -27,7 +27,7 @@ func NewFaultDisputeGameContract(addr common.Address, caller *batching.MultiCall } return &FaultDisputeGameContract{ - DisputeGameContract: DisputeGameContract{ + disputeGameContract: disputeGameContract{ multiCaller: caller, contract: batching.NewBoundContract(fdgAbi, addr), }, diff --git a/op-challenger/game/fault/contracts/faultdisputegame_test.go b/op-challenger/game/fault/contracts/faultdisputegame_test.go index 9a69683274820350fe80940b470a9a58c4e7d663..f96ffecb93e91ad999a89511da80d318326d7d51 100644 --- a/op-challenger/game/fault/contracts/faultdisputegame_test.go +++ b/op-challenger/game/fault/contracts/faultdisputegame_test.go @@ -14,9 +14,9 @@ import ( ) func TestFaultDisputeGameContract_CommonTests(t *testing.T) { - runCommonDisputeGameTests(t, func(t *testing.T) (*batchingTest.AbiBasedRpc, *DisputeGameContract) { + runCommonDisputeGameTests(t, func(t *testing.T) (*batchingTest.AbiBasedRpc, *disputeGameContract) { stubRpc, contract := setupFaultDisputeGameTest(t) - return stubRpc, &contract.DisputeGameContract + return stubRpc, &contract.disputeGameContract }) } diff --git a/op-challenger/game/fault/contracts/outputbisectiongame.go b/op-challenger/game/fault/contracts/outputbisectiongame.go index dce47ea4cb2142d4b74be385a3d6bc7e49ad1596..8e20b5ce5c4a975e8a0222536e12390423eac745 100644 --- a/op-challenger/game/fault/contracts/outputbisectiongame.go +++ b/op-challenger/game/fault/contracts/outputbisectiongame.go @@ -19,7 +19,7 @@ var ( ) type OutputBisectionGameContract struct { - DisputeGameContract + disputeGameContract } func NewOutputBisectionGameContract(addr common.Address, caller *batching.MultiCaller) (*OutputBisectionGameContract, error) { @@ -29,7 +29,7 @@ func NewOutputBisectionGameContract(addr common.Address, caller *batching.MultiC } return &OutputBisectionGameContract{ - DisputeGameContract: DisputeGameContract{ + disputeGameContract: disputeGameContract{ multiCaller: caller, contract: batching.NewBoundContract(contractAbi, addr), }, @@ -78,7 +78,7 @@ func (f *OutputBisectionGameContract) addLocalDataTx(claimIdx uint64, data *type return call.ToTxCandidate() } -func (f *DisputeGameContract) addGlobalDataTx(ctx context.Context, data *types.PreimageOracleData) (txmgr.TxCandidate, error) { +func (f *disputeGameContract) addGlobalDataTx(ctx context.Context, data *types.PreimageOracleData) (txmgr.TxCandidate, error) { vm, err := f.vm(ctx) if err != nil { return txmgr.TxCandidate{}, err diff --git a/op-challenger/game/fault/contracts/outputbisectiongame_test.go b/op-challenger/game/fault/contracts/outputbisectiongame_test.go index d8bcbba0b4cecc0e1ba18b8c0ec7269625480d72..e109ed104da1e6543d0f6e5f305525e86271f913 100644 --- a/op-challenger/game/fault/contracts/outputbisectiongame_test.go +++ b/op-challenger/game/fault/contracts/outputbisectiongame_test.go @@ -14,9 +14,9 @@ import ( ) func TestOutputBisectionGameContract_CommonTests(t *testing.T) { - runCommonDisputeGameTests(t, func(t *testing.T) (*batchingTest.AbiBasedRpc, *DisputeGameContract) { + runCommonDisputeGameTests(t, func(t *testing.T) (*batchingTest.AbiBasedRpc, *disputeGameContract) { stubRpc, contract := setupOutputBisectionGameTest(t) - return stubRpc, &contract.DisputeGameContract + return stubRpc, &contract.disputeGameContract }) }