Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 35 additions & 4 deletions op-bindings/bindings/outputbisectiongame.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion op-bindings/bindings/outputbisectiongame_more.go

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions op-chain-ops/genesis/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ type DeployConfig struct {
FaultGameMaxDuration uint64 `json:"faultGameMaxDuration"`
// OutputBisectionGameGenesisBlock is the block number for genesis.
OutputBisectionGameGenesisBlock uint64 `json:"outputBisectionGameGenesisBlock"`
// OutputBisectionGameGenesisOutputRoot is the output root for the genesis block.
OutputBisectionGameGenesisOutputRoot common.Hash `json:"outputBisectionGameGenesisOutputRoot"`
// OutputBisectionGameSplitDepth is the depth at which the output bisection game splits.
OutputBisectionGameSplitDepth uint64 `json:"outputBisectionGameSplitDepth"`
// FundDevAccounts configures whether or not to fund the dev accounts. Should only be used
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"faultGameMaxDepth": 63,
"faultGameMaxDuration": 604800,
"outputBisectionGameGenesisBlock": 0,
"outputBisectionGameGenesisOutputRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
"outputBisectionGameSplitDepth": 0,
"systemConfigStartBlock": 0,
"requiredProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000000",
Expand Down
6 changes: 5 additions & 1 deletion op-challenger/game/fault/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@ func registerOutputCannon(
if err != nil {
return nil, err
}
accessor, err := outputs.NewOutputCannonTraceAccessor(ctx, logger, m, cfg, l2Client, contract, dir, gameDepth, agreed, disputed)
splitDepth, err := contract.GetSplitDepth(ctx)
if err != nil {
return nil, fmt.Errorf("failed to load split depth: %w", err)
}
accessor, err := outputs.NewOutputCannonTraceAccessor(ctx, logger, m, cfg, l2Client, contract, dir, gameDepth, splitDepth, agreed, disputed)
if err != nil {
return nil, err
}
Expand Down
9 changes: 4 additions & 5 deletions op-challenger/game/fault/trace/outputs/output_cannon.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@ func NewOutputCannonTraceAccessor(
contract cannon.L1HeadSource,
dir string,
gameDepth uint64,
splitDepth uint64,
prestateBlock uint64,
poststateBlock uint64,
) (*trace.Accessor, error) {
// TODO(client-pod#43): Load depths from the contract
topDepth := gameDepth / 2
bottomDepth := gameDepth - topDepth
outputProvider, err := NewTraceProvider(ctx, logger, cfg.RollupRpc, topDepth, prestateBlock, poststateBlock)
bottomDepth := gameDepth - splitDepth
outputProvider, err := NewTraceProvider(ctx, logger, cfg.RollupRpc, splitDepth, prestateBlock, poststateBlock)
if err != nil {
return nil, err
}
Expand All @@ -48,6 +47,6 @@ func NewOutputCannonTraceAccessor(
}

cache := NewProviderCache(m, "output_cannon_provider", cannonCreator)
selector := split.NewSplitProviderSelector(outputProvider, int(topDepth), OutputRootSplitAdapter(outputProvider, cache.GetOrCreate))
selector := split.NewSplitProviderSelector(outputProvider, int(splitDepth), OutputRootSplitAdapter(outputProvider, cache.GetOrCreate))
return trace.NewAccessor(selector), nil
}
14 changes: 13 additions & 1 deletion op-e2e/e2eutils/disputegame/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ func (h *FactoryHelper) StartAlphabetGame(ctx context.Context, claimedAlphabet s
func (h *FactoryHelper) StartOutputCannonGame(ctx context.Context, rollupEndpoint string, rootClaim common.Hash) *OutputCannonGameHelper {
rollupClient, err := dial.DialRollupClientWithTimeout(ctx, 30*time.Second, testlog.Logger(h.t, log.LvlInfo), rollupEndpoint)
h.require.NoError(err)
h.t.Cleanup(rollupClient.Close)

extraData, _ := h.createBisectionGameExtraData(ctx, rollupClient)

Expand Down Expand Up @@ -279,11 +280,22 @@ func (h *FactoryHelper) createCannonGame(ctx context.Context, rootClaim common.H
}

func (h *FactoryHelper) createBisectionGameExtraData(ctx context.Context, client *sources.RollupClient) (extraData []byte, l2BlockNumber uint64) {
timeoutCtx, cancel := context.WithTimeout(ctx, 1*time.Minute)
defer cancel()
err := wait.For(timeoutCtx, time.Second, func() (bool, error) {
status, err := client.SyncStatus(ctx)
if err != nil {
return false, err
}
return status.SafeL2.Number > 0, nil
})
h.require.NoError(err, "Safe head did not progress past genesis")
syncStatus, err := client.SyncStatus(ctx)
h.require.NoError(err, "failed to get sync status")
l2BlockNumber = syncStatus.SafeL2.Number
h.t.Logf("Creating game with l2 block number: %v", l2BlockNumber)
extraData = make([]byte, 32)
binary.BigEndian.PutUint64(extraData, l2BlockNumber)
binary.BigEndian.PutUint64(extraData[24:], l2BlockNumber)
return
}

Expand Down
6 changes: 4 additions & 2 deletions op-e2e/e2eutils/disputegame/output_game_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,10 +402,12 @@ func (g *OutputGameHelper) gameData(ctx context.Context) string {
info = info + fmt.Sprintf("%v - Position: %v, Depth: %v, IndexAtDepth: %v Trace Index: %v, Value: %v, Countered: %v, ParentIndex: %v\n",
i, claim.Position.Int64(), pos.Depth(), pos.IndexAtDepth(), pos.TraceIndex(maxDepth), common.Hash(claim.Claim).Hex(), claim.Countered, claim.ParentIndex)
}
l2BlockNum, err := g.game.L2BlockNumber(opts)
g.require.NoError(err, "Load l2 block number")
status, err := g.game.Status(opts)
g.require.NoError(err, "Load game status")
return fmt.Sprintf("Game %v - %v - Split Depth: %v - Max Depth: %v:\n%v\n",
g.addr, Status(status), splitDepth, maxDepth, info)
return fmt.Sprintf("Game %v - %v - L2 Block: %v - Split Depth: %v - Max Depth: %v:\n%v\n",
g.addr, Status(status), l2BlockNum.Uint64(), splitDepth, maxDepth, info)
}

func (g *OutputGameHelper) LogGameData(ctx context.Context) {
Expand Down
8 changes: 2 additions & 6 deletions op-e2e/faultproofs/output_cannon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,8 @@ func TestOutputCannonGame(t *testing.T) {
game.Attack(ctx, i, common.Hash{0xaa})
game.LogGameData(ctx)
}
game.WaitForCorrectOutputRoot(ctx, splitDepth)

// Post the first cannon output root (with 01 status code to show the output root is invalid)
game.Attack(ctx, splitDepth, common.Hash{0x01})

// Challenger should counter
game.WaitForClaimAtDepth(ctx, int(splitDepth+2))
// Wait for the challenger to post the first claim in the cannon trace
game.WaitForClaimAtDepth(ctx, int(splitDepth+1))
game.LogGameData(ctx)
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@
"l2GenesisDeltaTimeOffset": null,
"l2GenesisCanyonTimeOffset": "0x0",
"faultGameAbsolutePrestate": "0x03c7ae758795765c6664a5d39bf63841c71ff191e9189522bad8ebff5d4eca98",
"faultGameMaxDepth": 30,
"faultGameMaxDepth": 44,
"faultGameMaxDuration": 1200,
"outputBisectionGameGenesisBlock": 0,
"outputBisectionGameSplitDepth": 15,
"outputBisectionGameGenesisOutputRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
"outputBisectionGameSplitDepth": 14,
"systemConfigStartBlock": 0,
"requiredProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000000",
"recommendedProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000000"
Expand Down
5 changes: 3 additions & 2 deletions packages/contracts-bedrock/scripts/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1027,8 +1027,8 @@ contract Deploy is Deployer {
_gameType: GameTypes.FAULT,
_absolutePrestate: loadMipsAbsolutePrestate(),
_faultVm: IBigStepper(mustGetAddress("Mips")),
_maxGameDepth: cfg.faultGameMaxDepth()
});
_maxGameDepth: 30 // Hard code depth for legacy game to keep e2e tests fast
});
}

