Skip to content

Commit

Permalink
feat: moving fee payout + make proof submission sequential (#8262)
Browse files Browse the repository at this point in the history
Fixing #7622 and #8259
  • Loading branch information
LHerskind authored and codygunton committed Aug 30, 2024
1 parent a078c95 commit 609d5ca
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 27 deletions.
28 changes: 2 additions & 26 deletions l1-contracts/src/core/Rollup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,7 @@ contract Rollup is Leonidas, IRollup, ITestRollup {
blocks[pendingBlockCount++] = BlockLog({
archive: _archive,
blockHash: _blockHash,
slotNumber: header.globalVariables.slotNumber.toUint128(),
isProven: false
slotNumber: header.globalVariables.slotNumber.toUint128()
});

// @note The block number here will always be >=1 as the genesis block is at 0
Expand All @@ -493,7 +492,7 @@ contract Rollup is Leonidas, IRollup, ITestRollup {
header.globalVariables.blockNumber, header.contentCommitment.outHash, l2ToL1TreeMinHeight
);

emit L2BlockProposed(header.globalVariables.blockNumber);
emit L2BlockProcessed(header.globalVariables.blockNumber);

// Automatically flag the block as proven if we have cheated and set assumeProvenUntilBlockNumber.
if (header.globalVariables.blockNumber < assumeProvenUntilBlockNumber) {
Expand Down Expand Up @@ -557,29 +556,6 @@ contract Rollup is Leonidas, IRollup, ITestRollup {
);
}

/**
* @notice Validates the header for submission
*
* @param _header - The proposed block header
* @param _signatures - The signatures for the attestations
* @param _digest - The digest that signatures signed
* @param _currentTime - The time of execution
* @dev - This value is provided to allow for simple simulation of future
* @param _flags - Flags specific to the execution, whether certain checks should be skipped
*/
function _validateHeader(
HeaderLib.Header memory _header,
SignatureLib.Signature[] memory _signatures,
bytes32 _digest,
uint256 _currentTime,
DataStructures.ExecutionFlags memory _flags
) internal view {
_validateHeaderForSubmissionBase(_header, _currentTime, _flags);
_validateHeaderForSubmissionSequencerSelection(
_header.globalVariables.slotNumber, _signatures, _digest, _currentTime, _flags
);
}

/**
* @notice Validate a header for submission to the pending chain (sequencer selection checks)
*
Expand Down
31 changes: 30 additions & 1 deletion l1-contracts/test/Rollup.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,27 @@ contract RollupTest is DecoderBase {
_;
}

function testRevertProveTwice() public setUpFor("mixed_block_1") {
DecoderBase.Data memory data = load("mixed_block_1").block;
bytes memory header = data.header;
bytes32 archive = data.archive;
bytes memory body = data.body;

// Progress time as necessary
vm.warp(max(block.timestamp, data.decodedHeader.globalVariables.timestamp));
availabilityOracle.publish(body);

// We jump to the time of the block. (unless it is in the past)
vm.warp(max(block.timestamp, data.decodedHeader.globalVariables.timestamp));

rollup.process(header, archive, bytes32(0));

rollup.submitBlockRootProof(header, archive, bytes32(0), "", "");

vm.expectRevert(abi.encodeWithSelector(Errors.Rollup__NonSequentialProving.selector));
rollup.submitBlockRootProof(header, archive, bytes32(0), "", "");
}

function testTimestamp() public setUpFor("mixed_block_1") {
// Ensure that the timestamp of the current slot is never in the future.
for (uint256 i = 0; i < 100; i++) {
Expand Down Expand Up @@ -198,6 +219,14 @@ contract RollupTest is DecoderBase {
// We jump to the time of the block. (unless it is in the past)
vm.warp(max(block.timestamp, data.decodedHeader.globalVariables.timestamp));

address coinbase = data.decodedHeader.globalVariables.coinbase;
uint256 coinbaseBalance = portalERC20.balanceOf(coinbase);
assertEq(coinbaseBalance, 0, "invalid initial coinbase balance");

// Assert that balance have NOT been increased by proposing the block
rollup.process(header, archive, bytes32(0));
assertEq(portalERC20.balanceOf(coinbase), 0, "invalid coinbase balance");

vm.expectRevert(
abi.encodeWithSelector(
IERC20Errors.ERC20InsufficientBalance.selector,
Expand Down Expand Up @@ -243,7 +272,7 @@ contract RollupTest is DecoderBase {

vm.warp(max(block.timestamp, data.decodedHeader.globalVariables.timestamp));
availabilityOracle.publish(body);
rollup.propose(header, archive, bytes32(0));
rollup.process(header, archive, bytes32(0));

vm.expectRevert(abi.encodeWithSelector(Errors.Rollup__NonSequentialProving.selector));
rollup.submitBlockRootProof(header, archive, bytes32(0), "", "");
Expand Down

0 comments on commit 609d5ca

Please sign in to comment.