MCPcopy Create free account
hub / github.com/SeismicSystems/summit / main

Function main

node/src/bin/protocol_params.rs:62–310  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

60}
61
62fn main() -> Result<(), Box<dyn std::error::Error>> {
63 let args = Args::parse();
64
65 // Remove data_dir if it exists to start fresh
66 let data_dir_path = PathBuf::from(&args.data_dir);
67 if data_dir_path.exists() {
68 fs::remove_dir_all(&data_dir_path)?;
69 }
70
71 // Create log directory if specified
72 if let Some(ref log_dir) = args.log_dir {
73 fs::remove_dir_all(log_dir)?;
74 fs::create_dir_all(log_dir)?;
75 }
76
77 let storage_dir = data_dir_path.join("stores");
78
79 let cfg = cw_tokio::Config::default()
80 .with_tcp_nodelay(Some(true))
81 .with_worker_threads(16)
82 .with_storage_directory(storage_dir)
83 .with_catch_panics(false);
84 let executor = cw_tokio::Runner::new(cfg);
85
86 let mut genesis = Genesis::load_from_file(GENESIS_PATH).expect("Failed to load genesis file");
87 genesis.blocks_per_epoch = E2E_BLOCKS_PER_EPOCH;
88 let blocks_per_epoch = genesis.blocks_per_epoch;
89
90 // Write modified genesis for nodes to use
91 fs::create_dir_all(&data_dir_path).expect("Failed to create data directory");
92 let e2e_genesis_path = data_dir_path.join("genesis.toml");
93 let genesis_str = toml::to_string_pretty(&genesis).expect("Failed to serialize genesis");
94 fs::write(&e2e_genesis_path, genesis_str).expect("Failed to write e2e genesis");
95 let e2e_genesis_path_str = e2e_genesis_path.to_str().unwrap().to_string();
96
97 executor.start(|context| {
98 async move {
99 let _critical_log_guard = summit::telemetry::init(Level::INFO, None);
100
101 // Vec to hold all the join handles
102 let mut handles = VecDeque::new();
103 let mut node_runtimes: Vec<NodeRuntime> = Vec::new();
104 // let mut read_threads = Vec::new();
105
106 // Start all nodes at the beginning
107 for x in 0..NUM_NODES {
108 // Start Reth
109 println!("******* STARTING RETH FOR NODE {x}");
110
111 // Create data directory if it doesn't exist
112 let data_dir = format!("{}/node{}/data/reth_db", args.data_dir, x);
113 fs::create_dir_all(&data_dir).expect("Failed to create data directory");
114
115 // Build and spawn reth instance
116 let reth_builder = Reth::new()
117 .instance(x + 1)
118 .keep_stdout()
119 // .genesis(serde_json::from_str(&genesis_str).expect("invalid genesis"))

Callers

nothing calls this directly

Calls 15

run_node_localFunction · 0.85
argMethod · 0.80
data_dirMethod · 0.80
keep_stdoutMethod · 0.80
instanceMethod · 0.80
spawnMethod · 0.80
stdoutMethod · 0.80
auth_portMethod · 0.80
pushMethod · 0.80
http_portMethod · 0.80
lenMethod · 0.80

Tested by

no test coverage detected