Skip to content

Commit bbddec3

Browse files
feat(shasta): select derivation params based on chain id (#892)
* feat(shasta): select derivation params based on chain id * refactor(shasta): use chain_id from common instead of duplicate field * feat: change taiko_protocol revision * bump version * chore: rename variable
1 parent f2a4085 commit bbddec3

8 files changed

Lines changed: 55 additions & 60 deletions

File tree

Cargo.lock

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

Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ resolver = "2"
1313
default-members = ["node"]
1414

1515
[workspace.package]
16-
version = "1.33.15"
16+
version = "1.34.0"
1717
edition = "2024"
1818
repository = "https://github.com/NethermindEth/Catalyst"
1919
license = "MIT"
@@ -87,11 +87,11 @@ ssz_rs = { version = "0.9.0" }
8787
strum = { version = "0.27", features = ["derive"] }
8888

8989
taiko_alethia_reth = { git = "https://github.com/taikoxyz/alethia-reth.git", rev = "a575e625374de3403df8517069626d007102cfc8", package = "alethia-reth-consensus" }
90-
taiko_bindings = { git = "https://github.com/taikoxyz/taiko-mono.git", rev = "1dcf91c3402a0a6bbfacab157ba7edda9a436ea1", package = "bindings" }
91-
taiko_preconfirmation_driver = { git = "https://github.com/taikoxyz/taiko-mono.git", rev = "1dcf91c3402a0a6bbfacab157ba7edda9a436ea1", package = "preconfirmation-driver" }
92-
taiko_preconfirmation_types = { git = "https://github.com/taikoxyz/taiko-mono.git", rev = "1dcf91c3402a0a6bbfacab157ba7edda9a436ea1", package = "preconfirmation-types" }
93-
taiko_protocol = { git = "https://github.com/taikoxyz/taiko-mono.git", rev = "1dcf91c3402a0a6bbfacab157ba7edda9a436ea1", package = "protocol" }
94-
taiko_rpc = { git = "https://github.com/taikoxyz/taiko-mono.git", rev = "1dcf91c3402a0a6bbfacab157ba7edda9a436ea1", package = "rpc" }
90+
taiko_bindings = { git = "https://github.com/taikoxyz/taiko-mono.git", rev = "09954cbde59b3e756870a2b509a35c503c67239c", package = "bindings" }
91+
taiko_preconfirmation_driver = { git = "https://github.com/taikoxyz/taiko-mono.git", rev = "09954cbde59b3e756870a2b509a35c503c67239c", package = "preconfirmation-driver" }
92+
taiko_preconfirmation_types = { git = "https://github.com/taikoxyz/taiko-mono.git", rev = "09954cbde59b3e756870a2b509a35c503c67239c", package = "preconfirmation-types" }
93+
taiko_protocol = { git = "https://github.com/taikoxyz/taiko-mono.git", rev = "09954cbde59b3e756870a2b509a35c503c67239c", package = "protocol" }
94+
taiko_rpc = { git = "https://github.com/taikoxyz/taiko-mono.git", rev = "09954cbde59b3e756870a2b509a35c503c67239c", package = "rpc" }
9595
tokio = { version = "1.49", default-features = false, features = ["full"] }
9696
tokio-util = { version = "0.7", default-features = false }
9797
tracing = { version = "0.1", default-features = false }

permissionless/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ pub async fn create_permissionless_node(
6767
taiko_config.signer.get_address(),
6868
)?)
6969
.map_err(|e| anyhow::anyhow!("Failed to create L2Engine: {}", e))?;
70-
let protocol_config = ethereum_l1.execution_layer.fetch_protocol_config().await?;
70+
let inbox_config = ethereum_l1.execution_layer.fetch_inbox_config().await?;
7171

