Skip to content

Commit

Permalink
feat: scaffolding for compatibility with preview and preprod
Browse files Browse the repository at this point in the history
  • Loading branch information
MaicoLeberle committed Feb 29, 2024
1 parent e3c7f81 commit 10acd0a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/bin/dolos/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ pub struct Args {
#[arg(long, short)]
epoch: u64,

#[arg(long, short)]
block_slot: u64,

#[arg(long, short)]
network_id: u8,
}
Expand Down Expand Up @@ -82,6 +85,9 @@ pub fn run(config: &super::Config, args: &Args) -> miette::Result<()> {
},
&ledger,
args.epoch,
args.block_slot,
config.upstream.network_magic as u32,
config.upstream.network_id,
)
.into_diagnostic()
.context("computing protocol params")?;
Expand Down
13 changes: 11 additions & 2 deletions src/sync/ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ pub struct Stage {
ledger: ApplyDB,
byron: byron::GenesisFile,
shelley: shelley::GenesisFile,
network_magic: u64,
network_id: u8,

current_pparams: Option<(u64, Environment)>,

Expand All @@ -41,6 +43,8 @@ impl Stage {
byron: byron::GenesisFile,
shelley: shelley::GenesisFile,
phase1_validation_enabled: bool,
network_magic: u64,
network_id: u8,
) -> Self {
Self {
ledger,
Expand All @@ -50,6 +54,8 @@ impl Stage {
.unwrap(),
byron,
shelley,
network_magic,
network_id,
current_pparams: None,
phase1_validation_enabled,
upstream: Default::default(),
Expand All @@ -58,7 +64,7 @@ impl Stage {
}
}

fn ensure_pparams(&mut self, epoch: u64) -> Result<(), WorkerError> {
fn ensure_pparams(&mut self, epoch: u64, block_slot: u64) -> Result<(), WorkerError> {
if self
.current_pparams
.as_ref()
Expand All @@ -74,6 +80,9 @@ impl Stage {
},
&self.ledger,
epoch,
block_slot,
self.network_magic as u32,
self.network_id,
)?;

warn!(?pparams, "pparams for new epoch");
Expand Down Expand Up @@ -152,7 +161,7 @@ impl gasket::framework::Worker<Stage> for Worker {
if stage.phase1_validation_enabled {
debug!("performing phase-1 validations");
let (epoch, _) = block.epoch(&stage.genesis_values);
stage.ensure_pparams(epoch)?;
stage.ensure_pparams(epoch, block.slot())?;
stage.execute_phase1_validation(&block)?;
}

Expand Down
9 changes: 8 additions & 1 deletion src/sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,14 @@ pub fn pipeline(
let mut roll = roll::Stage::new(wal, cursor_chain, cursor_ledger);

let mut chain = chain::Stage::new(chain);
let mut ledger = ledger::Stage::new(ledger, byron, shelley, config.phase1_validation_enabled);
let mut ledger = ledger::Stage::new(
ledger,
byron,
shelley,
config.phase1_validation_enabled,
config.network_magic,
config.network_id,
);

let (to_roll, from_pull) = gasket::messaging::tokio::mpsc_channel(50);
pull.downstream.connect(to_roll);
Expand Down
3 changes: 3 additions & 0 deletions src/sync/pparams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ pub fn compute_pparams(
genesis: Genesis,
ledger: &ApplyDB,
epoch: u64,
block_slot: u64,
prot_magic: u32,
network_id: u8,
) -> Result<Environment, WorkerError> {
if (290..=364).contains(&epoch) {
// Alonzo era
Expand Down

0 comments on commit 10acd0a

Please sign in to comment.