Skip to content

Commit

Permalink
feat(ctb): FPAC ops (#8877)
Browse files Browse the repository at this point in the history
* FPAC ops

* bindings

* Update packages/contracts-bedrock/scripts/fpac/README.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* `just` -> `make`

* @refcell Makefile help

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
clabby and coderabbitai[bot] authored Jan 9, 2024
1 parent 1b5413b commit 320fe93
Show file tree
Hide file tree
Showing 11 changed files with 219 additions and 22 deletions.
2 changes: 1 addition & 1 deletion op-bindings/bindings/mips_more.go

Large diffs are not rendered by default.

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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@
"l2GenesisRegolithTimeOffset": "0x0",
"l2GenesisDeltaTimeOffset": null,
"l2GenesisCanyonTimeOffset": "0x0",
"systemConfigStartBlock": 0,
"requiredProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000000",
"recommendedProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000000",
"faultGameAbsolutePrestate": "0x03c7ae758795765c6664a5d39bf63841c71ff191e9189522bad8ebff5d4eca98",
"faultGameMaxDepth": 44,
"faultGameMaxDuration": 1200,
"faultGameGenesisBlock": 0,
"faultGameGenesisOutputRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
"faultGameSplitDepth": 14,
"systemConfigStartBlock": 0,
"requiredProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000000",
"recommendedProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000000"
"faultGameSplitDepth": 14
}
8 changes: 7 additions & 1 deletion packages/contracts-bedrock/deploy-config/sepolia.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,11 @@
"l2GenesisRegolithTimeOffset": "0x0",
"systemConfigStartBlock": 0,
"requiredProtocolVersion": "0x0000000000000000000000000000000000000004000000000000000000000001",
"recommendedProtocolVersion": "0x0000000000000000000000000000000000000004000000000000000000000001"
"recommendedProtocolVersion": "0x0000000000000000000000000000000000000004000000000000000000000001",
"faultGameAbsolutePrestate": "0x037bbcc23684afbb7f608024369242c5cdea261a4f63981387efb7cd81763536",
"faultGameMaxDepth": 73,
"faultGameMaxDuration": 86400,
"faultGameGenesisBlock": 0,
"faultGameGenesisOutputRoot": "0x6a2fb9128c8bc82eed49ee590fba3e975bd67fede20535d0d20b3000ea6d99b1",
"faultGameSplitDepth": 32
}
31 changes: 17 additions & 14 deletions packages/contracts-bedrock/scripts/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ contract Deploy is Deployer {
deployImplementations();
initializeImplementations();

setAlphabetFaultGameImplementation();
setCannonFaultGameImplementation();
setAlphabetFaultGameImplementation({ _allowUpgrade: false });
setCannonFaultGameImplementation({ _allowUpgrade: false });

transferDisputeGameFactoryOwnership();
}
Expand Down Expand Up @@ -553,7 +553,7 @@ contract Deploy is Deployer {
}

