Commit 937acedf authored by Adrian Sutton's avatar Adrian Sutton

Prevent reiniting preimage uploads. (#190)

parent 1e2b19cb
......@@ -148,8 +148,8 @@
"sourceCodeHash": "0x115bd6a4c4d77ed210dfd468675b409fdae9f79b932063c138f0765ba9063462"
},
"src/cannon/PreimageOracle.sol": {
"initCodeHash": "0xe5db668fe41436f53995e910488c7c140766ba8745e19743773ebab508efd090",
"sourceCodeHash": "0x7c8b26cd263f6be144bace1f3faf0ec9265df0efb68ac34fa1fa7df7f608ab42"
"initCodeHash": "0x32c08eaf9873874cd56ce5e0518fc2c0b033bf56395d006578a1d8e1e813a624",
"sourceCodeHash": "0x4907fc15e4ff74f749365e2a95e4c3fe43e5b4d364c5e051275e8e016e205a45"
},
"src/dispute/AnchorStateRegistry.sol": {
"initCodeHash": "0x0305c21e50829b9e07d43358d8c2c82f1449534c90d4391400d46e76d0503a49",
......
......@@ -833,6 +833,11 @@
"name": "AlreadyFinalized",
"type": "error"
},
{
"inputs": [],
"name": "AlreadyInitialized",
"type": "error"
},
{
"inputs": [],
"name": "BadProposal",
......
......@@ -29,8 +29,8 @@ contract PreimageOracle is IPreimageOracle, ISemver {
uint256 public constant MAX_LEAF_COUNT = 2 ** KECCAK_TREE_DEPTH - 1;
/// @notice The semantic version of the Preimage Oracle contract.
/// @custom:semver 1.0.0
string public constant version = "1.0.0";
/// @custom:semver 1.0.1
string public constant version = "1.0.1";
////////////////////////////////////////////////////////////////
// Authorized Preimage Parts //
......@@ -429,6 +429,10 @@ contract PreimageOracle is IPreimageOracle, ISemver {
// Initialize the proposal metadata.
LPPMetaData metaData = proposalMetadata[msg.sender][_uuid];
// Revert if the proposal has already been initialized. 0-size preimages are *not* allowed.
if (metaData.claimedSize() != 0) revert AlreadyInitialized();
proposalMetadata[msg.sender][_uuid] = metaData.setPartOffset(_partOffset).setClaimedSize(_claimedSize);
proposals.push(LargePreimageProposalKeys(msg.sender, _uuid));
......
......@@ -37,6 +37,9 @@ error BadProposal();
/// @notice Thrown when attempting to add leaves to a preimage proposal that has not been initialized.
error NotInitialized();
/// @notice Thrown when attempting to re-initialize an existing large preimage proposal.
error AlreadyInitialized();
/// @notice Thrown when the caller of a function is not an EOA.
error NotEOA();
......
......@@ -312,6 +312,17 @@ contract PreimageOracle_LargePreimageProposals_Test is Test {
oracle.initLPP{ value: bondSize }(TEST_UUID, 0, uint32(data.length));
}
/// @notice Tests that the `initLPP` function reverts if the proposal has already been initialized.
function test_initLPP_alreadyInitialized_reverts() public {
// Initialize the proposal.
uint256 bondSize = oracle.MIN_BOND_SIZE();
oracle.initLPP{ value: bondSize }(TEST_UUID, 0, uint32(500));
// Re-initialize the proposal.
vm.expectRevert(AlreadyInitialized.selector);
oracle.initLPP{ value: bondSize }(TEST_UUID, 0, uint32(500));
}
/// @notice Gas snapshot for `addLeaves`
function test_addLeaves_gasSnapshot() public {
// Allocate the preimage data.
......
......@@ -27,13 +27,13 @@ contract DeploymentSummary is DeploymentSummaryCode {
address internal constant l1StandardBridgeProxyAddress = 0x20A42a5a785622c6Ba2576B2D6e924aA82BFA11D;
address internal constant l2OutputOracleAddress = 0x19652082F846171168Daf378C4fD3ee85a0D4A60;
address internal constant l2OutputOracleProxyAddress = 0x39Af23E00F1e662025aA01b0cEdA19542B78DF99;
address internal constant mipsAddress = 0xB3A0348310a0ff78E5FbDB7f14BB7d3e02d40773;
address internal constant mipsAddress = 0x1620d4F04388901B3a12303df1F235Bb0C92B53D;
address internal constant optimismMintableERC20FactoryAddress = 0x39Aea2Dd53f2d01c15877aCc2791af6BDD7aD567;
address internal constant optimismMintableERC20FactoryProxyAddress = 0xc7B87b2b892EA5C3CfF47168881FE168C00377FB;
address internal constant optimismPortalAddress = 0xbdD90485FCbcac869D5b5752179815a3103d8131;
address internal constant optimismPortal2Address = 0xae5DadFc48928543f706a9E6Ce25c682aaD2b63b;
address internal constant optimismPortalProxyAddress = 0x1c23A6d89F95ef3148BCDA8E242cAb145bf9c0E4;
address internal constant preimageOracleAddress = 0x3bd7E801E51d48c5d94Ea68e8B801DFFC275De75;
address internal constant preimageOracleAddress = 0xD408EC347b99Ed3Aa5E65A986adFCA7ef5E36582;
address internal constant protocolVersionsAddress = 0xfbfD64a6C0257F613feFCe050Aa30ecC3E3d7C3F;
address internal constant protocolVersionsProxyAddress = 0x4C52a6277b1B84121b3072C0c92b6Be0b7CC10F1;
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 {
address internal constant l1StandardBridgeProxyAddress = 0x20A42a5a785622c6Ba2576B2D6e924aA82BFA11D;
address internal constant l2OutputOracleAddress = 0x19652082F846171168Daf378C4fD3ee85a0D4A60;
address internal constant l2OutputOracleProxyAddress = 0x39Af23E00F1e662025aA01b0cEdA19542B78DF99;
address internal constant mipsAddress = 0xB3A0348310a0ff78E5FbDB7f14BB7d3e02d40773;
address internal constant mipsAddress = 0x1620d4F04388901B3a12303df1F235Bb0C92B53D;
address internal constant optimismMintableERC20FactoryAddress = 0x39Aea2Dd53f2d01c15877aCc2791af6BDD7aD567;
address internal constant optimismMintableERC20FactoryProxyAddress = 0xc7B87b2b892EA5C3CfF47168881FE168C00377FB;
address internal constant optimismPortalAddress = 0xbdD90485FCbcac869D5b5752179815a3103d8131;
address internal constant optimismPortal2Address = 0xae5DadFc48928543f706a9E6Ce25c682aaD2b63b;
address internal constant optimismPortalProxyAddress = 0x1c23A6d89F95ef3148BCDA8E242cAb145bf9c0E4;
address internal constant preimageOracleAddress = 0x3bd7E801E51d48c5d94Ea68e8B801DFFC275De75;
address internal constant preimageOracleAddress = 0xD408EC347b99Ed3Aa5E65A986adFCA7ef5E36582;
address internal constant protocolVersionsAddress = 0xfbfD64a6C0257F613feFCe050Aa30ecC3E3d7C3F;
address internal constant protocolVersionsProxyAddress = 0x4C52a6277b1B84121b3072C0c92b6Be0b7CC10F1;
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