7272
let taiko = Taiko::new(
7373
ethereum_l1.slot_clock.clone(),
74-
protocol_config.clone(),
74+
inbox_config,
7575
metrics.clone(),
7676
taiko_config,
7777
l2_engine,

shasta/src/l1/execution_layer.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use super::config::EthereumL1Config;
22
use super::proposal_tx_builder::ProposalTxBuilder;
3-
use super::protocol_config::ProtocolConfig;
43
use crate::l1::config::ContractAddresses;
54
use alloy::{
65
eips::BlockNumberOrTag,
@@ -28,6 +27,7 @@ use pacaya::l1::{
2827
};
2928
use serde_json::json;
3029
use std::sync::{Arc, OnceLock};
30+
use taiko_bindings::inbox::IInbox::Config;
3131
use taiko_bindings::inbox::{
3232
IForcedInclusionStore::ForcedInclusion,
3333
IInbox::CoreState,
@@ -223,20 +223,12 @@ impl ExecutionLayer {
223223
.context("is_transaction_in_progress")
224224
}
225225

226-
pub async fn fetch_protocol_config(&self) -> Result<ProtocolConfig, Error> {
227-
let shasta_config = self
228-
.inbox_instance
226+
pub async fn fetch_inbox_config(&self) -> Result<Config, Error> {
227+
self.inbox_instance
229228
.getConfig()
230229
.call()
231230
.await
232-
.map_err(|e| anyhow::anyhow!("Failed to call getConfig for Inbox: {e}"))?;
233-
234-
info!(
235-
"Shasta config: basefeeSharingPctg: {}",
236-
shasta_config.basefeeSharingPctg,
237-
);
238-
239-
Ok(ProtocolConfig::from(&shasta_config))
231+
.map_err(|e| anyhow::anyhow!("Failed to call getConfig for Inbox: {e}"))
240232
}
241233

242234
pub async fn get_activation_timestamp(&self) -> Result<u64, Error> {

shasta/src/l1/protocol_config.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
use taiko_bindings::inbox::IInbox::Config;
2+
use taiko_protocol::shasta::constants::{
3+
max_anchor_offset_for_chain, timestamp_max_offset_for_chain,
4+
};
25

36
#[derive(Clone, Default)]
47
pub struct ProtocolConfig {
@@ -8,11 +11,11 @@ pub struct ProtocolConfig {
811
}
912

1013
impl ProtocolConfig {
11-
pub fn from(shasta_config: &Config) -> Self {
14+
pub fn from(chain_id: u64, inbox_config: &Config) -> Self {
1215
Self {
13-
basefee_sharing_pctg: shasta_config.basefeeSharingPctg,
14-
max_anchor_offset: taiko_protocol::shasta::constants::MAX_ANCHOR_OFFSET,
15-
timestamp_max_offset: taiko_protocol::shasta::constants::TIMESTAMP_MAX_OFFSET,
16+
basefee_sharing_pctg: inbox_config.basefeeSharingPctg,
17+
max_anchor_offset: max_anchor_offset_for_chain(chain_id),
18+
timestamp_max_offset: timestamp_max_offset_for_chain(chain_id),
1619
}
1720
}
1821

shasta/src/l2/execution_layer.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ pub struct L2ExecutionLayer {
2424
common: ExecutionLayerCommon,
2525
provider: DynProvider,
2626
shasta_anchor: Anchor::AnchorInstance<DynProvider>,
27-
chain_id: u64,
2827
pub config: TaikoConfig,
2928
}
3029

@@ -33,22 +32,17 @@ impl L2ExecutionLayer {
3332
let provider =
3433
alloy_tools::create_alloy_provider_without_wallet(&taiko_config.taiko_geth_url).await?;
3534

36-
let chain_id = provider
37-
.get_chain_id()
38-
.await
39-
.map_err(|e| anyhow::anyhow!("Failed to get chain ID: {}", e))?;
40-
info!("L2 Chain ID: {}", chain_id);
41-
4235
let shasta_anchor = Anchor::new(taiko_config.taiko_anchor_address, provider.clone());
4336

4437
let common =
4538
ExecutionLayerCommon::new(provider.clone(), taiko_config.signer.get_address()).await?;
4639

40+
info!("L2 chain ID {}", common.chain_id());
41+
4742
Ok(Self {
4843
common,
4944
provider,
5045
shasta_anchor,
51-
chain_id,
5246
config: taiko_config,
5347
})
5448
}
@@ -79,7 +73,7 @@ impl L2ExecutionLayer {
7973
.max_fee_per_gas(u128::from(l2_slot_info.base_fee())) // value expected by Taiko
8074
.max_priority_fee_per_gas(0) // value expected by Taiko
8175
.nonce(nonce)
82-
.chain_id(self.chain_id);
76+
.chain_id(self.common.chain_id());
8377

8478
let typed_tx = call_builder
8579
.into_transaction_request()
@@ -124,7 +118,8 @@ impl L2ExecutionLayer {
124118
) -> Result<(), Error> {
125119
info!(
126120
"Transfer ETH from L2 to L1: srcChainId: {}, dstChainId: {}",
127-
self.chain_id, dest_chain_id
121+
self.common.chain_id(),
122+
dest_chain_id
128123
);
129124

130125
let provider =
@@ -135,7 +130,7 @@ impl L2ExecutionLayer {
135130
self.config.taiko_bridge_address,
136131
provider,
137132
amount,
138-
self.chain_id,
133+
self.common.chain_id(),
139134
dest_chain_id,
140135
preconfer_address,
141136
bridge_relayer_fee,

shasta/src/l2/taiko.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ use pacaya::l2::config::TaikoConfig;
2121
use std::{sync::Arc, time::Duration};
2222
use taiko_alethia_reth::validation::ANCHOR_V3_V4_GAS_LIMIT;
2323
use taiko_bindings::anchor::Anchor;
24+
use taiko_bindings::inbox::IInbox::Config;
25+
use taiko_protocol::shasta::constants::min_base_fee_for_chain;
2426
use tracing::{debug, trace};
2527

2628
pub struct Taiko {
@@ -34,7 +36,7 @@ pub struct Taiko {
3436
impl Taiko {
3537
pub async fn new(
3638
slot_clock: Arc<SlotClock>,
37-
protocol_config: ProtocolConfig,
39+
inbox_config: Config,
3840
metrics: Arc<Metrics>,
3941
taiko_config: TaikoConfig,
4042
l2_engine: L2Engine,
@@ -46,13 +48,17 @@ impl Taiko {
4648
jwt_secret_bytes: taiko_config.jwt_secret_bytes,
4749
call_timeout: Duration::from_millis(taiko_config.preconf_heartbeat_ms / 2),
4850
};
51+
52+
let l2_execution_layer = Arc::new(
53+
L2ExecutionLayer::new(taiko_config.clone())
54+
.await
55+
.map_err(|e| anyhow::anyhow!("Failed to create L2ExecutionLayer: {}", e))?,
56+
);
57+
let protocol_config =
58+
ProtocolConfig::from(l2_execution_layer.common().chain_id(), &inbox_config);
4959
Ok(Self {
5060
protocol_config,
51-
l2_execution_layer: Arc::new(
52-
L2ExecutionLayer::new(taiko_config.clone())
53-
.await
54-
.map_err(|e| anyhow::anyhow!("Failed to create L2ExecutionLayer: {}", e))?,
55-
),
61+
l2_execution_layer,
5662
driver: Arc::new(TaikoDriver::new(&driver_config, metrics).await?),
5763
slot_clock,
5864
l2_engine,
@@ -268,7 +274,7 @@ impl Taiko {
268274
&parent_block.header.inner,
269275
timestamp_diff,
270276
parent_base_fee_per_gas,
271-
taiko_alethia_reth::eip4396::MIN_BASE_FEE,
277+
min_base_fee_for_chain(self.l2_execution_layer.common().chain_id()),
272278
);
273279

274280
Ok(base_fee)

shasta/src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ pub use node::proposal_manager::ProposalManager;
1212
use anyhow::Error;
1313
use common::{
1414
batch_builder::BatchBuilderConfig,
15-
config::Config,
16-
config::ConfigTrait,
15+
config::{Config, ConfigTrait},
1716
fork_info::ForkInfo,
1817
funds_controller::FundsController,
1918
l1::{self as common_l1, traits::PreconferProvider},
@@ -61,11 +60,11 @@ pub async fn create_shasta_node(
6160
taiko_config.signer.get_address(),
6261
)?)
6362
.map_err(|e| anyhow::anyhow!("Failed to create L2Engine: {}", e))?;
64-
let protocol_config = ethereum_l1.execution_layer.fetch_protocol_config().await?;
63+
let inbox_config = ethereum_l1.execution_layer.fetch_inbox_config().await?;
6564

6665
let taiko = crate::l2::taiko::Taiko::new(
6766
ethereum_l1.slot_clock.clone(),
68-
protocol_config.clone(),
67+
inbox_config,
6968
metrics.clone(),
7069
taiko_config,
7170
l2_engine,

0 commit comments

Comments
 (0)