/// @notice Deploy the DisputeGameFactory
function deployDisputeGameFactory() public onlyDevnet broadcast returns (address addr_) {
function deployDisputeGameFactory() public onlyTestnetOrDevnet broadcast returns (address addr_) {
console.log("Deploying DisputeGameFactory implementation");
DisputeGameFactory factory = new DisputeGameFactory{ salt: _implSalt() }();
save("DisputeGameFactory", address(factory));
Expand Down Expand Up @@ -582,7 +582,7 @@ contract Deploy is Deployer {
}

/// @notice Deploy the PreimageOracle
function deployPreimageOracle() public onlyDevnet broadcast returns (address addr_) {
function deployPreimageOracle() public onlyTestnetOrDevnet broadcast returns (address addr_) {
console.log("Deploying PreimageOracle implementation");
PreimageOracle preimageOracle = new PreimageOracle{ salt: _implSalt() }();
save("PreimageOracle", address(preimageOracle));
Expand All @@ -592,7 +592,7 @@ contract Deploy is Deployer {
}

/// @notice Deploy Mips
function deployMips() public onlyDevnet broadcast returns (address addr_) {
function deployMips() public onlyTestnetOrDevnet broadcast returns (address addr_) {
console.log("Deploying Mips implementation");
MIPS mips = new MIPS{ salt: _implSalt() }(IPreimageOracle(mustGetAddress("PreimageOracle")));
save("Mips", address(mips));
Expand Down Expand Up @@ -704,7 +704,7 @@ contract Deploy is Deployer {
}

/// @notice Initialize the DisputeGameFactory
function initializeDisputeGameFactory() public onlyDevnet broadcast {
function initializeDisputeGameFactory() public onlyTestnetOrDevnet broadcast {
console.log("Upgrading and initializing DisputeGameFactory proxy");
address disputeGameFactoryProxy = mustGetAddress("DisputeGameFactoryProxy");
address disputeGameFactory = mustGetAddress("DisputeGameFactory");
Expand Down Expand Up @@ -952,7 +952,7 @@ contract Deploy is Deployer {
}

/// @notice Transfer ownership of the DisputeGameFactory contract to the final system owner
function transferDisputeGameFactoryOwnership() public onlyDevnet broadcast {
function transferDisputeGameFactoryOwnership() public onlyTestnetOrDevnet broadcast {
console.log("Transferring DisputeGameFactory ownership to Safe");
DisputeGameFactory disputeGameFactory = DisputeGameFactory(mustGetAddress("DisputeGameFactoryProxy"));
address owner = disputeGameFactory.owner();
Expand Down Expand Up @@ -985,14 +985,14 @@ contract Deploy is Deployer {
);
} else {
console.log(
"[Cannon Dispute Game] Using absolute prestate from config: %s", cfg.faultGameAbsolutePrestate()
"[Cannon Dispute Game] Using absolute prestate from config: %x", cfg.faultGameAbsolutePrestate()
);
mipsAbsolutePrestate_ = Claim.wrap(bytes32(cfg.faultGameAbsolutePrestate()));
}
}

/// @notice Sets the implementation for the `FAULT` game type in the `DisputeGameFactory`
function setCannonFaultGameImplementation() public onlyDevnet broadcast {
function setCannonFaultGameImplementation(bool _allowUpgrade) public onlyTestnetOrDevnet broadcast {
console.log("Setting Cannon FaultDisputeGame implementation");
DisputeGameFactory factory = DisputeGameFactory(mustGetAddress("DisputeGameFactoryProxy"));

Expand All @@ -1002,12 +1002,13 @@ contract Deploy is Deployer {
_gameType: GameTypes.CANNON,
_absolutePrestate: loadMipsAbsolutePrestate(),
_faultVm: IBigStepper(mustGetAddress("Mips")),
_maxGameDepth: cfg.faultGameMaxDepth()
_maxGameDepth: cfg.faultGameMaxDepth(),
_allowUpgrade: _allowUpgrade
});
}

/// @notice Sets the implementation for the `ALPHABET` game type in the `DisputeGameFactory`
function setAlphabetFaultGameImplementation() public onlyDevnet broadcast {
function setAlphabetFaultGameImplementation(bool _allowUpgrade) public onlyDevnet broadcast {
console.log("Setting Alphabet FaultDisputeGame implementation");
DisputeGameFactory factory = DisputeGameFactory(mustGetAddress("DisputeGameFactoryProxy"));

Expand All @@ -1018,7 +1019,8 @@ contract Deploy is Deployer {
_absolutePrestate: outputAbsolutePrestate,
_faultVm: IBigStepper(new AlphabetVM(outputAbsolutePrestate)),
// The max depth for the alphabet trace is always 3. Add 1 because split depth is fully inclusive.
_maxGameDepth: cfg.faultGameSplitDepth() + 3 + 1
_maxGameDepth: cfg.faultGameSplitDepth() + 3 + 1,
_allowUpgrade: _allowUpgrade
});
}

Expand All @@ -1028,11 +1030,12 @@ contract Deploy is Deployer {
GameType _gameType,
Claim _absolutePrestate,
IBigStepper _faultVm,
uint256 _maxGameDepth
uint256 _maxGameDepth,
bool _allowUpgrade
)
internal
{
if (address(_factory.gameImpls(_gameType)) != address(0)) {
if (address(_factory.gameImpls(_gameType)) != address(0) && !_allowUpgrade) {
console.log(
"[WARN] DisputeGameFactoryProxy: `FaultDisputeGame` implementation already set for game type: %s",
vm.toString(GameType.unwrap(_gameType))
Expand Down
5 changes: 4 additions & 1 deletion packages/contracts-bedrock/scripts/DeployConfig.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ contract DeployConfig is Script {
requiredProtocolVersion = stdJson.readUint(_json, "$.requiredProtocolVersion");
recommendedProtocolVersion = stdJson.readUint(_json, "$.recommendedProtocolVersion");

if (block.chainid == Chains.LocalDevnet || block.chainid == Chains.GethDevnet) {
if (
block.chainid == Chains.LocalDevnet || block.chainid == Chains.GethDevnet || block.chainid == Chains.Sepolia
|| block.chainid == Chains.Goerli
) {
faultGameAbsolutePrestate = stdJson.readUint(_json, "$.faultGameAbsolutePrestate");
faultGameMaxDepth = stdJson.readUint(_json, "$.faultGameMaxDepth");
faultGameSplitDepth = stdJson.readUint(_json, "$.faultGameSplitDepth");
Expand Down
12 changes: 12 additions & 0 deletions packages/contracts-bedrock/scripts/Deployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,18 @@ abstract contract Deployer is Script {
_writeTemp(_name, _deployed);
}

/// @notice Stubs a deployment retrieved through `get`.
/// @param _name The name of the deployment.
/// @param _addr The mock address of the deployment.
function prankDeployment(string memory _name, address _addr) public {
if (bytes(_name).length == 0) {
revert InvalidDeployment("EmptyName");
}

Deployment memory deployment = Deployment({ name: _name, addr: payable(_addr) });
_namedDeployments[_name] = deployment;
}

/// @notice Reads the temp deployments from disk that were generated
/// by the deploy script.
/// @return An array of deployments.
Expand Down
2 changes: 2 additions & 0 deletions packages/contracts-bedrock/scripts/fpac/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
prestate-artifacts/
prestate-artifacts.tar.gz
Loading

0 comments on commit 320fe93

Please sign in to comment.