Skip to content

Commit

Permalink
chore(serve): Implement ReadParams method in u5c server (#304)
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzalezzfelipe authored Aug 13, 2024
1 parent 1618ebb commit 1cd72d6
Show file tree
Hide file tree
Showing 7 changed files with 444 additions and 22 deletions.
3 changes: 3 additions & 0 deletions src/bin/dolos/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ pub async fn run(config: super::Config, _args: &Args) -> miette::Result<()> {
// TODO: spawn submit pipeline. Skipping for now since it's giving more trouble
// that benefits

// We need new file handled for the separate process.
let (byron, shelley, alonzo) = crate::common::open_genesis_files(&config.genesis)?;
let serve = tokio::spawn(dolos::serve::serve(
config.serve,
(alonzo, byron, shelley),
wal.clone(),
ledger.clone(),
mempool.clone(),
Expand Down
15 changes: 12 additions & 3 deletions src/bin/dolos/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,22 @@ pub async fn run(config: super::Config, _args: &Args) -> miette::Result<()> {
crate::common::setup_tracing(&config.logging)?;

let (wal, ledger) = crate::common::open_data_stores(&config)?;
let (byron, shelley, alonzo) = crate::common::open_genesis_files(&config.genesis)?;
let (txs_out, _txs_in) = gasket::messaging::tokio::mpsc_channel(64);
let mempool = Arc::new(dolos::submit::MempoolState::default());
let exit = crate::common::hook_exit_token();

dolos::serve::serve(config.serve, wal, ledger, mempool, txs_out, exit)
.await
.context("serving clients")?;
dolos::serve::serve(
config.serve,
(alonzo, byron, shelley),
wal,
ledger,
mempool,
txs_out,
exit,
)
.await
.context("serving clients")?;

warn!("shutdown complete");

Expand Down
17 changes: 10 additions & 7 deletions src/ledger/pparams/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ fn bootstrap_byron_pparams(byron: &byron::GenesisFile) -> ByronProtParams {
}
}

fn bootstrap_shelley_pparams(
_previous: ByronProtParams,
shelley: &shelley::GenesisFile,
) -> ShelleyProtParams {
fn bootstrap_shelley_pparams(shelley: &shelley::GenesisFile) -> ShelleyProtParams {
ShelleyProtParams {
protocol_version: shelley.protocol_params.protocol_version.clone().into(),
max_block_body_size: shelley.protocol_params.max_block_body_size,
Expand Down Expand Up @@ -226,8 +223,8 @@ fn advance_hardfork(
MultiEraProtocolParameters::Byron(current)
}
// Protocol version 2 transitions from Byron to Shelley
MultiEraProtocolParameters::Byron(current) if next_protocol == 2 => {
MultiEraProtocolParameters::Shelley(bootstrap_shelley_pparams(current, genesis.shelley))
MultiEraProtocolParameters::Byron(_) if next_protocol == 2 => {
MultiEraProtocolParameters::Shelley(bootstrap_shelley_pparams(genesis.shelley))
}
// Two intra-era hard forks, named Allegra (3) and Mary (4); we don't have separate types
// for these eras
Expand Down Expand Up @@ -263,7 +260,13 @@ pub fn fold_pparams(
updates: &[MultiEraUpdate],
for_epoch: u64,
) -> MultiEraProtocolParameters {
let mut pparams = MultiEraProtocolParameters::Byron(bootstrap_byron_pparams(genesis.byron));
let mut pparams = match &updates[0] {
MultiEraUpdate::Byron(_, _) => {
MultiEraProtocolParameters::Byron(bootstrap_byron_pparams(genesis.byron))
}
// Preview beggins directly on Shelley.
_ => MultiEraProtocolParameters::Shelley(bootstrap_shelley_pparams(genesis.shelley)),
};
let mut last_protocol = 0;

for epoch in 0..for_epoch {
Expand Down
5 changes: 4 additions & 1 deletion src/serve/grpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use crate::state::LedgerStore;
use crate::wal::redb::WalStore;
use crate::{prelude::*, submit::Transaction};

use super::GenesisFiles;

mod convert;
mod query;
mod submit;
Expand All @@ -23,6 +25,7 @@ pub struct Config {

pub async fn serve(
config: Config,
genesis_files: GenesisFiles,
wal: WalStore,
ledger: LedgerStore,
mempool: Arc<crate::submit::MempoolState>,
Expand All @@ -34,7 +37,7 @@ pub async fn serve(
let sync_service = sync::SyncServiceImpl::new(wal.clone(), ledger.clone());
let sync_service = u5c::sync::sync_service_server::SyncServiceServer::new(sync_service);

let query_service = query::QueryServiceImpl::new(ledger.clone());
let query_service = query::QueryServiceImpl::new(ledger.clone(), genesis_files);
let query_service = u5c::query::query_service_server::QueryServiceServer::new(query_service);

let watch_service = watch::WatchServiceImpl::new(wal.clone(), ledger.clone());
Expand Down
Loading

0 comments on commit 1cd72d6

Please sign in to comment.