Skip to content

Commit

Permalink
feat: going insane
Browse files Browse the repository at this point in the history
  • Loading branch information
LHerskind committed Aug 29, 2024
1 parent 5b614c2 commit 7b4a5dc
Show file tree
Hide file tree
Showing 20 changed files with 128 additions and 544 deletions.
60 changes: 7 additions & 53 deletions l1-contracts/src/core/Rollup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ contract Rollup is Leonidas, IRollup, ITestRollup {

bytes32 public vkTreeRoot;

// @note This should not exists, but we have it now to ensure we will not be killing the devnet with our
// timeliness requirements.
bool public isDevNet = Constants.IS_DEV_NET == 1;

// @note Assume that all blocks up to this value are automatically proven. Speeds up bootstrapping.
// Testing only. This should be removed eventually.
uint256 private assumeProvenUntilBlockNumber;
Expand Down Expand Up @@ -104,18 +100,17 @@ contract Rollup is Leonidas, IRollup, ITestRollup {
for (uint256 i = 0; i < _validators.length; i++) {
_addValidator(_validators[i]);
}
setupEpoch();
}

/**
* @notice Prune the pending chain up to the last proven block
*
* @dev Will revert if there is nothing to prune or if the chain is not ready to be pruned
*
* @dev While in devnet, this will be guarded behind an `onlyOwner`
*/
function prune() external override(IRollup) {
if (isDevNet) {
revert Errors.DevNet__NoPruningAllowed();
}

function prune() external override(IRollup) onlyOwner {
if (pendingBlockCount == provenBlockCount) {
revert Errors.Rollup__NothingToPrune();
}
Expand Down Expand Up @@ -154,17 +149,6 @@ contract Rollup is Leonidas, IRollup, ITestRollup {
assumeProvenUntilBlockNumber = blockNumber;
}

/**
* @notice Set the devnet mode
*
* @dev This is only needed for testing, and should be removed
*
* @param _devNet - Whether or not the contract is in devnet mode
*/
function setDevNet(bool _devNet) external override(ITestRollup) onlyOwner {
isDevNet = _devNet;
}

/**
* @notice Set the verifier contract
*
Expand Down Expand Up @@ -411,13 +395,9 @@ contract Rollup is Leonidas, IRollup, ITestRollup {
revert Errors.Rollup__InvalidArchive(tipArchive, _archive);
}

if (isDevNet) {
_devnetSequencerSubmissionChecks(_proposer);
} else {
address proposer = getProposerAt(_ts);
if (proposer != address(0) && proposer != _proposer) {
revert Errors.Leonidas__InvalidProposer(proposer, _proposer);
}
address proposer = getProposerAt(_ts);
if (proposer != address(0) && proposer != _proposer) {
revert Errors.Leonidas__InvalidProposer(proposer, _proposer);
}

return (slot, pendingBlockCount);
Expand Down Expand Up @@ -567,8 +547,6 @@ contract Rollup is Leonidas, IRollup, ITestRollup {
* This might be relaxed for allow consensus set to better handle short-term bursts of L1 congestion
* - The slot MUST be in the current epoch
*
* @dev While in isDevNet, we allow skipping all of the checks as we simply assume only TRUSTED sequencers
*
* @param _slot - The slot of the header to validate
* @param _signatures - The signatures to validate
* @param _digest - The digest that signatures sign over
Expand All @@ -580,19 +558,6 @@ contract Rollup is Leonidas, IRollup, ITestRollup {
uint256 _currentTime,
DataStructures.ExecutionFlags memory _flags
) internal view {
if (isDevNet) {
// @note If we are running in a devnet, we don't want to perform all the consensus
// checks, we instead simply require that either there are NO validators or
// that the proposer is a validator.
//
// This means that we relaxes the condition that the block must land in the
// correct slot and epoch to make it more fluid for the devnet launch
// or for testing.

_devnetSequencerSubmissionChecks(msg.sender);
return;
}

// Ensure that the slot proposed is NOT in the future
uint256 currentSlot = getSlotAt(_currentTime);
if (_slot != currentSlot) {
Expand Down Expand Up @@ -686,15 +651,4 @@ contract Rollup is Leonidas, IRollup, ITestRollup {
revert Errors.Rollup__UnavailableTxs(_header.contentCommitment.txsEffectsHash);
}
}

function _devnetSequencerSubmissionChecks(address _proposer) internal view {
if (getValidatorCount() == 0) {
return;
}

if (!isValidator(_proposer)) {
revert Errors.DevNet__InvalidProposer(getValidatorAt(0), _proposer);
}
return;
}
}
1 change: 0 additions & 1 deletion l1-contracts/src/core/interfaces/IRollup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {SignatureLib} from "../sequencer_selection/SignatureLib.sol";
import {DataStructures} from "../libraries/DataStructures.sol";

interface ITestRollup {
function setDevNet(bool _devNet) external;
function setVerifier(address _verifier) external;
function setVkTreeRoot(bytes32 _vkTreeRoot) external;
function setAssumeProvenUntilBlockNumber(uint256 blockNumber) external;
Expand Down
1 change: 0 additions & 1 deletion l1-contracts/src/core/libraries/ConstantsGen.sol
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ library Constants {
uint256 internal constant ETHEREUM_SLOT_DURATION = 12;
uint256 internal constant AZTEC_SLOT_DURATION = 12;
uint256 internal constant AZTEC_EPOCH_DURATION = 48;
uint256 internal constant IS_DEV_NET = 1;
uint256 internal constant GENESIS_ARCHIVE_ROOT =
8142738430000951296386584486068033372964809139261822027365426310856631083550;
uint256 internal constant FEE_JUICE_INITIAL_MINT = 20000000000;
Expand Down
21 changes: 6 additions & 15 deletions l1-contracts/src/core/sequencer_selection/Leonidas.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,6 @@ contract Leonidas is Ownable, ILeonidas {

constructor(address _ares) Ownable(_ares) {
GENESIS_TIME = block.timestamp;

// We will setup the initial epoch value
uint256 seed = _computeNextSeed(0);
epochs[0] = Epoch({committee: new address[](0), sampleSeed: type(uint256).max, nextSeed: seed});
lastSeed = seed;
}

/**
Expand Down Expand Up @@ -135,10 +130,6 @@ contract Leonidas is Ownable, ILeonidas {

function getCommitteeAt(uint256 _ts) internal view returns (address[] memory) {
uint256 epochNumber = getEpochAt(_ts);
if (epochNumber == 0) {
return new address[](0);
}

Epoch storage epoch = epochs[epochNumber];

if (epoch.sampleSeed != 0) {
Expand Down Expand Up @@ -427,11 +418,6 @@ contract Leonidas is Ownable, ILeonidas {
* @return The validators for the given epoch
*/
function _sampleValidators(uint256 _epoch, uint256 _seed) private view returns (address[] memory) {
// If we are in the first epoch, we just return an empty list
if (_epoch == 0) {
return new address[](0);
}

uint256 validatorSetSize = validatorSet.length();
if (validatorSetSize == 0) {
return new address[](0);
Expand All @@ -442,8 +428,10 @@ contract Leonidas is Ownable, ILeonidas {
return validatorSet.values();
}

uint256 fullSeed = uint256(keccak256(abi.encode(_epoch, _seed)));

uint256[] memory indicies =
SampleLib.computeCommitteeClever(TARGET_COMMITTEE_SIZE, validatorSetSize, _seed);
SampleLib.computeCommitteeClever(TARGET_COMMITTEE_SIZE, validatorSetSize, fullSeed);

address[] memory committee = new address[](TARGET_COMMITTEE_SIZE);
for (uint256 i = 0; i < TARGET_COMMITTEE_SIZE; i++) {
Expand All @@ -467,6 +455,9 @@ contract Leonidas is Ownable, ILeonidas {
* @return The sample seed for the epoch
*/
function _getSampleSeed(uint256 _epoch) private view returns (uint256) {
if (_epoch == 0) {
return type(uint256).max;
}
uint256 sampleSeed = epochs[_epoch].sampleSeed;
if (sampleSeed != 0) {
return sampleSeed;
Expand Down
11 changes: 0 additions & 11 deletions l1-contracts/test/Rollup.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,6 @@ contract RollupTest is DecoderBase {
}

function testRevertPrune() public setUpFor("mixed_block_1") {
if (rollup.isDevNet()) {
vm.expectRevert(abi.encodeWithSelector(Errors.DevNet__NoPruningAllowed.selector));
rollup.prune();

return;
}

vm.expectRevert(abi.encodeWithSelector(Errors.Rollup__NothingToPrune.selector));
rollup.prune();

Expand All @@ -136,10 +129,6 @@ contract RollupTest is DecoderBase {
}

function testPrune() public setUpFor("mixed_block_1") {
if (rollup.isDevNet()) {
return;
}

_testBlock("mixed_block_1", false);

assertEq(inbox.inProgress(), 3, "Invalid in progress");
Expand Down
12 changes: 6 additions & 6 deletions l1-contracts/test/fixtures/empty_block_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"l2ToL1Messages": []
},
"block": {
"archive": "0x0f24dbb7e2a507326574582c3f44c08266eb441e926f2d68ca112f358585669f",
"archive": "0x0218af77b084a488cc9f73f0f54d0c6a5f89b1e0789553d970284663a4e9d6ff",
"body": "0x00000000",
"txsEffectsHash": "0x00e994e16b3763fd5039413cf99c2b3c378e2bab939e7992a77bd201b28160d6",
"decodedHeader": {
Expand All @@ -22,10 +22,10 @@
"blockNumber": 1,
"slotNumber": "0x0000000000000000000000000000000000000000000000000000000000000033",
"chainId": 31337,
"timestamp": 1724861610,
"timestamp": 1724957263,
"version": 1,
"coinbase": "0x872bd7c2a38898f9fc254b86f0fd95475f7eec20",
"feeRecipient": "0x2d78818b03bcaf7034fca9d658f1212c6b2aecd6839e03cc21e2846fc061202d",
"coinbase": "0x7f320539cf6bcad297f32977336dfb51e0bae45e",
"feeRecipient": "0x2302fd7383931f3b97f770d877117fc671c939940d3c88fdb9bf5ac729cfa487",
"gasFees": {
"feePerDaGas": 0,
"feePerL2Gas": 0
Expand Down Expand Up @@ -56,8 +56,8 @@
}
}
},
"header": "0x1200a06aae1368abe36530b585bd7a4d2ba4de5037b82076412691a187d7621e00000001000000000000000000000000000000000000000000000000000000000000000200e994e16b3763fd5039413cf99c2b3c378e2bab939e7992a77bd201b28160d600089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c00f5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb14f44d672eb357739e42463497f9fdac46623af863eea4d947ca00a497dcdeb3000000100b59baa35b9dc267744f0ccb4e3b0255c1fc512460d91130c6bc19fb2668568d0000008019a8c197c12bb33da6314c4ef4f8f6fcb9e25250c085df8672adf67c8f1e3dbc0000010023c08a6b1297210c5e24c76b9a936250a1ce2721576c26ea797c7ec35f9e46a9000001000000000000000000000000000000000000000000000000000000000000007a690000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000330000000000000000000000000000000000000000000000000000000066cf4caa872bd7c2a38898f9fc254b86f0fd95475f7eec202d78818b03bcaf7034fca9d658f1212c6b2aecd6839e03cc21e2846fc061202d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"publicInputsHash": "0x00a46e722d885c3bf479f8cf2a786adfde7a8c43740214163f7f9846914cbe6f",
"header": "0x1200a06aae1368abe36530b585bd7a4d2ba4de5037b82076412691a187d7621e00000001000000000000000000000000000000000000000000000000000000000000000200e994e16b3763fd5039413cf99c2b3c378e2bab939e7992a77bd201b28160d600089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c00f5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb14f44d672eb357739e42463497f9fdac46623af863eea4d947ca00a497dcdeb3000000100b59baa35b9dc267744f0ccb4e3b0255c1fc512460d91130c6bc19fb2668568d0000008019a8c197c12bb33da6314c4ef4f8f6fcb9e25250c085df8672adf67c8f1e3dbc0000010023c08a6b1297210c5e24c76b9a936250a1ce2721576c26ea797c7ec35f9e46a9000001000000000000000000000000000000000000000000000000000000000000007a690000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000330000000000000000000000000000000000000000000000000000000066d0c24f7f320539cf6bcad297f32977336dfb51e0bae45e2302fd7383931f3b97f770d877117fc671c939940d3c88fdb9bf5ac729cfa487000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"publicInputsHash": "0x0059bdd614a8c8b246704422cd3f486b1926ef6aab395736479150c5c43a889c",
"numTxs": 0
}
}
14 changes: 7 additions & 7 deletions l1-contracts/test/fixtures/empty_block_2.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"l2ToL1Messages": []
},
"block": {
"archive": "0x25126f40ad58d24006e6db629c2efb1e0868a50d5c21aa342894137b2b08bc0b",
"archive": "0x1968ce2d1d81d3c61451b2292ad4b356ba376d006535ac2f9ed2d06d34063d50",
"body": "0x00000000",
"txsEffectsHash": "0x00e994e16b3763fd5039413cf99c2b3c378e2bab939e7992a77bd201b28160d6",
"decodedHeader": {
Expand All @@ -22,18 +22,18 @@
"blockNumber": 2,
"slotNumber": "0x0000000000000000000000000000000000000000000000000000000000000035",
"chainId": 31337,
"timestamp": 1724861634,
"timestamp": 1724957287,
"version": 1,
"coinbase": "0x872bd7c2a38898f9fc254b86f0fd95475f7eec20",
"feeRecipient": "0x2d78818b03bcaf7034fca9d658f1212c6b2aecd6839e03cc21e2846fc061202d",
"coinbase": "0x7f320539cf6bcad297f32977336dfb51e0bae45e",
"feeRecipient": "0x2302fd7383931f3b97f770d877117fc671c939940d3c88fdb9bf5ac729cfa487",
"gasFees": {
"feePerDaGas": 0,
"feePerL2Gas": 0
}
},
"lastArchive": {
"nextAvailableLeafIndex": 2,
"root": "0x0f24dbb7e2a507326574582c3f44c08266eb441e926f2d68ca112f358585669f"
"root": "0x0218af77b084a488cc9f73f0f54d0c6a5f89b1e0789553d970284663a4e9d6ff"
},
"stateReference": {
"l1ToL2MessageTree": {
Expand All @@ -56,8 +56,8 @@
}
}
},
"header": "0x0f24dbb7e2a507326574582c3f44c08266eb441e926f2d68ca112f358585669f00000002000000000000000000000000000000000000000000000000000000000000000200e994e16b3763fd5039413cf99c2b3c378e2bab939e7992a77bd201b28160d600089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c00f5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb14f44d672eb357739e42463497f9fdac46623af863eea4d947ca00a497dcdeb3000000200b59baa35b9dc267744f0ccb4e3b0255c1fc512460d91130c6bc19fb2668568d0000010019a8c197c12bb33da6314c4ef4f8f6fcb9e25250c085df8672adf67c8f1e3dbc0000018023c08a6b1297210c5e24c76b9a936250a1ce2721576c26ea797c7ec35f9e46a9000001800000000000000000000000000000000000000000000000000000000000007a690000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000350000000000000000000000000000000000000000000000000000000066cf4cc2872bd7c2a38898f9fc254b86f0fd95475f7eec202d78818b03bcaf7034fca9d658f1212c6b2aecd6839e03cc21e2846fc061202d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"publicInputsHash": "0x00de3870b035eca1a73e8adf24b738db855a034548805b300d8dbecfd2a6e66b",
"header": "0x0218af77b084a488cc9f73f0f54d0c6a5f89b1e0789553d970284663a4e9d6ff00000002000000000000000000000000000000000000000000000000000000000000000200e994e16b3763fd5039413cf99c2b3c378e2bab939e7992a77bd201b28160d600089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c00f5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb14f44d672eb357739e42463497f9fdac46623af863eea4d947ca00a497dcdeb3000000200b59baa35b9dc267744f0ccb4e3b0255c1fc512460d91130c6bc19fb2668568d0000010019a8c197c12bb33da6314c4ef4f8f6fcb9e25250c085df8672adf67c8f1e3dbc0000018023c08a6b1297210c5e24c76b9a936250a1ce2721576c26ea797c7ec35f9e46a9000001800000000000000000000000000000000000000000000000000000000000007a690000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000350000000000000000000000000000000000000000000000000000000066d0c2677f320539cf6bcad297f32977336dfb51e0bae45e2302fd7383931f3b97f770d877117fc671c939940d3c88fdb9bf5ac729cfa487000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"publicInputsHash": "0x001e06cb2f4d397512401d8196c86b7dbcbe8624f16143210e0a7a61d05d4bc4",
"numTxs": 0
}
}
12 changes: 6 additions & 6 deletions l1-contracts/test/fixtures/mixed_block_1.json

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions l1-contracts/test/fixtures/mixed_block_2.json

Large diffs are not rendered by default.

Loading

0 comments on commit 7b4a5dc

Please sign in to comment.