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 619cb8290b
commit a0c409b65e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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,
mk_alonzo_vk_wits_check_list, values_are_equal, verify_signature,
AlonzoError::*,
AlonzoProtParams, FeePolicy, UTxOs,
AlonzoProtParams, UTxOs,
ValidationError::{self, *},
ValidationResult,
};
@ -36,7 +36,7 @@ pub fn validate_alonzo_tx(
network_id: &u8,
) -> ValidationResult {
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_and_collateral_in_utxos(tx_body, utxos)?;
check_tx_validity_interval(tx_body, mtx, block_slot)?;
@ -131,7 +131,7 @@ fn check_upper_bound(
fn check_fee(
tx_body: &TransactionBody,
size: &u64,
size: &u32,
mtx: &MintedTx,
utxos: &UTxOs,
prot_pps: &AlonzoProtParams,
@ -147,11 +147,10 @@ fn check_fee(
// minimum fee.
fn check_min_fee(
tx_body: &TransactionBody,
size: &u64,
size: &u32,
prot_pps: &AlonzoProtParams,
) -> ValidationResult {
let fee_policy: &FeePolicy = &prot_pps.fee_policy;
if tx_body.fee < fee_policy.summand + fee_policy.multiplier * size {
if tx_body.fee < (prot_pps.minfee_b + prot_pps.minfee_a * size) as u64 {
return Err(Alonzo(FeeBelowMin));
}
Ok(())
@ -185,7 +184,7 @@ fn check_collaterals_number(
collaterals: &[TransactionInput],
prot_pps: &AlonzoProtParams,
) -> ValidationResult {
let number_collateral: u64 = collaterals.len() as u64;
let number_collateral: u32 = collaterals.len() as u32;
if number_collateral == 0 {
Err(Alonzo(CollateralMissing))
} else if number_collateral > prot_pps.max_collateral_inputs {
@ -222,7 +221,7 @@ fn check_collaterals_assets(
utxos: &UTxOs,
prot_pps: &AlonzoProtParams,
) -> 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 {
Some(collaterals) => {
for collateral in collaterals {
@ -317,7 +316,7 @@ fn compute_min_lovelace(output: &TransactionOutput, prot_pps: &AlonzoProtParams)
Some(_) => 37, // utxoEntrySizeWithoutVal (27) + dataHashSize (10)
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
@ -327,7 +326,7 @@ fn check_output_val_size(
prot_pps: &AlonzoProtParams,
) -> ValidationResult {
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));
}
}
@ -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.
fn check_tx_size(size: &u64, prot_pps: &AlonzoProtParams) -> ValidationResult {
if *size > prot_pps.max_tx_size {
fn check_tx_size(size: &u32, prot_pps: &AlonzoProtParams) -> ValidationResult {
if *size > prot_pps.max_transaction_size {
return Err(Alonzo(MaxTxSizeExceeded));
}
Ok(())
@ -384,7 +383,7 @@ fn check_tx_ex_units(mtx: &MintedTx, prot_pps: &AlonzoProtParams) -> ValidationR
mem += ex_units.mem;
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));
}
}

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,
values_are_equal, verify_signature,
BabbageError::*,
BabbageProtParams, FeePolicy, UTxOs,
BabbageProtParams, UTxOs,
ValidationError::{self, *},
ValidationResult,
};
@ -38,7 +38,7 @@ pub fn validate_babbage_tx(
network_id: &u8,
) -> ValidationResult {
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_all_ins_in_utxos(tx_body, utxos)?;
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(
tx_body: &MintedTransactionBody,
size: &u64,
size: &u32,
mtx: &MintedTx,
utxos: &UTxOs,
prot_pps: &BabbageProtParams,
@ -155,11 +155,10 @@ fn check_fee(
// minimum fee.
fn check_min_fee(
tx_body: &MintedTransactionBody,
size: &u64,
size: &u32,
prot_pps: &BabbageProtParams,
) -> ValidationResult {
let fee_policy: &FeePolicy = &prot_pps.fee_policy;
if tx_body.fee < fee_policy.summand + fee_policy.multiplier * size {
if tx_body.fee < (prot_pps.minfee_b + prot_pps.minfee_a * size) as u64 {
return Err(Babbage(FeeBelowMin));
}
Ok(())
@ -200,7 +199,7 @@ fn check_collaterals_number(
) -> ValidationResult {
if collaterals.is_empty() {
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))
} else {
Ok(())
@ -265,7 +264,7 @@ fn check_collaterals_assets(
// The balance between collateral inputs and output contains only lovelace.
let paid_collateral: u64 =
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.
if paid_collateral * 100 < fee_percentage {
return Err(Babbage(CollateralMinLovelace));
@ -357,7 +356,7 @@ fn check_min_lovelace(
}
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
@ -371,7 +370,7 @@ fn check_output_val_size(
PseudoTransactionOutput::Legacy(output) => &output.amount,
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));
}
}
@ -409,8 +408,8 @@ fn check_tx_network_id(tx_body: &MintedTransactionBody, network_id: &u8) -> Vali
Ok(())
}
fn check_tx_size(size: &u64, prot_pps: &BabbageProtParams) -> ValidationResult {
if *size > prot_pps.max_tx_size {
fn check_tx_size(size: &u32, prot_pps: &BabbageProtParams) -> ValidationResult {
if *size > prot_pps.max_transaction_size {
return Err(Babbage(MaxTxSizeExceeded));
}
Ok(())
@ -427,7 +426,7 @@ fn check_tx_ex_units(mtx: &MintedTx, prot_pps: &BabbageProtParams) -> Validation
mem += ex_units.mem;
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));
}
}

View file

@ -97,7 +97,7 @@ fn check_fees(tx: &Tx, size: &u64, utxos: &UTxOs, prot_pps: &ByronProtParams) ->
outputs_balance += output.amount
}
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 {
Err(Byron(FeesBelowMin))
} else {

View file

@ -13,17 +13,18 @@ use pallas_traverse::{Era, MultiEraTx};
use shelley_ma::validate_shelley_ma_tx;
pub use utils::{
Environment, MultiEraProtParams, UTxOs, ValidationError::TxAndProtParamsDiffer,
Environment, MultiEraProtocolParameters, UTxOs,
ValidationError::{TxAndProtParamsDiffer, UnknownProtParams},
ValidationResult,
};
pub fn validate(metx: &MultiEraTx, utxos: &UTxOs, env: &Environment) -> ValidationResult {
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()),
_ => Err(TxAndProtParamsDiffer),
},
MultiEraProtParams::Shelley(spp) => match metx {
MultiEraProtocolParameters::Shelley(spp) => match metx {
MultiEraTx::AlonzoCompatible(mtx, Era::Shelley)
| MultiEraTx::AlonzoCompatible(mtx, Era::Allegra)
| 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),
},
MultiEraProtParams::Alonzo(app) => match metx {
MultiEraProtocolParameters::Alonzo(app) => match metx {
MultiEraTx::AlonzoCompatible(mtx, Era::Alonzo) => {
validate_alonzo_tx(mtx, utxos, app, env.block_slot(), env.network_id())
}
_ => Err(TxAndProtParamsDiffer),
},
MultiEraProtParams::Babbage(bpp) => match metx {
MultiEraProtocolParameters::Babbage(bpp) => match metx {
MultiEraTx::Babbage(mtx) => validate_babbage_tx(
mtx,
utxos,

View file

@ -4,7 +4,6 @@ use crate::utils::{
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_val_size_in_words, mk_alonzo_vk_wits_check_list, values_are_equal, verify_signature,
FeePolicy,
ShelleyMAError::*,
ShelleyProtParams, UTxOs,
ValidationError::{self, *},
@ -32,7 +31,7 @@ pub fn validate_shelley_ma_tx(
) -> ValidationResult {
let tx_body: &TransactionBody = &mtx.transaction_body;
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_in_utxos(tx_body, utxos)?;
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 {
if *size > prot_pps.max_tx_size {
fn check_tx_size(size: &u32, prot_pps: &ShelleyProtParams) -> ValidationResult {
if *size > prot_pps.max_transaction_size {
return Err(ShelleyMA(MaxTxSizeExceeded));
}
Ok(())
@ -104,10 +103,10 @@ fn check_min_lovelace(
fn compute_min_lovelace(output: &TransactionOutput, prot_pps: &ShelleyProtParams) -> u64 {
match &output.amount {
Value::Coin(_) => prot_pps.min_lovelace,
Value::Coin(_) => prot_pps.min_utxo_value,
Value::Multiasset(lovelace, _) => {
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)
}
}
@ -174,11 +173,10 @@ fn get_produced(tx_body: &TransactionBody, era: &Era) -> Result<Value, Validatio
fn check_fees(
tx_body: &TransactionBody,
size: &u64,
size: &u32,
prot_pps: &ShelleyProtParams,
) -> ValidationResult {
let fee_policy: &FeePolicy = &prot_pps.fee_policy;
if tx_body.fee < fee_policy.summand + fee_policy.multiplier * size {
if tx_body.fee < (prot_pps.minfee_b + prot_pps.minfee_a * size) as u64 {
return Err(ShelleyMA(FeesBelowMin));
}
Ok(())

View file

@ -24,18 +24,18 @@ pub use validation::*;
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();
match encode(tx_body, &mut buff) {
Ok(()) => Some(buff.len() as u64),
Ok(()) => Some(buff.len() as u32),
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();
match encode(tx_body, &mut buff) {
Ok(()) => Some(buff.len() as u64),
Ok(()) => Some(buff.len() as u32),
Err(_) => None,
}
}

View file

@ -1,73 +1,289 @@
//! Types used for representing the environment required for validation in each
//! 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)]
pub struct Environment {
pub prot_params: MultiEraProtParams,
pub prot_params: MultiEraProtocolParameters,
pub prot_magic: u32,
pub block_slot: u64,
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 {
pub fn prot_params(&self) -> &MultiEraProtParams {
pub fn prot_params(&self) -> &MultiEraProtocolParameters {
&self.prot_params
}

View file

@ -4,6 +4,7 @@
#[non_exhaustive]
pub enum ValidationError {
TxAndProtParamsDiffer,
UnknownProtParams,
Byron(ByronError),
ShelleyMA(ShelleyMAError),
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 pallas_applying::{
utils::{
ByronError, ByronProtParams, Environment, FeePolicy, MultiEraProtParams, ValidationError::*,
ByronError, ByronProtParams, Environment, MultiEraProtocolParameters, ValidationError::*,
},
validate, UTxOs,
};
@ -33,17 +33,27 @@ mod byron_tests {
let utxos: UTxOs = mk_utxo_for_byron_tx(
&mtxp.transaction,
&[(
String::from(include_str!("../../test_data/byron2.address")),
String::from("83581CDC7E4DD6A44886816DEC9A4B2021056A8FCAF500C09E316028F2985FA002"),
19999000000,
)],
);
let env: Environment = Environment {
prot_params: MultiEraProtParams::Byron(ByronProtParams {
fee_policy: FeePolicy {
summand: 155381,
multiplier: 44,
},
prot_params: MultiEraProtocolParameters::Byron(ByronProtParams {
script_version: 0,
slot_duration: 20000,
max_block_size: 2000000,
max_header_size: 2000000,
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,
block_slot: 6341,
@ -65,17 +75,27 @@ mod byron_tests {
let utxos: UTxOs = mk_utxo_for_byron_tx(
&mtxp.transaction,
&[(
String::from(include_str!("../../test_data/byron1.address")),
String::from("83581cff66e7549ee0706abe5ce63ba325f792f2c1145d918baf563db2b457a101581e581cca3e553c9c63c5927480e7434620200eb3a162ef0b6cf6f671ba925100"),
19999000000,
)],
);
let env: Environment = Environment {
prot_params: MultiEraProtParams::Byron(ByronProtParams {
fee_policy: FeePolicy {
summand: 155381,
multiplier: 44,
},
prot_params: MultiEraProtocolParameters::Byron(ByronProtParams {
script_version: 0,
slot_duration: 20000,
max_block_size: 2000000,
max_header_size: 2000000,
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,
block_slot: 3241381,
@ -95,7 +115,7 @@ mod byron_tests {
let utxos: UTxOs = mk_utxo_for_byron_tx(
&mtxp.transaction,
&[(
String::from(include_str!("../../test_data/byron1.address")),
String::from("83581cff66e7549ee0706abe5ce63ba325f792f2c1145d918baf563db2b457a101581e581cca3e553c9c63c5927480e7434620200eb3a162ef0b6cf6f671ba925100"),
19999000000,
)],
);
@ -110,12 +130,22 @@ mod byron_tests {
mtxp.transaction = Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_byron(&mtxp);
let env: Environment = Environment {
prot_params: MultiEraProtParams::Byron(ByronProtParams {
fee_policy: FeePolicy {
summand: 155381,
multiplier: 44,
},
prot_params: MultiEraProtocolParameters::Byron(ByronProtParams {
script_version: 0,
slot_duration: 20000,
max_block_size: 2000000,
max_header_size: 2000000,
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,
block_slot: 3241381,
@ -148,17 +178,27 @@ mod byron_tests {
let utxos: UTxOs = mk_utxo_for_byron_tx(
&mtxp.transaction,
&[(
String::from(include_str!("../../test_data/byron1.address")),
String::from("83581cff66e7549ee0706abe5ce63ba325f792f2c1145d918baf563db2b457a101581e581cca3e553c9c63c5927480e7434620200eb3a162ef0b6cf6f671ba925100"),
19999000000,
)],
);
let env: Environment = Environment {
prot_params: MultiEraProtParams::Byron(ByronProtParams {
fee_policy: FeePolicy {
summand: 155381,
multiplier: 44,
},
prot_params: MultiEraProtocolParameters::Byron(ByronProtParams {
script_version: 0,
slot_duration: 20000,
max_block_size: 2000000,
max_header_size: 2000000,
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,
block_slot: 3241381,
@ -181,12 +221,22 @@ mod byron_tests {
let metx: MultiEraTx = MultiEraTx::from_byron(&mtxp);
let utxos: UTxOs = UTxOs::new();
let env: Environment = Environment {
prot_params: MultiEraProtParams::Byron(ByronProtParams {
fee_policy: FeePolicy {
summand: 155381,
multiplier: 44,
},
prot_params: MultiEraProtocolParameters::Byron(ByronProtParams {
script_version: 0,
slot_duration: 20000,
max_block_size: 2000000,
max_header_size: 2000000,
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,
block_slot: 3241381,
@ -225,17 +275,27 @@ mod byron_tests {
let utxos: UTxOs = mk_utxo_for_byron_tx(
&mtxp.transaction,
&[(
String::from(include_str!("../../test_data/byron1.address")),
String::from("83581cff66e7549ee0706abe5ce63ba325f792f2c1145d918baf563db2b457a101581e581cca3e553c9c63c5927480e7434620200eb3a162ef0b6cf6f671ba925100"),
19999000000,
)],
);
let env: Environment = Environment {
prot_params: MultiEraProtParams::Byron(ByronProtParams {
fee_policy: FeePolicy {
summand: 155381,
multiplier: 44,
},
prot_params: MultiEraProtocolParameters::Byron(ByronProtParams {
script_version: 0,
slot_duration: 20000,
max_block_size: 2000000,
max_header_size: 2000000,
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,
block_slot: 3241381,
@ -259,17 +319,27 @@ mod byron_tests {
let utxos: UTxOs = mk_utxo_for_byron_tx(
&mtxp.transaction,
&[(
String::from(include_str!("../../test_data/byron1.address")),
String::from("83581cff66e7549ee0706abe5ce63ba325f792f2c1145d918baf563db2b457a101581e581cca3e553c9c63c5927480e7434620200eb3a162ef0b6cf6f671ba925100"),
19999000000,
)],
);
let env: Environment = Environment {
prot_params: MultiEraProtParams::Byron(ByronProtParams {
fee_policy: FeePolicy {
summand: 1000,
multiplier: 1000,
},
prot_params: MultiEraProtocolParameters::Byron(ByronProtParams {
script_version: 0,
slot_duration: 20000,
max_block_size: 2000000,
max_header_size: 2000000,
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,
block_slot: 3241381,
@ -293,17 +363,27 @@ mod byron_tests {
let utxos: UTxOs = mk_utxo_for_byron_tx(
&mtxp.transaction,
&[(
String::from(include_str!("../../test_data/byron1.address")),
String::from("83581cff66e7549ee0706abe5ce63ba325f792f2c1145d918baf563db2b457a101581e581cca3e553c9c63c5927480e7434620200eb3a162ef0b6cf6f671ba925100"),
19999000000,
)],
);
let env: Environment = Environment {
prot_params: MultiEraProtParams::Byron(ByronProtParams {
fee_policy: FeePolicy {
summand: 155381,
multiplier: 44,
},
prot_params: MultiEraProtocolParameters::Byron(ByronProtParams {
script_version: 0,
slot_duration: 20000,
max_block_size: 2000000,
max_header_size: 2000000,
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,
block_slot: 3241381,
@ -319,7 +399,7 @@ mod byron_tests {
}
#[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() {
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);
@ -335,17 +415,27 @@ mod byron_tests {
let utxos: UTxOs = mk_utxo_for_byron_tx(
&mtxp.transaction,
&[(
String::from(include_str!("../../test_data/byron1.address")),
String::from("83581cff66e7549ee0706abe5ce63ba325f792f2c1145d918baf563db2b457a101581e581cca3e553c9c63c5927480e7434620200eb3a162ef0b6cf6f671ba925100"),
19999000000,
)],
);
let env: Environment = Environment {
prot_params: MultiEraProtParams::Byron(ByronProtParams {
fee_policy: FeePolicy {
summand: 155381,
multiplier: 44,
},
prot_params: MultiEraProtocolParameters::Byron(ByronProtParams {
script_version: 0,
slot_duration: 20000,
max_block_size: 2000000,
max_header_size: 2000000,
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,
block_slot: 3241381,
@ -386,17 +476,27 @@ mod byron_tests {
let utxos: UTxOs = mk_utxo_for_byron_tx(
&mtxp.transaction,
&[(
String::from(include_str!("../../test_data/byron1.address")),
String::from("83581cff66e7549ee0706abe5ce63ba325f792f2c1145d918baf563db2b457a101581e581cca3e553c9c63c5927480e7434620200eb3a162ef0b6cf6f671ba925100"),
19999000000,
)],
);
let env: Environment = Environment {
prot_params: MultiEraProtParams::Byron(ByronProtParams {
fee_policy: FeePolicy {
summand: 155381,
multiplier: 44,
},
prot_params: MultiEraProtocolParameters::Byron(ByronProtParams {
script_version: 0,
slot_duration: 20000,
max_block_size: 2000000,
max_header_size: 2000000,
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,
block_slot: 3241381,

View file

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