Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sov-rollup-starter #226

Merged
merged 5 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,22 @@ where
.await
.map_err(Bootstrap::raise_error)?;

let rollup_node_config = bootstrap
.init_rollup_node_config(&rollup_home_dir, bridge_driver)
.await?;

// TODO: Use `HasWalletAt<SequencerWallet, 0>` instead once we define a
// `CelestiaChainDriver` context that implements that.
let sequencer_wallet = chain_driver.wallets().get("sequencer").ok_or_else(|| {
Bootstrap::raise_error("expected chain driver to contain sequencer wallet")
})?;

let sequencer_address = Chain::wallet_address(sequencer_wallet);

let rollup_node_config = bootstrap
.init_rollup_node_config(&rollup_home_dir, bridge_driver, sequencer_address)
.await?;

let rollup_wallets = bootstrap.generate_rollup_wallets().await?;

let rollup_genesis = bootstrap
.generate_rollup_genesis(Chain::wallet_address(sequencer_wallet), &rollup_wallets)
.generate_rollup_genesis(sequencer_address, &rollup_wallets)
.await?;

bootstrap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ where
bootstrap: &Bootstrap,
sequencer_da_address: &Chain::Address,
rollup_wallets: &BTreeMap<String, Rollup::Wallet>,
) -> Result<Bootstrap::RollupGenesisConfig, Bootstrap::Error> {
) -> Result<SovereignGenesisConfig, Bootstrap::Error> {
let sequencer_wallet = rollup_wallets
.get("sequencer")
.ok_or_else(|| Bootstrap::raise_error("expect sequencer wallet to be present"))?;
Expand All @@ -62,12 +62,14 @@ where
tokens: vec![
TokenGenesis {
token_name: "stake".to_owned(),
token_address: staking_token_address.address.clone(),
address_and_balances: address_and_balances.clone(),
authorized_minters: vec![],
salt: 0,
},
TokenGenesis {
token_name: "coin".to_owned(),
token_address: transfer_token_address.address.clone(),
address_and_balances,
authorized_minters: vec![],
salt: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use hermes_celestia_test_components::bridge_driver::traits::bridge_rpc_port::Has
use hermes_runtime_components::traits::fs::write_file::CanWriteStringToFile;
use hermes_runtime_components::traits::os::reserve_port::CanReserveTcpPort;
use hermes_runtime_components::traits::runtime::HasRuntime;
use hermes_test_components::chain::traits::types::address::HasAddressType;
use hermes_test_components::chain_driver::traits::types::chain::HasChainType;

use crate::bootstrap::traits::init_rollup_node_config::RollupNodeConfigInitializer;
use crate::bootstrap::traits::types::rollup_node_config::HasRollupNodeConfigType;
Expand All @@ -17,15 +19,17 @@ use crate::types::rollup_node_config::{

pub struct InitSovereignRollupNodeConfig;

impl<Bootstrap, BridgeDriver, Runtime> RollupNodeConfigInitializer<Bootstrap>
impl<Bootstrap, Chain, BridgeDriver, Runtime> RollupNodeConfigInitializer<Bootstrap>
for InitSovereignRollupNodeConfig
where
Bootstrap: HasRuntime<Runtime = Runtime>
+ HasChainType<Chain = Chain>
+ HasBridgeDriverType<BridgeDriver = BridgeDriver>
+ HasRollupNodeConfigType
+ CanRaiseError<Runtime::Error>
+ CanRaiseError<toml::ser::Error>,
Runtime: CanReserveTcpPort + CanWriteStringToFile,
Chain: HasAddressType,
BridgeDriver: HasBridgeRpcPort + HasBridgeAuthToken,
BridgeDriver::BridgeAuthToken: Display,
Bootstrap::RollupNodeConfig: From<SovereignRollupNodeConfig>,
Expand All @@ -34,6 +38,7 @@ where
bootstrap: &Bootstrap,
rollup_home_dir: &Runtime::FilePath,
bridge_driver: &BridgeDriver,
sequencer_da_address: &Chain::Address,
) -> Result<Bootstrap::RollupNodeConfig, Bootstrap::Error> {
let runtime = bootstrap.runtime();

Expand All @@ -59,12 +64,13 @@ where
celestia_rpc_address: format!("http://127.0.0.1:{bridge_rpc_port}"),
max_celestia_response_body_size: 104_857_600,
celestia_rpc_timeout_seconds: 60,
own_celestia_address: sequencer_da_address.to_string(),
},
storage: SovereignStorageConfig {
path: Runtime::file_path_to_string(&data_path),
},
runner: SovereignRunnerConfig {
start_height: 1,
genesis_height: 1,
rpc_config: SovereignRpcConfig {
bind_host: "127.0.0.1".into(),
bind_port: rollup_rpc_port,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use cgp_core::CanRaiseError;
use hermes_runtime_components::traits::fs::file_path::HasFilePathType;
use hermes_runtime_components::traits::os::child_process::CanStartChildProcess;
use hermes_runtime_components::traits::os::reserve_port::CanReserveTcpPort;
use hermes_runtime_components::traits::runtime::HasRuntime;

use crate::bootstrap::traits::rollup_command_path::HasRollupCommandPath;
Expand All @@ -11,7 +12,7 @@ pub struct StartSovereignRollup;
impl<Bootstrap, Runtime> RollupStarter<Bootstrap> for StartSovereignRollup
where
Bootstrap: HasRuntime<Runtime = Runtime> + HasRollupCommandPath + CanRaiseError<Runtime::Error>,
Runtime: HasFilePathType + CanStartChildProcess,
Runtime: HasFilePathType + CanStartChildProcess + CanReserveTcpPort,
{
async fn start_rollup(
bootstrap: &Bootstrap,
Expand Down Expand Up @@ -40,6 +41,13 @@ where
&Runtime::file_path_from_string("stderr.log"),
);

let runtime = bootstrap.runtime();

let metrics_port = runtime
.reserve_tcp_port()
.await
.map_err(Bootstrap::raise_error)?;

let child = bootstrap
.runtime()
.start_child_process(
Expand All @@ -51,6 +59,8 @@ where
&Runtime::file_path_to_string(&rollup_genesis_path),
"--kernel-genesis-paths",
&Runtime::file_path_to_string(&rollup_chain_state_path),
"--metrics",
&metrics_port.to_string(),
],
&[("RUST_BACKTRACE", "full")],
Some(&stdout_path),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@ use cgp_core::prelude::*;
use hermes_celestia_test_components::bootstrap::traits::types::bridge_driver::HasBridgeDriverType;
use hermes_runtime_components::traits::fs::file_path::{FilePathOf, HasFilePathType};
use hermes_runtime_components::traits::runtime::HasRuntimeType;
use hermes_test_components::chain::traits::types::address::{AddressOf, HasAddressType};
use hermes_test_components::chain_driver::traits::types::chain::HasChainType;

use crate::bootstrap::traits::types::rollup_node_config::HasRollupNodeConfigType;

#[derive_component(RollupNodeConfigInitializerComponent, RollupNodeConfigInitializer<Bootstrap>)]
#[async_trait]
pub trait CanInitRollupNodeConfig:
HasRuntimeType + HasBridgeDriverType + HasRollupNodeConfigType + HasErrorType
HasRuntimeType + HasChainType + HasBridgeDriverType + HasRollupNodeConfigType + HasErrorType
where
Self::Runtime: HasFilePathType,
Self::Chain: HasAddressType,
{
async fn init_rollup_node_config(
&self,
rollup_home_dir: &FilePathOf<Self::Runtime>,
bridge_driver: &Self::BridgeDriver,
sequencer_da_address: &AddressOf<Self::Chain>,
) -> Result<Self::RollupNodeConfig, Self::Error>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub struct BankGenesis {
#[derive(Serialize)]
pub struct TokenGenesis {
pub token_name: String,
pub token_address: String,
pub address_and_balances: Vec<(String, u128)>,
pub authorized_minters: Vec<String>,
pub salt: u128,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub struct SovereignDaConfig {
pub celestia_rpc_address: String,
pub max_celestia_response_body_size: u64,
pub celestia_rpc_timeout_seconds: u64,
pub own_celestia_address: String,
}

#[derive(Serialize)]
Expand All @@ -23,7 +24,7 @@ pub struct SovereignStorageConfig {

#[derive(Serialize)]
pub struct SovereignRunnerConfig {
pub start_height: u64,
pub genesis_height: u64,
pub rpc_config: SovereignRpcConfig,
pub da_polling_interval_ms: u64,
}
Expand Down
36 changes: 9 additions & 27 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
flake-utils.url = github:numtide/flake-utils;
cosmos-nix.url = github:informalsystems/cosmos.nix;
cosmos-nix-wasm.url = github:informalsystems/cosmos.nix/jonathan/ibc-go-wasm;
sovereign-nix.url = github:informalsystems/sov-rollup-starter?rev=0ca6b94f9275be5efc5a685b164101e9e831b130;
sovereign-nix.url = github:informalsystems/sov-rollup-starter/ibc-rollup;
};

outputs = inputs: let
Expand Down
Loading