diff --git a/op-challenger2/game/fault/agent.go b/op-challenger2/game/fault/agent.go index 9a82250f59213..609e848eb9117 100644 --- a/op-challenger2/game/fault/agent.go +++ b/op-challenger2/game/fault/agent.go @@ -123,7 +123,7 @@ func (a *Agent) performAction(ctx context.Context, wg *sync.WaitGroup, action ty containsOracleData := action.OracleData != nil isLocal := containsOracleData && action.OracleData.IsLocal actionLog = actionLog.New( - "is_attack", action.IsAttack, + "attackBranch", action.AttackBranch, "parent", action.ParentClaim.ContractIndex, "prestate", common.Bytes2Hex(action.PreState), "proof", common.Bytes2Hex(action.ProofData), @@ -133,13 +133,15 @@ func (a *Agent) performAction(ctx context.Context, wg *sync.WaitGroup, action ty if action.OracleData != nil { actionLog = actionLog.New("oracleKey", common.Bytes2Hex(action.OracleData.OracleKey)) } - } else if action.Type == types.ActionTypeMove { - actionLog = actionLog.New("is_attack", action.IsAttack, "parent", action.ParentClaim.ContractIndex, "value", action.Value) + } else if action.Type == types.ActionTypeAttackV2 { + actionLog = actionLog.New("attackBranch", action.AttackBranch, "parent", action.ParentClaim.ContractIndex, "value", action.Value) } switch action.Type { case types.ActionTypeMove: a.metrics.RecordGameMove() + case types.ActionTypeAttackV2: + a.metrics.RecordGameAttackV2() case types.ActionTypeStep: a.metrics.RecordGameStep() case types.ActionTypeChallengeL2BlockNumber: diff --git a/op-challenger2/game/fault/contracts/faultdisputegame.go b/op-challenger2/game/fault/contracts/faultdisputegame.go index 384bb1065bf8e..28aa9f4523df8 100644 --- a/op-challenger2/game/fault/contracts/faultdisputegame.go +++ b/op-challenger2/game/fault/contracts/faultdisputegame.go @@ -44,7 +44,7 @@ var ( methodAttack = "attack" methodDefend = "defend" methodStep = "step" - methodAddLocalData = "addLocalData" + methodAddLocalData = "addLocalData2" methodVM = "vm" methodStartingBlockNumber = "startingBlockNumber" methodStartingRootHash = "startingRootHash" @@ -75,6 +75,8 @@ type FaultDisputeGameContractLatest struct { metrics metrics.ContractMetricer multiCaller *batching.MultiCaller contract *batching.BoundContract + nbits uint64 + splitDepth types.Depth } type Proposal struct { @@ -130,11 +132,23 @@ func NewFaultDisputeGameContract(ctx context.Context, metrics metrics.ContractMe }, }, nil } else { - return &FaultDisputeGameContractLatest{ + + contract := &FaultDisputeGameContractLatest{ metrics: metrics, multiCaller: caller, contract: batching.NewBoundContract(contractAbi, addr), - }, nil + } + nbits, err := contract.GetNBits(ctx) + if err != nil { + return nil, err + } + splitDepth, err := contract.GetSplitDepth(ctx) + if err != nil { + return nil, err + } + contract.nbits = nbits + contract.splitDepth = splitDepth + return contract, nil } } @@ -349,6 +363,9 @@ func (f *FaultDisputeGameContractLatest) UpdateOracleTx(ctx context.Context, cla } func (f *FaultDisputeGameContractLatest) addLocalDataTx(claimIdx uint64, data *types.PreimageOracleData) (txmgr.TxCandidate, error) { + if data.OutputRootDAItem.DaType == nil { + return txmgr.TxCandidate{}, fmt.Errorf("DaType isn't set") + } call := f.contract.Call( methodAddLocalData, data.GetIdent(), @@ -479,6 +496,11 @@ func (f *FaultDisputeGameContractLatest) GetAllClaimsWithSubValues(ctx context.C return nil, err } for idx, claim := range claims { + if claim.IsRoot() { // root claim contains no subValues in DA, we create subvalues manually + claim.SubValues = &[]common.Hash{claim.Value} + claims[idx] = claim + continue + } subValues, attackBranch, err := f.getSubValuesAndAttackBranch(ctx, &claim) if err != nil { return nil, fmt.Errorf("failed to load subValues: %w", err) @@ -510,7 +532,6 @@ func (f *FaultDisputeGameContractLatest) getSubValuesAndAttackBranch(ctx context return nil, 0, fmt.Errorf("failed to get move event log: %w", moveIter.Error()) } txHash := moveIter.Event.Raw.TxHash - getTxByHashCall := batching.NewTxGetByHash(f.contract.Abi(), txHash, methodAttackV2) result, err := f.multiCaller.SingleCall(ctx, rpcblock.Latest, getTxByHashCall) if err != nil { @@ -535,9 +556,13 @@ func (f *FaultDisputeGameContractLatest) getSubValuesAndAttackBranch(ctx context if err != nil { return nil, 0, err } - valuesBytesLen := uint(32 * maxAttackBranch) + nelements := maxAttackBranch + if aggClaim.Position.Depth() == types.Depth(f.nbits)+f.splitDepth { + nelements = 1 + } + valuesBytesLen := uint(32 * nelements) bytes := abi.ConvertType(inputMap[fieldSubValues], make([]byte, valuesBytesLen)).([]byte) - for i := uint64(0); i < maxAttackBranch; i++ { + for i := uint64(0); i < nelements; i++ { hash := common.BytesToHash(bytes[i*32 : (i+1)*32]) subValues = append(subValues, hash) } @@ -715,17 +740,13 @@ func (f *FaultDisputeGameContractLatest) GetMaxAttackBranch(ctx context.Context) } func (f *FaultDisputeGameContractLatest) AttackV2Tx(ctx context.Context, parent types.Claim, attackBranch uint64, daType uint64, claims []byte) (txmgr.TxCandidate, error) { - nBits, err := f.GetNBits(ctx) - if err != nil { - return txmgr.TxCandidate{}, fmt.Errorf("failed to retrieve nbits: %w", err) - } call := f.contract.Call(methodAttackV2, parent.Value, big.NewInt(int64(parent.ContractIndex)), new(big.Int).SetUint64(attackBranch), new(big.Int).SetUint64(daType), claims) - return f.txWithBond(ctx, parent.Position.MoveN(nBits, attackBranch), call) + return f.txWithBond(ctx, parent.Position.MoveN(f.nbits, attackBranch), call) } func (f *FaultDisputeGameContractLatest) StepV2Tx(claimIdx uint64, attackBranch uint64, stateData []byte, proof types.StepProof) (txmgr.TxCandidate, error) { diff --git a/op-challenger2/game/fault/contracts/faultdisputegame_test.go b/op-challenger2/game/fault/contracts/faultdisputegame_test.go index ced0eb91ee1f9..e7313bd290cc9 100644 --- a/op-challenger2/game/fault/contracts/faultdisputegame_test.go +++ b/op-challenger2/game/fault/contracts/faultdisputegame_test.go @@ -481,20 +481,6 @@ func TestGetBlockRange(t *testing.T) { } } -func TestGetSplitDepth(t *testing.T) { - for _, version := range versions { - version := version - t.Run(version.version, func(t *testing.T) { - stubRpc, contract := setupFaultDisputeGameTest(t, version) - expectedSplitDepth := faultTypes.Depth(15) - stubRpc.SetResponse(fdgAddr, methodSplitDepth, rpcblock.Latest, nil, []interface{}{new(big.Int).SetUint64(uint64(expectedSplitDepth))}) - splitDepth, err := contract.GetSplitDepth(context.Background()) - require.NoError(t, err) - require.Equal(t, expectedSplitDepth, splitDepth) - }) - } -} - func TestGetGameMetadata(t *testing.T) { for _, version := range versions { version := version @@ -794,6 +780,9 @@ func setupFaultDisputeGameTest(t *testing.T, version contractVersion) (*batching caller := batching.NewMultiCaller(stubRpc, batching.DefaultBatchSize) stubRpc.SetResponse(fdgAddr, methodVersion, rpcblock.Latest, nil, []interface{}{version.version}) + nbitOrSplitDepth := big.NewInt(2) + stubRpc.SetResponse(fdgAddr, methodNBits, rpcblock.Latest, nil, []interface{}{nbitOrSplitDepth}) + stubRpc.SetResponse(fdgAddr, methodSplitDepth, rpcblock.Latest, nil, []interface{}{nbitOrSplitDepth}) game, err := NewFaultDisputeGameContract(context.Background(), contractMetrics.NoopContractMetrics, fdgAddr, caller) require.NoError(t, err) return stubRpc, game @@ -874,6 +863,7 @@ func TestGetAllClaimsWithSubValues(t *testing.T) { attackBranch := big.NewInt(0) parent := faultTypes.Claim{ClaimData: faultTypes.ClaimData{Value: common.Hash{0xbb}, Position: parentPos}, ContractIndex: 111} stubRpc.SetResponse(fdgAddr, methodNBits, block, nil, []interface{}{new(big.Int).SetUint64(nBits)}) + stubRpc.SetResponse(fdgAddr, methodSplitDepth, block, nil, []interface{}{new(big.Int).SetUint64(nBits)}) stubRpc.SetResponse(fdgAddr, methodRequiredBond, block, []interface{}{parent.Position.MoveN(nBits, attackBranch.Uint64()).ToGIndex()}, []interface{}{bond}) stubRpc.SetResponse(fdgAddr, methodAttackV2, block, []interface{}{parent.Value, big.NewInt(111), attackBranch, daType, claimsBytes[:]}, nil) txCandidate, err := game.AttackV2Tx(context.Background(), parent, attackBranch.Uint64(), daType.Uint64(), claimsBytes[:]) @@ -886,10 +876,8 @@ func TestGetAllClaimsWithSubValues(t *testing.T) { Value: big.NewInt(111), Data: txCandidate.TxData, }) - packed, err := tx.MarshalBinary() - require.NoError(t, err) txHash := tx.Hash() - stubRpc.SetGetTxByHashResponse(txHash, packed) + stubRpc.SetGetTxByHashResponse(txHash, tx) // mock eventLog eventName := eventMove @@ -915,7 +903,7 @@ func TestGetAllClaimsWithSubValues(t *testing.T) { }, } - stubRpc.SetFilterLogResponse(topics, fdgAddr, block, out) + stubRpc.SetFilterLogResponse(topics, []common.Address{fdgAddr}, block, out) stubRpc.SetResponse(fdgAddr, methodClaimCount, block, nil, []interface{}{big.NewInt(1)}) stubRpc.SetResponse(fdgAddr, methodMaxAttackBranch, block, nil, []interface{}{big.NewInt(1<= uint64(len(*claim.SubValues)) { + return true, fmt.Errorf("branch must be less than maxAttachBranch") } - return &types.Claim{ - ClaimData: types.ClaimData{Value: value, Position: position}, - ParentContractIndex: claim.ContractIndex, - }, nil + ourValue, err := s.trace.Get(ctx, game, claim, claim.Position.MoveRightN(branch)) + return bytes.Equal(ourValue[:], (*claim.SubValues)[branch][:]), err } -// defend returns a response that defends the claim. -func (s *claimSolver) defend(ctx context.Context, game types.Game, claim types.Claim) (*types.Claim, error) { - if claim.IsRoot() { - return nil, nil - } - position := claim.Defend() - value, err := s.trace.Get(ctx, game, claim, position) - if err != nil { - return nil, fmt.Errorf("defend claim: %w", err) - } +func (s *claimSolver) attackV2(ctx context.Context, game types.Game, claim types.Claim, branch uint64) (*types.Claim, error) { + var err error + var value common.Hash + var values []common.Hash + maxAttackBranch := game.MaxAttackBranch() + position := claim.MoveN(game.NBits(), branch) + for i := uint64(0); i < maxAttackBranch; i++ { + tmpPosition := position.MoveRightN(i) + if tmpPosition.Depth() == (game.SplitDepth()+types.Depth(game.NBits())) && i != 0 { + break + } else { + value, err = s.trace.Get(ctx, game, claim, tmpPosition) + if err != nil { + return nil, fmt.Errorf("attack claim: %w", err) + } + values = append(values, value) + } + } + hash := contracts.SubValuesHash(values) return &types.Claim{ - ClaimData: types.ClaimData{Value: value, Position: position}, + ClaimData: types.ClaimData{Value: hash, Position: position}, ParentContractIndex: claim.ContractIndex, + SubValues: &values, + AttackBranch: branch, }, nil } - -// agreeWithClaim returns true if the claim is correct according to the internal [TraceProvider]. -func (s *claimSolver) agreeWithClaim(ctx context.Context, game types.Game, claim types.Claim) (bool, error) { - ourValue, err := s.trace.Get(ctx, game, claim, claim.Position) - return bytes.Equal(ourValue[:], claim.Value[:]), err -} diff --git a/op-challenger2/game/fault/solver/solver_test.go b/op-challenger2/game/fault/solver/solver_test.go index 4fb5723fde8eb..7ce1049419b34 100644 --- a/op-challenger2/game/fault/solver/solver_test.go +++ b/op-challenger2/game/fault/solver/solver_test.go @@ -5,84 +5,124 @@ import ( "math/big" "testing" + "github.com/ethereum-optimism/optimism/op-challenger2/game/fault/contracts" faulttest "github.com/ethereum-optimism/optimism/op-challenger2/game/fault/test" "github.com/ethereum-optimism/optimism/op-challenger2/game/fault/trace" + "github.com/ethereum-optimism/optimism/op-challenger2/game/fault/trace/alphabet" + "github.com/ethereum-optimism/optimism/op-challenger2/game/fault/trace/split" "github.com/ethereum-optimism/optimism/op-challenger2/game/fault/types" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" "github.com/stretchr/testify/require" ) -func TestAttemptStep(t *testing.T) { - maxDepth := types.Depth(3) +func TestAttemptStepNary2(t *testing.T) { + maxDepth := types.Depth(7) startingL2BlockNumber := big.NewInt(0) nbits := uint64(1) splitDepth := types.Depth(3) claimBuilder := faulttest.NewAlphabetClaimBuilder2(t, startingL2BlockNumber, maxDepth, nbits, splitDepth) + traceDepth := maxDepth - splitDepth - types.Depth(nbits) // Last accessible leaf is the second last trace index // The root node is used for the last trace index and can only be attacked. - lastLeafTraceIndex := big.NewInt(1<= disputeBlockNum { - pos = pos.Attack() - claim = claim.Attack(ctx, getClaimValue(claim, pos)) + pos = pos.MoveN(nbits, 0) + subValues := []common.Hash{} + for i := 0; i < 1<= 0 { + return hexutil.EncodeBig(number) + } + // It's negative. + if number.IsInt64() { + return rpc.BlockNumber(number.Int64()).String() + } + // It's negative and large, which is invalid. + return fmt.Sprintf("", number) +} diff --git a/op-service/sources/batching/event_call_test.go b/op-service/sources/batching/event_call_test.go index 6144e34bd402e..01e41901872b0 100644 --- a/op-service/sources/batching/event_call_test.go +++ b/op-service/sources/batching/event_call_test.go @@ -57,7 +57,7 @@ func TestEventLogFilter(t *testing.T) { out[i] = r } - stub.SetFilterLogResponse(topics, addr, block, _out) + stub.SetFilterLogResponse(topics, []common.Address{addr}, block, _out) caller := NewMultiCaller(stub, DefaultBatchSize) filter, err := batchingTest.NewERC20Filterer(addr, caller) diff --git a/op-service/sources/batching/test/abi_stub.go b/op-service/sources/batching/test/abi_stub.go index d29d2f22045be..7fe0635135f12 100644 --- a/op-service/sources/batching/test/abi_stub.go +++ b/op-service/sources/batching/test/abi_stub.go @@ -149,7 +149,7 @@ func (l *AbiBasedRpc) SetResponse(to common.Address, method string, block rpcblo }) } -func (l *AbiBasedRpc) SetFilterLogResponse(topics [][]common.Hash, to common.Address, block rpcblock.Block, output []types.Log) { +func (l *AbiBasedRpc) SetFilterLogResponse(topics [][]common.Hash, to []common.Address, block rpcblock.Block, output []types.Log) { if output == nil { output = []types.Log{} } @@ -162,9 +162,9 @@ func (l *AbiBasedRpc) SetFilterLogResponse(topics [][]common.Hash, to common.Add }) } -func (l *AbiBasedRpc) SetGetTxByHashResponse(txHash common.Hash, output []byte) { +func (l *AbiBasedRpc) SetGetTxByHashResponse(txHash common.Hash, output *types.Transaction) { if output == nil { - output = []byte{} + output = &types.Transaction{} } l.AddExpectedCall(&expectedGetTxByHashCall{txHash: txHash, outputs: output}) } diff --git a/op-service/sources/batching/test/event_stub.go b/op-service/sources/batching/test/event_stub.go index 6b46d385f8191..29a00c6932148 100644 --- a/op-service/sources/batching/test/event_stub.go +++ b/op-service/sources/batching/test/event_stub.go @@ -14,28 +14,32 @@ import ( type expectedFilterLogsCall struct { topics [][]common.Hash - to common.Address + to []common.Address block rpcblock.Block outputs []types.Log err error } func (c *expectedFilterLogsCall) Matches(rpcMethod string, args ...interface{}) error { - if rpcMethod != "eth_getFilterLogs" { - return fmt.Errorf("expected rpcMethod eth_getFilterLogs but was %v", rpcMethod) + if rpcMethod != "eth_getLogs" { + return fmt.Errorf("expected rpcMethod eth_getLogs but was %v", rpcMethod) } - topics, ok := args[0].([][]common.Hash) + query, ok := args[0].(map[string]interface{}) if !ok { - return fmt.Errorf("arg 0 is not [][]common.Hash") + return fmt.Errorf("arg 0 is not map[string]interface{}") + } + topics := query["topics"].([][]common.Hash) + if !ok { + return fmt.Errorf("topics is not [][]common.Hash") } if !reflect.DeepEqual(topics, c.topics) { return fmt.Errorf("expected topics %v but was %v", c.topics, topics) } - to := args[1].(common.Address) - if to != c.to { + to := query["address"].([]common.Address) + if !reflect.DeepEqual(to, c.to) { return fmt.Errorf("expected contract address %v but was %v", c.to, to) } return c.err @@ -52,7 +56,7 @@ func (c *expectedFilterLogsCall) String() string { return fmt.Sprintf("{to: %v, block: %v, outputs: %v}", c.to, c.block, c.outputs) } -func (l *RpcStub) SetFilterLogResponse(topics [][]common.Hash, to common.Address, block rpcblock.Block, output []types.Log) { +func (l *RpcStub) SetFilterLogResponse(topics [][]common.Hash, to []common.Address, block rpcblock.Block, output []types.Log) { if output == nil { output = []types.Log{} } diff --git a/op-service/sources/batching/test/generic_stub.go b/op-service/sources/batching/test/generic_stub.go index d79d121d4363a..ffbc1ac6af5dd 100644 --- a/op-service/sources/batching/test/generic_stub.go +++ b/op-service/sources/batching/test/generic_stub.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum-optimism/optimism/op-service/sources/batching/rpcblock" "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/rpc" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -80,11 +81,11 @@ func NewGetBalanceCall(addr common.Address, block rpcblock.Block, balance *big.I } } -func NewGetTxCall(txHash common.Hash, block rpcblock.Block, out *[]byte) ExpectedRpcCall { +func NewGetTxCall(txHash common.Hash, block rpcblock.Block, out *types.Transaction) ExpectedRpcCall { return &GenericExpectedCall{ method: "eth_getTransactionByHash", - args: []interface{}{txHash, block.ArgValue()}, - result: hexutil.Encode(*out), + args: []interface{}{txHash}, + result: out, } } diff --git a/op-service/sources/batching/test/tx_stub.go b/op-service/sources/batching/test/tx_stub.go index 4b14a7592781c..562093d3187c1 100644 --- a/op-service/sources/batching/test/tx_stub.go +++ b/op-service/sources/batching/test/tx_stub.go @@ -6,13 +6,13 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/core/types" "github.com/stretchr/testify/require" ) type expectedGetTxByHashCall struct { txHash common.Hash - outputs []byte + outputs *types.Transaction err error } @@ -34,7 +34,7 @@ func (c *expectedGetTxByHashCall) Matches(rpcMethod string, args ...interface{}) } func (c *expectedGetTxByHashCall) Execute(t *testing.T, out interface{}) error { - j, err := json.Marshal(hexutil.Bytes(c.outputs)) + j, err := json.Marshal(c.outputs) require.NoError(t, err) require.NoError(t, json.Unmarshal(j, out)) return c.err diff --git a/op-service/sources/batching/tx_call.go b/op-service/sources/batching/tx_call.go index de3d223e2e5d4..e5a0c3b9bf4cf 100644 --- a/op-service/sources/batching/tx_call.go +++ b/op-service/sources/batching/tx_call.go @@ -6,7 +6,6 @@ import ( "github.com/ethereum-optimism/optimism/op-service/sources/batching/rpcblock" "github.com/ethereum/go-ethereum/accounts/abi" "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/rpc" ) @@ -27,25 +26,19 @@ func NewTxGetByHash(abi *abi.ABI, txhash common.Hash, method string) *TxGetByHas func (b *TxGetByHashCall) ToBatchElemCreator() (BatchElementCreator, error) { return func(block rpcblock.Block) (any, rpc.BatchElem) { - out := new(hexutil.Bytes) + out := new(types.Transaction) return out, rpc.BatchElem{ Method: "eth_getTransactionByHash", - Args: []interface{}{b.TxHash, block.ArgValue()}, + Args: []interface{}{b.TxHash}, Result: &out, } }, nil } func (c *TxGetByHashCall) HandleResult(result interface{}) (*CallResult, error) { - res, ok := result.(*hexutil.Bytes) + txn, ok := result.(*types.Transaction) if !ok { - return nil, fmt.Errorf("result is not hexutil.Bytes") - } - - txn := new(types.Transaction) - err := txn.UnmarshalBinary(*res) - if err != nil { - return nil, err + return nil, fmt.Errorf("result is not types.Transaction") } return &CallResult{out: []interface{}{txn}}, nil } diff --git a/op-service/sources/batching/tx_call_test.go b/op-service/sources/batching/tx_call_test.go index 7dfdefb883352..b92d3cd1d880f 100644 --- a/op-service/sources/batching/tx_call_test.go +++ b/op-service/sources/batching/tx_call_test.go @@ -31,11 +31,9 @@ func TestUnpackTxCalldata(t *testing.T) { Data: inputData, }) require.NoError(t, err) - packed, err := tx.MarshalBinary() - require.NoError(t, err) stub := test.NewRpcStub(t) - stub.AddExpectedCall(test.NewGetTxCall(txHash, rpcblock.Latest, &packed)) + stub.AddExpectedCall(test.NewGetTxCall(txHash, rpcblock.Latest, tx)) caller := NewMultiCaller(stub, DefaultBatchSize) txCall := NewTxGetByHash(testAbi, txHash, "approve") diff --git a/packages/contracts-bedrock/scripts/Deploy.s.sol b/packages/contracts-bedrock/scripts/Deploy.s.sol index 6abe05b612940..76708c9b728b4 100644 --- a/packages/contracts-bedrock/scripts/Deploy.s.sol +++ b/packages/contracts-bedrock/scripts/Deploy.s.sol @@ -35,6 +35,7 @@ import { DataAvailabilityChallenge } from "src/L1/DataAvailabilityChallenge.sol" import { Constants } from "src/libraries/Constants.sol"; import { DisputeGameFactory } from "src/dispute/DisputeGameFactory.sol"; import { FaultDisputeGame } from "src/dispute/FaultDisputeGame.sol"; +import "src/dispute/FaultDisputeGameN.sol" as FdgN; import { PermissionedDisputeGame } from "src/dispute/PermissionedDisputeGame.sol"; import { DelayedWETH } from "src/dispute/weth/DelayedWETH.sol"; import { AnchorStateRegistry } from "src/dispute/AnchorStateRegistry.sol"; @@ -1420,7 +1421,7 @@ contract Deploy is Deployer { new AlphabetVM(outputAbsolutePrestate, PreimageOracle(mustGetAddress("PreimageOracle")), 4) ), // The max depth for the alphabet trace is always 3. Add 1 because split depth is fully inclusive. - maxGameDepth: cfg.faultGameSplitDepth() + 3 + 1 + maxGameDepth: 12 }) }); } @@ -1443,21 +1444,39 @@ contract Deploy is Deployer { uint32 rawGameType = GameType.unwrap(_params.gameType); if (rawGameType != GameTypes.PERMISSIONED_CANNON.raw()) { - _factory.setImplementation( - _params.gameType, - new FaultDisputeGame({ - _gameType: _params.gameType, - _absolutePrestate: _params.absolutePrestate, - _maxGameDepth: _params.maxGameDepth, - _splitDepth: cfg.faultGameSplitDepth(), - _clockExtension: Duration.wrap(uint64(cfg.faultGameClockExtension())), - _maxClockDuration: Duration.wrap(uint64(cfg.faultGameMaxClockDuration())), - _vm: _params.faultVm, - _weth: _params.weth, - _anchorStateRegistry: _params.anchorStateRegistry, - _l2ChainId: cfg.l2ChainID() - }) - ); + if (_params.gameType.raw() == GameTypes.ALPHABET.raw()) { + _factory.setImplementation( + _params.gameType, + new FdgN.FaultDisputeGame({ + _gameType: _params.gameType, + _absolutePrestate: _params.absolutePrestate, + _maxGameDepth: _params.maxGameDepth, + _splitDepth: 4, + _clockExtension: Duration.wrap(uint64(cfg.faultGameClockExtension())), + _maxClockDuration: Duration.wrap(uint64(cfg.faultGameMaxClockDuration())), + _vm: _params.faultVm, + _weth: _params.weth, + _anchorStateRegistry: _params.anchorStateRegistry, + _l2ChainId: cfg.l2ChainID() + }) + ); + } else { + _factory.setImplementation( + _params.gameType, + new FaultDisputeGame({ + _gameType: _params.gameType, + _absolutePrestate: _params.absolutePrestate, + _maxGameDepth: _params.maxGameDepth, + _splitDepth: cfg.faultGameSplitDepth(), + _clockExtension: Duration.wrap(uint64(cfg.faultGameClockExtension())), + _maxClockDuration: Duration.wrap(uint64(cfg.faultGameMaxClockDuration())), + _vm: _params.faultVm, + _weth: _params.weth, + _anchorStateRegistry: _params.anchorStateRegistry, + _l2ChainId: cfg.l2ChainID() + }) + ); + } } else { _factory.setImplementation( _params.gameType, diff --git a/packages/contracts-bedrock/snapshots/abi/FaultDisputeGameN.json b/packages/contracts-bedrock/snapshots/abi/FaultDisputeGameN.json index e76bb6f238045..24fb50cc645e8 100644 --- a/packages/contracts-bedrock/snapshots/abi/FaultDisputeGameN.json +++ b/packages/contracts-bedrock/snapshots/abi/FaultDisputeGameN.json @@ -1,1292 +1,1292 @@ [ - { - "type": "constructor", - "inputs": [ - { - "name": "_gameType", - "type": "uint32", - "internalType": "GameType" - }, - { - "name": "_absolutePrestate", - "type": "bytes32", - "internalType": "Claim" - }, - { - "name": "_maxGameDepth", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "_splitDepth", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "_clockExtension", - "type": "uint64", - "internalType": "Duration" - }, - { - "name": "_maxClockDuration", - "type": "uint64", - "internalType": "Duration" - }, - { - "name": "_vm", - "type": "address", - "internalType": "contract IBigStepper" - }, - { - "name": "_weth", - "type": "address", - "internalType": "contract IDelayedWETH" - }, - { - "name": "_anchorStateRegistry", - "type": "address", - "internalType": "contract IAnchorStateRegistry" - }, - { - "name": "_l2ChainId", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "MAX_ATTACK_BRANCH", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "N_BITS", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "absolutePrestate", - "inputs": [], - "outputs": [ - { - "name": "absolutePrestate_", - "type": "bytes32", - "internalType": "Claim" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "addLocalData", - "inputs": [ - { - "name": "_ident", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "_execLeafIdx", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "_partOffset", + { + "type": "constructor", + "inputs": [ + { + "name": "_gameType", + "type": "uint32", + "internalType": "GameType" + }, + { + "name": "_absolutePrestate", + "type": "bytes32", + "internalType": "Claim" + }, + { + "name": "_maxGameDepth", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "_splitDepth", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "_clockExtension", + "type": "uint64", + "internalType": "Duration" + }, + { + "name": "_maxClockDuration", + "type": "uint64", + "internalType": "Duration" + }, + { + "name": "_vm", + "type": "address", + "internalType": "contract IBigStepper" + }, + { + "name": "_weth", + "type": "address", + "internalType": "contract IDelayedWETH" + }, + { + "name": "_anchorStateRegistry", + "type": "address", + "internalType": "contract IAnchorStateRegistry" + }, + { + "name": "_l2ChainId", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "MAX_ATTACK_BRANCH", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "N_BITS", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "absolutePrestate", + "inputs": [], + "outputs": [ + { + "name": "absolutePrestate_", + "type": "bytes32", + "internalType": "Claim" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "addLocalData", + "inputs": [ + { + "name": "_ident", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "_execLeafIdx", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "_partOffset", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "addLocalData2", + "inputs": [ + { + "name": "_ident", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "_execLeafIdx", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "_partOffset", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "_daItem", + "type": "tuple", + "internalType": "struct LibDA.DAItem", + "components": [ + { + "name": "daType", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "dataHash", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "proof", + "type": "bytes", + "internalType": "bytes" + } + ] + } + ], + "outputs": [ + { + "name": "uuid_", + "type": "bytes32", + "internalType": "Hash" + }, + { + "name": "value_", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "anchorStateRegistry", + "inputs": [], + "outputs": [ + { + "name": "registry_", + "type": "address", + "internalType": "contract IAnchorStateRegistry" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "attack", + "inputs": [ + { + "name": "_disputed", + "type": "bytes32", + "internalType": "Claim" + }, + { + "name": "_parentIndex", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "_claim", + "type": "bytes32", + "internalType": "Claim" + } + ], + "outputs": [], + "stateMutability": "payable" + }, + { + "type": "function", + "name": "attackV2", + "inputs": [ + { + "name": "_disputed", + "type": "bytes32", + "internalType": "Claim" + }, + { + "name": "_parentIndex", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "_attackBranch", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "_daType", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "_claims", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [], + "stateMutability": "payable" + }, + { + "type": "function", + "name": "challengeRootL2Block", + "inputs": [ + { + "name": "_outputRootProof", + "type": "tuple", + "internalType": "struct Types.OutputRootProof", + "components": [ + { + "name": "version", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "stateRoot", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "messagePasserStorageRoot", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "latestBlockhash", + "type": "bytes32", + "internalType": "bytes32" + } + ] + }, + { + "name": "_headerRLP", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "claimCredit", + "inputs": [ + { + "name": "_recipient", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "claimData", + "inputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "parentIndex", + "type": "uint32", + "internalType": "uint32" + }, + { + "name": "counteredBy", + "type": "address", + "internalType": "address" + }, + { + "name": "claimant", + "type": "address", + "internalType": "address" + }, + { + "name": "bond", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "claim", + "type": "bytes32", + "internalType": "Claim" + }, + { + "name": "position", + "type": "uint128", + "internalType": "Position" + }, + { + "name": "clock", + "type": "uint128", + "internalType": "Clock" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "claimDataLen", + "inputs": [], + "outputs": [ + { + "name": "len_", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "claims", + "inputs": [ + { + "name": "", + "type": "bytes32", + "internalType": "Hash" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "clockExtension", + "inputs": [], + "outputs": [ + { + "name": "clockExtension_", + "type": "uint64", + "internalType": "Duration" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "createdAt", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint64", + "internalType": "Timestamp" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "credit", + "inputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "defend", + "inputs": [ + { + "name": "_disputed", + "type": "bytes32", + "internalType": "Claim" + }, + { + "name": "_parentIndex", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "_claim", + "type": "bytes32", + "internalType": "Claim" + } + ], + "outputs": [], + "stateMutability": "payable" + }, + { + "type": "function", + "name": "extraData", + "inputs": [], + "outputs": [ + { + "name": "extraData_", + "type": "bytes", + "internalType": "bytes" + } + ], + "stateMutability": "pure" + }, + { + "type": "function", + "name": "gameCreator", + "inputs": [], + "outputs": [ + { + "name": "creator_", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "pure" + }, + { + "type": "function", + "name": "gameData", + "inputs": [], + "outputs": [ + { + "name": "gameType_", + "type": "uint32", + "internalType": "GameType" + }, + { + "name": "rootClaim_", + "type": "bytes32", + "internalType": "Claim" + }, + { + "name": "extraData_", + "type": "bytes", + "internalType": "bytes" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "gameType", + "inputs": [], + "outputs": [ + { + "name": "gameType_", + "type": "uint32", + "internalType": "GameType" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getChallengerDuration", + "inputs": [ + { + "name": "_claimIndex", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "duration_", + "type": "uint64", + "internalType": "Duration" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getNumToResolve", + "inputs": [ + { + "name": "_claimIndex", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "numRemainingChildren_", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getRequiredBond", + "inputs": [ + { + "name": "_position", + "type": "uint128", + "internalType": "Position" + } + ], + "outputs": [ + { + "name": "requiredBond_", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "initialize", + "inputs": [], + "outputs": [], + "stateMutability": "payable" + }, + { + "type": "function", + "name": "l1Head", + "inputs": [], + "outputs": [ + { + "name": "l1Head_", + "type": "bytes32", + "internalType": "Hash" + } + ], + "stateMutability": "pure" + }, + { + "type": "function", + "name": "l2BlockNumber", + "inputs": [], + "outputs": [ + { + "name": "l2BlockNumber_", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "pure" + }, + { + "type": "function", + "name": "l2BlockNumberChallenged", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "l2BlockNumberChallenger", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "l2ChainId", + "inputs": [], + "outputs": [ + { + "name": "l2ChainId_", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "maxAttackBranch", + "inputs": [], + "outputs": [ + { + "name": "maxAttackBranch_", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "maxClockDuration", + "inputs": [], + "outputs": [ + { + "name": "maxClockDuration_", + "type": "uint64", + "internalType": "Duration" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "maxGameDepth", + "inputs": [], + "outputs": [ + { + "name": "maxGameDepth_", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "move", + "inputs": [ + { + "name": "_disputed", + "type": "bytes32", + "internalType": "Claim" + }, + { + "name": "_challengeIndex", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "_claim", + "type": "bytes32", + "internalType": "Claim" + }, + { + "name": "_isAttack", + "type": "bool", + "internalType": "bool" + } + ], + "outputs": [], + "stateMutability": "payable" + }, + { + "type": "function", + "name": "nBits", + "inputs": [], + "outputs": [ + { + "name": "nBits_", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "resolutionCheckpoints", + "inputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "initialCheckpointComplete", + "type": "bool", + "internalType": "bool" + }, + { + "name": "subgameIndex", + "type": "uint32", + "internalType": "uint32" + }, + { + "name": "leftmostPosition", + "type": "uint128", + "internalType": "Position" + }, + { + "name": "counteredBy", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "resolve", + "inputs": [], + "outputs": [ + { + "name": "status_", + "type": "uint8", + "internalType": "enum GameStatus" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "resolveClaim", + "inputs": [ + { + "name": "_claimIndex", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "_numToResolve", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "resolvedAt", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint64", + "internalType": "Timestamp" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "resolvedSubgames", + "inputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "rootClaim", + "inputs": [], + "outputs": [ + { + "name": "rootClaim_", + "type": "bytes32", + "internalType": "Claim" + } + ], + "stateMutability": "pure" + }, + { + "type": "function", + "name": "splitDepth", + "inputs": [], + "outputs": [ + { + "name": "splitDepth_", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "startingBlockNumber", + "inputs": [], + "outputs": [ + { + "name": "startingBlockNumber_", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "startingOutputRoot", + "inputs": [], + "outputs": [ + { + "name": "root", + "type": "bytes32", + "internalType": "Hash" + }, + { + "name": "l2BlockNumber", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "startingRootHash", + "inputs": [], + "outputs": [ + { + "name": "startingRootHash_", + "type": "bytes32", + "internalType": "Hash" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "status", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint8", + "internalType": "enum GameStatus" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "step", + "inputs": [ + { + "name": "_claimIndex", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "_isAttack", + "type": "bool", + "internalType": "bool" + }, + { + "name": "_stateData", + "type": "bytes", + "internalType": "bytes" + }, + { + "name": "_proof", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "stepV2", + "inputs": [ + { + "name": "_claimIndex", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "_attackBranch", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "_stateData", + "type": "bytes", + "internalType": "bytes" + }, + { + "name": "_proof", + "type": "tuple", + "internalType": "struct FaultDisputeGame.StepProof", + "components": [ + { + "name": "preStateItem", + "type": "tuple", + "internalType": "struct LibDA.DAItem", + "components": [ + { + "name": "daType", "type": "uint256", "internalType": "uint256" - }, - { - "name": "_daItem", - "type": "tuple", - "internalType": "struct LibDA.DAItem", - "components": [ - { - "name": "daType", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "dataHash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "proof", - "type": "bytes", - "internalType": "bytes" - } - ] - } - ], - "outputs": [ - { - "name": "uuid_", - "type": "bytes32", - "internalType": "Hash" - }, - { - "name": "value_", + }, + { + "name": "dataHash", "type": "bytes32", "internalType": "bytes32" - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "addLocalData", - "inputs": [ - { - "name": "_ident", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "_execLeafIdx", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "_partOffset", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "anchorStateRegistry", - "inputs": [], - "outputs": [ - { - "name": "registry_", - "type": "address", - "internalType": "contract IAnchorStateRegistry" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "attack", - "inputs": [ - { - "name": "_disputed", - "type": "bytes32", - "internalType": "Claim" - }, - { - "name": "_parentIndex", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "_claim", - "type": "bytes32", - "internalType": "Claim" - } - ], - "outputs": [], - "stateMutability": "payable" - }, - { - "type": "function", - "name": "attackV2", - "inputs": [ - { - "name": "_disputed", - "type": "bytes32", - "internalType": "Claim" - }, - { - "name": "_parentIndex", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "_attackBranch", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "_daType", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "_claims", + }, + { + "name": "proof", "type": "bytes", "internalType": "bytes" - } - ], - "outputs": [], - "stateMutability": "payable" - }, - { - "type": "function", - "name": "challengeRootL2Block", - "inputs": [ - { - "name": "_outputRootProof", - "type": "tuple", - "internalType": "struct Types.OutputRootProof", - "components": [ - { - "name": "version", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "stateRoot", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "messagePasserStorageRoot", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "latestBlockhash", - "type": "bytes32", - "internalType": "bytes32" - } - ] - }, - { - "name": "_headerRLP", - "type": "bytes", - "internalType": "bytes" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "claimCredit", - "inputs": [ - { - "name": "_recipient", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "claimData", - "inputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [ - { - "name": "parentIndex", - "type": "uint32", - "internalType": "uint32" - }, - { - "name": "counteredBy", - "type": "address", - "internalType": "address" - }, - { - "name": "claimant", - "type": "address", - "internalType": "address" - }, - { - "name": "bond", - "type": "uint128", - "internalType": "uint128" - }, - { - "name": "claim", - "type": "bytes32", - "internalType": "Claim" - }, - { - "name": "position", - "type": "uint128", - "internalType": "Position" - }, - { - "name": "clock", - "type": "uint128", - "internalType": "Clock" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "claimDataLen", - "inputs": [], - "outputs": [ - { - "name": "len_", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "claims", - "inputs": [ - { - "name": "", - "type": "bytes32", - "internalType": "Hash" - } - ], - "outputs": [ - { - "name": "", - "type": "bool", - "internalType": "bool" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "clockExtension", - "inputs": [], - "outputs": [ - { - "name": "clockExtension_", - "type": "uint64", - "internalType": "Duration" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "createdAt", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "uint64", - "internalType": "Timestamp" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "credit", - "inputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "", + } + ] + }, + { + "name": "postStateItem", + "type": "tuple", + "internalType": "struct LibDA.DAItem", + "components": [ + { + "name": "daType", "type": "uint256", "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "defend", - "inputs": [ - { - "name": "_disputed", + }, + { + "name": "dataHash", "type": "bytes32", - "internalType": "Claim" - }, - { - "name": "_parentIndex", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "_claim", - "type": "bytes32", - "internalType": "Claim" - } - ], - "outputs": [], - "stateMutability": "payable" - }, - { - "type": "function", - "name": "extraData", - "inputs": [], - "outputs": [ - { - "name": "extraData_", - "type": "bytes", - "internalType": "bytes" - } - ], - "stateMutability": "pure" - }, - { - "type": "function", - "name": "gameCreator", - "inputs": [], - "outputs": [ - { - "name": "creator_", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "pure" - }, - { - "type": "function", - "name": "gameData", - "inputs": [], - "outputs": [ - { - "name": "gameType_", - "type": "uint32", - "internalType": "GameType" - }, - { - "name": "rootClaim_", - "type": "bytes32", - "internalType": "Claim" - }, - { - "name": "extraData_", - "type": "bytes", - "internalType": "bytes" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "gameType", - "inputs": [], - "outputs": [ - { - "name": "gameType_", - "type": "uint32", - "internalType": "GameType" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "getChallengerDuration", - "inputs": [ - { - "name": "_claimIndex", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [ - { - "name": "duration_", - "type": "uint64", - "internalType": "Duration" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "getNumToResolve", - "inputs": [ - { - "name": "_claimIndex", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [ - { - "name": "numRemainingChildren_", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "getRequiredBond", - "inputs": [ - { - "name": "_position", - "type": "uint128", - "internalType": "Position" - } - ], - "outputs": [ - { - "name": "requiredBond_", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "initialize", - "inputs": [], - "outputs": [], - "stateMutability": "payable" - }, - { - "type": "function", - "name": "l1Head", - "inputs": [], - "outputs": [ - { - "name": "l1Head_", - "type": "bytes32", - "internalType": "Hash" - } - ], - "stateMutability": "pure" - }, - { - "type": "function", - "name": "l2BlockNumber", - "inputs": [], - "outputs": [ - { - "name": "l2BlockNumber_", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "pure" - }, - { - "type": "function", - "name": "l2BlockNumberChallenged", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "bool", - "internalType": "bool" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "l2BlockNumberChallenger", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "l2ChainId", - "inputs": [], - "outputs": [ - { - "name": "l2ChainId_", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "maxAttackBranch", - "inputs": [], - "outputs": [ - { - "name": "maxAttackBranch_", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "maxClockDuration", - "inputs": [], - "outputs": [ - { - "name": "maxClockDuration_", - "type": "uint64", - "internalType": "Duration" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "maxGameDepth", - "inputs": [], - "outputs": [ - { - "name": "maxGameDepth_", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "move", - "inputs": [ - { - "name": "_disputed", - "type": "bytes32", - "internalType": "Claim" - }, - { - "name": "_challengeIndex", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "_claim", - "type": "bytes32", - "internalType": "Claim" - }, - { - "name": "_isAttack", - "type": "bool", - "internalType": "bool" - } - ], - "outputs": [], - "stateMutability": "payable" - }, - { - "type": "function", - "name": "nBits", - "inputs": [], - "outputs": [ - { - "name": "nBits_", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "resolutionCheckpoints", - "inputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [ - { - "name": "initialCheckpointComplete", - "type": "bool", - "internalType": "bool" - }, - { - "name": "subgameIndex", - "type": "uint32", - "internalType": "uint32" - }, - { - "name": "leftmostPosition", - "type": "uint128", - "internalType": "Position" - }, - { - "name": "counteredBy", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "resolve", - "inputs": [], - "outputs": [ - { - "name": "status_", - "type": "uint8", - "internalType": "enum GameStatus" - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "resolveClaim", - "inputs": [ - { - "name": "_claimIndex", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "_numToResolve", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "resolvedAt", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "uint64", - "internalType": "Timestamp" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "resolvedSubgames", - "inputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [ - { - "name": "", - "type": "bool", - "internalType": "bool" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "rootClaim", - "inputs": [], - "outputs": [ - { - "name": "rootClaim_", - "type": "bytes32", - "internalType": "Claim" - } - ], - "stateMutability": "pure" - }, - { - "type": "function", - "name": "splitDepth", - "inputs": [], - "outputs": [ - { - "name": "splitDepth_", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "startingBlockNumber", - "inputs": [], - "outputs": [ - { - "name": "startingBlockNumber_", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "startingOutputRoot", - "inputs": [], - "outputs": [ - { - "name": "root", - "type": "bytes32", - "internalType": "Hash" - }, - { - "name": "l2BlockNumber", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "startingRootHash", - "inputs": [], - "outputs": [ - { - "name": "startingRootHash_", - "type": "bytes32", - "internalType": "Hash" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "status", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "uint8", - "internalType": "enum GameStatus" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "step", - "inputs": [ - { - "name": "_claimIndex", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "_isAttack", - "type": "bool", - "internalType": "bool" - }, - { - "name": "_stateData", - "type": "bytes", - "internalType": "bytes" - }, - { - "name": "_proof", - "type": "bytes", - "internalType": "bytes" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "stepV2", - "inputs": [ - { - "name": "_claimIndex", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "_attackBranch", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "_stateData", + "internalType": "bytes32" + }, + { + "name": "proof", "type": "bytes", "internalType": "bytes" - }, - { - "name": "_proof", - "type": "tuple", - "internalType": "struct FaultDisputeGame.StepProof", - "components": [ - { - "name": "preStateItem", - "type": "tuple", - "internalType": "struct LibDA.DAItem", - "components": [ - { - "name": "daType", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "dataHash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "proof", - "type": "bytes", - "internalType": "bytes" - } - ] - }, - { - "name": "postStateItem", - "type": "tuple", - "internalType": "struct LibDA.DAItem", - "components": [ - { - "name": "daType", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "dataHash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "proof", - "type": "bytes", - "internalType": "bytes" - } - ] - }, - { - "name": "vmProof", - "type": "bytes", - "internalType": "bytes" - } - ] - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "subgames", - "inputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "string", - "internalType": "string" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "vm", - "inputs": [], - "outputs": [ - { - "name": "vm_", - "type": "address", - "internalType": "contract IBigStepper" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "weth", - "inputs": [], - "outputs": [ - { - "name": "weth_", - "type": "address", - "internalType": "contract IDelayedWETH" - } - ], - "stateMutability": "view" - }, - { - "type": "event", - "name": "Move", - "inputs": [ - { - "name": "parentIndex", - "type": "uint256", - "indexed": true, - "internalType": "uint256" - }, - { - "name": "claim", - "type": "bytes32", - "indexed": true, - "internalType": "Claim" - }, - { - "name": "claimant", - "type": "address", - "indexed": true, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "Resolved", - "inputs": [ - { - "name": "status", - "type": "uint8", - "indexed": true, - "internalType": "enum GameStatus" - } - ], - "anonymous": false - }, - { - "type": "error", - "name": "AlreadyInitialized", - "inputs": [] - }, - { - "type": "error", - "name": "AnchorRootNotFound", - "inputs": [] - }, - { - "type": "error", - "name": "BlockNumberMatches", - "inputs": [] - }, - { - "type": "error", - "name": "BondTransferFailed", - "inputs": [] - }, - { - "type": "error", - "name": "CannotDefendRootClaim", - "inputs": [] - }, - { - "type": "error", - "name": "ClaimAboveSplit", - "inputs": [] - }, - { - "type": "error", - "name": "ClaimAlreadyExists", - "inputs": [] - }, - { - "type": "error", - "name": "ClaimAlreadyResolved", - "inputs": [] - }, - { - "type": "error", - "name": "ClockNotExpired", - "inputs": [] - }, - { - "type": "error", - "name": "ClockTimeExceeded", - "inputs": [] - }, - { - "type": "error", - "name": "ContentLengthMismatch", - "inputs": [] - }, - { - "type": "error", - "name": "DuplicateStep", - "inputs": [] - }, - { - "type": "error", - "name": "EmptyItem", - "inputs": [] - }, - { - "type": "error", - "name": "GameDepthExceeded", - "inputs": [] - }, - { - "type": "error", - "name": "GameNotInProgress", - "inputs": [] - }, - { - "type": "error", - "name": "IncorrectBondAmount", - "inputs": [] - }, - { - "type": "error", - "name": "InvalidClockExtension", - "inputs": [] - }, - { - "type": "error", - "name": "InvalidDataRemainder", - "inputs": [] - }, - { - "type": "error", - "name": "InvalidDisputedClaimIndex", - "inputs": [] - }, - { - "type": "error", - "name": "InvalidHeader", - "inputs": [] - }, - { - "type": "error", - "name": "InvalidHeaderRLP", - "inputs": [] - }, - { - "type": "error", - "name": "InvalidLocalIdent", - "inputs": [] - }, - { - "type": "error", - "name": "InvalidOutputRootProof", - "inputs": [] - }, - { - "type": "error", - "name": "InvalidParent", - "inputs": [] - }, - { - "type": "error", - "name": "InvalidPosition", - "inputs": [] - }, - { - "type": "error", - "name": "InvalidPrestate", - "inputs": [] - }, - { - "type": "error", - "name": "InvalidSplitDepth", - "inputs": [] - }, - { - "type": "error", - "name": "L2BlockNumberChallenged", - "inputs": [] - }, - { - "type": "error", - "name": "MaxDepthTooLarge", - "inputs": [] - }, - { - "type": "error", - "name": "NoCreditToClaim", - "inputs": [] - }, - { - "type": "error", - "name": "NotSupported", - "inputs": [] - }, - { - "type": "error", - "name": "OutOfOrderResolution", - "inputs": [] - }, - { - "type": "error", - "name": "UnexpectedList", - "inputs": [] - }, - { - "type": "error", - "name": "UnexpectedRootClaim", - "inputs": [ - { - "name": "rootClaim", - "type": "bytes32", - "internalType": "Claim" - } + } + ] + }, + { + "name": "vmProof", + "type": "bytes", + "internalType": "bytes" + } ] - }, - { - "type": "error", - "name": "UnexpectedString", - "inputs": [] - }, - { - "type": "error", - "name": "ValidStep", - "inputs": [] - } + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "subgames", + "inputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "version", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "string", + "internalType": "string" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "vm", + "inputs": [], + "outputs": [ + { + "name": "vm_", + "type": "address", + "internalType": "contract IBigStepper" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "weth", + "inputs": [], + "outputs": [ + { + "name": "weth_", + "type": "address", + "internalType": "contract IDelayedWETH" + } + ], + "stateMutability": "view" + }, + { + "type": "event", + "name": "Move", + "inputs": [ + { + "name": "parentIndex", + "type": "uint256", + "indexed": true, + "internalType": "uint256" + }, + { + "name": "claim", + "type": "bytes32", + "indexed": true, + "internalType": "Claim" + }, + { + "name": "claimant", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Resolved", + "inputs": [ + { + "name": "status", + "type": "uint8", + "indexed": true, + "internalType": "enum GameStatus" + } + ], + "anonymous": false + }, + { + "type": "error", + "name": "AlreadyInitialized", + "inputs": [] + }, + { + "type": "error", + "name": "AnchorRootNotFound", + "inputs": [] + }, + { + "type": "error", + "name": "BlockNumberMatches", + "inputs": [] + }, + { + "type": "error", + "name": "BondTransferFailed", + "inputs": [] + }, + { + "type": "error", + "name": "CannotDefendRootClaim", + "inputs": [] + }, + { + "type": "error", + "name": "ClaimAboveSplit", + "inputs": [] + }, + { + "type": "error", + "name": "ClaimAlreadyExists", + "inputs": [] + }, + { + "type": "error", + "name": "ClaimAlreadyResolved", + "inputs": [] + }, + { + "type": "error", + "name": "ClockNotExpired", + "inputs": [] + }, + { + "type": "error", + "name": "ClockTimeExceeded", + "inputs": [] + }, + { + "type": "error", + "name": "ContentLengthMismatch", + "inputs": [] + }, + { + "type": "error", + "name": "DuplicateStep", + "inputs": [] + }, + { + "type": "error", + "name": "EmptyItem", + "inputs": [] + }, + { + "type": "error", + "name": "GameDepthExceeded", + "inputs": [] + }, + { + "type": "error", + "name": "GameNotInProgress", + "inputs": [] + }, + { + "type": "error", + "name": "IncorrectBondAmount", + "inputs": [] + }, + { + "type": "error", + "name": "InvalidClockExtension", + "inputs": [] + }, + { + "type": "error", + "name": "InvalidDataRemainder", + "inputs": [] + }, + { + "type": "error", + "name": "InvalidDisputedClaimIndex", + "inputs": [] + }, + { + "type": "error", + "name": "InvalidHeader", + "inputs": [] + }, + { + "type": "error", + "name": "InvalidHeaderRLP", + "inputs": [] + }, + { + "type": "error", + "name": "InvalidLocalIdent", + "inputs": [] + }, + { + "type": "error", + "name": "InvalidOutputRootProof", + "inputs": [] + }, + { + "type": "error", + "name": "InvalidParent", + "inputs": [] + }, + { + "type": "error", + "name": "InvalidPosition", + "inputs": [] + }, + { + "type": "error", + "name": "InvalidPrestate", + "inputs": [] + }, + { + "type": "error", + "name": "InvalidSplitDepth", + "inputs": [] + }, + { + "type": "error", + "name": "L2BlockNumberChallenged", + "inputs": [] + }, + { + "type": "error", + "name": "MaxDepthTooLarge", + "inputs": [] + }, + { + "type": "error", + "name": "NoCreditToClaim", + "inputs": [] + }, + { + "type": "error", + "name": "NotSupported", + "inputs": [] + }, + { + "type": "error", + "name": "OutOfOrderResolution", + "inputs": [] + }, + { + "type": "error", + "name": "UnexpectedList", + "inputs": [] + }, + { + "type": "error", + "name": "UnexpectedRootClaim", + "inputs": [ + { + "name": "rootClaim", + "type": "bytes32", + "internalType": "Claim" + } + ] + }, + { + "type": "error", + "name": "UnexpectedString", + "inputs": [] + }, + { + "type": "error", + "name": "ValidStep", + "inputs": [] + } ] diff --git a/packages/contracts-bedrock/src/dispute/FaultDisputeGameN.sol b/packages/contracts-bedrock/src/dispute/FaultDisputeGameN.sol index 7a23f8604c47f..d3e1e99fead79 100644 --- a/packages/contracts-bedrock/src/dispute/FaultDisputeGameN.sol +++ b/packages/contracts-bedrock/src/dispute/FaultDisputeGameN.sol @@ -477,7 +477,7 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, ISemver { revert NotSupported(); } - function addLocalData( + function addLocalData2( uint256 _ident, uint256 _execLeafIdx, uint256 _partOffset, @@ -1209,7 +1209,12 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, ISemver { public payable { - Claim claim = Claim.wrap(LibDA.getClaimsHash(_daType, MAX_ATTACK_BRANCH, _claims)); + uint256 nelements = MAX_ATTACK_BRANCH; + ClaimData storage parent = claimData[_parentIndex]; + if (parent.position.depth() == SPLIT_DEPTH) { + nelements = 1; + } + Claim claim = Claim.wrap(LibDA.getClaimsHash(_daType, nelements, _claims)); moveV2(_disputed, _parentIndex, claim, _attackBranch); } diff --git a/packages/contracts-bedrock/test/actors/FaultDisputeActorsN.sol b/packages/contracts-bedrock/test/actors/FaultDisputeActorsN.sol index 60e9620681f0f..c7de8680df5ad 100644 --- a/packages/contracts-bedrock/test/actors/FaultDisputeActorsN.sol +++ b/packages/contracts-bedrock/test/actors/FaultDisputeActorsN.sol @@ -525,7 +525,7 @@ contract HonestDisputeActor is DisputeActor { dataHash: "00000000000000000000000000000000", proof: hex"" }); - GAME.addLocalData({ + GAME.addLocalData2({ _ident: LocalPreimageKey.DISPUTED_L2_BLOCK_NUMBER, _execLeafIdx: challengeIndex, _partOffset: 0, diff --git a/packages/contracts-bedrock/test/dispute/FaultDisputeGameN.t.sol b/packages/contracts-bedrock/test/dispute/FaultDisputeGameN.t.sol index 6b7bc491c2812..390b29024975f 100644 --- a/packages/contracts-bedrock/test/dispute/FaultDisputeGameN.t.sol +++ b/packages/contracts-bedrock/test/dispute/FaultDisputeGameN.t.sol @@ -857,7 +857,7 @@ contract FaultDisputeGameN_Test is FaultDisputeGame_Init { // (,,,, disputed,,) = gameProxy.claimData(3); // gameProxy.attackV2{ value: _getRequiredBondV2(3, 0) }(disputed, 3, _dummyClaim(), 0); - // gameProxy.addLocalData(LocalPreimageKey.DISPUTED_L2_BLOCK_NUMBER, 4, 0); + // gameProxy.addLocalData2(LocalPreimageKey.DISPUTED_L2_BLOCK_NUMBER, 4, 0); // gameProxy.stepV2(4, 0, absolutePrestateData, hex""); // vm.expectRevert(DuplicateStep.selector); @@ -897,7 +897,7 @@ contract FaultDisputeGameN_Test is FaultDisputeGame_Init { // This variable is not used LibDA.DAItem memory localDataItem = LibDA.DAItem({ daType: LibDA.DA_TYPE_CALLDATA, dataHash: "00000000000000000000000000000000", proof: hex"" }); - gameProxy.addLocalData(LocalPreimageKey.DISPUTED_L2_BLOCK_NUMBER, 4, 0, localDataItem); + gameProxy.addLocalData2(LocalPreimageKey.DISPUTED_L2_BLOCK_NUMBER, 4, 0, localDataItem); // This variable is not used LibDA.DAItem memory preStateItem = @@ -956,7 +956,7 @@ contract FaultDisputeGameN_Test is FaultDisputeGame_Init { FaultDisputeGame.StepProof memory stepProof = FaultDisputeGame.StepProof({ preStateItem: preStateItem, postStateItem: postStateItem, vmProof: hex"" }); - gameProxy.addLocalData(LocalPreimageKey.DISPUTED_L2_BLOCK_NUMBER, 4, 1, preStateItem); + gameProxy.addLocalData2(LocalPreimageKey.DISPUTED_L2_BLOCK_NUMBER, 4, 1, preStateItem); gameProxy.stepV2({ _claimIndex: 4, _attackBranch: 1, _stateData: claimData1, _proof: stepProof }); } @@ -1003,7 +1003,7 @@ contract FaultDisputeGameN_Test is FaultDisputeGame_Init { FaultDisputeGame.StepProof memory stepProof = FaultDisputeGame.StepProof({ preStateItem: preStateItem, postStateItem: postStateItem, vmProof: hex"" }); - gameProxy.addLocalData(LocalPreimageKey.DISPUTED_L2_BLOCK_NUMBER, 4, 2, preStateItem); + gameProxy.addLocalData2(LocalPreimageKey.DISPUTED_L2_BLOCK_NUMBER, 4, 2, preStateItem); gameProxy.stepV2({ _claimIndex: 4, _attackBranch: 2, _stateData: claimData2, _proof: stepProof }); } @@ -1051,7 +1051,7 @@ contract FaultDisputeGameN_Test is FaultDisputeGame_Init { FaultDisputeGame.StepProof memory stepProof = FaultDisputeGame.StepProof({ preStateItem: preStateItem, postStateItem: postStateItem, vmProof: hex"" }); - gameProxy.addLocalData(LocalPreimageKey.DISPUTED_L2_BLOCK_NUMBER, 4, 3, preStateItem); + gameProxy.addLocalData2(LocalPreimageKey.DISPUTED_L2_BLOCK_NUMBER, 4, 3, preStateItem); vm.expectRevert(ValidStep.selector); gameProxy.stepV2({ _claimIndex: 4, _attackBranch: 3, _stateData: claimData3, _proof: stepProof }); } @@ -1095,10 +1095,10 @@ contract FaultDisputeGameN_Test is FaultDisputeGame_Init { proof: abi.encodePacked(claim2, claim3) }); (, bytes32 startingOutputRoot) = - gameProxy.addLocalData(LocalPreimageKey.STARTING_OUTPUT_ROOT, 4, 0, startingDataItem); + gameProxy.addLocalData2(LocalPreimageKey.STARTING_OUTPUT_ROOT, 4, 0, startingDataItem); assertEq(startingOutputRoot, gameProxy.startingRootHash().raw()); (, bytes32 disputedOutputRoot) = - gameProxy.addLocalData(LocalPreimageKey.DISPUTED_OUTPUT_ROOT, 4, 0, disputedDataItem); + gameProxy.addLocalData2(LocalPreimageKey.DISPUTED_OUTPUT_ROOT, 4, 0, disputedDataItem); assertEq(disputedOutputRoot, claim1.raw()); } @@ -1144,10 +1144,10 @@ contract FaultDisputeGameN_Test is FaultDisputeGame_Init { proof: abi.encodePacked(claim1, claim3) }); (, bytes32 startingOutputRoot) = - gameProxy.addLocalData(LocalPreimageKey.STARTING_OUTPUT_ROOT, 4, 0, startingDataItem); + gameProxy.addLocalData2(LocalPreimageKey.STARTING_OUTPUT_ROOT, 4, 0, startingDataItem); assertEq(startingOutputRoot, claim1.raw()); (, bytes32 disputedOutputRoot) = - gameProxy.addLocalData(LocalPreimageKey.DISPUTED_OUTPUT_ROOT, 4, 0, disputedDataItem); + gameProxy.addLocalData2(LocalPreimageKey.DISPUTED_OUTPUT_ROOT, 4, 0, disputedDataItem); assertEq(disputedOutputRoot, claim2.raw()); } @@ -1193,10 +1193,10 @@ contract FaultDisputeGameN_Test is FaultDisputeGame_Init { proof: bytes.concat(keccak256(abi.encode(claim1.raw(), claim2.raw()))) }); (, bytes32 startingOutputRoot) = - gameProxy.addLocalData(LocalPreimageKey.STARTING_OUTPUT_ROOT, 4, 0, startingDataItem); + gameProxy.addLocalData2(LocalPreimageKey.STARTING_OUTPUT_ROOT, 4, 0, startingDataItem); assertEq(startingOutputRoot, claim2.raw()); (, bytes32 disputedOutputRoot) = - gameProxy.addLocalData(LocalPreimageKey.DISPUTED_OUTPUT_ROOT, 4, 0, disputedDataItem); + gameProxy.addLocalData2(LocalPreimageKey.DISPUTED_OUTPUT_ROOT, 4, 0, disputedDataItem); assertEq(disputedOutputRoot, claim3.raw()); } @@ -1242,10 +1242,10 @@ contract FaultDisputeGameN_Test is FaultDisputeGame_Init { proof: abi.encodePacked(claim2, claim3) }); (, bytes32 startingOutputRoot) = - gameProxy.addLocalData(LocalPreimageKey.STARTING_OUTPUT_ROOT, 4, 0, startingDataItem); + gameProxy.addLocalData2(LocalPreimageKey.STARTING_OUTPUT_ROOT, 4, 0, startingDataItem); assertEq(startingOutputRoot, claim3.raw()); (, bytes32 disputedOutputRoot) = - gameProxy.addLocalData(LocalPreimageKey.DISPUTED_OUTPUT_ROOT, 4, 0, disputedDataItem); + gameProxy.addLocalData2(LocalPreimageKey.DISPUTED_OUTPUT_ROOT, 4, 0, disputedDataItem); assertEq(disputedOutputRoot, claim1.raw()); } @@ -1287,10 +1287,10 @@ contract FaultDisputeGameN_Test is FaultDisputeGame_Init { }); LibDA.DAItem memory disputedDataItem = startingDataItem; (, bytes32 startingOutputRoot) = - gameProxy.addLocalData(LocalPreimageKey.STARTING_OUTPUT_ROOT, 4, 3, startingDataItem); + gameProxy.addLocalData2(LocalPreimageKey.STARTING_OUTPUT_ROOT, 4, 3, startingDataItem); assertEq(startingOutputRoot, claim3.raw()); (, bytes32 disputedOutputRoot) = - gameProxy.addLocalData(LocalPreimageKey.DISPUTED_OUTPUT_ROOT, 4, 3, disputedDataItem); + gameProxy.addLocalData2(LocalPreimageKey.DISPUTED_OUTPUT_ROOT, 4, 3, disputedDataItem); assertEq(disputedOutputRoot, claim3.raw()); } @@ -1333,10 +1333,10 @@ contract FaultDisputeGameN_Test is FaultDisputeGame_Init { LibDA.DAItem memory disputedDataItem = LibDA.DAItem({ daType: LibDA.DA_TYPE_CALLDATA, dataHash: ROOT_CLAIM.raw(), proof: hex"" }); (, bytes32 startingOutputRoot) = - gameProxy.addLocalData(LocalPreimageKey.STARTING_OUTPUT_ROOT, 4, 3, startingDataItem); + gameProxy.addLocalData2(LocalPreimageKey.STARTING_OUTPUT_ROOT, 4, 3, startingDataItem); assertEq(startingOutputRoot, claim3.raw()); (, bytes32 disputedOutputRoot) = - gameProxy.addLocalData(LocalPreimageKey.DISPUTED_OUTPUT_ROOT, 4, 3, disputedDataItem); + gameProxy.addLocalData2(LocalPreimageKey.DISPUTED_OUTPUT_ROOT, 4, 3, disputedDataItem); assertEq(disputedOutputRoot, ROOT_CLAIM.raw()); } @@ -1611,7 +1611,7 @@ contract FaultDisputeGameN_Test is FaultDisputeGame_Init { // This variable is not used LibDA.DAItem memory localDataItem = LibDA.DAItem({ daType: LibDA.DA_TYPE_CALLDATA, dataHash: "00000000000000000000000000000000", proof: hex"" }); - gameProxy.addLocalData(LocalPreimageKey.DISPUTED_L2_BLOCK_NUMBER, 4, 0, localDataItem); + gameProxy.addLocalData2(LocalPreimageKey.DISPUTED_L2_BLOCK_NUMBER, 4, 0, localDataItem); // This variable is not used LibDA.DAItem memory preStateItem = @@ -1696,7 +1696,7 @@ contract FaultDisputeGameN_Test is FaultDisputeGame_Init { // This variable is not used LibDA.DAItem memory localDataItem = LibDA.DAItem({ daType: LibDA.DA_TYPE_CALLDATA, dataHash: "00000000000000000000000000000000", proof: hex"" }); - gameProxy.addLocalData(LocalPreimageKey.DISPUTED_L2_BLOCK_NUMBER, 4, 0, localDataItem); + gameProxy.addLocalData2(LocalPreimageKey.DISPUTED_L2_BLOCK_NUMBER, 4, 0, localDataItem); // This variable is not used LibDA.DAItem memory preStateItem = @@ -1931,7 +1931,7 @@ contract FaultDisputeGameN_Test is FaultDisputeGame_Init { } /// @dev Tests that adding local data with an out of bounds identifier reverts. - function testFuzz_addLocalData_oob_reverts(uint256 _ident) public { + function testFuzz_addLocalData2_oob_reverts(uint256 _ident) public { Claim disputed; // Get a claim below the split depth so that we can add local data for an execution trace subgame. for (uint256 i; i < 2; i++) { @@ -1950,12 +1950,12 @@ contract FaultDisputeGameN_Test is FaultDisputeGame_Init { LibDA.DAItem memory localDataItem = LibDA.DAItem({ daType: LibDA.DA_TYPE_CALLDATA, dataHash: "00000000000000000000000000000000", proof: hex"" }); vm.expectRevert(InvalidLocalIdent.selector); - gameProxy.addLocalData(_ident, 3, 0, localDataItem); + gameProxy.addLocalData2(_ident, 3, 0, localDataItem); } /// @dev Tests that local data is loaded into the preimage oracle correctly in the subgame /// that is disputing the transition from `GENESIS -> GENESIS + 1` - function test_addLocalDataGenesisTransition_static_succeeds() public { + function test_addLocalData2GenesisTransition_static_succeeds() public { IPreimageOracle oracle = IPreimageOracle(address(gameProxy.vm().oracle())); Claim disputed; Claim[] memory claims = generateClaims(3); @@ -2001,9 +2001,9 @@ contract FaultDisputeGameN_Test is FaultDisputeGame_Init { bytes32 key = _getKey(i, keccak256(abi.encode(disputedClaim.raw(), disputedPos))); if (LocalPreimageKey.DISPUTED_OUTPUT_ROOT == i) { - gameProxy.addLocalData(i, 3, 0, disputedDataItem); + gameProxy.addLocalData2(i, 3, 0, disputedDataItem); } else { - gameProxy.addLocalData(i, 3, 0, startingDataItem); + gameProxy.addLocalData2(i, 3, 0, startingDataItem); } (bytes32 dat, uint256 datLen) = oracle.readPreimage(key, 0); assertEq(dat >> 0xC0, bytes32(expectedLen)); @@ -2015,9 +2015,9 @@ contract FaultDisputeGameN_Test is FaultDisputeGame_Init { assertEq(datLen, expectedLen + (i > 3 ? 8 : 0)); if (LocalPreimageKey.DISPUTED_OUTPUT_ROOT == i) { - gameProxy.addLocalData(i, 3, 8, disputedDataItem); + gameProxy.addLocalData2(i, 3, 8, disputedDataItem); } else { - gameProxy.addLocalData(i, 3, 8, startingDataItem); + gameProxy.addLocalData2(i, 3, 8, startingDataItem); } (dat, datLen) = oracle.readPreimage(key, 8); assertEq(dat, data[i - 1]); @@ -2026,7 +2026,7 @@ contract FaultDisputeGameN_Test is FaultDisputeGame_Init { } /// @dev Tests that local data is loaded into the preimage oracle correctly. - function test_addLocalDataMiddle_static_succeeds() public { + function test_addLocalData2Middle_static_succeeds() public { IPreimageOracle oracle = IPreimageOracle(address(gameProxy.vm().oracle())); Claim[] memory claims = generateClaims(3); Claim root = Claim.wrap( @@ -2073,9 +2073,9 @@ contract FaultDisputeGameN_Test is FaultDisputeGame_Init { bytes32 key = _getKey(i, keccak256(abi.encode(root.raw(), startingPos, root.raw(), disputedPos))); if (LocalPreimageKey.DISPUTED_OUTPUT_ROOT == i) { - gameProxy.addLocalData(i, 3, 0, disputedDataItem); + gameProxy.addLocalData2(i, 3, 0, disputedDataItem); } else { - gameProxy.addLocalData(i, 3, 0, startingDataItem); + gameProxy.addLocalData2(i, 3, 0, startingDataItem); } (bytes32 dat, uint256 datLen) = oracle.readPreimage(key, 0); assertEq(dat >> 0xC0, bytes32(expectedLen)); @@ -2087,9 +2087,9 @@ contract FaultDisputeGameN_Test is FaultDisputeGame_Init { assertEq(datLen, expectedLen + (i > 3 ? 8 : 0)); if (LocalPreimageKey.DISPUTED_OUTPUT_ROOT == i) { - gameProxy.addLocalData(i, 3, 8, disputedDataItem); + gameProxy.addLocalData2(i, 3, 8, disputedDataItem); } else { - gameProxy.addLocalData(i, 3, 8, startingDataItem); + gameProxy.addLocalData2(i, 3, 8, startingDataItem); } (dat, datLen) = oracle.readPreimage(key, 8); assertEq(dat, data[i - 1]); @@ -2262,7 +2262,7 @@ contract FaultDisputeGameN_Test is FaultDisputeGame_Init { LibDA.DAItem memory dummyDataItem = LibDA.DAItem({ daType: LibDA.DA_TYPE_CALLDATA, dataHash: _dummyClaim().raw(), proof: hex"" }); - gameProxy.addLocalData(LocalPreimageKey.DISPUTED_L2_BLOCK_NUMBER, 4, 2, dummyDataItem); + gameProxy.addLocalData2(LocalPreimageKey.DISPUTED_L2_BLOCK_NUMBER, 4, 2, dummyDataItem); LibDA.DAItem memory preStateItem = LibDA.DAItem({ daType: LibDA.DA_TYPE_CALLDATA, @@ -2357,7 +2357,7 @@ contract FaultDisputeGameN_LessSplitDepth_Test is FaultDisputeGame_Init { FaultDisputeGame.StepProof memory stepProof = FaultDisputeGame.StepProof({ preStateItem: preStateItem, postStateItem: postStateItem, vmProof: hex"" }); - gameProxy.addLocalData(LocalPreimageKey.DISPUTED_L2_BLOCK_NUMBER, 4, 3, preStateItem); + gameProxy.addLocalData2(LocalPreimageKey.DISPUTED_L2_BLOCK_NUMBER, 4, 3, preStateItem); gameProxy.stepV2({ _claimIndex: 4, _attackBranch: 3, _stateData: claimData6, _proof: stepProof }); } @@ -2411,7 +2411,7 @@ contract FaultDisputeGameN_LessSplitDepth_Test is FaultDisputeGame_Init { FaultDisputeGame.StepProof memory stepProof = FaultDisputeGame.StepProof({ preStateItem: preStateItem, postStateItem: postStateItem, vmProof: hex"" }); - gameProxy.addLocalData(LocalPreimageKey.DISPUTED_L2_BLOCK_NUMBER, 4, 3, preStateItem); + gameProxy.addLocalData2(LocalPreimageKey.DISPUTED_L2_BLOCK_NUMBER, 4, 3, preStateItem); vm.expectRevert(ValidStep.selector); gameProxy.stepV2({ _claimIndex: 4, _attackBranch: 3, _stateData: claimData6, _proof: stepProof }); } @@ -2464,7 +2464,7 @@ contract FaultDisputeGameN_LessSplitDepth_Test is FaultDisputeGame_Init { FaultDisputeGame.StepProof memory stepProof = FaultDisputeGame.StepProof({ preStateItem: preStateItem, postStateItem: postStateItem, vmProof: hex"" }); - gameProxy.addLocalData(LocalPreimageKey.DISPUTED_L2_BLOCK_NUMBER, 4, 3, preStateItem); + gameProxy.addLocalData2(LocalPreimageKey.DISPUTED_L2_BLOCK_NUMBER, 4, 3, preStateItem); gameProxy.stepV2({ _claimIndex: 4, _attackBranch: 3, _stateData: claimData6, _proof: stepProof }); }