-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move fullnode to it's own crate (#720)
* Skeleton * Checkin * Use Citrea fullnode instead of sov * Use sequencer in CitreaRollupBlueprint * Cleanup unused import * Fix RPC test
- Loading branch information
Showing
14 changed files
with
1,189 additions
and
468 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
[package] | ||
name = "citrea-fullnode" | ||
version.workspace = true | ||
authors.workspace = true | ||
edition.workspace = true | ||
homepage.workspace = true | ||
license.workspace = true | ||
publish.workspace = true | ||
repository.workspace = true | ||
|
||
[dependencies] | ||
# Citrea Deps | ||
sequencer-client = { path = "../sequencer-client" } | ||
shared-backup-db = { path = "../shared-backup-db" } | ||
|
||
# Sov SDK deps | ||
sov-db = { path = "../sovereign-sdk/full-node/db/sov-db" } | ||
sov-mock-da = { path = "../sovereign-sdk/adapters/mock-da", features = ["native"] } | ||
sov-modules-api = { path = "../sovereign-sdk/module-system/sov-modules-api", default-features = false } | ||
sov-modules-rollup-blueprint = { path = "../sovereign-sdk/module-system/sov-modules-rollup-blueprint" } | ||
sov-modules-stf-blueprint = { path = "../sovereign-sdk/module-system/sov-modules-stf-blueprint", features = ["native"] } | ||
sov-rollup-interface = { path = "../sovereign-sdk/rollup-interface" } | ||
sov-stf-runner = { path = "../sovereign-sdk/full-node/sov-stf-runner" } | ||
|
||
# 3rd-party deps | ||
anyhow = { workspace = true } | ||
backoff = { workspace = true } | ||
borsh = { workspace = true } | ||
futures = { workspace = true } | ||
hex = { workspace = true } | ||
jsonrpsee = { workspace = true } | ||
rand = { workspace = true } | ||
rs_merkle = { workspace = true } | ||
serde = { workspace = true } | ||
serde_json = { workspace = true } | ||
tokio = { workspace = true } | ||
tracing = { workspace = true } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
use std::net::SocketAddr; | ||
|
||
pub use runner::*; | ||
use sov_modules_rollup_blueprint::RollupBlueprint; | ||
use sov_modules_stf_blueprint::StfBlueprint; | ||
use tokio::sync::oneshot; | ||
use tracing::instrument; | ||
mod runner; | ||
|
||
/// Dependencies needed to run the rollup. | ||
pub struct FullNode<S: RollupBlueprint> { | ||
/// The State Transition Runner. | ||
#[allow(clippy::type_complexity)] | ||
pub runner: CitreaFullnode< | ||
StfBlueprint<S::NativeContext, S::DaSpec, S::Vm, S::NativeRuntime>, | ||
S::StorageManager, | ||
S::DaService, | ||
S::Vm, | ||
S::NativeContext, | ||
>, | ||
/// Rpc methods for the rollup. | ||
pub rpc_methods: jsonrpsee::RpcModule<()>, | ||
} | ||
|
||
impl<S: RollupBlueprint> FullNode<S> { | ||
/// Runs the rollup. | ||
#[instrument(level = "trace", skip(self), err, ret(level = "error"))] | ||
pub async fn run(self) -> Result<(), anyhow::Error> { | ||
self.run_and_report_rpc_port(None).await | ||
} | ||
|
||
/// Only run the rpc. | ||
pub async fn run_rpc(self) -> Result<(), anyhow::Error> { | ||
self.runner.start_rpc_server(self.rpc_methods, None).await; | ||
Ok(()) | ||
} | ||
|
||
/// Runs the rollup. Reports rpc port to the caller using the provided channel. | ||
pub async fn run_and_report_rpc_port( | ||
self, | ||
channel: Option<oneshot::Sender<SocketAddr>>, | ||
) -> Result<(), anyhow::Error> { | ||
let mut runner = self.runner; | ||
runner.start_rpc_server(self.rpc_methods, channel).await; | ||
|
||
runner.run().await?; | ||
Ok(()) | ||
} | ||
} |
Oops, something went wrong.