Commit b945bcf0 authored by clabby's avatar clabby Committed by Adrian Sutton

fix: Choose min block in FDG local inputs

parent dae569e1
...@@ -8,4 +8,4 @@ GasBenchMark_L1StandardBridge_Finalize:test_finalizeETHWithdrawal_benchmark() (g ...@@ -8,4 +8,4 @@ GasBenchMark_L1StandardBridge_Finalize:test_finalizeETHWithdrawal_benchmark() (g
GasBenchMark_L2OutputOracle:test_proposeL2Output_benchmark() (gas: 92973) GasBenchMark_L2OutputOracle:test_proposeL2Output_benchmark() (gas: 92973)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark() (gas: 68433) GasBenchMark_OptimismPortal:test_depositTransaction_benchmark() (gas: 68433)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark_1() (gas: 68903) GasBenchMark_OptimismPortal:test_depositTransaction_benchmark_1() (gas: 68903)
GasBenchMark_OptimismPortal:test_proveWithdrawalTransaction_benchmark() (gas: 155618) GasBenchMark_OptimismPortal:test_proveWithdrawalTransaction_benchmark() (gas: 155618)
\ No newline at end of file
...@@ -160,8 +160,8 @@ ...@@ -160,8 +160,8 @@
"sourceCodeHash": "0x918c395ac5d77357f2551616aad0613e68893862edd14e554623eb16ee6ba148" "sourceCodeHash": "0x918c395ac5d77357f2551616aad0613e68893862edd14e554623eb16ee6ba148"
}, },
"src/dispute/FaultDisputeGame.sol": { "src/dispute/FaultDisputeGame.sol": {
"initCodeHash": "0xed4f3a194664b205e65a5a304223a1c093e3b2395b068c73e4494f76c50dcc52", "initCodeHash": "0x8a5b0a63aa89d54bfdfee0520c7d93d148dcf1bfaefd0649d070492cf1b40327",
"sourceCodeHash": "0xd1c6636914525cd601402bc8f66ff33d7abb0527f1295e14cb32a389ca903ac4" "sourceCodeHash": "0x8412814c752106251edf5d96881c8e00b1962b406ef2920837e9b4a1209a408b"
}, },
"src/dispute/weth/DelayedWETH.sol": { "src/dispute/weth/DelayedWETH.sol": {
"initCodeHash": "0x8f9a5b50374331ad2fabe03a7ce28a0012bfaca5fa48ee917339c3eec39a319f", "initCodeHash": "0x8f9a5b50374331ad2fabe03a7ce28a0012bfaca5fa48ee917339c3eec39a319f",
......
...@@ -194,9 +194,8 @@ library MIPSInstructions { ...@@ -194,9 +194,8 @@ library MIPSInstructions {
// Check for zero rs. // Check for zero rs.
if ( if (
// SLL, SRL, SRA // SLL, SRL, SRA
func == 0x00 || func == 0x02 || func == 0x03
// MFHI, MFLO // MFHI, MFLO
|| func == 0x10 || func == 0x12 func == 0x00 || func == 0x02 || func == 0x03 || func == 0x10 || func == 0x12
) { ) {
require(rs == 0, "MIPS: rs not zero"); require(rs == 0, "MIPS: rs not zero");
} }
...@@ -204,9 +203,8 @@ library MIPSInstructions { ...@@ -204,9 +203,8 @@ library MIPSInstructions {
// Check for zero rt. // Check for zero rt.
if ( if (
// JR, JALR // JR, JALR
func == 0x08 || func == 0x09
// MFHI, MFLO, MTHI, MTLO // MFHI, MFLO, MTHI, MTLO
|| (func >= 0x10 && func <= 0x13) func == 0x08 || func == 0x09 || (func >= 0x10 && func <= 0x13)
) { ) {
require(rt == 0, "MIPS: rt not zero"); require(rt == 0, "MIPS: rt not zero");
} }
...@@ -214,11 +212,9 @@ library MIPSInstructions { ...@@ -214,11 +212,9 @@ library MIPSInstructions {
// Check for zero rd. // Check for zero rd.
if ( if (
// JR // JR
func == 0x08
// MTHI, MTLO // MTHI, MTLO
|| func == 0x11 || func == 0x13
// MULT, MULTU, DIV, DIVU // MULT, MULTU, DIV, DIVU
|| (func >= 0x18 && func <= 0x1B) func == 0x08 || func == 0x11 || func == 0x13 || (func >= 0x18 && func <= 0x1B)
) { ) {
require(rd == 0, "MIPS: rd not zero"); require(rd == 0, "MIPS: rd not zero");
} }
...@@ -226,17 +222,13 @@ library MIPSInstructions { ...@@ -226,17 +222,13 @@ library MIPSInstructions {
// Check for zero shamt. // Check for zero shamt.
if ( if (
// JR, JALR // JR, JALR
func == 0x08 || func == 0x09
// SYNC // SYNC
|| func == 0x0F
// MFHI, MFLO, MTHI, MTLO // MFHI, MFLO, MTHI, MTLO
|| (func >= 0x10 && func <= 0x13)
// MULT, MULTU, DIV, DIVU // MULT, MULTU, DIV, DIVU
|| (func >= 0x18 && func <= 0x1B)
// ADD, ADDU, SUB, SUBU, AND, OR, XOR, NOR // ADD, ADDU, SUB, SUBU, AND, OR, XOR, NOR
|| (func >= 0x20 && func <= 0x27)
// SLT, SLTU // SLT, SLTU
|| func == 0x2A || func == 0x2B func == 0x08 || func == 0x09 || func == 0x0F || (func >= 0x10 && func <= 0x13)
|| (func >= 0x18 && func <= 0x1B) || (func >= 0x20 && func <= 0x27) || func == 0x2A || func == 0x2B
) { ) {
require(shamt == 0, "MIPS: shamt not zero"); require(shamt == 0, "MIPS: shamt not zero");
} }
......
...@@ -69,8 +69,8 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, ISemver { ...@@ -69,8 +69,8 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, ISemver {
uint256 internal constant HEADER_BLOCK_NUMBER_INDEX = 8; uint256 internal constant HEADER_BLOCK_NUMBER_INDEX = 8;
/// @notice Semantic version. /// @notice Semantic version.
/// @custom:semver 1.2.1 /// @custom:semver 1.3.0
string public constant version = "1.2.1"; string public constant version = "1.3.0";
/// @notice The starting timestamp of the game /// @notice The starting timestamp of the game
Timestamp public createdAt; Timestamp public createdAt;
...@@ -464,6 +464,9 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, ISemver { ...@@ -464,6 +464,9 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, ISemver {
// block number. // block number.
uint256 l2Number = startingOutputRoot.l2BlockNumber + disputedPos.traceIndex(SPLIT_DEPTH) + 1; uint256 l2Number = startingOutputRoot.l2BlockNumber + disputedPos.traceIndex(SPLIT_DEPTH) + 1;
// Choose the minimum between the `l2BlockNumber` claim and the bisected-to L2 block number.
l2Number = l2Number < l2BlockNumber() ? l2Number : l2BlockNumber();
oracle.loadLocalData(_ident, uuid.raw(), bytes32(l2Number << 0xC0), 8, _partOffset); oracle.loadLocalData(_ident, uuid.raw(), bytes32(l2Number << 0xC0), 8, _partOffset);
} else if (_ident == LocalPreimageKey.CHAIN_ID) { } else if (_ident == LocalPreimageKey.CHAIN_ID) {
// Load the chain ID as a big-endian uint64 in the high order 8 bytes of the word. // Load the chain ID as a big-endian uint64 in the high order 8 bytes of the word.
......
...@@ -1711,6 +1711,70 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init { ...@@ -1711,6 +1711,70 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init {
} }
} }
/// @dev Tests that the L2 block number claim is favored over the bisected-to block when adding data
///
function test_addLocalData_l2BlockNumberExtension_succeeds() public {
// Deploy a new dispute game with a L2 block number claim of 8. This is directly in the middle of
// the leaves in our output bisection test tree, at SPLIT_DEPTH = 2 ** 2
FaultDisputeGame game = FaultDisputeGame(
address(disputeGameFactory.create(GAME_TYPE, Claim.wrap(bytes32(uint256(0xFF))), abi.encode(uint256(8))))
);
// Get a claim below the split depth so that we can add local data for an execution trace subgame.
{
Claim disputed;
Position parent;
Position pos;
for (uint256 i; i < 4; i++) {
(,,,,, parent,) = game.claimData(i);
pos = parent.move(true);
uint256 bond = game.getRequiredBond(pos);
(,,,, disputed,,) = game.claimData(i);
if (i == 0) {
game.attack{ value: bond }(disputed, i, Claim.wrap(bytes32(i)));
} else {
game.defend{ value: bond }(disputed, i, Claim.wrap(bytes32(i)));
}
}
(,,,,, parent,) = game.claimData(4);
pos = parent.move(true);
uint256 lastBond = game.getRequiredBond(pos);
(,,,, disputed,,) = game.claimData(4);
game.defend{ value: lastBond }(disputed, 4, _changeClaimStatus(ROOT_CLAIM, VMStatuses.INVALID));
}
// Expected start/disputed claims
bytes32 startingClaim = bytes32(uint256(3));
Position startingPos = LibPosition.wrap(4, 14);
bytes32 disputedClaim = bytes32(uint256(0xFF));
Position disputedPos = LibPosition.wrap(0, 0);
// Expected local data. This should be `l2BlockNumber`, and not the actual bisected-to block,
// as we choose the minimum between the two.
bytes32 expectedNumber = bytes32(uint256(8 << 0xC0));
uint256 expectedLen = 8;
uint256 l2NumberIdent = LocalPreimageKey.DISPUTED_L2_BLOCK_NUMBER;
// Compute the preimage key for the local data
bytes32 localContext = keccak256(abi.encode(startingClaim, startingPos, disputedClaim, disputedPos));
bytes32 rawKey = keccak256(abi.encode(l2NumberIdent | (1 << 248), address(game), localContext));
bytes32 key = bytes32((uint256(rawKey) & ~uint256(0xFF << 248)) | (1 << 248));
IPreimageOracle oracle = IPreimageOracle(address(game.vm().oracle()));
game.addLocalData(l2NumberIdent, 5, 0);
(bytes32 dat, uint256 datLen) = oracle.readPreimage(key, 0);
assertEq(dat >> 0xC0, bytes32(expectedLen));
assertEq(datLen, expectedLen + 8);
game.addLocalData(l2NumberIdent, 5, 8);
(dat, datLen) = oracle.readPreimage(key, 8);
assertEq(dat, expectedNumber);
assertEq(datLen, expectedLen);
}
/// @dev Static unit test asserting that resolveClaim isn't possible if there's time /// @dev Static unit test asserting that resolveClaim isn't possible if there's time
/// left for a counter. /// left for a counter.
function test_resolution_lastSecondDisputes_succeeds() public { function test_resolution_lastSecondDisputes_succeeds() public {
......
...@@ -27,13 +27,13 @@ contract DeploymentSummary is DeploymentSummaryCode { ...@@ -27,13 +27,13 @@ contract DeploymentSummary is DeploymentSummaryCode {
address internal constant l1StandardBridgeProxyAddress = 0x20A42a5a785622c6Ba2576B2D6e924aA82BFA11D; address internal constant l1StandardBridgeProxyAddress = 0x20A42a5a785622c6Ba2576B2D6e924aA82BFA11D;
address internal constant l2OutputOracleAddress = 0x19652082F846171168Daf378C4fD3ee85a0D4A60; address internal constant l2OutputOracleAddress = 0x19652082F846171168Daf378C4fD3ee85a0D4A60;
address internal constant l2OutputOracleProxyAddress = 0x39Af23E00F1e662025aA01b0cEdA19542B78DF99; address internal constant l2OutputOracleProxyAddress = 0x39Af23E00F1e662025aA01b0cEdA19542B78DF99;
address internal constant mipsAddress = 0xfc0E48bB2bDa4158Bc6F0809ac65F8C17750a57C; address internal constant mipsAddress = 0x96A4FAe2Ef523cecC7E4a202Cdc1D5FD25f76484;
address internal constant optimismMintableERC20FactoryAddress = 0x39Aea2Dd53f2d01c15877aCc2791af6BDD7aD567; address internal constant optimismMintableERC20FactoryAddress = 0x39Aea2Dd53f2d01c15877aCc2791af6BDD7aD567;
address internal constant optimismMintableERC20FactoryProxyAddress = 0xc7B87b2b892EA5C3CfF47168881FE168C00377FB; address internal constant optimismMintableERC20FactoryProxyAddress = 0xc7B87b2b892EA5C3CfF47168881FE168C00377FB;
address internal constant optimismPortalAddress = 0xbdD90485FCbcac869D5b5752179815a3103d8131; address internal constant optimismPortalAddress = 0xbdD90485FCbcac869D5b5752179815a3103d8131;
address internal constant optimismPortal2Address = 0xae5DadFc48928543f706a9E6Ce25c682aaD2b63b; address internal constant optimismPortal2Address = 0xae5DadFc48928543f706a9E6Ce25c682aaD2b63b;
address internal constant optimismPortalProxyAddress = 0x1c23A6d89F95ef3148BCDA8E242cAb145bf9c0E4; address internal constant optimismPortalProxyAddress = 0x1c23A6d89F95ef3148BCDA8E242cAb145bf9c0E4;
address internal constant preimageOracleAddress = 0x5dF69aDD67a34e9b1e29dB9097f17ECe07DBC440; address internal constant preimageOracleAddress = 0xC8B5749cEFfbC5F70E7C48f9a464883289574D99;
address internal constant protocolVersionsAddress = 0xfbfD64a6C0257F613feFCe050Aa30ecC3E3d7C3F; address internal constant protocolVersionsAddress = 0xfbfD64a6C0257F613feFCe050Aa30ecC3E3d7C3F;
address internal constant protocolVersionsProxyAddress = 0x4C52a6277b1B84121b3072C0c92b6Be0b7CC10F1; address internal constant protocolVersionsProxyAddress = 0x4C52a6277b1B84121b3072C0c92b6Be0b7CC10F1;
address internal constant proxyAdminAddress = 0x62c20Aa1e0272312BC100b4e23B4DC1Ed96dD7D1; address internal constant proxyAdminAddress = 0x62c20Aa1e0272312BC100b4e23B4DC1Ed96dD7D1;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -27,13 +27,13 @@ contract DeploymentSummaryFaultProofs is DeploymentSummaryFaultProofsCode { ...@@ -27,13 +27,13 @@ contract DeploymentSummaryFaultProofs is DeploymentSummaryFaultProofsCode {
address internal constant l1StandardBridgeProxyAddress = 0x20A42a5a785622c6Ba2576B2D6e924aA82BFA11D; address internal constant l1StandardBridgeProxyAddress = 0x20A42a5a785622c6Ba2576B2D6e924aA82BFA11D;
address internal constant l2OutputOracleAddress = 0x19652082F846171168Daf378C4fD3ee85a0D4A60; address internal constant l2OutputOracleAddress = 0x19652082F846171168Daf378C4fD3ee85a0D4A60;
address internal constant l2OutputOracleProxyAddress = 0x39Af23E00F1e662025aA01b0cEdA19542B78DF99; address internal constant l2OutputOracleProxyAddress = 0x39Af23E00F1e662025aA01b0cEdA19542B78DF99;
address internal constant mipsAddress = 0xfc0E48bB2bDa4158Bc6F0809ac65F8C17750a57C; address internal constant mipsAddress = 0x96A4FAe2Ef523cecC7E4a202Cdc1D5FD25f76484;
address internal constant optimismMintableERC20FactoryAddress = 0x39Aea2Dd53f2d01c15877aCc2791af6BDD7aD567; address internal constant optimismMintableERC20FactoryAddress = 0x39Aea2Dd53f2d01c15877aCc2791af6BDD7aD567;
address internal constant optimismMintableERC20FactoryProxyAddress = 0xc7B87b2b892EA5C3CfF47168881FE168C00377FB; address internal constant optimismMintableERC20FactoryProxyAddress = 0xc7B87b2b892EA5C3CfF47168881FE168C00377FB;
address internal constant optimismPortalAddress = 0xbdD90485FCbcac869D5b5752179815a3103d8131; address internal constant optimismPortalAddress = 0xbdD90485FCbcac869D5b5752179815a3103d8131;
address internal constant optimismPortal2Address = 0xae5DadFc48928543f706a9E6Ce25c682aaD2b63b; address internal constant optimismPortal2Address = 0xae5DadFc48928543f706a9E6Ce25c682aaD2b63b;
address internal constant optimismPortalProxyAddress = 0x1c23A6d89F95ef3148BCDA8E242cAb145bf9c0E4; address internal constant optimismPortalProxyAddress = 0x1c23A6d89F95ef3148BCDA8E242cAb145bf9c0E4;
address internal constant preimageOracleAddress = 0xbc8Fd6DC3e97736bBdcdB65E92378FBc0a2dD484; address internal constant preimageOracleAddress = 0xC8B5749cEFfbC5F70E7C48f9a464883289574D99;
address internal constant protocolVersionsAddress = 0xfbfD64a6C0257F613feFCe050Aa30ecC3E3d7C3F; address internal constant protocolVersionsAddress = 0xfbfD64a6C0257F613feFCe050Aa30ecC3E3d7C3F;
address internal constant protocolVersionsProxyAddress = 0x4C52a6277b1B84121b3072C0c92b6Be0b7CC10F1; address internal constant protocolVersionsProxyAddress = 0x4C52a6277b1B84121b3072C0c92b6Be0b7CC10F1;
address internal constant proxyAdminAddress = 0x62c20Aa1e0272312BC100b4e23B4DC1Ed96dD7D1; address internal constant proxyAdminAddress = 0x62c20Aa1e0272312BC100b4e23B4DC1Ed96dD7D1;
......
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