Commit 00f13077 authored by clabby's avatar clabby Committed by GitHub

feat(ctb): Add Cancun activation timestamp to `PreimageOracle` (#9307)

* Add `CANCUN_ACTIVATION` timestamp to preimage oracle

* chores

* fix: add the cancun activation timestamp

* fix: add cancun activation field to full deploy config testdata:

---------
Co-authored-by: default avatarrefcell <abigger87@gmail.com>
parent a422f56b
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -222,6 +222,8 @@ type DeployConfig struct {
PreimageOracleMinProposalSize uint64 `json:"preimageOracleMinProposalSize"`
// PreimageOracleChallengePeriod is the number of seconds that challengers have to challenge a large preimage proposal.
PreimageOracleChallengePeriod uint64 `json:"preimageOracleChallengePeriod"`
// PreimageOracleCancunActivationTimestamp is the timestamp at which blob preimages are able to be loaded into the preimage oracle.
PreimageOracleCancunActivationTimestamp uint64 `json:"preimageOracleCancunActivationTimestamp"`
// FundDevAccounts configures whether or not to fund the dev accounts. Should only be used
// during devnet deployments.
FundDevAccounts bool `json:"fundDevAccounts"`
......
......@@ -73,6 +73,7 @@
"faultGameSplitDepth": 0,
"preimageOracleMinProposalSize": 1800000,
"preimageOracleChallengePeriod": 86400,
"preimageOracleCancunActivationTimestamp": 0,
"systemConfigStartBlock": 0,
"requiredProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000000",
"recommendedProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000000"
......
......@@ -56,5 +56,6 @@
"faultGameGenesisOutputRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
"faultGameSplitDepth": 14,
"preimageOracleMinProposalSize": 18000,
"preimageOracleChallengePeriod": 86400
"preimageOracleChallengePeriod": 86400,
"preimageOracleCancunActivationTimestamp": 0
}
......@@ -49,5 +49,6 @@
"faultGameGenesisOutputRoot": "0x6a2fb9128c8bc82eed49ee590fba3e975bd67fede20535d0d20b3000ea6d99b1",
"faultGameSplitDepth": 32,
"preimageOracleMinProposalSize": 1800000,
"preimageOracleChallengePeriod": 86400
"preimageOracleChallengePeriod": 86400,
"preimageOracleCancunActivationTimestamp": 1706655072
}
......@@ -616,7 +616,8 @@ contract Deploy is Deployer {
console.log("Deploying PreimageOracle implementation");
PreimageOracle preimageOracle = new PreimageOracle{ salt: _implSalt() }({
_minProposalSize: cfg.preimageOracleMinProposalSize(),
_challengePeriod: cfg.preimageOracleChallengePeriod()
_challengePeriod: cfg.preimageOracleChallengePeriod(),
_cancunActivation: cfg.preimageOracleCancunActivationTimestamp()
});
save("PreimageOracle", address(preimageOracle));
console.log("PreimageOracle deployed at %s", address(preimageOracle));
......
......@@ -55,6 +55,7 @@ contract DeployConfig is Script {
uint256 public faultGameMaxDuration;
uint256 public preimageOracleMinProposalSize;
uint256 public preimageOracleChallengePeriod;
uint256 public preimageOracleCancunActivationTimestamp;
uint256 public systemConfigStartBlock;
uint256 public requiredProtocolVersion;
uint256 public recommendedProtocolVersion;
......@@ -118,6 +119,8 @@ contract DeployConfig is Script {
preimageOracleMinProposalSize = stdJson.readUint(_json, "$.preimageOracleMinProposalSize");
preimageOracleChallengePeriod = stdJson.readUint(_json, "$.preimageOracleChallengePeriod");
preimageOracleCancunActivationTimestamp =
stdJson.readUint(_json, "$.preimageOracleCancunActivationTimestamp");
}
}
......
......@@ -97,7 +97,8 @@ config=$(cat << EOL
"faultGameSplitDepth": 14,
"preimageOracleMinProposalSize": 1800000,
"preimageOracleChallengePeriod": 86400
"preimageOracleChallengePeriod": 86400,
"preimageOracleCancunActivationTimestamp": 0
}
EOL
)
......
......@@ -1144,10 +1144,10 @@
"impact": "Medium",
"confidence": "Medium",
"check": "uninitialized-local",
"description": "PreimageOracle.challengeFirstLPP(address,uint256,PreimageOracle.Leaf,bytes32[]).stateMatrix (src/cannon/PreimageOracle.sol#534) is a local variable never initialized\n",
"description": "PreimageOracle.challengeFirstLPP(address,uint256,PreimageOracle.Leaf,bytes32[]).stateMatrix (src/cannon/PreimageOracle.sol#541) is a local variable never initialized\n",
"type": "variable",
"name": "stateMatrix",
"start": 25088,
"start": 25480,
"length": 40,
"filename_relative": "src/cannon/PreimageOracle.sol"
},
......
......@@ -10,6 +10,11 @@
"internalType": "uint256",
"name": "_challengePeriod",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_cancunActivation",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
......@@ -765,6 +770,11 @@
"name": "BadProposal",
"type": "error"
},
{
"inputs": [],
"name": "CancunNotActive",
"type": "error"
},
{
"inputs": [],
"name": "InvalidInputSize",
......
......@@ -1954,7 +1954,7 @@
"newValue": "0x0000000000000000000000000000000000000000000000000000000000000000",
"previousValue": "0x0000000000000000000000000000000000000000000000000000000000000000",
"reverted": false,
"slot": "0x0000000000000000000000000000000000000000000000000000000000000037"
"slot": "0x0000000000000000000000000000000000000000000000000000000000000038"
}
],
"value": 0
......@@ -1980,7 +1980,7 @@
"newValue": "0x0000000000000000000000000000000000000000000000000000000000000000",
"previousValue": "0x0000000000000000000000000000000000000000000000000000000000000000",
"reverted": false,
"slot": "0x0000000000000000000000000000000000000000000000000000000000000038"
"slot": "0x0000000000000000000000000000000000000000000000000000000000000039"
}
],
"value": 0
......@@ -2441,7 +2441,7 @@
"newValue": "0x0000000000000000000000000000000000000000000000000000000000000000",
"previousValue": "0x0000000000000000000000000000000000000000000000000000000000000000",
"reverted": false,
"slot": "0x0000000000000000000000000000000000000000000000000000000000000037"
"slot": "0x0000000000000000000000000000000000000000000000000000000000000038"
}
],
"value": 0
......@@ -2519,7 +2519,7 @@
"newValue": "0x0000000000000000000000000000000000000000000000000000000000000000",
"previousValue": "0x0000000000000000000000000000000000000000000000000000000000000000",
"reverted": false,
"slot": "0x0000000000000000000000000000000000000000000000000000000000000038"
"slot": "0x0000000000000000000000000000000000000000000000000000000000000039"
}
],
"value": 0
......@@ -7162,7 +7162,7 @@
"newValue": "0x0000000000000000000000000000000000000000000000000000000000000000",
"previousValue": "0x0000000000000000000000000000000000000000000000000000000000000000",
"reverted": false,
"slot": "0x0000000000000000000000000000000000000000000000000000000000000036"
"slot": "0x0000000000000000000000000000000000000000000000000000000000000037"
}
],
"value": 0
......
......@@ -16,6 +16,9 @@ contract PreimageOracle is IPreimageOracle {
// Constants & Immutables //
////////////////////////////////////////////////////////////////
/// @notice The timestamp of Cancun activation on the current chain.
/// @custom:network-specific
uint256 internal immutable CANCUN_ACTIVATION;
/// @notice The duration of the large preimage proposal challenge period.
uint256 internal immutable CHALLENGE_PERIOD;
/// @notice The minimum size of a preimage that can be proposed in the large preimage path.
......@@ -77,9 +80,10 @@ contract PreimageOracle is IPreimageOracle {
// Constructor //
////////////////////////////////////////////////////////////////
constructor(uint256 _minProposalSize, uint256 _challengePeriod) {
constructor(uint256 _minProposalSize, uint256 _challengePeriod, uint256 _cancunActivation) {
MIN_LPP_SIZE_BYTES = _minProposalSize;
CHALLENGE_PERIOD = _challengePeriod;
CANCUN_ACTIVATION = _cancunActivation;
// Compute hashes in empty sparse Merkle tree. The first hash is not set, and kept as zero as the identity.
for (uint256 height = 0; height < KECCAK_TREE_DEPTH - 1; height++) {
......@@ -241,6 +245,9 @@ contract PreimageOracle is IPreimageOracle {
)
external
{
// Prior to Cancun activation, the blob preimage precompile is not available.
if (block.timestamp < CANCUN_ACTIVATION) revert CancunNotActive();
bytes32 key;
bytes32 part;
assembly {
......
......@@ -39,3 +39,6 @@ error NotInitialized();
/// @notice Thrown when the caller of a function is not an EOA.
error NotEOA();
/// @notice Thrown when a function that requires Cancun EVM features is called on at a time where Cancun is not enabled.
error CancunNotActive();
......@@ -12,7 +12,7 @@ contract MIPS_Test is CommonTest {
function setUp() public virtual override {
super.setUp();
oracle = new PreimageOracle(0, 0);
oracle = new PreimageOracle(0, 0, 0);
mips = new MIPS(oracle);
vm.store(address(mips), 0x0, bytes32(abi.encode(address(oracle))));
vm.label(address(oracle), "PreimageOracle");
......
......@@ -15,7 +15,7 @@ contract PreimageOracle_Test is Test {
/// @notice Sets up the testing suite.
function setUp() public {
oracle = new PreimageOracle(0, 0);
oracle = new PreimageOracle(0, 0, 0);
vm.label(address(oracle), "PreimageOracle");
}
......@@ -182,7 +182,11 @@ contract PreimageOracle_LargePreimageProposals_Test is Test {
/// @notice Sets up the testing suite.
function setUp() public {
oracle = new PreimageOracle({ _minProposalSize: MIN_SIZE_BYTES, _challengePeriod: CHALLENGE_PERIOD });
oracle = new PreimageOracle({
_minProposalSize: MIN_SIZE_BYTES,
_challengePeriod: CHALLENGE_PERIOD,
_cancunActivation: 0
});
vm.label(address(oracle), "PreimageOracle");
// Set `tx.origin` and `msg.sender` to `address(this)` so that it may behave like an EOA for `addLeavesLPP`.
......@@ -204,7 +208,8 @@ contract PreimageOracle_LargePreimageProposals_Test is Test {
/// @notice Tests that the `initLPP` function reverts when the part offset is out of bounds of the full preimage.
function test_initLPP_sizeTooSmall_reverts() public {
oracle = new PreimageOracle({ _minProposalSize: 1000, _challengePeriod: CHALLENGE_PERIOD });
oracle =
new PreimageOracle({ _minProposalSize: 1000, _challengePeriod: CHALLENGE_PERIOD, _cancunActivation: 0 });
// Allocate the preimage data.
bytes memory data = new bytes(136);
......
......@@ -14,7 +14,7 @@ contract AlphabetVM is IBigStepper {
constructor(Claim _absolutePrestate) {
ABSOLUTE_PRESTATE = _absolutePrestate;
oracle = new PreimageOracle(0, 0);
oracle = new PreimageOracle(0, 0, 0);
}
/// @inheritdoc IBigStepper
......
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