Skip to content

Commit

Permalink
feat: Move DEFAULT_STARTING_ANCHOR_ROOTS to Constants library
Browse files Browse the repository at this point in the history
  • Loading branch information
maurelian committed Oct 4, 2024
1 parent c814258 commit dad7e0d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
11 changes: 3 additions & 8 deletions packages/contracts-bedrock/scripts/DeployOPChain.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,10 @@ contract DeployOPChainInput is BaseDeployIO {
// because to to update to the permissionless game, we will need to update its starting
// anchor root and deploy a new permissioned dispute game contract anyway.
//
// You can `console.logBytes(abi.encode(defaultStartingAnchorRoots))` to get the bytes that
// You can `console.logBytes(abi.encode(Constants.DEFAULT_STARTING_ANCHOR_ROOTS()))` to get the bytes that
// are hardcoded into `op-chain-ops/deployer/opcm/opchain.go`
IAnchorStateRegistry.StartingAnchorRoot[] memory defaultStartingAnchorRoots =
new IAnchorStateRegistry.StartingAnchorRoot[](1);
defaultStartingAnchorRoots[0] = IAnchorStateRegistry.StartingAnchorRoot({
gameType: GameTypes.PERMISSIONED_CANNON,
outputRoot: OutputRoot({ root: Hash.wrap(bytes32(hex"dead")), l2BlockNumber: 0 })
});
return abi.encode(defaultStartingAnchorRoots);

return abi.encode(Constants.DEFAULT_STARTING_ANCHOR_ROOTS());
}

function opcmProxy() public returns (OPContractsManager) {
Expand Down
12 changes: 12 additions & 0 deletions packages/contracts-bedrock/src/libraries/Constants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
pragma solidity ^0.8.0;

import { IResourceMetering } from "src/L1/interfaces/IResourceMetering.sol";
import { IAnchorStateRegistry } from "src/dispute/interfaces/IAnchorStateRegistry.sol";
import { GameTypes, OutputRoot, Hash } from "src/dispute/lib/Types.sol";

/// @title Constants
/// @notice Constants is a library for storing constants. Simple! Don't put everything in here, just
Expand Down Expand Up @@ -50,4 +52,14 @@ library Constants {
});
return config;
}

function DEFAULT_STARTING_ANCHOR_ROOTS() internal pure returns (IAnchorStateRegistry.StartingAnchorRoot[] memory) {
IAnchorStateRegistry.StartingAnchorRoot[] memory defaultStartingAnchorRoots =
new IAnchorStateRegistry.StartingAnchorRoot[](1);
defaultStartingAnchorRoots[0] = IAnchorStateRegistry.StartingAnchorRoot({
gameType: GameTypes.PERMISSIONED_CANNON,
outputRoot: OutputRoot({ root: Hash.wrap(bytes32(hex"dead")), l2BlockNumber: 0 })
});
return defaultStartingAnchorRoots;
}
}

0 comments on commit dad7e0d

Please sign in to comment.