Skip to content
Draft
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
3 changes: 3 additions & 0 deletions bin/ream/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ pub struct Cli {

#[arg(long, help = "Purges the database.")]
pub purge_db: bool,

#[arg(long, short, help = "Proposer proves and gossips state transition, validators verify")]
pub proof_gen: bool,
}

#[derive(Debug, Subcommand)]
Expand Down
7 changes: 4 additions & 3 deletions bin/ream/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,11 @@ fn main() {
}

let ream_db = ReamDB::new(ream_dir.clone()).expect("unable to init Ream Database");
let proof_gen = cli.proof_gen;

match cli.command {
Commands::LeanNode(config) => {
executor_clone.spawn(async move { run_lean_node(*config, executor, ream_db).await });
executor_clone.spawn(async move { run_lean_node(*config, executor, ream_db, proof_gen).await });
}
Commands::BeaconNode(config) => {
executor_clone.spawn(async move { run_beacon_node(*config, executor, ream_db).await });
Expand Down Expand Up @@ -139,7 +140,7 @@ fn main() {
/// is used by all services.
///
/// Besides the shared state, each service holds the channels to communicate with each other.
pub async fn run_lean_node(config: LeanNodeConfig, executor: ReamExecutor, ream_db: ReamDB) {
pub async fn run_lean_node(config: LeanNodeConfig, executor: ReamExecutor, ream_db: ReamDB, proof_gen: bool) {
info!("starting up lean node...");

// Initialize prometheus metrics
Expand Down Expand Up @@ -215,7 +216,7 @@ pub async fn run_lean_node(config: LeanNodeConfig, executor: ReamExecutor, ream_
let keystores = load_validator_registry(&config.validator_registry_path, &config.node_id)
.expect("Failed to load validator registry");
let validator_service =
LeanValidatorService::new(lean_chain_reader.clone(), keystores, chain_sender).await;
LeanValidatorService::new(lean_chain_reader.clone(), keystores, chain_sender, proof_gen).await;

let server_config = RpcServerConfig::new(
config.http_address,
Expand Down
5 changes: 5 additions & 0 deletions crates/common/chain/lean/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,9 @@ pub enum LeanChainServiceMessage {
is_trusted: bool,
need_gossip: bool,
},

ProduceProofBlock {
slot: u64,
sender: oneshot::Sender<Block>,
},
}
2 changes: 2 additions & 0 deletions crates/common/chain/lean/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ impl LeanChainService {
warn!("Failed to send item to outbound gossip channel: {err:?}");
}
}

LeanChainServiceMessage::ProduceProofBlock { slot, sender } => todo!(),
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions crates/common/validator/lean/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,21 @@ pub struct ValidatorService {
lean_chain: LeanChainReader,
keystores: Vec<LeanKeystore>,
chain_sender: mpsc::UnboundedSender<LeanChainServiceMessage>,
proof: bool,
}

impl ValidatorService {
pub async fn new(
lean_chain: LeanChainReader,
keystores: Vec<LeanKeystore>,
chain_sender: mpsc::UnboundedSender<LeanChainServiceMessage>,
proof: bool,
) -> Self {
ValidatorService {
lean_chain,
keystores,
chain_sender,
proof,
}
}

Expand Down Expand Up @@ -77,6 +80,12 @@ impl ValidatorService {
keystore.validator_id,
);

if self.proof {
let (tx, rx) = oneshot::channel();
self.chain_sender
.send(LeanChainServiceMessage::ProduceProofBlock { slot, sender: tx })
.expect("Failed to send vote to LeanChainService");
}
// TODO: Sign the block with the keystore.
let signed_block = SignedBlock {
message: new_block,
Expand Down