Skip to content

Commit

Permalink
chore: reduce the number of local variables for deployment script
Browse files Browse the repository at this point in the history
  • Loading branch information
fakedev9999 committed Feb 15, 2025
1 parent 03953df commit 139ee5d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 31 deletions.
7 changes: 0 additions & 7 deletions contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,4 @@ fs_permissions = [
{ access = "read-write", path = "./opsuccinctl2ooconfig-test.json" }
]

# To handle solc's "Stack too deep" error for "script/fp/DeployOPSuccinctFDG.s.sol".
via-ir = true
optimizer = true

[profile.ci.invariant]
depth = 32

# See more config options https://github.com/foundry-rs/foundry/tree/master/config
37 changes: 13 additions & 24 deletions contracts/script/fp/DeployOPSuccinctFDG.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,41 +30,36 @@ contract DeployOPSuccinctDG is Script {
function run() public {
vm.startBroadcast();

// Deploy the factory implementation.
DisputeGameFactory factoryImpl = new DisputeGameFactory();

// Deploy factory proxy.
ERC1967Proxy factoryProxy = new ERC1967Proxy(
address(factoryImpl), abi.encodeWithSelector(DisputeGameFactory.initialize.selector, msg.sender)
address(new DisputeGameFactory()),
abi.encodeWithSelector(DisputeGameFactory.initialize.selector, msg.sender)
);
DisputeGameFactory factory = DisputeGameFactory(address(factoryProxy));

// Deploy the anchor state registry implementation.
AnchorStateRegistry registryImpl = new AnchorStateRegistry();

// Deploy the anchor state registry proxy.
SuperchainConfig superchainConfig = new SuperchainConfig();

GameType gameType = GameType.wrap(uint32(vm.envUint("GAME_TYPE")));
uint256 disputeGameFinalityDelaySeconds = vm.envUint("DISPUTE_GAME_FINALITY_DELAY_SECONDS");

// TODO(fakedev9999): Use real OptimismPortal2.
MockOptimismPortal2 portal = new MockOptimismPortal2(gameType, disputeGameFinalityDelaySeconds);
MockOptimismPortal2 portal =
new MockOptimismPortal2(gameType, vm.envUint("DISPUTE_GAME_FINALITY_DELAY_SECONDS"));
console.log("OptimismPortal2:", address(portal));

OutputRoot memory startingAnchorRoot = OutputRoot({root: Hash.wrap(keccak256("genesis")), l2BlockNumber: 0});

// Deploy the anchor state registry proxy.
ERC1967Proxy registryProxy = new ERC1967Proxy(
address(registryImpl),
address(new AnchorStateRegistry()),
abi.encodeCall(
AnchorStateRegistry.initialize,
(
ISuperchainConfig(address(superchainConfig)),
ISuperchainConfig(address(new SuperchainConfig())),
IDisputeGameFactory(address(factory)),
IOptimismPortal2(payable(address(portal))),
startingAnchorRoot
)
)
);

AnchorStateRegistry registry = AnchorStateRegistry(address(registryProxy));
console.log("Anchor state registry:", address(registry));
// Deploy the access manager contract.
Expand All @@ -76,20 +71,14 @@ contract DeployOPSuccinctDG is Script {
accessManager.setProposer(address(0), true);
accessManager.setChallenger(address(0), true);

// Get config values independant of the `USE_SP1_MOCK_VERIFIER` flag.
uint64 maxChallengeDuration = uint64(vm.envUint("MAX_CHALLENGE_DURATION"));
uint64 maxProveDuration = uint64(vm.envUint("MAX_PROVE_DURATION"));
uint256 proofReward = vm.envOr("PROOF_REWARD", uint256(0.01 ether));

// Config values dependent on the `USE_SP1_MOCK_VERIFIER` flag.
address sp1VerifierAddress;
bytes32 rollupConfigHash;
bytes32 aggregationVkey;
bytes32 rangeVkeyCommitment;

// Get or deploy SP1 verifier based on environment variable.
bool useMockVerifier = vm.envOr("USE_SP1_MOCK_VERIFIER", false);
if (useMockVerifier) {
if (vm.envOr("USE_SP1_MOCK_VERIFIER", false)) {
// Deploy mock verifier for testing.
SP1MockVerifier sp1Verifier = new SP1MockVerifier();
sp1VerifierAddress = address(sp1Verifier);
Expand All @@ -109,14 +98,14 @@ contract DeployOPSuccinctDG is Script {
}

OPSuccinctFaultDisputeGame gameImpl = new OPSuccinctFaultDisputeGame(
Duration.wrap(maxChallengeDuration),
Duration.wrap(maxProveDuration),
Duration.wrap(uint64(vm.envUint("MAX_CHALLENGE_DURATION"))),
Duration.wrap(uint64(vm.envUint("MAX_PROVE_DURATION"))),
IDisputeGameFactory(address(factory)),
ISP1Verifier(sp1VerifierAddress),
rollupConfigHash,
aggregationVkey,
rangeVkeyCommitment,
proofReward,
vm.envOr("PROOF_REWARD", uint256(0.01 ether)),
IAnchorStateRegistry(address(registry)),
accessManager
);
Expand Down
3 changes: 3 additions & 0 deletions contracts/utils/MockOptimismPortal2.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;

// Libraries
import {GameType} from "src/dispute/lib/Types.sol";

Expand Down

0 comments on commit 139ee5d

Please sign in to comment.