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
81 changes: 29 additions & 52 deletions packages/contracts-bedrock/scripts/deploy/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,6 @@ import { IPreimageOracle } from "src/cannon/interfaces/IPreimageOracle.sol";
contract Deploy is Deployer {
using stdJson for string;

/// @notice FaultDisputeGameParams is a struct that contains the parameters necessary to call
/// the function _setFaultGameImplementation. This struct exists because the EVM needs
/// to finally adopt PUSHN and get rid of stack too deep once and for all.
/// Someday we will look back and laugh about stack too deep, today is not that day.
struct FaultDisputeGameParams {
IAnchorStateRegistry anchorStateRegistry;
IDelayedWETH weth;
GameType gameType;
Claim absolutePrestate;
IBigStepper faultVm;
uint256 maxGameDepth;
Duration maxClockDuration;
}

////////////////////////////////////////////////////////////////
// Modifiers //
////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -871,14 +857,17 @@ contract Deploy is Deployer {
// Set the Cannon FaultDisputeGame implementation in the factory.
_setFaultGameImplementation({
_factory: factory,
_params: FaultDisputeGameParams({
anchorStateRegistry: IAnchorStateRegistry(mustGetAddress("AnchorStateRegistryProxy")),
weth: weth,
_params: IFaultDisputeGame.GameConstructorParams({
gameType: GameTypes.CANNON,
absolutePrestate: loadMipsAbsolutePrestate(),
faultVm: IBigStepper(mustGetAddress("Mips")),
maxGameDepth: cfg.faultGameMaxDepth(),
maxClockDuration: Duration.wrap(uint64(cfg.faultGameMaxClockDuration()))
splitDepth: cfg.faultGameSplitDepth(),
clockExtension: Duration.wrap(uint64(cfg.faultGameClockExtension())),
maxClockDuration: Duration.wrap(uint64(cfg.faultGameMaxClockDuration())),
vm: IBigStepper(mustGetAddress("Mips")),
weth: weth,
anchorStateRegistry: IAnchorStateRegistry(mustGetAddress("AnchorStateRegistryProxy")),
l2ChainId: cfg.l2ChainID()
})
});
}
Expand All @@ -892,15 +881,18 @@ contract Deploy is Deployer {
Claim outputAbsolutePrestate = Claim.wrap(bytes32(cfg.faultGameAbsolutePrestate()));
_setFaultGameImplementation({
_factory: factory,
_params: FaultDisputeGameParams({
anchorStateRegistry: IAnchorStateRegistry(mustGetAddress("AnchorStateRegistryProxy")),
weth: weth,
_params: IFaultDisputeGame.GameConstructorParams({
gameType: GameTypes.ALPHABET,
absolutePrestate: outputAbsolutePrestate,
faultVm: IBigStepper(new AlphabetVM(outputAbsolutePrestate, IPreimageOracle(mustGetAddress("PreimageOracle")))),
// The max depth for the alphabet trace is always 3. Add 1 because split depth is fully inclusive.
maxGameDepth: cfg.faultGameSplitDepth() + 3 + 1,
maxClockDuration: Duration.wrap(uint64(cfg.faultGameMaxClockDuration()))
splitDepth: cfg.faultGameSplitDepth(),
clockExtension: Duration.wrap(uint64(cfg.faultGameClockExtension())),
maxClockDuration: Duration.wrap(uint64(cfg.faultGameMaxClockDuration())),
vm: IBigStepper(new AlphabetVM(outputAbsolutePrestate, IPreimageOracle(mustGetAddress("PreimageOracle")))),
weth: weth,
anchorStateRegistry: IAnchorStateRegistry(mustGetAddress("AnchorStateRegistryProxy")),
l2ChainId: cfg.l2ChainID()
})
});
}
Expand All @@ -925,23 +917,26 @@ contract Deploy is Deployer {
);
_setFaultGameImplementation({
_factory: factory,
_params: FaultDisputeGameParams({
anchorStateRegistry: IAnchorStateRegistry(mustGetAddress("AnchorStateRegistryProxy")),
weth: weth,
_params: IFaultDisputeGame.GameConstructorParams({
gameType: GameTypes.FAST,
absolutePrestate: outputAbsolutePrestate,
faultVm: IBigStepper(new AlphabetVM(outputAbsolutePrestate, fastOracle)),
// The max depth for the alphabet trace is always 3. Add 1 because split depth is fully inclusive.
maxGameDepth: cfg.faultGameSplitDepth() + 3 + 1,
maxClockDuration: Duration.wrap(0) // Resolvable immediately
})
splitDepth: cfg.faultGameSplitDepth(),
clockExtension: Duration.wrap(uint64(cfg.faultGameClockExtension())),
maxClockDuration: Duration.wrap(0), // Resolvable immediately
vm: IBigStepper(new AlphabetVM(outputAbsolutePrestate, fastOracle)),
weth: weth,
anchorStateRegistry: IAnchorStateRegistry(mustGetAddress("AnchorStateRegistryProxy")),
l2ChainId: cfg.l2ChainID()
})
});
}

/// @notice Sets the implementation for the given fault game type in the `DisputeGameFactory`.
function _setFaultGameImplementation(
IDisputeGameFactory _factory,
FaultDisputeGameParams memory _params
IFaultDisputeGame.GameConstructorParams memory _params
)
internal
{
Expand All @@ -954,37 +949,19 @@ contract Deploy is Deployer {
}

uint32 rawGameType = GameType.unwrap(_params.gameType);

// Redefine _param variable to avoid stack too deep error during compilation
FaultDisputeGameParams memory _params_ = _params;
require(
rawGameType != GameTypes.PERMISSIONED_CANNON.raw(), "Deploy: Permissioned Game should be deployed by OPCM"
);

_factory.setImplementation(
_params_.gameType,
_params.gameType,
IDisputeGame(
DeployUtils.create2AndSave({
_save: this,
_salt: _implSalt(),
_name: "FaultDisputeGame",
_nick: string.concat("FaultDisputeGame_", vm.toString(rawGameType)),
_args: DeployUtils.encodeConstructor(
abi.encodeCall(
IFaultDisputeGame.__constructor__,
(
_params_.gameType,
_params_.absolutePrestate,
_params_.maxGameDepth,
cfg.faultGameSplitDepth(),
Duration.wrap(uint64(cfg.faultGameClockExtension())),
_params_.maxClockDuration,
_params_.faultVm,
_params_.weth,
IAnchorStateRegistry(mustGetAddress("AnchorStateRegistryProxy")),
cfg.l2ChainID()
)
)
)
_args: DeployUtils.encodeConstructor(abi.encodeCall(IFaultDisputeGame.__constructor__, (_params)))
})
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,19 +270,17 @@ contract DeployDisputeGame is Script {

function deployDisputeGameImpl(DeployDisputeGameInput _dgi, DeployDisputeGameOutput _dgo) internal {
// Shove the arguments into a struct to avoid stack-too-deep errors.
DisputeGameConstructorArgs memory args = DisputeGameConstructorArgs({
IFaultDisputeGame.GameConstructorParams memory args = IFaultDisputeGame.GameConstructorParams({
gameType: GameType.wrap(uint32(_dgi.gameType())),
absolutePrestate: Claim.wrap(_dgi.absolutePrestate()),
maxGameDepth: _dgi.maxGameDepth(),
splitDepth: _dgi.splitDepth(),
clockExtension: Duration.wrap(uint64(_dgi.clockExtension())),
maxClockDuration: Duration.wrap(uint64(_dgi.maxClockDuration())),
gameVm: IBigStepper(address(_dgi.vmAddress())),
delayedWethProxy: _dgi.delayedWethProxy(),
anchorStateRegistryProxy: _dgi.anchorStateRegistryProxy(),
l2ChainId: _dgi.l2ChainId(),
proposer: _dgi.proposer(),
challenger: _dgi.challenger()
vm: IBigStepper(address(_dgi.vmAddress())),
weth: _dgi.delayedWethProxy(),
anchorStateRegistry: _dgi.anchorStateRegistryProxy(),
l2ChainId: _dgi.l2ChainId()
});

// PermissionedDisputeGame is used as the type here because it is a superset of
Expand All @@ -294,47 +292,15 @@ contract DeployDisputeGame is Script {
impl = IPermissionedDisputeGame(
DeployUtils.create1({
_name: "FaultDisputeGame",
_args: DeployUtils.encodeConstructor(
abi.encodeCall(
IFaultDisputeGame.__constructor__,
(
args.gameType,
args.absolutePrestate,
args.maxGameDepth,
args.splitDepth,
args.clockExtension,
args.maxClockDuration,
args.gameVm,
args.delayedWethProxy,
args.anchorStateRegistryProxy,
args.l2ChainId
)
)
)
_args: DeployUtils.encodeConstructor(abi.encodeCall(IFaultDisputeGame.__constructor__, (args)))
})
);
} else {
impl = IPermissionedDisputeGame(
DeployUtils.create1({
_name: "PermissionedDisputeGame",
_args: DeployUtils.encodeConstructor(
abi.encodeCall(
IPermissionedDisputeGame.__constructor__,
(
args.gameType,
args.absolutePrestate,
args.maxGameDepth,
args.splitDepth,
args.clockExtension,
args.maxClockDuration,
args.gameVm,
args.delayedWethProxy,
args.anchorStateRegistryProxy,
args.l2ChainId,
args.proposer,
args.challenger
)
)
abi.encodeCall(IPermissionedDisputeGame.__constructor__, (args, _dgi.proposer(), _dgi.challenger()))
)
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,18 @@ contract DeployUpgrade is Deployer {
bytes memory constructorInput = abi.encodeCall(
IFaultDisputeGame.__constructor__,
(
GameTypes.CANNON,
Claim.wrap(bytes32(cfg.faultGameAbsolutePrestate())),
cfg.faultGameMaxDepth(),
cfg.faultGameSplitDepth(),
Duration.wrap(uint64(cfg.faultGameClockExtension())),
Duration.wrap(uint64(cfg.faultGameMaxClockDuration())),
IBigStepper(mustGetAddress("MIPS")),
IDelayedWETH(payable(mustGetAddress("DelayedWETHProxyFDG"))),
IAnchorStateRegistry(mustGetAddress("AnchorStateRegistry")),
cfg.l2ChainID()
IFaultDisputeGame.GameConstructorParams({
gameType: GameTypes.CANNON,
absolutePrestate: Claim.wrap(bytes32(cfg.faultGameAbsolutePrestate())),
maxGameDepth: cfg.faultGameMaxDepth(),
splitDepth: cfg.faultGameSplitDepth(),
clockExtension: Duration.wrap(uint64(cfg.faultGameClockExtension())),
maxClockDuration: Duration.wrap(uint64(cfg.faultGameMaxClockDuration())),
vm: IBigStepper(mustGetAddress("MIPS")),
weth: IDelayedWETH(payable(mustGetAddress("DelayedWETHProxyFDG"))),
anchorStateRegistry: IAnchorStateRegistry(mustGetAddress("AnchorStateRegistry")),
l2ChainId: cfg.l2ChainID()
})
)
);

Expand Down Expand Up @@ -197,16 +199,18 @@ contract DeployUpgrade is Deployer {
bytes memory constructorInput = abi.encodeCall(
IPermissionedDisputeGame.__constructor__,
(
GameTypes.PERMISSIONED_CANNON,
Claim.wrap(bytes32(cfg.faultGameAbsolutePrestate())),
cfg.faultGameMaxDepth(),
cfg.faultGameSplitDepth(),
Duration.wrap(uint64(cfg.faultGameClockExtension())),
Duration.wrap(uint64(cfg.faultGameMaxClockDuration())),
IBigStepper(mustGetAddress("MIPS")),
IDelayedWETH(payable(mustGetAddress("DelayedWETHProxyPDG"))),
IAnchorStateRegistry(mustGetAddress("AnchorStateRegistry")),
cfg.l2ChainID(),
IFaultDisputeGame.GameConstructorParams({
gameType: GameTypes.PERMISSIONED_CANNON,
absolutePrestate: Claim.wrap(bytes32(cfg.faultGameAbsolutePrestate())),
maxGameDepth: cfg.faultGameMaxDepth(),
splitDepth: cfg.faultGameSplitDepth(),
clockExtension: Duration.wrap(uint64(cfg.faultGameClockExtension())),
maxClockDuration: Duration.wrap(uint64(cfg.faultGameMaxClockDuration())),
vm: IBigStepper(mustGetAddress("MIPS")),
weth: IDelayedWETH(payable(mustGetAddress("DelayedWETHProxyPDG"))),
anchorStateRegistry: IAnchorStateRegistry(mustGetAddress("AnchorStateRegistry")),
l2ChainId: cfg.l2ChainID()
}),
cfg.l2OutputOracleProposer(),
cfg.l2OutputOracleChallenger()
)
Expand Down
103 changes: 55 additions & 48 deletions packages/contracts-bedrock/snapshots/abi/FaultDisputeGame.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,61 @@
{
"inputs": [
{
"internalType": "GameType",
"name": "_gameType",
"type": "uint32"
},
{
"internalType": "Claim",
"name": "_absolutePrestate",
"type": "bytes32"
},
{
"internalType": "uint256",
"name": "_maxGameDepth",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_splitDepth",
"type": "uint256"
},
{
"internalType": "Duration",
"name": "_clockExtension",
"type": "uint64"
},
{
"internalType": "Duration",
"name": "_maxClockDuration",
"type": "uint64"
},
{
"internalType": "contract IBigStepper",
"name": "_vm",
"type": "address"
},
{
"internalType": "contract IDelayedWETH",
"name": "_weth",
"type": "address"
},
{
"internalType": "contract IAnchorStateRegistry",
"name": "_anchorStateRegistry",
"type": "address"
},
{
"internalType": "uint256",
"name": "_l2ChainId",
"type": "uint256"
"components": [
{
"internalType": "GameType",
"name": "gameType",
"type": "uint32"
},
{
"internalType": "Claim",
"name": "absolutePrestate",
"type": "bytes32"
},
{
"internalType": "uint256",
"name": "maxGameDepth",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "splitDepth",
"type": "uint256"
},
{
"internalType": "Duration",
"name": "clockExtension",
"type": "uint64"
},
{
"internalType": "Duration",
"name": "maxClockDuration",
"type": "uint64"
},
{
"internalType": "contract IBigStepper",
"name": "vm",
"type": "address"
},
{
"internalType": "contract IDelayedWETH",
"name": "weth",
"type": "address"
},
{
"internalType": "contract IAnchorStateRegistry",
"name": "anchorStateRegistry",
"type": "address"
},
{
"internalType": "uint256",
"name": "l2ChainId",
"type": "uint256"
}
],
"internalType": "struct FaultDisputeGame.GameConstructorParams",
"name": "_params",
"type": "tuple"
}
],
"stateMutability": "nonpayable",
Expand Down
Loading