forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 0
feat(contracts-rootstock): carry the dispute-game init bond as an ABI argument #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+163
−13
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
packages/contracts-rootstock/test/RSKDeployOPChainInitBond.t.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity 0.8.15; | ||
|
|
||
| import {IDisputeGameFactory} from "interfaces/dispute/IDisputeGameFactory.sol"; | ||
| import {GameTypes} from "src/dispute/lib/Types.sol"; | ||
|
|
||
| import {RSKDeployOPChain} from "../script/RSKDeployOPChain.s.sol"; | ||
| import {RSKOPCTestBase} from "./helpers/RSKOPCTestBase.sol"; | ||
|
|
||
| /// @notice Tests for the configurable dispute-game init bond that | ||
| /// rskdeployer.DeployOPChainSplit supplies from | ||
| /// `[deployer].dispute_game_init_bond_wei`. | ||
| /// @dev The bond is an ordinary argument, so these are ordinary tests: no | ||
| /// process-global state, no harness, no quarantined invocation. The Go | ||
| /// side resolves the effective value (config or default) and passes it, | ||
| /// which is why the script itself has no notion of "unset". | ||
| contract RSKDeployOPChainInitBond_Test is RSKOPCTestBase { | ||
| function test_runSplitWithBond_zero_deploysZeroBond() public { | ||
| RSKDeployOPChain script = new RSKDeployOPChain(); | ||
| RSKDeployOPChain.Output memory output_ = script.runSplitWithBond(deployInput, 0); | ||
|
|
||
| IDisputeGameFactory dgf = IDisputeGameFactory(address(output_.disputeGameFactoryProxy)); | ||
| assertEq(dgf.initBonds(GameTypes.PERMISSIONED_CANNON), 0); | ||
| assertEq(dgf.initBonds(GameTypes.SUPER_PERMISSIONED_CANNON), 0); | ||
| } | ||
|
|
||
| function test_runSplitWithBond_custom_deploysCustomBond() public { | ||
| RSKDeployOPChain script = new RSKDeployOPChain(); | ||
| RSKDeployOPChain.Output memory output_ = script.runSplitWithBond(deployInput, 12345); | ||
|
|
||
| IDisputeGameFactory dgf = IDisputeGameFactory(address(output_.disputeGameFactoryProxy)); | ||
| assertEq(dgf.initBonds(GameTypes.PERMISSIONED_CANNON), 12345); | ||
| // Disabled game types keep a zero bond regardless of the argument. | ||
| assertEq(dgf.initBonds(GameTypes.SUPER_PERMISSIONED_CANNON), 0); | ||
| } | ||
|
|
||
| /// @notice `runSplit` is the upstream-parity path: no bond argument, so it | ||
| /// must apply the upstream default. This is what an absent | ||
| /// dispute_game_init_bond_wei has to preserve. | ||
| function test_runSplit_appliesUpstreamDefaultBond() public { | ||
| RSKDeployOPChain script = new RSKDeployOPChain(); | ||
| RSKDeployOPChain.Output memory output_ = script.runSplit(deployInput); | ||
|
|
||
| IDisputeGameFactory dgf = IDisputeGameFactory(address(output_.disputeGameFactoryProxy)); | ||
| assertEq(dgf.initBonds(GameTypes.PERMISSIONED_CANNON), DEFAULT_INIT_BOND); | ||
| } | ||
|
|
||
| /// @notice The RSK entry point carries (input, bond) in one ABI blob; | ||
| /// rskdeployer packs exactly this shape. A mismatch here is the | ||
| /// failure mode that would break a real deploy at decode time. | ||
| function test_runSplitWithBytes_decodesInputAndBond() public { | ||
| RSKDeployOPChain script = new RSKDeployOPChain(); | ||
| bytes memory encoded = script.runSplitWithBytes(abi.encode(deployInput, uint256(777))); | ||
| RSKDeployOPChain.Output memory output_ = abi.decode(encoded, (RSKDeployOPChain.Output)); | ||
|
|
||
| IDisputeGameFactory dgf = IDisputeGameFactory(address(output_.disputeGameFactoryProxy)); | ||
| assertEq(dgf.initBonds(GameTypes.PERMISSIONED_CANNON), 777); | ||
| // Output must round-trip through the same 15-field shape as runWithBytes. | ||
| assertEq(address(output_.disputeGameFactoryProxy), address(dgf)); | ||
| assertGt(address(output_.systemConfigProxy).code.length, 0); | ||
| } | ||
|
|
||
| function test_runSplitWithBytes_emptyInput_reverts() public { | ||
| RSKDeployOPChain script = new RSKDeployOPChain(); | ||
| vm.expectRevert("RSKDeployOPChain: input cannot be empty"); | ||
| script.runSplitWithBytes(bytes("")); | ||
| } | ||
|
|
||
| /// @notice Guards the Go-side default against an upstream bump: rskdeployer | ||
| /// hard-codes 0.08 ether as DefaultDisputeGameInitBondWei, so if | ||
| /// upstream ever changes this constant the two must be reconciled | ||
| /// deliberately rather than drifting apart on a merge. | ||
| function test_defaultInitBond_matchesGoSideConstant() public { | ||
| RSKDeployOPChain script = new RSKDeployOPChain(); | ||
| assertEq(script.DEFAULT_INIT_BOND(), 80_000_000_000_000_000); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.