Skip to content

Commit

Permalink
feat(verkle): setup verkle bridge
Browse files Browse the repository at this point in the history
  • Loading branch information
morph-dev committed Aug 4, 2024
1 parent 4ba2af9 commit 196d44f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
1 change: 1 addition & 0 deletions portal-bridge/src/bridge/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ pub mod era1;
pub mod history;
pub mod state;
pub mod utils;
pub mod verkle;
31 changes: 30 additions & 1 deletion portal-bridge/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ use tracing::Instrument;
use ethportal_api::jsonrpsee::http_client::{HttpClient, HttpClientBuilder};
use portal_bridge::{
api::{consensus::ConsensusApi, execution::ExecutionApi},
bridge::{beacon::BeaconBridge, era1::Era1Bridge, history::HistoryBridge, state::StateBridge},
bridge::{
beacon::BeaconBridge, era1::Era1Bridge, history::HistoryBridge, state::StateBridge,
verkle::VerkleBridge,
},
cli::BridgeConfig,
types::{mode::BridgeMode, network::NetworkKind},
};
Expand Down Expand Up @@ -91,6 +94,32 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
bridge_tasks.push(bridge_handle);
}

// Launch Verkle Network portal bridge
if bridge_config
.portal_subnetworks
.contains(&NetworkKind::Verkle)
{
let bridge_mode = bridge_config.mode.clone();
let portal_client_clone = portal_client.clone();
let epoch_acc_path = bridge_config.epoch_acc_path.clone();
let header_oracle = HeaderOracle::default();
let verkle_bridge = VerkleBridge::new(
bridge_mode,
portal_client_clone,
header_oracle,
epoch_acc_path,
bridge_config.gossip_limit,
)
.await?;
let bridge_handle = tokio::spawn(async move {
verkle_bridge
.launch()
.instrument(tracing::trace_span!("verkle"))
.await;
});
bridge_tasks.push(bridge_handle);
}

// Launch History Network portal bridge
if bridge_config
.portal_subnetworks
Expand Down
7 changes: 6 additions & 1 deletion portal-bridge/src/types/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub enum NetworkKind {
Beacon,
History,
State,
Verkle,
}

impl fmt::Display for NetworkKind {
Expand All @@ -14,6 +15,7 @@ impl fmt::Display for NetworkKind {
Self::Beacon => write!(f, "beacon"),
Self::History => write!(f, "history"),
Self::State => write!(f, "state"),
Self::Verkle => write!(f, "verkle"),
}
}
}
Expand All @@ -26,7 +28,10 @@ impl FromStr for NetworkKind {
"beacon" => Ok(NetworkKind::Beacon),
"history" => Ok(NetworkKind::History),
"state" => Ok(NetworkKind::State),
_ => Err("Invalid network arg. Expected either 'beacon', 'history' or 'state'"),
"verkle" => Ok(NetworkKind::Verkle),
_ => {
Err("Invalid network arg. Expected either 'beacon', 'history', 'state' or 'verkle'")
}
}
}
}

0 comments on commit 196d44f

Please sign in to comment.