@@ -22,8 +22,9 @@ contract Zenith is Passage {
22
22
}
23
23
24
24
/// @notice The sequence number of the next block that can be submitted for a given rollup chainId.
25
- /// rollupChainId => nextSequence number
26
- mapping (uint256 => uint256 ) public nextSequence;
25
+ /// @dev Because sequences must start at 1, accessors must add 1 to this number.
26
+ /// rollupChainId => (nextSequence - 1)
27
+ mapping (uint256 => uint256 ) sequences;
27
28
28
29
/// @notice The host block number that a block was last submitted at for a given rollup chainId.
29
30
/// rollupChainId => host blockNumber that block was last submitted at
@@ -82,6 +83,22 @@ contract Zenith is Passage {
82
83
sequencerAdmin = _sequencerAdmin;
83
84
}
84
85
86
+ /// @notice Returns the next sequence number.
87
+ /// @dev Because sequences must start at 1, we add 1 to the mapping value.
88
+ /// @param _rollupChainId - the chainId of the rollup chain. Any chainId is accepted by the contract.
89
+ /// @return The next sequence number.
90
+ function nextSequence (uint256 _rollupChainId ) public view returns (uint256 ) {
91
+ return sequences[_rollupChainId] + 1 ;
92
+ }
93
+
94
+ /// @notice Increments the sequence number and returns it.
95
+ /// @dev Because sequences must start at 1, we add 1 to the mapping value.
96
+ /// @param _rollupChainId - the chainId of the rollup chain. Any chainId is accepted by the contract.
97
+ /// @return The next sequence number.
98
+ function incrementSequence (uint256 _rollupChainId ) internal returns (uint256 ) {
99
+ return ++ sequences[_rollupChainId];
100
+ }
101
+
85
102
/// @notice Add a sequencer to the permissioned sequencer list.
86
103
/// @param sequencer - the address of the sequencer to add.
87
104
/// @custom:emits SequencerSet if the sequencer is added.
@@ -134,7 +151,7 @@ contract Zenith is Passage {
134
151
135
152
function _submitBlock (BlockHeader memory header , bytes32 blockDataHash , uint8 v , bytes32 r , bytes32 s ) internal {
136
153
// assert that the sequence number is valid and increment it
137
- uint256 _nextSequence = nextSequence[ header.rollupChainId] ++ ;
154
+ uint256 _nextSequence = incrementSequence ( header.rollupChainId) ;
138
155
if (_nextSequence != header.sequence) revert BadSequence (_nextSequence);
139
156
140
157
// assert that confirmBy time has not passed
0 commit comments