refactor(applying): unify approach for protocol params access (#432)

This commit is contained in:
Maico Leberle 2024-04-11 21:41:27 -03:00 committed by GitHub
parent df3291bef5
commit fb8b7402fe
45 changed files with 2056 additions and 1520 deletions

View file

@ -6,7 +6,7 @@ use crate::utils::{
get_network_id_value, get_payment_part, get_shelley_address, get_val_size_in_words, get_network_id_value, get_payment_part, get_shelley_address, get_val_size_in_words,
mk_alonzo_vk_wits_check_list, values_are_equal, verify_signature, mk_alonzo_vk_wits_check_list, values_are_equal, verify_signature,
AlonzoError::*, AlonzoError::*,
AlonzoProtParams, FeePolicy, UTxOs, AlonzoProtParams, UTxOs,
ValidationError::{self, *}, ValidationError::{self, *},
ValidationResult, ValidationResult,
}; };
@ -36,7 +36,7 @@ pub fn validate_alonzo_tx(
network_id: &u8, network_id: &u8,
) -> ValidationResult { ) -> ValidationResult {
let tx_body: &TransactionBody = &mtx.transaction_body; let tx_body: &TransactionBody = &mtx.transaction_body;
let size: &u64 = &get_alonzo_comp_tx_size(tx_body).ok_or(Alonzo(UnknownTxSize))?; let size: &u32 = &get_alonzo_comp_tx_size(tx_body).ok_or(Alonzo(UnknownTxSize))?;
check_ins_not_empty(tx_body)?; check_ins_not_empty(tx_body)?;
check_ins_and_collateral_in_utxos(tx_body, utxos)?; check_ins_and_collateral_in_utxos(tx_body, utxos)?;
check_tx_validity_interval(tx_body, mtx, block_slot)?; check_tx_validity_interval(tx_body, mtx, block_slot)?;
@ -131,7 +131,7 @@ fn check_upper_bound(
fn check_fee( fn check_fee(
tx_body: &TransactionBody, tx_body: &TransactionBody,
size: &u64, size: &u32,
mtx: &MintedTx, mtx: &MintedTx,
utxos: &UTxOs, utxos: &UTxOs,
prot_pps: &AlonzoProtParams, prot_pps: &AlonzoProtParams,
@ -147,11 +147,10 @@ fn check_fee(
// minimum fee. // minimum fee.
fn check_min_fee( fn check_min_fee(
tx_body: &TransactionBody, tx_body: &TransactionBody,
size: &u64, size: &u32,
prot_pps: &AlonzoProtParams, prot_pps: &AlonzoProtParams,
) -> ValidationResult { ) -> ValidationResult {
let fee_policy: &FeePolicy = &prot_pps.fee_policy; if tx_body.fee < (prot_pps.minfee_b + prot_pps.minfee_a * size) as u64 {
if tx_body.fee < fee_policy.summand + fee_policy.multiplier * size {
return Err(Alonzo(FeeBelowMin)); return Err(Alonzo(FeeBelowMin));
} }
Ok(()) Ok(())
@ -185,7 +184,7 @@ fn check_collaterals_number(
collaterals: &[TransactionInput], collaterals: &[TransactionInput],
prot_pps: &AlonzoProtParams, prot_pps: &AlonzoProtParams,
) -> ValidationResult { ) -> ValidationResult {
let number_collateral: u64 = collaterals.len() as u64; let number_collateral: u32 = collaterals.len() as u32;
if number_collateral == 0 { if number_collateral == 0 {
Err(Alonzo(CollateralMissing)) Err(Alonzo(CollateralMissing))
} else if number_collateral > prot_pps.max_collateral_inputs { } else if number_collateral > prot_pps.max_collateral_inputs {
@ -222,7 +221,7 @@ fn check_collaterals_assets(
utxos: &UTxOs, utxos: &UTxOs,
prot_pps: &AlonzoProtParams, prot_pps: &AlonzoProtParams,
) -> ValidationResult { ) -> ValidationResult {
let fee_percentage: u64 = tx_body.fee * prot_pps.collateral_percent; let fee_percentage: u64 = tx_body.fee * prot_pps.collateral_percentage as u64;
match &tx_body.collateral { match &tx_body.collateral {
Some(collaterals) => { Some(collaterals) => {
for collateral in collaterals { for collateral in collaterals {
@ -317,7 +316,7 @@ fn compute_min_lovelace(output: &TransactionOutput, prot_pps: &AlonzoProtParams)
Some(_) => 37, // utxoEntrySizeWithoutVal (27) + dataHashSize (10) Some(_) => 37, // utxoEntrySizeWithoutVal (27) + dataHashSize (10)
None => 27, // utxoEntrySizeWithoutVal None => 27, // utxoEntrySizeWithoutVal
}; };
prot_pps.coins_per_utxo_word * output_entry_size prot_pps.ada_per_utxo_byte * output_entry_size
} }
// The size of the value in each of the outputs should not be greater than the // The size of the value in each of the outputs should not be greater than the
@ -327,7 +326,7 @@ fn check_output_val_size(
prot_pps: &AlonzoProtParams, prot_pps: &AlonzoProtParams,
) -> ValidationResult { ) -> ValidationResult {
for output in tx_body.outputs.iter() { for output in tx_body.outputs.iter() {
if get_val_size_in_words(&output.amount) > prot_pps.max_val_size { if get_val_size_in_words(&output.amount) > prot_pps.max_value_size as u64 {
return Err(Alonzo(MaxValSizeExceeded)); return Err(Alonzo(MaxValSizeExceeded));
} }
} }
@ -364,8 +363,8 @@ fn check_tx_network_id(tx_body: &TransactionBody, network_id: &u8) -> Validation
} }
// The transaction size does not exceed the protocol limit. // The transaction size does not exceed the protocol limit.
fn check_tx_size(size: &u64, prot_pps: &AlonzoProtParams) -> ValidationResult { fn check_tx_size(size: &u32, prot_pps: &AlonzoProtParams) -> ValidationResult {
if *size > prot_pps.max_tx_size { if *size > prot_pps.max_transaction_size {
return Err(Alonzo(MaxTxSizeExceeded)); return Err(Alonzo(MaxTxSizeExceeded));
} }
Ok(()) Ok(())
@ -384,7 +383,7 @@ fn check_tx_ex_units(mtx: &MintedTx, prot_pps: &AlonzoProtParams) -> ValidationR
mem += ex_units.mem; mem += ex_units.mem;
steps += ex_units.steps; steps += ex_units.steps;
} }
if mem > prot_pps.max_tx_ex_mem || steps > prot_pps.max_tx_ex_steps { if mem > prot_pps.max_tx_ex_units.mem || steps > prot_pps.max_tx_ex_units.steps {
return Err(Alonzo(TxExUnitsExceeded)); return Err(Alonzo(TxExUnitsExceeded));
} }
} }

View file

@ -7,7 +7,7 @@ use crate::utils::{
get_val_size_in_words, is_byron_address, lovelace_diff_or_fail, mk_alonzo_vk_wits_check_list, get_val_size_in_words, is_byron_address, lovelace_diff_or_fail, mk_alonzo_vk_wits_check_list,
values_are_equal, verify_signature, values_are_equal, verify_signature,
BabbageError::*, BabbageError::*,
BabbageProtParams, FeePolicy, UTxOs, BabbageProtParams, UTxOs,
ValidationError::{self, *}, ValidationError::{self, *},
ValidationResult, ValidationResult,
}; };
@ -38,7 +38,7 @@ pub fn validate_babbage_tx(
network_id: &u8, network_id: &u8,
) -> ValidationResult { ) -> ValidationResult {
let tx_body: &MintedTransactionBody = &mtx.transaction_body.clone(); let tx_body: &MintedTransactionBody = &mtx.transaction_body.clone();
let size: &u64 = &get_babbage_tx_size(tx_body).ok_or(Babbage(UnknownTxSize))?; let size: &u32 = &get_babbage_tx_size(tx_body).ok_or(Babbage(UnknownTxSize))?;
check_ins_not_empty(tx_body)?; check_ins_not_empty(tx_body)?;
check_all_ins_in_utxos(tx_body, utxos)?; check_all_ins_in_utxos(tx_body, utxos)?;
check_tx_validity_interval(tx_body, block_slot)?; check_tx_validity_interval(tx_body, block_slot)?;
@ -139,7 +139,7 @@ fn check_upper_bound(tx_body: &MintedTransactionBody, block_slot: u64) -> Valida
fn check_fee( fn check_fee(
tx_body: &MintedTransactionBody, tx_body: &MintedTransactionBody,
size: &u64, size: &u32,
mtx: &MintedTx, mtx: &MintedTx,
utxos: &UTxOs, utxos: &UTxOs,
prot_pps: &BabbageProtParams, prot_pps: &BabbageProtParams,
@ -155,11 +155,10 @@ fn check_fee(
// minimum fee. // minimum fee.
fn check_min_fee( fn check_min_fee(
tx_body: &MintedTransactionBody, tx_body: &MintedTransactionBody,
size: &u64, size: &u32,
prot_pps: &BabbageProtParams, prot_pps: &BabbageProtParams,
) -> ValidationResult { ) -> ValidationResult {
let fee_policy: &FeePolicy = &prot_pps.fee_policy; if tx_body.fee < (prot_pps.minfee_b + prot_pps.minfee_a * size) as u64 {
if tx_body.fee < fee_policy.summand + fee_policy.multiplier * size {
return Err(Babbage(FeeBelowMin)); return Err(Babbage(FeeBelowMin));
} }
Ok(()) Ok(())
@ -200,7 +199,7 @@ fn check_collaterals_number(
) -> ValidationResult { ) -> ValidationResult {
if collaterals.is_empty() { if collaterals.is_empty() {
Err(Babbage(CollateralMissing)) Err(Babbage(CollateralMissing))
} else if collaterals.len() > prot_pps.max_collateral_inputs as usize { } else if collaterals.len() as u32 > prot_pps.max_collateral_inputs {
Err(Babbage(TooManyCollaterals)) Err(Babbage(TooManyCollaterals))
} else { } else {
Ok(()) Ok(())
@ -265,7 +264,7 @@ fn check_collaterals_assets(
// The balance between collateral inputs and output contains only lovelace. // The balance between collateral inputs and output contains only lovelace.
let paid_collateral: u64 = let paid_collateral: u64 =
lovelace_diff_or_fail(&coll_input, &coll_return, &Babbage(NonLovelaceCollateral))?; lovelace_diff_or_fail(&coll_input, &coll_return, &Babbage(NonLovelaceCollateral))?;
let fee_percentage: u64 = tx_body.fee * prot_pps.collateral_percent; let fee_percentage: u64 = tx_body.fee * prot_pps.collateral_percentage as u64;
// The balance is not lower than the minimum allowed. // The balance is not lower than the minimum allowed.
if paid_collateral * 100 < fee_percentage { if paid_collateral * 100 < fee_percentage {
return Err(Babbage(CollateralMinLovelace)); return Err(Babbage(CollateralMinLovelace));
@ -357,7 +356,7 @@ fn check_min_lovelace(
} }
fn compute_min_lovelace(val: &Value, prot_pps: &BabbageProtParams) -> u64 { fn compute_min_lovelace(val: &Value, prot_pps: &BabbageProtParams) -> u64 {
prot_pps.coins_per_utxo_word * (get_val_size_in_words(val) + 160) prot_pps.ada_per_utxo_byte * (get_val_size_in_words(val) + 160)
} }
// The size of the value in each of the outputs should not be greater than the // The size of the value in each of the outputs should not be greater than the
@ -371,7 +370,7 @@ fn check_output_val_size(
PseudoTransactionOutput::Legacy(output) => &output.amount, PseudoTransactionOutput::Legacy(output) => &output.amount,
PseudoTransactionOutput::PostAlonzo(output) => &output.value, PseudoTransactionOutput::PostAlonzo(output) => &output.value,
}; };
if get_val_size_in_words(val) > prot_pps.max_val_size { if get_val_size_in_words(val) > prot_pps.max_value_size as u64 {
return Err(Babbage(MaxValSizeExceeded)); return Err(Babbage(MaxValSizeExceeded));
} }
} }
@ -409,8 +408,8 @@ fn check_tx_network_id(tx_body: &MintedTransactionBody, network_id: &u8) -> Vali
Ok(()) Ok(())
} }
fn check_tx_size(size: &u64, prot_pps: &BabbageProtParams) -> ValidationResult { fn check_tx_size(size: &u32, prot_pps: &BabbageProtParams) -> ValidationResult {
if *size > prot_pps.max_tx_size { if *size > prot_pps.max_transaction_size {
return Err(Babbage(MaxTxSizeExceeded)); return Err(Babbage(MaxTxSizeExceeded));
} }
Ok(()) Ok(())
@ -427,7 +426,7 @@ fn check_tx_ex_units(mtx: &MintedTx, prot_pps: &BabbageProtParams) -> Validation
mem += ex_units.mem; mem += ex_units.mem;
steps += ex_units.steps; steps += ex_units.steps;
} }
if mem > prot_pps.max_tx_ex_mem || steps > prot_pps.max_tx_ex_steps { if mem > prot_pps.max_tx_ex_units.mem || steps > prot_pps.max_tx_ex_units.steps {
return Err(Babbage(TxExUnitsExceeded)); return Err(Babbage(TxExUnitsExceeded));
} }
} }

View file

@ -97,7 +97,7 @@ fn check_fees(tx: &Tx, size: &u64, utxos: &UTxOs, prot_pps: &ByronProtParams) ->
outputs_balance += output.amount outputs_balance += output.amount
} }
let total_balance: u64 = inputs_balance - outputs_balance; let total_balance: u64 = inputs_balance - outputs_balance;
let min_fees: u64 = prot_pps.fee_policy.summand + prot_pps.fee_policy.multiplier * size; let min_fees: u64 = prot_pps.summand + prot_pps.multiplier * size;
if total_balance < min_fees { if total_balance < min_fees {
Err(Byron(FeesBelowMin)) Err(Byron(FeesBelowMin))
} else { } else {

View file

@ -13,17 +13,18 @@ use pallas_traverse::{Era, MultiEraTx};
use shelley_ma::validate_shelley_ma_tx; use shelley_ma::validate_shelley_ma_tx;
pub use utils::{ pub use utils::{
Environment, MultiEraProtParams, UTxOs, ValidationError::TxAndProtParamsDiffer, Environment, MultiEraProtocolParameters, UTxOs,
ValidationError::{TxAndProtParamsDiffer, UnknownProtParams},
ValidationResult, ValidationResult,
}; };
pub fn validate(metx: &MultiEraTx, utxos: &UTxOs, env: &Environment) -> ValidationResult { pub fn validate(metx: &MultiEraTx, utxos: &UTxOs, env: &Environment) -> ValidationResult {
match env.prot_params() { match env.prot_params() {
MultiEraProtParams::Byron(bpp) => match metx { MultiEraProtocolParameters::Byron(bpp) => match metx {
MultiEraTx::Byron(mtxp) => validate_byron_tx(mtxp, utxos, bpp, env.prot_magic()), MultiEraTx::Byron(mtxp) => validate_byron_tx(mtxp, utxos, bpp, env.prot_magic()),
_ => Err(TxAndProtParamsDiffer), _ => Err(TxAndProtParamsDiffer),
}, },
MultiEraProtParams::Shelley(spp) => match metx { MultiEraProtocolParameters::Shelley(spp) => match metx {
MultiEraTx::AlonzoCompatible(mtx, Era::Shelley) MultiEraTx::AlonzoCompatible(mtx, Era::Shelley)
| MultiEraTx::AlonzoCompatible(mtx, Era::Allegra) | MultiEraTx::AlonzoCompatible(mtx, Era::Allegra)
| MultiEraTx::AlonzoCompatible(mtx, Era::Mary) => validate_shelley_ma_tx( | MultiEraTx::AlonzoCompatible(mtx, Era::Mary) => validate_shelley_ma_tx(
@ -36,13 +37,13 @@ pub fn validate(metx: &MultiEraTx, utxos: &UTxOs, env: &Environment) -> Validati
), ),
_ => Err(TxAndProtParamsDiffer), _ => Err(TxAndProtParamsDiffer),
}, },
MultiEraProtParams::Alonzo(app) => match metx { MultiEraProtocolParameters::Alonzo(app) => match metx {
MultiEraTx::AlonzoCompatible(mtx, Era::Alonzo) => { MultiEraTx::AlonzoCompatible(mtx, Era::Alonzo) => {
validate_alonzo_tx(mtx, utxos, app, env.block_slot(), env.network_id()) validate_alonzo_tx(mtx, utxos, app, env.block_slot(), env.network_id())
} }
_ => Err(TxAndProtParamsDiffer), _ => Err(TxAndProtParamsDiffer),
}, },
MultiEraProtParams::Babbage(bpp) => match metx { MultiEraProtocolParameters::Babbage(bpp) => match metx {
MultiEraTx::Babbage(mtx) => validate_babbage_tx( MultiEraTx::Babbage(mtx) => validate_babbage_tx(
mtx, mtx,
utxos, utxos,

View file

@ -4,7 +4,6 @@ use crate::utils::{
add_minted_value, add_values, aux_data_from_alonzo_minted_tx, empty_value, add_minted_value, add_values, aux_data_from_alonzo_minted_tx, empty_value,
get_alonzo_comp_tx_size, get_lovelace_from_alonzo_val, get_payment_part, get_shelley_address, get_alonzo_comp_tx_size, get_lovelace_from_alonzo_val, get_payment_part, get_shelley_address,
get_val_size_in_words, mk_alonzo_vk_wits_check_list, values_are_equal, verify_signature, get_val_size_in_words, mk_alonzo_vk_wits_check_list, values_are_equal, verify_signature,
FeePolicy,
ShelleyMAError::*, ShelleyMAError::*,
ShelleyProtParams, UTxOs, ShelleyProtParams, UTxOs,
ValidationError::{self, *}, ValidationError::{self, *},
@ -32,7 +31,7 @@ pub fn validate_shelley_ma_tx(
) -> ValidationResult { ) -> ValidationResult {
let tx_body: &TransactionBody = &mtx.transaction_body; let tx_body: &TransactionBody = &mtx.transaction_body;
let tx_wits: &MintedWitnessSet = &mtx.transaction_witness_set; let tx_wits: &MintedWitnessSet = &mtx.transaction_witness_set;
let size: &u64 = &get_alonzo_comp_tx_size(tx_body).ok_or(ShelleyMA(UnknownTxSize))?; let size: &u32 = &get_alonzo_comp_tx_size(tx_body).ok_or(ShelleyMA(UnknownTxSize))?;
check_ins_not_empty(tx_body)?; check_ins_not_empty(tx_body)?;
check_ins_in_utxos(tx_body, utxos)?; check_ins_in_utxos(tx_body, utxos)?;
check_ttl(tx_body, block_slot)?; check_ttl(tx_body, block_slot)?;
@ -75,8 +74,8 @@ fn check_ttl(tx_body: &TransactionBody, block_slot: &u64) -> ValidationResult {
} }
} }
fn check_tx_size(size: &u64, prot_pps: &ShelleyProtParams) -> ValidationResult { fn check_tx_size(size: &u32, prot_pps: &ShelleyProtParams) -> ValidationResult {
if *size > prot_pps.max_tx_size { if *size > prot_pps.max_transaction_size {
return Err(ShelleyMA(MaxTxSizeExceeded)); return Err(ShelleyMA(MaxTxSizeExceeded));
} }
Ok(()) Ok(())
@ -104,10 +103,10 @@ fn check_min_lovelace(
fn compute_min_lovelace(output: &TransactionOutput, prot_pps: &ShelleyProtParams) -> u64 { fn compute_min_lovelace(output: &TransactionOutput, prot_pps: &ShelleyProtParams) -> u64 {
match &output.amount { match &output.amount {
Value::Coin(_) => prot_pps.min_lovelace, Value::Coin(_) => prot_pps.min_utxo_value,
Value::Multiasset(lovelace, _) => { Value::Multiasset(lovelace, _) => {
let utxo_entry_size: u64 = 27 + get_val_size_in_words(&output.amount); let utxo_entry_size: u64 = 27 + get_val_size_in_words(&output.amount);
let coins_per_utxo_word: u64 = prot_pps.min_lovelace / 27; let coins_per_utxo_word: u64 = prot_pps.min_utxo_value / 27;
max(*lovelace, utxo_entry_size * coins_per_utxo_word) max(*lovelace, utxo_entry_size * coins_per_utxo_word)
} }
} }
@ -174,11 +173,10 @@ fn get_produced(tx_body: &TransactionBody, era: &Era) -> Result<Value, Validatio
fn check_fees( fn check_fees(
tx_body: &TransactionBody, tx_body: &TransactionBody,
size: &u64, size: &u32,
prot_pps: &ShelleyProtParams, prot_pps: &ShelleyProtParams,
) -> ValidationResult { ) -> ValidationResult {
let fee_policy: &FeePolicy = &prot_pps.fee_policy; if tx_body.fee < (prot_pps.minfee_b + prot_pps.minfee_a * size) as u64 {
if tx_body.fee < fee_policy.summand + fee_policy.multiplier * size {
return Err(ShelleyMA(FeesBelowMin)); return Err(ShelleyMA(FeesBelowMin));
} }
Ok(()) Ok(())

View file

@ -24,18 +24,18 @@ pub use validation::*;
pub type UTxOs<'b> = HashMap<MultiEraInput<'b>, MultiEraOutput<'b>>; pub type UTxOs<'b> = HashMap<MultiEraInput<'b>, MultiEraOutput<'b>>;
pub fn get_alonzo_comp_tx_size(tx_body: &TransactionBody) -> Option<u64> { pub fn get_alonzo_comp_tx_size(tx_body: &TransactionBody) -> Option<u32> {
let mut buff: Vec<u8> = Vec::new(); let mut buff: Vec<u8> = Vec::new();
match encode(tx_body, &mut buff) { match encode(tx_body, &mut buff) {
Ok(()) => Some(buff.len() as u64), Ok(()) => Some(buff.len() as u32),
Err(_) => None, Err(_) => None,
} }
} }
pub fn get_babbage_tx_size(tx_body: &MintedTransactionBody) -> Option<u64> { pub fn get_babbage_tx_size(tx_body: &MintedTransactionBody) -> Option<u32> {
let mut buff: Vec<u8> = Vec::new(); let mut buff: Vec<u8> = Vec::new();
match encode(tx_body, &mut buff) { match encode(tx_body, &mut buff) {
Ok(()) => Some(buff.len() as u64), Ok(()) => Some(buff.len() as u32),
Err(_) => None, Err(_) => None,
} }
} }

View file

@ -1,73 +1,289 @@
//! Types used for representing the environment required for validation in each //! Types used for representing the environment required for validation in each
//! era. //! era.
use pallas_codec::minicbor::{self, Decode, Encode};
use pallas_primitives::{
alonzo::{
Coin, CostMdls, Epoch, ExUnitPrices, ExUnits, Nonce, ProtocolVersion, RationalNumber,
UnitInterval,
},
babbage::CostMdls as BabbageCostMdls,
};
#[derive(Debug, Clone, Encode, Decode)]
#[non_exhaustive]
pub enum MultiEraProtocolParameters {
#[n(0)]
Byron(#[n(1)] ByronProtParams),
#[n(2)]
Shelley(#[n(3)] ShelleyProtParams),
#[n(4)]
Alonzo(#[n(5)] AlonzoProtParams),
#[n(6)]
Babbage(#[n(7)] BabbageProtParams),
}
#[derive(Debug, Clone, Encode, Decode)]
pub struct ByronProtParams {
#[n(0)]
pub script_version: u16,
#[n(1)]
pub slot_duration: u64,
#[n(2)]
pub max_block_size: u64,
#[n(3)]
pub max_header_size: u64,
#[n(4)]
pub max_tx_size: u64,
#[n(5)]
pub max_proposal_size: u64,
#[n(6)]
pub mpc_thd: u64,
#[n(7)]
pub heavy_del_thd: u64,
#[n(8)]
pub update_vote_thd: u64,
#[n(9)]
pub update_proposal_thd: u64,
#[n(10)]
pub update_implicit: u64,
#[n(11)]
pub soft_fork_rule: (u64, u64, u64),
#[n(12)]
pub summand: u64,
#[n(13)]
pub multiplier: u64,
#[n(14)]
pub unlock_stake_epoch: u64,
}
#[derive(Debug, Clone, Encode, Decode)]
pub struct ShelleyProtParams {
#[n(0)]
pub minfee_a: u32,
#[n(1)]
pub minfee_b: u32,
#[n(2)]
pub max_block_body_size: u32,
#[n(3)]
pub max_transaction_size: u32,
#[n(4)]
pub max_block_header_size: u32,
#[n(5)]
pub key_deposit: Coin,
#[n(6)]
pub pool_deposit: Coin,
#[n(7)]
pub maximum_epoch: Epoch,
#[n(8)]
pub desired_number_of_stake_pools: u32,
#[n(9)]
pub pool_pledge_influence: RationalNumber,
#[n(10)]
pub expansion_rate: UnitInterval,
#[n(11)]
pub treasury_growth_rate: UnitInterval,
#[n(12)]
pub decentralization_constant: UnitInterval,
#[n(13)]
pub extra_entropy: Nonce,
#[n(14)]
pub protocol_version: ProtocolVersion,
#[n(15)]
pub min_utxo_value: Coin,
}
#[derive(Debug, Clone, Encode, Decode)]
pub struct AlonzoProtParams {
#[n(0)]
pub minfee_a: u32,
#[n(1)]
pub minfee_b: u32,
#[n(2)]
pub max_block_body_size: u32,
#[n(3)]
pub max_transaction_size: u32,
#[n(4)]
pub max_block_header_size: u32,
#[n(5)]
pub key_deposit: Coin,
#[n(6)]
pub pool_deposit: Coin,
#[n(7)]
pub maximum_epoch: Epoch,
#[n(8)]
pub desired_number_of_stake_pools: u32,
#[n(9)]
pub pool_pledge_influence: RationalNumber,
#[n(10)]
pub expansion_rate: UnitInterval,
#[n(11)]
pub treasury_growth_rate: UnitInterval,
#[n(12)]
pub decentralization_constant: UnitInterval,
#[n(13)]
pub extra_entropy: Nonce,
#[n(14)]
pub protocol_version: ProtocolVersion,
#[n(15)]
pub min_pool_cost: Coin,
#[n(16)]
pub ada_per_utxo_byte: Coin,
#[n(17)]
pub cost_models_for_script_languages: CostMdls,
#[n(18)]
pub execution_costs: ExUnitPrices,
#[n(19)]
pub max_tx_ex_units: ExUnits,
#[n(20)]
pub max_block_ex_units: ExUnits,
#[n(21)]
pub max_value_size: u32,
#[n(22)]
pub collateral_percentage: u32,
#[n(24)]
pub max_collateral_inputs: u32,
}
#[derive(Debug, Clone, Encode, Decode)]
pub struct BabbageProtParams {
#[n(0)]
pub minfee_a: u32,
#[n(1)]
pub minfee_b: u32,
#[n(2)]
pub max_block_body_size: u32,
#[n(3)]
pub max_transaction_size: u32,
#[n(4)]
pub max_block_header_size: u32,
#[n(5)]
pub key_deposit: Coin,
#[n(6)]
pub pool_deposit: Coin,
#[n(7)]
pub maximum_epoch: Epoch,
#[n(8)]
pub desired_number_of_stake_pools: u32,
#[n(9)]
pub pool_pledge_influence: RationalNumber,
#[n(10)]
pub expansion_rate: UnitInterval,
#[n(11)]
pub treasury_growth_rate: UnitInterval,
#[n(12)]
pub decentralization_constant: UnitInterval,
#[n(13)]
pub extra_entropy: Nonce,
#[n(14)]
pub protocol_version: ProtocolVersion,
#[n(15)]
pub min_pool_cost: Coin,
#[n(16)]
pub ada_per_utxo_byte: Coin,
#[n(17)]
pub cost_models_for_script_languages: BabbageCostMdls,
#[n(18)]
pub execution_costs: ExUnitPrices,
#[n(19)]
pub max_tx_ex_units: ExUnits,
#[n(20)]
pub max_block_ex_units: ExUnits,
#[n(21)]
pub max_value_size: u32,
#[n(22)]
pub collateral_percentage: u32,
#[n(24)]
pub max_collateral_inputs: u32,
}
#[derive(Debug)] #[derive(Debug)]
pub struct Environment { pub struct Environment {
pub prot_params: MultiEraProtParams, pub prot_params: MultiEraProtocolParameters,
pub prot_magic: u32, pub prot_magic: u32,
pub block_slot: u64, pub block_slot: u64,
pub network_id: u8, pub network_id: u8,
} }
// TODO: add variants for the other eras.
#[derive(Debug)]
#[non_exhaustive]
pub enum MultiEraProtParams {
Byron(ByronProtParams),
Shelley(ShelleyProtParams),
Alonzo(AlonzoProtParams),
Babbage(BabbageProtParams),
}
#[derive(Debug, Clone)]
pub struct ByronProtParams {
pub fee_policy: FeePolicy,
pub max_tx_size: u64,
}
#[derive(Debug, Clone)]
pub struct ShelleyProtParams {
pub fee_policy: FeePolicy,
pub max_tx_size: u64,
pub min_lovelace: u64,
}
#[derive(Debug, Clone)]
pub struct FeePolicy {
pub summand: u64,
pub multiplier: u64,
}
#[derive(Debug, Clone)]
pub struct AlonzoProtParams {
pub fee_policy: FeePolicy,
pub max_tx_size: u64,
pub max_block_ex_mem: u64,
pub max_block_ex_steps: u64,
pub max_tx_ex_mem: u32,
pub max_tx_ex_steps: u64,
pub max_val_size: u64,
pub collateral_percent: u64,
pub max_collateral_inputs: u64,
pub coins_per_utxo_word: u64,
}
#[derive(Debug, Clone)]
pub struct BabbageProtParams {
pub fee_policy: FeePolicy,
pub max_tx_size: u64,
pub max_block_ex_mem: u64,
pub max_block_ex_steps: u64,
pub max_tx_ex_mem: u32,
pub max_tx_ex_steps: u64,
pub max_val_size: u64,
pub collateral_percent: u64,
pub max_collateral_inputs: u64,
pub coins_per_utxo_word: u64,
}
impl Environment { impl Environment {
pub fn prot_params(&self) -> &MultiEraProtParams { pub fn prot_params(&self) -> &MultiEraProtocolParameters {
&self.prot_params &self.prot_params
} }

View file

@ -4,6 +4,7 @@
#[non_exhaustive] #[non_exhaustive]
pub enum ValidationError { pub enum ValidationError {
TxAndProtParamsDiffer, TxAndProtParamsDiffer,
UnknownProtParams,
Byron(ByronError), Byron(ByronError),
ShelleyMA(ShelleyMAError), ShelleyMA(ShelleyMAError),
Alonzo(AlonzoError), Alonzo(AlonzoError),

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -3,7 +3,7 @@ pub mod common;
use common::{cbor_to_bytes, minted_tx_payload_from_cbor, mk_utxo_for_byron_tx}; use common::{cbor_to_bytes, minted_tx_payload_from_cbor, mk_utxo_for_byron_tx};
use pallas_applying::{ use pallas_applying::{
utils::{ utils::{
ByronError, ByronProtParams, Environment, FeePolicy, MultiEraProtParams, ValidationError::*, ByronError, ByronProtParams, Environment, MultiEraProtocolParameters, ValidationError::*,
}, },
validate, UTxOs, validate, UTxOs,
}; };
@ -33,17 +33,27 @@ mod byron_tests {
let utxos: UTxOs = mk_utxo_for_byron_tx( let utxos: UTxOs = mk_utxo_for_byron_tx(
&mtxp.transaction, &mtxp.transaction,
&[( &[(
String::from(include_str!("../../test_data/byron2.address")), String::from("83581CDC7E4DD6A44886816DEC9A4B2021056A8FCAF500C09E316028F2985FA002"),
19999000000, 19999000000,
)], )],
); );
let env: Environment = Environment { let env: Environment = Environment {
prot_params: MultiEraProtParams::Byron(ByronProtParams { prot_params: MultiEraProtocolParameters::Byron(ByronProtParams {
fee_policy: FeePolicy { script_version: 0,
summand: 155381, slot_duration: 20000,
multiplier: 44, max_block_size: 2000000,
}, max_header_size: 2000000,
max_tx_size: 4096, max_tx_size: 4096,
max_proposal_size: 700,
mpc_thd: 20000000000000,
heavy_del_thd: 300000000000,
update_vote_thd: 1000000000000,
update_proposal_thd: 100000000000000,
update_implicit: 10000,
soft_fork_rule: (900000000000000, 600000000000000, 50000000000000),
summand: 155381,
multiplier: 44,
unlock_stake_epoch: 18446744073709551615,
}), }),
prot_magic: 764824073, prot_magic: 764824073,
block_slot: 6341, block_slot: 6341,
@ -65,17 +75,27 @@ mod byron_tests {
let utxos: UTxOs = mk_utxo_for_byron_tx( let utxos: UTxOs = mk_utxo_for_byron_tx(
&mtxp.transaction, &mtxp.transaction,
&[( &[(
String::from(include_str!("../../test_data/byron1.address")), String::from("83581cff66e7549ee0706abe5ce63ba325f792f2c1145d918baf563db2b457a101581e581cca3e553c9c63c5927480e7434620200eb3a162ef0b6cf6f671ba925100"),
19999000000, 19999000000,
)], )],
); );
let env: Environment = Environment { let env: Environment = Environment {
prot_params: MultiEraProtParams::Byron(ByronProtParams { prot_params: MultiEraProtocolParameters::Byron(ByronProtParams {
fee_policy: FeePolicy { script_version: 0,
summand: 155381, slot_duration: 20000,
multiplier: 44, max_block_size: 2000000,
}, max_header_size: 2000000,
max_tx_size: 4096, max_tx_size: 4096,
max_proposal_size: 700,
mpc_thd: 20000000000000,
heavy_del_thd: 300000000000,
update_vote_thd: 1000000000000,
update_proposal_thd: 100000000000000,
update_implicit: 10000,
soft_fork_rule: (900000000000000, 600000000000000, 50000000000000),
summand: 155381,
multiplier: 44,
unlock_stake_epoch: 18446744073709551615,
}), }),
prot_magic: 764824073, prot_magic: 764824073,
block_slot: 3241381, block_slot: 3241381,
@ -95,7 +115,7 @@ mod byron_tests {
let utxos: UTxOs = mk_utxo_for_byron_tx( let utxos: UTxOs = mk_utxo_for_byron_tx(
&mtxp.transaction, &mtxp.transaction,
&[( &[(
String::from(include_str!("../../test_data/byron1.address")), String::from("83581cff66e7549ee0706abe5ce63ba325f792f2c1145d918baf563db2b457a101581e581cca3e553c9c63c5927480e7434620200eb3a162ef0b6cf6f671ba925100"),
19999000000, 19999000000,
)], )],
); );
@ -110,12 +130,22 @@ mod byron_tests {
mtxp.transaction = Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap(); mtxp.transaction = Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_byron(&mtxp); let metx: MultiEraTx = MultiEraTx::from_byron(&mtxp);
let env: Environment = Environment { let env: Environment = Environment {
prot_params: MultiEraProtParams::Byron(ByronProtParams { prot_params: MultiEraProtocolParameters::Byron(ByronProtParams {
fee_policy: FeePolicy { script_version: 0,
summand: 155381, slot_duration: 20000,
multiplier: 44, max_block_size: 2000000,
}, max_header_size: 2000000,
max_tx_size: 4096, max_tx_size: 4096,
max_proposal_size: 700,
mpc_thd: 20000000000000,
heavy_del_thd: 300000000000,
update_vote_thd: 1000000000000,
update_proposal_thd: 100000000000000,
update_implicit: 10000,
soft_fork_rule: (900000000000000, 600000000000000, 50000000000000),
summand: 155381,
multiplier: 44,
unlock_stake_epoch: 18446744073709551615,
}), }),
prot_magic: 764824073, prot_magic: 764824073,
block_slot: 3241381, block_slot: 3241381,
@ -148,17 +178,27 @@ mod byron_tests {
let utxos: UTxOs = mk_utxo_for_byron_tx( let utxos: UTxOs = mk_utxo_for_byron_tx(
&mtxp.transaction, &mtxp.transaction,
&[( &[(
String::from(include_str!("../../test_data/byron1.address")), String::from("83581cff66e7549ee0706abe5ce63ba325f792f2c1145d918baf563db2b457a101581e581cca3e553c9c63c5927480e7434620200eb3a162ef0b6cf6f671ba925100"),
19999000000, 19999000000,
)], )],
); );
let env: Environment = Environment { let env: Environment = Environment {
prot_params: MultiEraProtParams::Byron(ByronProtParams { prot_params: MultiEraProtocolParameters::Byron(ByronProtParams {
fee_policy: FeePolicy { script_version: 0,
summand: 155381, slot_duration: 20000,
multiplier: 44, max_block_size: 2000000,
}, max_header_size: 2000000,
max_tx_size: 4096, max_tx_size: 4096,
max_proposal_size: 700,
mpc_thd: 20000000000000,
heavy_del_thd: 300000000000,
update_vote_thd: 1000000000000,
update_proposal_thd: 100000000000000,
update_implicit: 10000,
soft_fork_rule: (900000000000000, 600000000000000, 50000000000000),
summand: 155381,
multiplier: 44,
unlock_stake_epoch: 18446744073709551615,
}), }),
prot_magic: 764824073, prot_magic: 764824073,
block_slot: 3241381, block_slot: 3241381,
@ -181,12 +221,22 @@ mod byron_tests {
let metx: MultiEraTx = MultiEraTx::from_byron(&mtxp); let metx: MultiEraTx = MultiEraTx::from_byron(&mtxp);
let utxos: UTxOs = UTxOs::new(); let utxos: UTxOs = UTxOs::new();
let env: Environment = Environment { let env: Environment = Environment {
prot_params: MultiEraProtParams::Byron(ByronProtParams { prot_params: MultiEraProtocolParameters::Byron(ByronProtParams {
fee_policy: FeePolicy { script_version: 0,
summand: 155381, slot_duration: 20000,
multiplier: 44, max_block_size: 2000000,
}, max_header_size: 2000000,
max_tx_size: 4096, max_tx_size: 4096,
max_proposal_size: 700,
mpc_thd: 20000000000000,
heavy_del_thd: 300000000000,
update_vote_thd: 1000000000000,
update_proposal_thd: 100000000000000,
update_implicit: 10000,
soft_fork_rule: (900000000000000, 600000000000000, 50000000000000),
summand: 155381,
multiplier: 44,
unlock_stake_epoch: 18446744073709551615,
}), }),
prot_magic: 764824073, prot_magic: 764824073,
block_slot: 3241381, block_slot: 3241381,
@ -225,17 +275,27 @@ mod byron_tests {
let utxos: UTxOs = mk_utxo_for_byron_tx( let utxos: UTxOs = mk_utxo_for_byron_tx(
&mtxp.transaction, &mtxp.transaction,
&[( &[(
String::from(include_str!("../../test_data/byron1.address")), String::from("83581cff66e7549ee0706abe5ce63ba325f792f2c1145d918baf563db2b457a101581e581cca3e553c9c63c5927480e7434620200eb3a162ef0b6cf6f671ba925100"),
19999000000, 19999000000,
)], )],
); );
let env: Environment = Environment { let env: Environment = Environment {
prot_params: MultiEraProtParams::Byron(ByronProtParams { prot_params: MultiEraProtocolParameters::Byron(ByronProtParams {
fee_policy: FeePolicy { script_version: 0,
summand: 155381, slot_duration: 20000,
multiplier: 44, max_block_size: 2000000,
}, max_header_size: 2000000,
max_tx_size: 4096, max_tx_size: 4096,
max_proposal_size: 700,
mpc_thd: 20000000000000,
heavy_del_thd: 300000000000,
update_vote_thd: 1000000000000,
update_proposal_thd: 100000000000000,
update_implicit: 10000,
soft_fork_rule: (900000000000000, 600000000000000, 50000000000000),
summand: 155381,
multiplier: 44,
unlock_stake_epoch: 18446744073709551615,
}), }),
prot_magic: 764824073, prot_magic: 764824073,
block_slot: 3241381, block_slot: 3241381,
@ -259,17 +319,27 @@ mod byron_tests {
let utxos: UTxOs = mk_utxo_for_byron_tx( let utxos: UTxOs = mk_utxo_for_byron_tx(
&mtxp.transaction, &mtxp.transaction,
&[( &[(
String::from(include_str!("../../test_data/byron1.address")), String::from("83581cff66e7549ee0706abe5ce63ba325f792f2c1145d918baf563db2b457a101581e581cca3e553c9c63c5927480e7434620200eb3a162ef0b6cf6f671ba925100"),
19999000000, 19999000000,
)], )],
); );
let env: Environment = Environment { let env: Environment = Environment {
prot_params: MultiEraProtParams::Byron(ByronProtParams { prot_params: MultiEraProtocolParameters::Byron(ByronProtParams {
fee_policy: FeePolicy { script_version: 0,
summand: 1000, slot_duration: 20000,
multiplier: 1000, max_block_size: 2000000,
}, max_header_size: 2000000,
max_tx_size: 4096, max_tx_size: 4096,
max_proposal_size: 700,
mpc_thd: 20000000000000,
heavy_del_thd: 300000000000,
update_vote_thd: 1000000000000,
update_proposal_thd: 100000000000000,
update_implicit: 10000,
soft_fork_rule: (900000000000000, 600000000000000, 50000000000000),
summand: 1000,
multiplier: 1000,
unlock_stake_epoch: 18446744073709551615,
}), }),
prot_magic: 764824073, prot_magic: 764824073,
block_slot: 3241381, block_slot: 3241381,
@ -293,17 +363,27 @@ mod byron_tests {
let utxos: UTxOs = mk_utxo_for_byron_tx( let utxos: UTxOs = mk_utxo_for_byron_tx(
&mtxp.transaction, &mtxp.transaction,
&[( &[(
String::from(include_str!("../../test_data/byron1.address")), String::from("83581cff66e7549ee0706abe5ce63ba325f792f2c1145d918baf563db2b457a101581e581cca3e553c9c63c5927480e7434620200eb3a162ef0b6cf6f671ba925100"),
19999000000, 19999000000,
)], )],
); );
let env: Environment = Environment { let env: Environment = Environment {
prot_params: MultiEraProtParams::Byron(ByronProtParams { prot_params: MultiEraProtocolParameters::Byron(ByronProtParams {
fee_policy: FeePolicy { script_version: 0,
summand: 155381, slot_duration: 20000,
multiplier: 44, max_block_size: 2000000,
}, max_header_size: 2000000,
max_tx_size: 0, max_tx_size: 0,
max_proposal_size: 700,
mpc_thd: 20000000000000,
heavy_del_thd: 300000000000,
update_vote_thd: 1000000000000,
update_proposal_thd: 100000000000000,
update_implicit: 10000,
soft_fork_rule: (900000000000000, 600000000000000, 50000000000000),
summand: 155381,
multiplier: 44,
unlock_stake_epoch: 18446744073709551615,
}), }),
prot_magic: 764824073, prot_magic: 764824073,
block_slot: 3241381, block_slot: 3241381,
@ -319,7 +399,7 @@ mod byron_tests {
} }
#[test] #[test]
// The input to the transaction does not have a corresponding witness. // The input to the transaction does not have a matching witness.
fn missing_witness() { fn missing_witness() {
let cbor_bytes: Vec<u8> = cbor_to_bytes(include_str!("../../test_data/byron1.tx")); let cbor_bytes: Vec<u8> = cbor_to_bytes(include_str!("../../test_data/byron1.tx"));
let mut mtxp: MintedTxPayload = minted_tx_payload_from_cbor(&cbor_bytes); let mut mtxp: MintedTxPayload = minted_tx_payload_from_cbor(&cbor_bytes);
@ -335,17 +415,27 @@ mod byron_tests {
let utxos: UTxOs = mk_utxo_for_byron_tx( let utxos: UTxOs = mk_utxo_for_byron_tx(
&mtxp.transaction, &mtxp.transaction,
&[( &[(
String::from(include_str!("../../test_data/byron1.address")), String::from("83581cff66e7549ee0706abe5ce63ba325f792f2c1145d918baf563db2b457a101581e581cca3e553c9c63c5927480e7434620200eb3a162ef0b6cf6f671ba925100"),
19999000000, 19999000000,
)], )],
); );
let env: Environment = Environment { let env: Environment = Environment {
prot_params: MultiEraProtParams::Byron(ByronProtParams { prot_params: MultiEraProtocolParameters::Byron(ByronProtParams {
fee_policy: FeePolicy { script_version: 0,
summand: 155381, slot_duration: 20000,
multiplier: 44, max_block_size: 2000000,
}, max_header_size: 2000000,
max_tx_size: 4096, max_tx_size: 4096,
max_proposal_size: 700,
mpc_thd: 20000000000000,
heavy_del_thd: 300000000000,
update_vote_thd: 1000000000000,
update_proposal_thd: 100000000000000,
update_implicit: 10000,
soft_fork_rule: (900000000000000, 600000000000000, 50000000000000),
summand: 155381,
multiplier: 44,
unlock_stake_epoch: 18446744073709551615,
}), }),
prot_magic: 764824073, prot_magic: 764824073,
block_slot: 3241381, block_slot: 3241381,
@ -386,17 +476,27 @@ mod byron_tests {
let utxos: UTxOs = mk_utxo_for_byron_tx( let utxos: UTxOs = mk_utxo_for_byron_tx(
&mtxp.transaction, &mtxp.transaction,
&[( &[(
String::from(include_str!("../../test_data/byron1.address")), String::from("83581cff66e7549ee0706abe5ce63ba325f792f2c1145d918baf563db2b457a101581e581cca3e553c9c63c5927480e7434620200eb3a162ef0b6cf6f671ba925100"),
19999000000, 19999000000,
)], )],
); );
let env: Environment = Environment { let env: Environment = Environment {
prot_params: MultiEraProtParams::Byron(ByronProtParams { prot_params: MultiEraProtocolParameters::Byron(ByronProtParams {
fee_policy: FeePolicy { script_version: 0,
summand: 155381, slot_duration: 20000,
multiplier: 44, max_block_size: 2000000,
}, max_header_size: 2000000,
max_tx_size: 4096, max_tx_size: 4096,
max_proposal_size: 700,
mpc_thd: 20000000000000,
heavy_del_thd: 300000000000,
update_vote_thd: 1000000000000,
update_proposal_thd: 100000000000000,
update_implicit: 10000,
soft_fork_rule: (900000000000000, 600000000000000, 50000000000000),
summand: 155381,
multiplier: 44,
unlock_stake_epoch: 18446744073709551615,
}), }),
prot_magic: 764824073, prot_magic: 764824073,
block_slot: 3241381, block_slot: 3241381,

View file

@ -4,7 +4,7 @@ use common::*;
use pallas_addresses::{Address, Network, ShelleyAddress}; use pallas_addresses::{Address, Network, ShelleyAddress};
use pallas_applying::{ use pallas_applying::{
utils::{ utils::{
Environment, FeePolicy, MultiEraProtParams, ShelleyMAError, ShelleyProtParams, Environment, MultiEraProtocolParameters, ShelleyMAError, ShelleyProtParams,
ValidationError::*, ValidationError::*,
}, },
validate, UTxOs, validate, UTxOs,
@ -17,7 +17,8 @@ use pallas_codec::{
utils::{Bytes, Nullable}, utils::{Bytes, Nullable},
}; };
use pallas_primitives::alonzo::{ use pallas_primitives::alonzo::{
MintedTx, MintedWitnessSet, TransactionBody, TransactionOutput, VKeyWitness, Value, MintedTx, MintedWitnessSet, Nonce, NonceVariant, RationalNumber, TransactionBody,
TransactionOutput, VKeyWitness, Value,
}; };
use pallas_traverse::{Era, MultiEraTx}; use pallas_traverse::{Era, MultiEraTx};
@ -35,19 +36,47 @@ mod shelley_ma_tests {
let utxos: UTxOs = mk_utxo_for_alonzo_compatible_tx( let utxos: UTxOs = mk_utxo_for_alonzo_compatible_tx(
&mtx.transaction_body, &mtx.transaction_body,
&[( &[(
String::from(include_str!("../../test_data/shelley1.address")), String::from("0129bb156d52d014bb444a14138cbee36044c6faed37d0c2d49d2358315c465cbf8c5536970e8a29bb7adcda0d663b20007d481813694c64ef"),
Value::Coin(2332267427205), Value::Coin(2332267427205),
None, None,
)], )],
); );
let env: Environment = Environment { let env: Environment = Environment {
prot_params: MultiEraProtParams::Shelley(ShelleyProtParams { prot_params: MultiEraProtocolParameters::Shelley(ShelleyProtParams {
fee_policy: FeePolicy { minfee_b: 155381,
summand: 155381, minfee_a: 44,
multiplier: 44, max_block_body_size: 65536,
max_transaction_size: 4096,
max_block_header_size: 1100,
key_deposit: 2000000,
pool_deposit: 500000000,
maximum_epoch: 18,
desired_number_of_stake_pools: 150,
pool_pledge_influence: RationalNumber {
// FIX: this is a made-up value.
numerator: 1,
denominator: 1,
}, },
max_tx_size: 4096, expansion_rate: RationalNumber {
min_lovelace: 1000000, // FIX: this is a made-up value.
numerator: 1,
denominator: 1,
},
treasury_growth_rate: RationalNumber {
// FIX: this is a made-up value.
numerator: 1,
denominator: 1,
},
decentralization_constant: RationalNumber {
numerator: 1,
denominator: 1,
},
extra_entropy: Nonce {
variant: NonceVariant::NeutralNonce,
hash: None,
},
protocol_version: (0, 2),
min_utxo_value: 1000000,
}), }),
prot_magic: 764824073, prot_magic: 764824073,
block_slot: 5281340, block_slot: 5281340,
@ -69,19 +98,47 @@ mod shelley_ma_tests {
let utxos: UTxOs = mk_utxo_for_alonzo_compatible_tx( let utxos: UTxOs = mk_utxo_for_alonzo_compatible_tx(
&mtx.transaction_body, &mtx.transaction_body,
&[( &[(
String::from(include_str!("../../test_data/shelley2.address")), String::from("7165c197d565e88a20885e535f93755682444d3c02fd44dd70883fe89e"),
Value::Coin(2000000), Value::Coin(2000000),
None, None,
)], )],
); );
let env: Environment = Environment { let env: Environment = Environment {
prot_params: MultiEraProtParams::Shelley(ShelleyProtParams { prot_params: MultiEraProtocolParameters::Shelley(ShelleyProtParams {
fee_policy: FeePolicy { minfee_b: 155381,
summand: 155381, minfee_a: 44,
multiplier: 44, max_block_body_size: 65536,
max_transaction_size: 4096,
max_block_header_size: 1100,
key_deposit: 2000000,
pool_deposit: 500000000,
maximum_epoch: 18,
desired_number_of_stake_pools: 150,
pool_pledge_influence: RationalNumber {
// FIX: this is a made-up value.
numerator: 1,
denominator: 1,
}, },
max_tx_size: 4096, expansion_rate: RationalNumber {
min_lovelace: 1000000, // FIX: this is a made-up value.
numerator: 1,
denominator: 1,
},
treasury_growth_rate: RationalNumber {
// FIX: this is a made-up value.
numerator: 1,
denominator: 1,
},
decentralization_constant: RationalNumber {
numerator: 1,
denominator: 1,
},
extra_entropy: Nonce {
variant: NonceVariant::NeutralNonce,
hash: None,
},
protocol_version: (0, 2),
min_utxo_value: 1000000,
}), }),
prot_magic: 764824073, prot_magic: 764824073,
block_slot: 17584925, block_slot: 17584925,
@ -103,19 +160,47 @@ mod shelley_ma_tests {
let utxos: UTxOs = mk_utxo_for_alonzo_compatible_tx( let utxos: UTxOs = mk_utxo_for_alonzo_compatible_tx(
&mtx.transaction_body, &mtx.transaction_body,
&[( &[(
String::from(include_str!("../../test_data/shelley3.address")), String::from("61c96001f4a4e10567ac18be3c47663a00a858f51c56779e94993d30ef"),
Value::Coin(10000000), Value::Coin(10000000),
None, None,
)], )],
); );
let env: Environment = Environment { let env: Environment = Environment {
prot_params: MultiEraProtParams::Shelley(ShelleyProtParams { prot_params: MultiEraProtocolParameters::Shelley(ShelleyProtParams {
fee_policy: FeePolicy { minfee_b: 155381,
summand: 155381, minfee_a: 44,
multiplier: 44, max_block_body_size: 65536,
max_transaction_size: 4096,
max_block_header_size: 1100,
key_deposit: 2000000,
pool_deposit: 500000000,
maximum_epoch: 18,
desired_number_of_stake_pools: 150,
pool_pledge_influence: RationalNumber {
// FIX: this is a made-up value.
numerator: 1,
denominator: 1,
}, },
max_tx_size: 4096, expansion_rate: RationalNumber {
min_lovelace: 1000000, // FIX: this is a made-up value.
numerator: 1,
denominator: 1,
},
treasury_growth_rate: RationalNumber {
// FIX: this is a made-up value.
numerator: 1,
denominator: 1,
},
decentralization_constant: RationalNumber {
numerator: 1,
denominator: 1,
},
extra_entropy: Nonce {
variant: NonceVariant::NeutralNonce,
hash: None,
},
protocol_version: (0, 2),
min_utxo_value: 1000000,
}), }),
prot_magic: 764824073, prot_magic: 764824073,
block_slot: 5860488, block_slot: 5860488,
@ -137,19 +222,47 @@ mod shelley_ma_tests {
let utxos: UTxOs = mk_utxo_for_alonzo_compatible_tx( let utxos: UTxOs = mk_utxo_for_alonzo_compatible_tx(
&mtx.transaction_body, &mtx.transaction_body,
&[( &[(
String::from(include_str!("../../test_data/mary1.address")), String::from("611489ac0c22c04abc9c6de7f95d71e1ba2c95c9b4e2f6f2900f682285"),
Value::Coin(3500000), Value::Coin(3500000),
None, None,
)], )],
); );
let env: Environment = Environment { let env: Environment = Environment {
prot_params: MultiEraProtParams::Shelley(ShelleyProtParams { prot_params: MultiEraProtocolParameters::Shelley(ShelleyProtParams {
fee_policy: FeePolicy { minfee_b: 155381,
summand: 155381, minfee_a: 44,
multiplier: 44, max_block_body_size: 65536,
max_transaction_size: 4096,
max_block_header_size: 1100,
key_deposit: 2000000,
pool_deposit: 500000000,
maximum_epoch: 18,
desired_number_of_stake_pools: 150,
pool_pledge_influence: RationalNumber {
// FIX: this is a made-up value.
numerator: 1,
denominator: 1,
}, },
max_tx_size: 4096, expansion_rate: RationalNumber {
min_lovelace: 1000000, // FIX: this is a made-up value.
numerator: 1,
denominator: 1,
},
treasury_growth_rate: RationalNumber {
// FIX: this is a made-up value.
numerator: 1,
denominator: 1,
},
decentralization_constant: RationalNumber {
numerator: 1,
denominator: 1,
},
extra_entropy: Nonce {
variant: NonceVariant::NeutralNonce,
hash: None,
},
protocol_version: (0, 2),
min_utxo_value: 1000000,
}), }),
prot_magic: 764824073, prot_magic: 764824073,
block_slot: 24381863, block_slot: 24381863,
@ -169,7 +282,7 @@ mod shelley_ma_tests {
let utxos: UTxOs = mk_utxo_for_alonzo_compatible_tx( let utxos: UTxOs = mk_utxo_for_alonzo_compatible_tx(
&mtx.transaction_body, &mtx.transaction_body,
&[( &[(
String::from(include_str!("../../test_data/shelley1.address")), String::from("0129bb156d52d014bb444a14138cbee36044c6faed37d0c2d49d2358315c465cbf8c5536970e8a29bb7adcda0d663b20007d481813694c64ef"),
Value::Coin(2332267427205), Value::Coin(2332267427205),
None, None,
)], )],
@ -186,13 +299,41 @@ mod shelley_ma_tests {
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap(); Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Shelley); let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Shelley);
let env: Environment = Environment { let env: Environment = Environment {
prot_params: MultiEraProtParams::Shelley(ShelleyProtParams { prot_params: MultiEraProtocolParameters::Shelley(ShelleyProtParams {
fee_policy: FeePolicy { minfee_b: 155381,
summand: 155381, minfee_a: 44,
multiplier: 44, max_block_body_size: 65536,
max_transaction_size: 4096,
max_block_header_size: 1100,
key_deposit: 2000000,
pool_deposit: 500000000,
maximum_epoch: 18,
desired_number_of_stake_pools: 150,
pool_pledge_influence: RationalNumber {
// FIX: this is a made-up value.
numerator: 1,
denominator: 1,
}, },
max_tx_size: 4096, expansion_rate: RationalNumber {
min_lovelace: 1000000, // FIX: this is a made-up value.
numerator: 1,
denominator: 1,
},
treasury_growth_rate: RationalNumber {
// FIX: this is a made-up value.
numerator: 1,
denominator: 1,
},
decentralization_constant: RationalNumber {
numerator: 1,
denominator: 1,
},
extra_entropy: Nonce {
variant: NonceVariant::NeutralNonce,
hash: None,
},
protocol_version: (0, 2),
min_utxo_value: 1000000,
}), }),
prot_magic: 764824073, prot_magic: 764824073,
block_slot: 5281340, block_slot: 5281340,
@ -215,13 +356,41 @@ mod shelley_ma_tests {
let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Shelley); let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Shelley);
let utxos: UTxOs = UTxOs::new(); let utxos: UTxOs = UTxOs::new();
let env: Environment = Environment { let env: Environment = Environment {
prot_params: MultiEraProtParams::Shelley(ShelleyProtParams { prot_params: MultiEraProtocolParameters::Shelley(ShelleyProtParams {
fee_policy: FeePolicy { minfee_b: 155381,
summand: 155381, minfee_a: 44,
multiplier: 44, max_block_body_size: 65536,
max_transaction_size: 4096,
max_block_header_size: 1100,
key_deposit: 2000000,
pool_deposit: 500000000,
maximum_epoch: 18,
desired_number_of_stake_pools: 150,
pool_pledge_influence: RationalNumber {
// FIX: this is a made-up value.
numerator: 1,
denominator: 1,
}, },
max_tx_size: 4096, expansion_rate: RationalNumber {
min_lovelace: 1000000, // FIX: this is a made-up value.
numerator: 1,
denominator: 1,
},
treasury_growth_rate: RationalNumber {
// FIX: this is a made-up value.
numerator: 1,
denominator: 1,
},
decentralization_constant: RationalNumber {
numerator: 1,
denominator: 1,
},
extra_entropy: Nonce {
variant: NonceVariant::NeutralNonce,
hash: None,
},
protocol_version: (0, 2),
min_utxo_value: 1000000,
}), }),
prot_magic: 764824073, prot_magic: 764824073,
block_slot: 5281340, block_slot: 5281340,
@ -244,7 +413,7 @@ mod shelley_ma_tests {
let utxos: UTxOs = mk_utxo_for_alonzo_compatible_tx( let utxos: UTxOs = mk_utxo_for_alonzo_compatible_tx(
&mtx.transaction_body, &mtx.transaction_body,
&[( &[(
String::from(include_str!("../../test_data/shelley1.address")), String::from("0129bb156d52d014bb444a14138cbee36044c6faed37d0c2d49d2358315c465cbf8c5536970e8a29bb7adcda0d663b20007d481813694c64ef"),
Value::Coin(2332267427205), Value::Coin(2332267427205),
None, None,
)], )],
@ -260,13 +429,41 @@ mod shelley_ma_tests {
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap(); Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Shelley); let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Shelley);
let env: Environment = Environment { let env: Environment = Environment {
prot_params: MultiEraProtParams::Shelley(ShelleyProtParams { prot_params: MultiEraProtocolParameters::Shelley(ShelleyProtParams {
fee_policy: FeePolicy { minfee_b: 155381,
summand: 155381, minfee_a: 44,
multiplier: 44, max_block_body_size: 65536,
max_transaction_size: 4096,
max_block_header_size: 1100,
key_deposit: 2000000,
pool_deposit: 500000000,
maximum_epoch: 18,
desired_number_of_stake_pools: 150,
pool_pledge_influence: RationalNumber {
// FIX: this is a made-up value.
numerator: 1,
denominator: 1,
}, },
max_tx_size: 4096, expansion_rate: RationalNumber {
min_lovelace: 1000000, // FIX: this is a made-up value.
numerator: 1,
denominator: 1,
},
treasury_growth_rate: RationalNumber {
// FIX: this is a made-up value.
numerator: 1,
denominator: 1,
},
decentralization_constant: RationalNumber {
numerator: 1,
denominator: 1,
},
extra_entropy: Nonce {
variant: NonceVariant::NeutralNonce,
hash: None,
},
protocol_version: (0, 2),
min_utxo_value: 1000000,
}), }),
prot_magic: 764824073, prot_magic: 764824073,
block_slot: 5281340, block_slot: 5281340,
@ -290,19 +487,47 @@ mod shelley_ma_tests {
let utxos: UTxOs = mk_utxo_for_alonzo_compatible_tx( let utxos: UTxOs = mk_utxo_for_alonzo_compatible_tx(
&mtx.transaction_body, &mtx.transaction_body,
&[( &[(
String::from(include_str!("../../test_data/shelley1.address")), String::from("0129bb156d52d014bb444a14138cbee36044c6faed37d0c2d49d2358315c465cbf8c5536970e8a29bb7adcda0d663b20007d481813694c64ef"),
Value::Coin(2332267427205), Value::Coin(2332267427205),
None, None,
)], )],
); );
let env: Environment = Environment { let env: Environment = Environment {
prot_params: MultiEraProtParams::Shelley(ShelleyProtParams { prot_params: MultiEraProtocolParameters::Shelley(ShelleyProtParams {
fee_policy: FeePolicy { minfee_b: 155381,
summand: 155381, minfee_a: 44,
multiplier: 44, max_block_body_size: 65536,
max_transaction_size: 4096,
max_block_header_size: 1100,
key_deposit: 2000000,
pool_deposit: 500000000,
maximum_epoch: 18,
desired_number_of_stake_pools: 150,
pool_pledge_influence: RationalNumber {
// FIX: this is a made-up value.
numerator: 1,
denominator: 1,
}, },
max_tx_size: 4096, expansion_rate: RationalNumber {
min_lovelace: 1000000, // FIX: this is a made-up value.
numerator: 1,
denominator: 1,
},
treasury_growth_rate: RationalNumber {
// FIX: this is a made-up value.
numerator: 1,
denominator: 1,
},
decentralization_constant: RationalNumber {
numerator: 1,
denominator: 1,
},
extra_entropy: Nonce {
variant: NonceVariant::NeutralNonce,
hash: None,
},
protocol_version: (0, 2),
min_utxo_value: 1000000,
}), }),
prot_magic: 764824073, prot_magic: 764824073,
block_slot: 9999999, block_slot: 9999999,
@ -326,19 +551,47 @@ mod shelley_ma_tests {
let utxos: UTxOs = mk_utxo_for_alonzo_compatible_tx( let utxos: UTxOs = mk_utxo_for_alonzo_compatible_tx(
&mtx.transaction_body, &mtx.transaction_body,
&[( &[(
String::from(include_str!("../../test_data/shelley1.address")), String::from("0129bb156d52d014bb444a14138cbee36044c6faed37d0c2d49d2358315c465cbf8c5536970e8a29bb7adcda0d663b20007d481813694c64ef"),
Value::Coin(2332267427205), Value::Coin(2332267427205),
None, None,
)], )],
); );
let env: Environment = Environment { let env: Environment = Environment {
prot_params: MultiEraProtParams::Shelley(ShelleyProtParams { prot_params: MultiEraProtocolParameters::Shelley(ShelleyProtParams {
fee_policy: FeePolicy { minfee_b: 155381,
summand: 155381, minfee_a: 44,
multiplier: 44, max_block_body_size: 65536,
max_transaction_size: 0,
max_block_header_size: 1100,
key_deposit: 2000000,
pool_deposit: 500000000,
maximum_epoch: 18,
desired_number_of_stake_pools: 150,
pool_pledge_influence: RationalNumber {
// FIX: this is a made-up value.
numerator: 1,
denominator: 1,
}, },
max_tx_size: 0, expansion_rate: RationalNumber {
min_lovelace: 1000000, // FIX: this is a made-up value.
numerator: 1,
denominator: 1,
},
treasury_growth_rate: RationalNumber {
// FIX: this is a made-up value.
numerator: 1,
denominator: 1,
},
decentralization_constant: RationalNumber {
numerator: 1,
denominator: 1,
},
extra_entropy: Nonce {
variant: NonceVariant::NeutralNonce,
hash: None,
},
protocol_version: (0, 2),
min_utxo_value: 1000000,
}), }),
prot_magic: 764824073, prot_magic: 764824073,
block_slot: 5281340, block_slot: 5281340,
@ -363,19 +616,47 @@ mod shelley_ma_tests {
let utxos: UTxOs = mk_utxo_for_alonzo_compatible_tx( let utxos: UTxOs = mk_utxo_for_alonzo_compatible_tx(
&mtx.transaction_body, &mtx.transaction_body,
&[( &[(
String::from(include_str!("../../test_data/shelley1.address")), String::from("0129bb156d52d014bb444a14138cbee36044c6faed37d0c2d49d2358315c465cbf8c5536970e8a29bb7adcda0d663b20007d481813694c64ef"),
Value::Coin(2332267427205), Value::Coin(2332267427205),
None, None,
)], )],
); );
let env: Environment = Environment { let env: Environment = Environment {
prot_params: MultiEraProtParams::Shelley(ShelleyProtParams { prot_params: MultiEraProtocolParameters::Shelley(ShelleyProtParams {
fee_policy: FeePolicy { minfee_b: 155381,
summand: 155381, minfee_a: 44,
multiplier: 44, max_block_body_size: 65536,
max_transaction_size: 4096,
max_block_header_size: 1100,
key_deposit: 2000000,
pool_deposit: 500000000,
maximum_epoch: 18,
desired_number_of_stake_pools: 150,
pool_pledge_influence: RationalNumber {
// FIX: this is a made-up value.
numerator: 1,
denominator: 1,
}, },
max_tx_size: 4096, expansion_rate: RationalNumber {
min_lovelace: 10000000000000, // FIX: this is a made-up value.
numerator: 1,
denominator: 1,
},
treasury_growth_rate: RationalNumber {
// FIX: this is a made-up value.
numerator: 1,
denominator: 1,
},
decentralization_constant: RationalNumber {
numerator: 1,
denominator: 1,
},
extra_entropy: Nonce {
variant: NonceVariant::NeutralNonce,
hash: None,
},
protocol_version: (0, 2),
min_utxo_value: 10000000000000,
}), }),
prot_magic: 764824073, prot_magic: 764824073,
block_slot: 5281340, block_slot: 5281340,
@ -409,19 +690,47 @@ mod shelley_ma_tests {
let utxos: UTxOs = mk_utxo_for_alonzo_compatible_tx( let utxos: UTxOs = mk_utxo_for_alonzo_compatible_tx(
&mtx.transaction_body, &mtx.transaction_body,
&[( &[(
String::from(include_str!("../../test_data/shelley1.address")), String::from("0129bb156d52d014bb444a14138cbee36044c6faed37d0c2d49d2358315c465cbf8c5536970e8a29bb7adcda0d663b20007d481813694c64ef"),
Value::Coin(2332267427205), Value::Coin(2332267427205),
None, None,
)], )],
); );
let env: Environment = Environment { let env: Environment = Environment {
prot_params: MultiEraProtParams::Shelley(ShelleyProtParams { prot_params: MultiEraProtocolParameters::Shelley(ShelleyProtParams {
fee_policy: FeePolicy { minfee_b: 155381,
summand: 155381, minfee_a: 44,
multiplier: 44, max_block_body_size: 65536,
max_transaction_size: 4096,
max_block_header_size: 1100,
key_deposit: 2000000,
pool_deposit: 500000000,
maximum_epoch: 18,
desired_number_of_stake_pools: 150,
pool_pledge_influence: RationalNumber {
// FIX: this is a made-up value.
numerator: 1,
denominator: 1,
}, },
max_tx_size: 4096, expansion_rate: RationalNumber {
min_lovelace: 1000000, // FIX: this is a made-up value.
numerator: 1,
denominator: 1,
},
treasury_growth_rate: RationalNumber {
// FIX: this is a made-up value.
numerator: 1,
denominator: 1,
},
decentralization_constant: RationalNumber {
numerator: 1,
denominator: 1,
},
extra_entropy: Nonce {
variant: NonceVariant::NeutralNonce,
hash: None,
},
protocol_version: (0, 2),
min_utxo_value: 1000000,
}), }),
prot_magic: 764824073, prot_magic: 764824073,
block_slot: 5281340, block_slot: 5281340,
@ -445,19 +754,47 @@ mod shelley_ma_tests {
let utxos: UTxOs = mk_utxo_for_alonzo_compatible_tx( let utxos: UTxOs = mk_utxo_for_alonzo_compatible_tx(
&mtx.transaction_body, &mtx.transaction_body,
&[( &[(
String::from(include_str!("../../test_data/shelley1.address")), String::from("0129bb156d52d014bb444a14138cbee36044c6faed37d0c2d49d2358315c465cbf8c5536970e8a29bb7adcda0d663b20007d481813694c64ef"),
Value::Coin(2332267427205), Value::Coin(2332267427205),
None, None,
)], )],
); );
let env: Environment = Environment { let env: Environment = Environment {
prot_params: MultiEraProtParams::Shelley(ShelleyProtParams { prot_params: MultiEraProtocolParameters::Shelley(ShelleyProtParams {
fee_policy: FeePolicy { minfee_b: 155381,
summand: 155381, minfee_a: 70,
multiplier: 70, // This value was 44 during Shelley on mainnet. max_block_body_size: 65536,
max_transaction_size: 4096,
max_block_header_size: 1100,
key_deposit: 2000000,
pool_deposit: 500000000,
maximum_epoch: 18,
desired_number_of_stake_pools: 150,
pool_pledge_influence: RationalNumber {
// FIX: this is a made-up value.
numerator: 1,
denominator: 1,
}, },
max_tx_size: 4096, expansion_rate: RationalNumber {
min_lovelace: 1000000, // FIX: this is a made-up value.
numerator: 1,
denominator: 1,
},
treasury_growth_rate: RationalNumber {
// FIX: this is a made-up value.
numerator: 1,
denominator: 1,
},
decentralization_constant: RationalNumber {
numerator: 1,
denominator: 1,
},
extra_entropy: Nonce {
variant: NonceVariant::NeutralNonce,
hash: None,
},
protocol_version: (0, 2),
min_utxo_value: 1000000,
}), }),
prot_magic: 764824073, prot_magic: 764824073,
block_slot: 5281340, block_slot: 5281340,
@ -510,13 +847,41 @@ mod shelley_ma_tests {
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap(); Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Shelley); let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Shelley);
let env: Environment = Environment { let env: Environment = Environment {
prot_params: MultiEraProtParams::Shelley(ShelleyProtParams { prot_params: MultiEraProtocolParameters::Shelley(ShelleyProtParams {
fee_policy: FeePolicy { minfee_b: 155381,
summand: 155381, minfee_a: 44,
multiplier: 44, max_block_body_size: 65536,
max_transaction_size: 4096,
max_block_header_size: 1100,
key_deposit: 2000000,
pool_deposit: 500000000,
maximum_epoch: 18,
desired_number_of_stake_pools: 150,
pool_pledge_influence: RationalNumber {
// FIX: this is a made-up value.
numerator: 1,
denominator: 1,
}, },
max_tx_size: 4096, expansion_rate: RationalNumber {
min_lovelace: 1000000, // FIX: this is a made-up value.
numerator: 1,
denominator: 1,
},
treasury_growth_rate: RationalNumber {
// FIX: this is a made-up value.
numerator: 1,
denominator: 1,
},
decentralization_constant: RationalNumber {
numerator: 1,
denominator: 1,
},
extra_entropy: Nonce {
variant: NonceVariant::NeutralNonce,
hash: None,
},
protocol_version: (0, 2),
min_utxo_value: 1000000,
}), }),
prot_magic: 764824073, prot_magic: 764824073,
block_slot: 5281340, block_slot: 5281340,
@ -525,7 +890,7 @@ mod shelley_ma_tests {
let utxos: UTxOs = mk_utxo_for_alonzo_compatible_tx( let utxos: UTxOs = mk_utxo_for_alonzo_compatible_tx(
&mtx.transaction_body, &mtx.transaction_body,
&[( &[(
String::from(include_str!("../../test_data/shelley1.address")), String::from("0129bb156d52d014bb444a14138cbee36044c6faed37d0c2d49d2358315c465cbf8c5536970e8a29bb7adcda0d663b20007d481813694c64ef"),
Value::Coin(2332267427205), Value::Coin(2332267427205),
None, None,
)], )],
@ -551,19 +916,47 @@ mod shelley_ma_tests {
let utxos: UTxOs = mk_utxo_for_alonzo_compatible_tx( let utxos: UTxOs = mk_utxo_for_alonzo_compatible_tx(
&mtx.transaction_body, &mtx.transaction_body,
&[( &[(
String::from(include_str!("../../test_data/shelley3.address")), String::from("61c96001f4a4e10567ac18be3c47663a00a858f51c56779e94993d30ef"),
Value::Coin(10000000), Value::Coin(10000000),
None, None,
)], )],
); );
let env: Environment = Environment { let env: Environment = Environment {
prot_params: MultiEraProtParams::Shelley(ShelleyProtParams { prot_params: MultiEraProtocolParameters::Shelley(ShelleyProtParams {
fee_policy: FeePolicy { minfee_b: 155381,
summand: 155381, minfee_a: 44,
multiplier: 44, max_block_body_size: 65536,
max_transaction_size: 4096,
max_block_header_size: 1100,
key_deposit: 2000000,
pool_deposit: 500000000,
maximum_epoch: 18,
desired_number_of_stake_pools: 150,
pool_pledge_influence: RationalNumber {
// FIX: this is a made-up value.
numerator: 1,
denominator: 1,
}, },
max_tx_size: 4096, expansion_rate: RationalNumber {
min_lovelace: 1000000, // FIX: this is a made-up value.
numerator: 1,
denominator: 1,
},
treasury_growth_rate: RationalNumber {
// FIX: this is a made-up value.
numerator: 1,
denominator: 1,
},
decentralization_constant: RationalNumber {
numerator: 1,
denominator: 1,
},
extra_entropy: Nonce {
variant: NonceVariant::NeutralNonce,
hash: None,
},
protocol_version: (0, 2),
min_utxo_value: 1000000,
}), }),
prot_magic: 764824073, prot_magic: 764824073,
block_slot: 5860488, block_slot: 5860488,
@ -597,13 +990,41 @@ mod shelley_ma_tests {
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap(); Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Shelley); let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Shelley);
let env: Environment = Environment { let env: Environment = Environment {
prot_params: MultiEraProtParams::Shelley(ShelleyProtParams { prot_params: MultiEraProtocolParameters::Shelley(ShelleyProtParams {
fee_policy: FeePolicy { minfee_b: 155381,
summand: 155381, minfee_a: 44,
multiplier: 44, max_block_body_size: 65536,
max_transaction_size: 4096,
max_block_header_size: 1100,
key_deposit: 2000000,
pool_deposit: 500000000,
maximum_epoch: 18,
desired_number_of_stake_pools: 150,
pool_pledge_influence: RationalNumber {
// FIX: this is a made-up value.
numerator: 1,
denominator: 1,
}, },
max_tx_size: 4096, expansion_rate: RationalNumber {
min_lovelace: 1000000, // FIX: this is a made-up value.
numerator: 1,
denominator: 1,
},
treasury_growth_rate: RationalNumber {
// FIX: this is a made-up value.
numerator: 1,
denominator: 1,
},
decentralization_constant: RationalNumber {
numerator: 1,
denominator: 1,
},
extra_entropy: Nonce {
variant: NonceVariant::NeutralNonce,
hash: None,
},
protocol_version: (0, 2),
min_utxo_value: 1000000,
}), }),
prot_magic: 764824073, prot_magic: 764824073,
block_slot: 5281340, block_slot: 5281340,
@ -612,7 +1033,7 @@ mod shelley_ma_tests {
let utxos: UTxOs = mk_utxo_for_alonzo_compatible_tx( let utxos: UTxOs = mk_utxo_for_alonzo_compatible_tx(
&mtx.transaction_body, &mtx.transaction_body,
&[( &[(
String::from(include_str!("../../test_data/shelley1.address")), String::from("0129bb156d52d014bb444a14138cbee36044c6faed37d0c2d49d2358315c465cbf8c5536970e8a29bb7adcda0d663b20007d481813694c64ef"),
Value::Coin(2332267427205), Value::Coin(2332267427205),
None, None,
)], )],
@ -650,13 +1071,41 @@ mod shelley_ma_tests {
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap(); Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Shelley); let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Shelley);
let env: Environment = Environment { let env: Environment = Environment {
prot_params: MultiEraProtParams::Shelley(ShelleyProtParams { prot_params: MultiEraProtocolParameters::Shelley(ShelleyProtParams {
fee_policy: FeePolicy { minfee_b: 155381,
summand: 155381, minfee_a: 44,
multiplier: 44, max_block_body_size: 65536,
max_transaction_size: 4096,
max_block_header_size: 1100,
key_deposit: 2000000,
pool_deposit: 500000000,
maximum_epoch: 18,
desired_number_of_stake_pools: 150,
pool_pledge_influence: RationalNumber {
// FIX: this is a made-up value.
numerator: 1,
denominator: 1,
}, },
max_tx_size: 4096, expansion_rate: RationalNumber {
min_lovelace: 1000000, // FIX: this is a made-up value.
numerator: 1,
denominator: 1,
},
treasury_growth_rate: RationalNumber {
// FIX: this is a made-up value.
numerator: 1,
denominator: 1,
},
decentralization_constant: RationalNumber {
numerator: 1,
denominator: 1,
},
extra_entropy: Nonce {
variant: NonceVariant::NeutralNonce,
hash: None,
},
protocol_version: (0, 2),
min_utxo_value: 1000000,
}), }),
prot_magic: 764824073, prot_magic: 764824073,
block_slot: 5281340, block_slot: 5281340,
@ -665,7 +1114,7 @@ mod shelley_ma_tests {
let utxos: UTxOs = mk_utxo_for_alonzo_compatible_tx( let utxos: UTxOs = mk_utxo_for_alonzo_compatible_tx(
&mtx.transaction_body, &mtx.transaction_body,
&[( &[(
String::from(include_str!("../../test_data/shelley1.address")), String::from("0129bb156d52d014bb444a14138cbee36044c6faed37d0c2d49d2358315c465cbf8c5536970e8a29bb7adcda0d663b20007d481813694c64ef"),
Value::Coin(2332267427205), Value::Coin(2332267427205),
None, None,
)], )],
@ -698,13 +1147,41 @@ mod shelley_ma_tests {
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap(); Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Shelley); let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Shelley);
let env: Environment = Environment { let env: Environment = Environment {
prot_params: MultiEraProtParams::Shelley(ShelleyProtParams { prot_params: MultiEraProtocolParameters::Shelley(ShelleyProtParams {
fee_policy: FeePolicy { minfee_b: 155381,
summand: 155381, minfee_a: 44,
multiplier: 44, max_block_body_size: 65536,
max_transaction_size: 4096,
max_block_header_size: 1100,
key_deposit: 2000000,
pool_deposit: 500000000,
maximum_epoch: 18,
desired_number_of_stake_pools: 150,
pool_pledge_influence: RationalNumber {
// FIX: this is a made-up value.
numerator: 1,
denominator: 1,
}, },
max_tx_size: 4096, expansion_rate: RationalNumber {
min_lovelace: 1000000, // FIX: this is a made-up value.
numerator: 1,
denominator: 1,
},
treasury_growth_rate: RationalNumber {
// FIX: this is a made-up value.
numerator: 1,
denominator: 1,
},
decentralization_constant: RationalNumber {
numerator: 1,
denominator: 1,
},
extra_entropy: Nonce {
variant: NonceVariant::NeutralNonce,
hash: None,
},
protocol_version: (0, 2),
min_utxo_value: 1000000,
}), }),
prot_magic: 764824073, prot_magic: 764824073,
block_slot: 5281340, block_slot: 5281340,
@ -713,7 +1190,7 @@ mod shelley_ma_tests {
let utxos: UTxOs = mk_utxo_for_alonzo_compatible_tx( let utxos: UTxOs = mk_utxo_for_alonzo_compatible_tx(
&mtx.transaction_body, &mtx.transaction_body,
&[( &[(
String::from(include_str!("../../test_data/shelley2.address")), String::from("7165c197d565e88a20885e535f93755682444d3c02fd44dd70883fe89e"),
Value::Coin(2000000), Value::Coin(2000000),
None, None,
)], )],

View file

@ -1208,10 +1208,10 @@ pub struct ExUnits {
#[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone)] #[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone)]
pub struct ExUnitPrices { pub struct ExUnitPrices {
#[n(0)] #[n(0)]
mem_price: PositiveInterval, pub mem_price: PositiveInterval,
#[n(1)] #[n(1)]
step_price: PositiveInterval, pub step_price: PositiveInterval,
} }
#[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone, Copy)] #[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone, Copy)]

View file

@ -12,7 +12,7 @@ use pallas_codec::utils::{Bytes, CborWrap, KeepRaw, KeyValuePairs, MaybeIndefArr
// required for derive attrs to work // required for derive attrs to work
use pallas_codec::minicbor; use pallas_codec::minicbor;
pub use crate::alonzo::VrfCert; use crate::alonzo::VrfCert;
#[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone)] #[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone)]
pub struct HeaderBody { pub struct HeaderBody {

View file

@ -1 +0,0 @@
018c9ae79bca586ac36dcfdbbf4d2826c685a6969411c338c14973cc7f7bdb37706cd03711fe64747f8cfcfd574c7445cc0378781e77a8cc00

View file

@ -1 +0,0 @@
714a59ebd93ea53d1bbf7f82232c7b012700a0cf4bb78d879dabb1a20a

View file

@ -1 +0,0 @@
01c81ffcbc08ff49965d74f90c391541ff1cc2b043ffe41c81d840be8729f2ae5ed49a1734823ba37fd09923f5f7d494ae0efa23dd98ce02da

View file

@ -1 +0,0 @@
01c81ffcbc08ff49965d74f90c391541ff1cc2b043ffe41c81d840be8729f2ae5ed49a1734823ba37fd09923f5f7d494ae0efa23dd98ce02da

View file

@ -1 +0,0 @@
01c81ffcbc08ff49965d74f90c391541ff1cc2b043ffe41c81d840be8729f2ae5ed49a1734823ba37fd09923f5f7d494ae0efa23dd98ce02da

View file

@ -1 +0,0 @@
01c81ffcbc08ff49965d74f90c391541ff1cc2b043ffe41c81d840be8729f2ae5ed49a1734823ba37fd09923f5f7d494ae0efa23dd98ce02da

View file

@ -1 +0,0 @@
01c81ffcbc08ff49965d74f90c391541ff1cc2b043ffe41c81d840be8729f2ae5ed49a1734823ba37fd09923f5f7d494ae0efa23dd98ce02da

View file

@ -1 +0,0 @@
01c81ffcbc08ff49965d74f90c391541ff1cc2b043ffe41c81d840be8729f2ae5ed49a1734823ba37fd09923f5f7d494ae0efa23dd98ce02da

View file

@ -1 +0,0 @@
01c81ffcbc08ff49965d74f90c391541ff1cc2b043ffe41c81d840be8729f2ae5ed49a1734823ba37fd09923f5f7d494ae0efa23dd98ce02da

View file

@ -1 +0,0 @@
612e137a27a74aca6caff726fb9da65c371ad2d7f1cc8645648fcc11d1

View file

@ -1 +0,0 @@
01f64b141bfa7761c00a48a137b15d433af02c9275dbf52ea95566b59cb4f05ecc9fd8c9066ef7fd907db854c76caf6462b132ce133dc7cc44

View file

@ -1 +0,0 @@
011be1f490912af2fc39f8e3637a2bade2ecbebefe63e8bfef10989cd6f593309a155b0ebb45ff830747e61f98e5b77feaf7529ce9df351382

View file

@ -1 +0,0 @@
11a55f409501bf65805bb0dc76f6f9ae90b61e19ed870bc0025681360881728e7ed4cf324e1323135e7e6d931f01e30792d9cdf17129cb806d

View file

@ -1 +0,0 @@
01f1e126304308006938d2e8571842ff87302fff95a037b3fd838451b8b3c9396d0680d912487139cb7fc85aa279ea70e8cdacee4c6cae40fd

View file

@ -1 +0,0 @@
01f1e126304308006938d2e8571842ff87302fff95a037b3fd838451b8b3c9396d0680d912487139cb7fc85aa279ea70e8cdacee4c6cae40fd

View file

@ -1 +0,0 @@
719b85d5e8611945505f078aeededcbed1d6ca11053f61e3f9d999fe44

View file

@ -1 +0,0 @@
0121316dbc84420a5ee7461438483564c41fae876029319b3ee641fe4422339411d2df4c9c7c50b3d8f88db98d475e9d1bccd4244b412fbe5e

View file

@ -1 +0,0 @@
0121316dbc84420a5ee7461438483564c41fae876029319b3ee641fe4422339411d2df4c9c7c50b3d8f88db98d475e9d1bccd4244b412fbe5e

View file

@ -1 +0,0 @@
11A55F409501BF65805BB0DC76F6F9AE90B61E19ED870BC0025681360881728E7ED4CF324E1323135E7E6D931F01E30792D9CDF17129CB806D

View file

@ -1 +0,0 @@
01EDA33318624ADE03D53B7E954713D9E69440891F0D02E823267B610D6018DC6C7989A46EC26822425A3D2BAC60EEC2682A022740361ED957

View file

@ -1 +0,0 @@
01eda33318624ade03d53b7e954713d9e69440891f0d02e823267b610d6018dc6c7989a46ec26822425a3d2bac60eec2682a022740361ed957

View file

@ -1 +0,0 @@
119068A7A3F008803EDAC87AF1619860F2CDCDE40C26987325ACE138AD81728E7ED4CF324E1323135E7E6D931F01E30792D9CDF17129CB806D

View file

@ -1 +0,0 @@
01A7D37F1D43D1197A994D95B3CE15D9AF3B4697CC7CDF9BCD1F81688D3499AC08066B36BC6C2D86A21243B940E84DBE5CAC3FAB5F76AB9229

View file

@ -1 +0,0 @@
01a7d37f1d43d1197a994d95b3ce15d9af3b4697cc7cdf9bcd1f81688d3499ac08066b36bc6c2d86a21243b940e84dbe5cac3fab5f76ab9229

View file

@ -1 +0,0 @@
119068a7a3f008803edac87af1619860f2cdcde40c26987325ace138ad81728e7ed4cf324e1323135e7e6d931f01e30792d9cdf17129cb806d

View file

@ -1 +0,0 @@
83581cff66e7549ee0706abe5ce63ba325f792f2c1145d918baf563db2b457a101581e581cca3e553c9c63c5927480e7434620200eb3a162ef0b6cf6f671ba925100

View file

@ -1 +0,0 @@
83581CDC7E4DD6A44886816DEC9A4B2021056A8FCAF500C09E316028F2985FA002

View file

@ -1 +0,0 @@
611489ac0c22c04abc9c6de7f95d71e1ba2c95c9b4e2f6f2900f682285

View file

@ -1 +0,0 @@
0129bb156d52d014bb444a14138cbee36044c6faed37d0c2d49d2358315c465cbf8c5536970e8a29bb7adcda0d663b20007d481813694c64ef

View file

@ -1 +0,0 @@
7165c197d565e88a20885e535f93755682444d3c02fd44dd70883fe89e

View file

@ -1 +0,0 @@
61c96001f4a4e10567ac18be3c47663a00a858f51c56779e94993d30ef