Skip to content

Commit 14bf33c

Browse files
authored
Merge pull request #17 from init4tech/prestwich/header-in-event
fix: header event emits indexed and unindexed header
2 parents 8833122 + 5556e5b commit 14bf33c

File tree

3 files changed

+56
-12
lines changed

3 files changed

+56
-12
lines changed

.gas-snapshot

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
HelpersTest:test_signature() (gas: 6587)
2-
ZenithTest:test_badSequence() (gas: 77336)
3-
ZenithTest:test_badSignature() (gas: 66901)
4-
ZenithTest:test_blockExpired() (gas: 55457)
5-
ZenithTest:test_notSequencer() (gas: 58632)
6-
ZenithTest:test_onePerBlock() (gas: 121189)
7-
ZenithTest:test_submitBlock() (gas: 88201)
2+
ZenithTest:test_badSequence() (gas: 77167)
3+
ZenithTest:test_badSignature() (gas: 66732)
4+
ZenithTest:test_blockExpired() (gas: 55352)
5+
ZenithTest:test_notSequencer() (gas: 58463)
6+
ZenithTest:test_onePerBlock() (gas: 123114)
7+
ZenithTest:test_submitBlock() (gas: 90231)

src/Zenith.sol

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,21 @@ contract Zenith is Passage, AccessControlDefaultAdminRules {
5050

5151
/// @notice Emitted when a new rollup block is successfully submitted.
5252
/// @param sequencer - the address of the sequencer that signed the block.
53-
/// @param header - the block header information for the block.
53+
/// @param rollupChainId - the chainId of the rollup chain.
54+
/// @param sequence - the sequence number of the rollup block.
55+
/// @param confirmBy - the timestamp by which the block must be submitted.
56+
/// @param gasLimit - the gas limit for the rollup block.
57+
/// @param rewardAddress - the address to receive the rollup block reward.
5458
/// @param blockDataHash - keccak256(blockData). the Node will discard the block if the hash doens't match.
55-
event BlockSubmitted(address indexed sequencer, BlockHeader indexed header, bytes32 blockDataHash);
59+
event BlockSubmitted(
60+
address indexed sequencer,
61+
uint256 indexed rollupChainId,
62+
uint256 indexed sequence,
63+
uint256 confirmBy,
64+
uint256 gasLimit,
65+
address rewardAddress,
66+
bytes32 blockDataHash
67+
);
5668

5769
/// @notice Emit the entire block data for easy visibility
5870
event BlockData(bytes blockData);
@@ -115,7 +127,15 @@ contract Zenith is Passage, AccessControlDefaultAdminRules {
115127
lastSubmittedAtBlock[header.rollupChainId] = block.number;
116128

117129
// emit event
118-
emit BlockSubmitted(sequencer, header, blockDataHash);
130+
emit BlockSubmitted(
131+
sequencer,
132+
header.rollupChainId,
133+
header.sequence,
134+
header.confirmBy,
135+
header.gasLimit,
136+
header.rewardAddress,
137+
blockDataHash
138+
);
119139
}
120140

121141
/// @notice Construct hash of block details that the sequencer signs.

test/Zenith.t.sol

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@ contract ZenithTest is Test {
1616
uint256 sequencerKey = 123;
1717
uint256 notSequencerKey = 300;
1818

19-
event BlockSubmitted(address indexed sequencer, Zenith.BlockHeader indexed header, bytes32 blockDataHash);
19+
event BlockSubmitted(
20+
address indexed sequencer,
21+
uint256 indexed rollupChainId,
22+
uint256 indexed sequence,
23+
uint256 confirmBy,
24+
uint256 gasLimit,
25+
address rewardAddress,
26+
bytes32 blockDataHash
27+
);
2028

2129
function setUp() public {
2230
target = new Zenith(block.chainid + 1, address(this));
@@ -68,7 +76,15 @@ contract ZenithTest is Test {
6876

6977
// should emit BlockSubmitted event
7078
vm.expectEmit();
71-
emit BlockSubmitted(vm.addr(sequencerKey), header, blockDataHash);
79+
emit BlockSubmitted(
80+
vm.addr(sequencerKey),
81+
header.rollupChainId,
82+
header.sequence,
83+
header.confirmBy,
84+
header.gasLimit,
85+
header.rewardAddress,
86+
blockDataHash
87+
);
7288
target.submitBlock(header, blockDataHash, v, r, s, blockData);
7389

7490
// should increment sequence number
@@ -105,7 +121,15 @@ contract ZenithTest is Test {
105121

106122
// should emit BlockSubmitted event
107123
vm.expectEmit();
108-
emit BlockSubmitted(vm.addr(sequencerKey), header, blockDataHash);
124+
emit BlockSubmitted(
125+
vm.addr(sequencerKey),
126+
header.rollupChainId,
127+
header.sequence,
128+
header.confirmBy,
129+
header.gasLimit,
130+
header.rewardAddress,
131+
blockDataHash
132+
);
109133
target.submitBlock(header, blockDataHash, v, r, s, blockData);
110134

111135
// incerement the header sequence

0 commit comments

Comments
 (0)