Skip to content

Commit

Permalink
feat(applying): scaffold Shelley phase-1 validations
Browse files Browse the repository at this point in the history
  • Loading branch information
MaicoLeberle committed Nov 15, 2023
1 parent 317e23f commit a7f9e9a
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 89 deletions.
14 changes: 12 additions & 2 deletions pallas-applying/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
//! Logic for validating and applying new blocks and txs to the chain state
pub mod byron;
pub mod shelley;
pub mod types;

use byron::validate_byron_tx;

use pallas_traverse::{MultiEraTx, MultiEraTx::Byron as ByronTxPayload};
use pallas_traverse::{
Era, MultiEraTx, MultiEraTx::AlonzoCompatible, MultiEraTx::Byron as ByronTxPayload,
};
use shelley::validate_shelley_tx;

pub use types::{Environment, MultiEraProtParams, UTxOs, ValidationResult};

Expand All @@ -18,6 +21,13 @@ pub fn validate(metx: &MultiEraTx, utxos: &UTxOs, env: &Environment) -> Validati
prot_magic,
},
) => validate_byron_tx(mtxp, utxos, bpp, prot_magic),
(
AlonzoCompatible(shelley_minted_tx, Era::Shelley),
Environment {
prot_params: MultiEraProtParams::Shelley(spp),
prot_magic,
},
) => validate_shelley_tx(shelley_minted_tx, utxos, spp, prot_magic),
// TODO: implement the rest of the eras.
_ => Ok(()),
}
Expand Down
15 changes: 15 additions & 0 deletions pallas-applying/src/shelley.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//! Utilities required for Shelley-era transaction validation.
use crate::types::{ShelleyProtParams, UTxOs, ValidationResult};

use pallas_primitives::alonzo::MintedTx;

// TODO: implement each of the validation rules.
pub fn validate_shelley_tx(
_mtxp: &MintedTx,
_utxos: &UTxOs,
_prot_pps: &ShelleyProtParams,
_prot_magic: &u32,
) -> ValidationResult {
Ok(())
}
4 changes: 4 additions & 0 deletions pallas-applying/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ pub struct ByronProtParams {
pub max_tx_size: u64,
}

#[derive(Debug, Clone)]
pub struct ShelleyProtParams;

// TODO: add variants for the other eras.
#[derive(Debug)]
#[non_exhaustive]
pub enum MultiEraProtParams {
Byron(ByronProtParams),
Shelley(ShelleyProtParams),
}

#[derive(Debug)]
Expand Down
Loading

0 comments on commit a7f9e9a

Please sign in to comment.