Skip to content

Commit b41a1ad

Browse files
chore: introduce separate structure for Shasta slot info (#748)
* chore: introduce separate structure for Shasta slot info * chore: move l2SlotInfoV2 to common crate * feat: add L2SlotContext * feat: add dummy block * chore: rename to draft block * chore: add L2BlockV2Payload * fix * feat: add support for consecutive proofs * chore: add comment * fix Inbox.getConfig ABI * cargo fmt * bump version * fix * fix: remove bond instruction * chore: rename gas_limit to gas_limit_without_anchor * feat: implement block payload * chore: remove comments * bump version
1 parent 7b189a8 commit b41a1ad

File tree

17 files changed

+381
-284
lines changed

17 files changed

+381
-284
lines changed

Cargo.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ resolver = "2"
1212
default-members = ["node"]
1313

1414
[workspace.package]
15-
version = "1.23.30"
15+
version = "1.23.31"
1616
edition = "2024"
1717
repository = "https://github.com/NethermindEth/Catalyst"
1818
license = "MIT"

common/src/shared/l2_block_v2.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
use crate::shared::l2_tx_lists::PreBuiltTxList;
22
use alloy::primitives::Address;
33

4+
#[derive(Debug, Clone)]
5+
pub struct L2BlockV2Draft {
6+
pub prebuilt_tx_list: PreBuiltTxList,
7+
pub timestamp_sec: u64,
8+
pub gas_limit_without_anchor: u64,
9+
}
10+
411
#[derive(Debug, Clone)]
512
pub struct L2BlockV2 {
613
pub prebuilt_tx_list: PreBuiltTxList,
714
pub timestamp_sec: u64,
815
pub coinbase: Address,
916
pub anchor_block_number: u64,
10-
pub gas_limit: u64,
17+
pub gas_limit_without_anchor: u64,
1118
}
1219

1320
impl L2BlockV2 {
@@ -16,29 +23,29 @@ impl L2BlockV2 {
1623
timestamp_sec: u64,
1724
coinbase: Address,
1825
anchor_block_number: u64,
19-
gas_limit: u64,
26+
gas_limit_without_anchor: u64,
2027
) -> Self {
2128
L2BlockV2 {
2229
prebuilt_tx_list: tx_list,
2330
timestamp_sec,
2431
coinbase,
2532
anchor_block_number,
26-
gas_limit,
33+
gas_limit_without_anchor,
2734
}
2835
}
2936

3037
pub fn new_empty(
3138
timestamp_sec: u64,
3239
coinbase: Address,
3340
anchor_block_number: u64,
34-
gas_limit: u64,
41+
gas_limit_without_anchor: u64,
3542
) -> Self {
3643
L2BlockV2 {
3744
prebuilt_tx_list: PreBuiltTxList::empty(),
3845
timestamp_sec,
3946
coinbase,
4047
anchor_block_number,
41-
gas_limit,
48+
gas_limit_without_anchor,
4249
}
4350
}
4451
}

common/src/shared/l2_slot_info.rs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
use alloy::primitives::B256;
22

3+
pub trait SlotData {
4+
fn slot_timestamp(&self) -> u64;
5+
fn parent_id(&self) -> u64;
6+
fn parent_hash(&self) -> &B256;
7+
}
8+
39
pub struct L2SlotInfo {
410
base_fee: u64,
511
slot_timestamp: u64,
612
parent_id: u64,
713
parent_hash: B256,
814
parent_gas_used: u32,
9-
parent_gas_limit_without_anchor: u64,
1015
parent_timestamp: u64,
1116
}
1217

@@ -17,7 +22,6 @@ impl L2SlotInfo {
1722
parent_id: u64,
1823
parent_hash: B256,
1924
parent_gas_used: u32,
20-
parent_gas_limit_without_anchor: u64,
2125
parent_timestamp: u64,
2226
) -> Self {
2327
Self {
@@ -26,7 +30,6 @@ impl L2SlotInfo {
2630
parent_id,
2731
parent_hash,
2832
parent_gas_used,
29-
parent_gas_limit_without_anchor,
3033
parent_timestamp,
3134
}
3235
}
@@ -51,11 +54,21 @@ impl L2SlotInfo {
5154
self.parent_gas_used
5255
}
5356

54-
pub fn parent_gas_limit_without_anchor(&self) -> u64 {
55-
self.parent_gas_limit_without_anchor
56-
}
57-
5857
pub fn parent_timestamp(&self) -> u64 {
5958
self.parent_timestamp
6059
}
6160
}
61+
62+
impl SlotData for L2SlotInfo {
63+
fn slot_timestamp(&self) -> u64 {
64+
self.slot_timestamp
65+
}
66+
67+
fn parent_id(&self) -> u64 {
68+
self.parent_id
69+
}
70+
71+
fn parent_hash(&self) -> &B256 {
72+
&self.parent_hash
73+
}
74+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
use super::l2_slot_info::SlotData;
2+
use alloy::primitives::B256;
3+
4+
pub struct L2SlotContext {
5+
pub info: L2SlotInfoV2,
6+
pub end_of_sequencing: bool,
7+
pub allow_forced_inclusion: bool,
8+
}
9+
10+
#[derive(Debug, Clone)]
11+
pub struct L2SlotInfoV2 {
12+
base_fee: u64,
13+
slot_timestamp: u64,
14+
parent_id: u64,
15+
parent_hash: B256,
16+
parent_gas_limit_without_anchor: u64,
17+
parent_timestamp: u64,
18+
}
19+
20+
impl L2SlotInfoV2 {
21+
pub fn new(
22+
base_fee: u64,
23+
slot_timestamp: u64,
24+
parent_id: u64,
25+
parent_hash: B256,
26+
parent_gas_limit_without_anchor: u64,
27+
parent_timestamp: u64,
28+
) -> Self {
29+
Self {
30+
base_fee,
31+
slot_timestamp,
32+
parent_id,
33+
parent_hash,
34+
parent_gas_limit_without_anchor,
35+
parent_timestamp,
36+
}
37+
}
38+
39+
pub fn base_fee(&self) -> u64 {
40+
self.base_fee
41+
}
42+
43+
pub fn slot_timestamp(&self) -> u64 {
44+
self.slot_timestamp
45+
}
46+
47+
pub fn parent_id(&self) -> u64 {
48+
self.parent_id
49+
}
50+
51+
pub fn parent_hash(&self) -> &B256 {
52+
&self.parent_hash
53+
}
54+
55+
pub fn parent_gas_limit_without_anchor(&self) -> u64 {
56+
self.parent_gas_limit_without_anchor
57+
}
58+
59+
pub fn parent_timestamp(&self) -> u64 {
60+
self.parent_timestamp
61+
}
62+
}
63+
64+
impl SlotData for L2SlotInfoV2 {
65+
fn slot_timestamp(&self) -> u64 {
66+
self.slot_timestamp
67+
}
68+
69+
fn parent_id(&self) -> u64 {
70+
self.parent_id
71+
}
72+
73+
fn parent_hash(&self) -> &B256 {
74+
&self.parent_hash
75+
}
76+
}

common/src/shared/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ pub mod head_verifier;
55
pub mod l2_block;
66
pub mod l2_block_v2;
77
pub mod l2_slot_info;
8+
pub mod l2_slot_info_v2;
89
pub mod l2_tx_lists;
910
pub mod transaction_monitor;

pacaya/src/l2/taiko.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,6 @@ impl Taiko {
163163
let parent_id = block_info.header.number();
164164
let parent_hash = block_info.header.hash;
165165
let parent_gas_used = block_info.header.gas_used();
166-
// For Pacaya we do not use that value so we can set it to zero
167-
let parent_gas_limit_without_anchor = 0;
168166
let parent_timestamp = block_info.header.timestamp();
169167
// Safe conversion with overflow check
170168
let parent_gas_used_u32 = u32::try_from(parent_gas_used).map_err(|_| {
@@ -196,7 +194,6 @@ impl Taiko {
196194
parent_id,
197195
parent_hash,
198196
parent_gas_used_u32,
199-
parent_gas_limit_without_anchor,
200197
parent_timestamp,
201198
))
202199
}

pacaya/src/node/operator/mod.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use common::{
88
fork_info::ForkInfo,
99
l1::slot_clock::{Clock, SlotClock},
1010
l2::taiko_driver::{StatusProvider, models::TaikoStatus},
11-
shared::l2_slot_info::L2SlotInfo,
11+
shared::l2_slot_info::SlotData,
1212
utils::{cancellation_token::CancellationToken, types::*},
1313
};
1414
pub use status::Status;
@@ -65,7 +65,7 @@ impl<T: PreconfOperator, U: Clock, V: StatusProvider> Operator<T, U, V> {
6565
}
6666

6767
/// Get the current status of the operator based on the current L1 and L2 slots
68-
pub async fn get_status(&mut self, l2_slot_info: &L2SlotInfo) -> Result<Status, Error> {
68+
pub async fn get_status<S: SlotData>(&mut self, l2_slot_info: &S) -> Result<Status, Error> {
6969
if !self
7070
.execution_layer
7171
.is_preconf_router_specified_in_taiko_wrapper()
@@ -183,9 +183,9 @@ impl<T: PreconfOperator, U: Clock, V: StatusProvider> Operator<T, U, V> {
183183
}
184184
}
185185

186-
async fn is_driver_synced(
186+
async fn is_driver_synced<S: SlotData>(
187187
&mut self,
188-
l2_slot_info: &L2SlotInfo,
188+
l2_slot_info: &S,
189189
driver_status: &TaikoStatus,
190190
) -> Result<bool, Error> {
191191
let taiko_geth_synced_with_l1 = self.is_taiko_geth_synced_with_l1(l2_slot_info).await?;
@@ -209,12 +209,12 @@ impl<T: PreconfOperator, U: Clock, V: StatusProvider> Operator<T, U, V> {
209209
Ok(false)
210210
}
211211

212-
async fn is_preconfer(
212+
async fn is_preconfer<S: SlotData>(
213213
&mut self,
214214
current_operator: bool,
215215
handover_window: bool,
216216
l1_slot: Slot,
217-
l2_slot_info: &L2SlotInfo,
217+
l2_slot_info: &S,
218218
driver_status: &TaikoStatus,
219219
) -> Result<bool, Error> {
220220
if self
@@ -245,10 +245,10 @@ impl<T: PreconfOperator, U: Clock, V: StatusProvider> Operator<T, U, V> {
245245
}
246246
}
247247

248-
async fn is_handover_buffer(
248+
async fn is_handover_buffer<S: SlotData>(
249249
&self,
250250
l1_slot: Slot,
251-
l2_slot_info: &L2SlotInfo,
251+
l2_slot_info: &S,
252252
driver_status: &TaikoStatus,
253253
) -> Result<bool, Error> {
254254
if self.get_ms_from_handover_window_start(l1_slot)? <= self.handover_start_buffer_ms {
@@ -262,10 +262,10 @@ impl<T: PreconfOperator, U: Clock, V: StatusProvider> Operator<T, U, V> {
262262
Ok(false)
263263
}
264264

265-
fn end_of_sequencing_marker_received(
265+
fn end_of_sequencing_marker_received<S: SlotData>(
266266
&self,
267267
driver_status: &TaikoStatus,
268-
l2_slot_info: &L2SlotInfo,
268+
l2_slot_info: &S,
269269
) -> bool {
270270
*l2_slot_info.parent_hash() == driver_status.end_of_sequencing_block_hash
271271
}
@@ -299,10 +299,10 @@ impl<T: PreconfOperator, U: Clock, V: StatusProvider> Operator<T, U, V> {
299299
Ok(result)
300300
}
301301

302-
async fn is_block_height_synced_between_taiko_geth_and_the_driver(
302+
async fn is_block_height_synced_between_taiko_geth_and_the_driver<S: SlotData>(
303303
&self,
304304
status: &TaikoStatus,
305-
l2_slot_info: &L2SlotInfo,
305+
l2_slot_info: &S,
306306
) -> Result<bool, Error> {
307307
if status.highest_unsafe_l2_payload_block_id == 0 {
308308
return Ok(true);
@@ -319,7 +319,10 @@ impl<T: PreconfOperator, U: Clock, V: StatusProvider> Operator<T, U, V> {
319319
Ok(taiko_geth_height == status.highest_unsafe_l2_payload_block_id)
320320
}
321321

322-
async fn is_taiko_geth_synced_with_l1(&self, l2_slot_info: &L2SlotInfo) -> Result<bool, Error> {
322+
async fn is_taiko_geth_synced_with_l1<S: SlotData>(
323+
&self,
324+
l2_slot_info: &S,
325+
) -> Result<bool, Error> {
323326
let taiko_inbox_height = self
324327
.execution_layer
325328
.get_l2_height_from_taiko_inbox()

0 commit comments

Comments
 (0)