/// @notice Sets the implementation for the `OUTPUT_CANNON` game type in the `DisputeGameFactory`
Expand Down Expand Up @@ -1106,6 +1106,7 @@ contract Deploy is Deployer {
_gameType: _gameType,
_absolutePrestate: _absolutePrestate,
_genesisBlockNumber: cfg.outputBisectionGameGenesisBlock(),
_genesisOutputRoot: Hash.wrap(cfg.outputBisectionGameGenesisOutputRoot()),
_maxGameDepth: _maxGameDepth,
_splitDepth: cfg.outputBisectionGameSplitDepth(),
_gameDuration: Duration.wrap(uint64(cfg.faultGameMaxDuration())),
Expand Down
2 changes: 2 additions & 0 deletions packages/contracts-bedrock/scripts/DeployConfig.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ contract DeployConfig is Script {
uint256 public faultGameMaxDepth;
uint256 public faultGameMaxDuration;
uint256 public outputBisectionGameGenesisBlock;
bytes32 public outputBisectionGameGenesisOutputRoot;
uint256 public outputBisectionGameSplitDepth;
uint256 public systemConfigStartBlock;
uint256 public requiredProtocolVersion;
Expand Down Expand Up @@ -107,6 +108,7 @@ contract DeployConfig is Script {
faultGameMaxDepth = stdJson.readUint(_json, "$.faultGameMaxDepth");
faultGameMaxDuration = stdJson.readUint(_json, "$.faultGameMaxDuration");
outputBisectionGameGenesisBlock = stdJson.readUint(_json, "$.outputBisectionGameGenesisBlock");
outputBisectionGameGenesisOutputRoot = stdJson.readBytes32(_json, "$.outputBisectionGameGenesisOutputRoot");
outputBisectionGameSplitDepth = stdJson.readUint(_json, "$.outputBisectionGameSplitDepth");
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts-bedrock/semver-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@
"sourceCodeHash": "0x1d0cacaf259aff7802aae91a793e3c7234a4d063614cf9c72176fb04738e7c97"
},
"src/dispute/OutputBisectionGame.sol": {
"initCodeHash": "0xc5ac9d76d7c46ccc073f3e5d74a78253bf2f627b04af9b2e3c86803c44890075",
"sourceCodeHash": "0x68df25016fa101a9d40e5d00f839dd053e7b5aa0c73c06c61d483cdfda0be124"
"initCodeHash": "0x400a99278755979b815712d1d26598463dd98ed193df8cd1736ae2ae5831d7c7",
"sourceCodeHash": "0x7e267ad18eb946a0242df41ba044c5ee6f0b456e74bef07605a7dd2eb5b3ed01"
},
"src/legacy/DeployerWhitelist.sol": {
"initCodeHash": "0x8de80fb23b26dd9d849f6328e56ea7c173cd9e9ce1f05c9beea559d1720deb3d",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
"name": "_genesisBlockNumber",
"type": "uint256"
},
{
"internalType": "Hash",
"name": "_genesisOutputRoot",
"type": "bytes32"
},
{
"internalType": "uint256",
"name": "_maxGameDepth",
Expand Down Expand Up @@ -198,6 +203,19 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "GENESIS_OUTPUT_ROOT",
"outputs": [
{
"internalType": "Hash",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "MAX_GAME_DEPTH",
Expand Down
Loading