Commit 8539ae62 authored by clabby's avatar clabby Committed by GitHub

feat(ctb): Relax re-proving constraints in `OptimismPortal2` (#10154)

* chore(ctb): Add test for `LibClone` improvement

fmt

* feat(ctb): Relax re-proving constraints in `OptimismPortal2`

* bindings, semver
parent 05ab396e
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -36,8 +36,8 @@
"sourceCodeHash": "0xd3450653cecc14bf8fbc21f2fa9b4a5fde348c2b6313d72e74e08666201295a2"
},
"src/L1/OptimismPortal2.sol": {
"initCodeHash": "0x12407ad2db89ab758460e1cbd93bdc61fc3c30b20acab6ab61c96c51767c16f6",
"sourceCodeHash": "0x1cd093d048b893846319bc242c8dd5744de1f675e87551de423e0ae4ab3216e1"
"initCodeHash": "0xc70422a7500313e2e43fd01123643f4aa5bac3b7e26f304f5b1bb57e14af7598",
"sourceCodeHash": "0xab39ebdd0cb534771d11cacb1e217585db20d5b5bd89803c8485dbccb7baaaf8"
},
"src/L1/ProtocolVersions.sol": {
"initCodeHash": "0x72cd467e8bcf019c02675d72ab762e088bcc9cc0f1a4e9f587fa4589f7fdd1b8",
......
......@@ -121,8 +121,8 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver {
}
/// @notice Semantic version.
/// @custom:semver 3.6.0
string public constant version = "3.6.0";
/// @custom:semver 3.7.0
string public constant version = "3.7.0";
/// @notice Constructs the OptimismPortal contract.
constructor(
......@@ -253,7 +253,6 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver {
// Load the ProvenWithdrawal into memory, using the withdrawal hash as a unique identifier.
bytes32 withdrawalHash = Hashing.hashWithdrawal(_tx);
ProvenWithdrawal memory provenWithdrawal = provenWithdrawals[withdrawalHash][msg.sender];
// We do not allow for proving withdrawals against dispute games that have resolved against the favor
// of the root claim.
......@@ -262,19 +261,6 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver {
"OptimismPortal: cannot prove against invalid dispute games"
);
// We generally want to prevent users from proving the same withdrawal multiple times
// because each successive proof will update the timestamp. A malicious user can take
// advantage of this to prevent other users from finalizing their withdrawal. However,
// in the case that an honest user proves their withdrawal against a dispute game that
// resolves against the root claim, or the dispute game is blacklisted, we allow
// re-proving the withdrawal against a new proposal.
IDisputeGame oldGame = provenWithdrawal.disputeGameProxy;
require(
provenWithdrawal.timestamp == 0 || oldGame.status() == GameStatus.CHALLENGER_WINS
|| disputeGameBlacklist[oldGame] || oldGame.gameType().raw() != respectedGameType.raw(),
"OptimismPortal: withdrawal hash has already been proven, and the old dispute game is not invalid"
);
// Compute the storage slot of the withdrawal hash in the L2ToL1MessagePasser contract.
// Refer to the Solidity documentation for more information on how storage layouts are
// computed for mappings.
......
......@@ -444,58 +444,6 @@ contract OptimismPortal2_FinalizeWithdrawal_Test is CommonTest {
});
}
/// @dev Tests that `proveWithdrawalTransaction` reverts when the withdrawal has already been proven, and the
/// re-prove attempt is for the same dispute game.
function test_proveWithdrawalTransaction_replayProve_sameGame_reverts() external {
vm.expectEmit(true, true, true, true);
emit WithdrawalProven(_withdrawalHash, alice, bob);
optimismPortal2.proveWithdrawalTransaction({
_tx: _defaultTx,
_disputeGameIndex: _proposedGameIndex,
_outputRootProof: _outputRootProof,
_withdrawalProof: _withdrawalProof
});
vm.expectRevert(
"OptimismPortal: withdrawal hash has already been proven, and the old dispute game is not invalid"
);
optimismPortal2.proveWithdrawalTransaction({
_tx: _defaultTx,
_disputeGameIndex: _proposedGameIndex,
_outputRootProof: _outputRootProof,
_withdrawalProof: _withdrawalProof
});
}
/// @dev Tests that `proveWithdrawalTransaction` reverts when the withdrawal has already been proven, and the first
/// game is currently being disputed, is otherwise not invalid, and has not been blacklisted.
function test_proveWithdrawalTransaction_replayProve_differentGameFirstGameGood_reverts() external {
vm.expectEmit(true, true, true, true);
emit WithdrawalProven(_withdrawalHash, alice, bob);
optimismPortal2.proveWithdrawalTransaction({
_tx: _defaultTx,
_disputeGameIndex: _proposedGameIndex,
_outputRootProof: _outputRootProof,
_withdrawalProof: _withdrawalProof
});
// Create a new dispute game, but don't mock anything about the first game.
disputeGameFactory.create(
optimismPortal2.respectedGameType(), Claim.wrap(_outputRoot), abi.encode(_proposedBlockNumber + 1)
);
_proposedGameIndex = disputeGameFactory.gameCount() - 1;
vm.expectRevert(
"OptimismPortal: withdrawal hash has already been proven, and the old dispute game is not invalid"
);
optimismPortal2.proveWithdrawalTransaction({
_tx: _defaultTx,
_disputeGameIndex: _proposedGameIndex,
_outputRootProof: _outputRootProof,
_withdrawalProof: _withdrawalProof
});
}
/// @dev Tests that `proveWithdrawalTransaction` reverts when the withdrawal has already been proven, and the new
/// game has the `CHALLENGER_WINS` status.
function test_proveWithdrawalTransaction_replayProve_differentGameChallengerWins_reverts() external {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment