Add support for protocol parameters (except cost models)

We can now simulate transactions with protocol parameters voting
  procedures. Cost models remain to be done, though.
This commit is contained in:
KtorZ 2024-08-11 18:47:28 +02:00
parent 50dad1fdfe
commit f244b9c496
No known key found for this signature in database
GPG Key ID: 33173CB6F77F4277
15 changed files with 6621 additions and 1938 deletions

10
Cargo.lock generated vendored
View File

@ -1942,7 +1942,7 @@ checksum = "caff54706df99d2a78a5a4e3455ff45448d81ef1bb63c22cd14052ca0e993a3f"
[[package]] [[package]]
name = "pallas-addresses" name = "pallas-addresses"
version = "0.29.0" version = "0.29.0"
source = "git+https://github.com/KtorZ/pallas.git?rev=7e5c90694c760e91fc7ac4d553db0f649b6a53a2#7e5c90694c760e91fc7ac4d553db0f649b6a53a2" source = "git+https://github.com/KtorZ/pallas.git?rev=454b3bcf32cdc238aba65e4c3e4656a352480ec1#454b3bcf32cdc238aba65e4c3e4656a352480ec1"
dependencies = [ dependencies = [
"base58", "base58",
"bech32", "bech32",
@ -1957,7 +1957,7 @@ dependencies = [
[[package]] [[package]]
name = "pallas-codec" name = "pallas-codec"
version = "0.29.0" version = "0.29.0"
source = "git+https://github.com/KtorZ/pallas.git?rev=7e5c90694c760e91fc7ac4d553db0f649b6a53a2#7e5c90694c760e91fc7ac4d553db0f649b6a53a2" source = "git+https://github.com/KtorZ/pallas.git?rev=454b3bcf32cdc238aba65e4c3e4656a352480ec1#454b3bcf32cdc238aba65e4c3e4656a352480ec1"
dependencies = [ dependencies = [
"hex", "hex",
"minicbor", "minicbor",
@ -1969,7 +1969,7 @@ dependencies = [
[[package]] [[package]]
name = "pallas-crypto" name = "pallas-crypto"
version = "0.29.0" version = "0.29.0"
source = "git+https://github.com/KtorZ/pallas.git?rev=7e5c90694c760e91fc7ac4d553db0f649b6a53a2#7e5c90694c760e91fc7ac4d553db0f649b6a53a2" source = "git+https://github.com/KtorZ/pallas.git?rev=454b3bcf32cdc238aba65e4c3e4656a352480ec1#454b3bcf32cdc238aba65e4c3e4656a352480ec1"
dependencies = [ dependencies = [
"cryptoxide", "cryptoxide",
"hex", "hex",
@ -1982,7 +1982,7 @@ dependencies = [
[[package]] [[package]]
name = "pallas-primitives" name = "pallas-primitives"
version = "0.29.0" version = "0.29.0"
source = "git+https://github.com/KtorZ/pallas.git?rev=7e5c90694c760e91fc7ac4d553db0f649b6a53a2#7e5c90694c760e91fc7ac4d553db0f649b6a53a2" source = "git+https://github.com/KtorZ/pallas.git?rev=454b3bcf32cdc238aba65e4c3e4656a352480ec1#454b3bcf32cdc238aba65e4c3e4656a352480ec1"
dependencies = [ dependencies = [
"base58", "base58",
"bech32", "bech32",
@ -1997,7 +1997,7 @@ dependencies = [
[[package]] [[package]]
name = "pallas-traverse" name = "pallas-traverse"
version = "0.29.0" version = "0.29.0"
source = "git+https://github.com/KtorZ/pallas.git?rev=7e5c90694c760e91fc7ac4d553db0f649b6a53a2#7e5c90694c760e91fc7ac4d553db0f649b6a53a2" source = "git+https://github.com/KtorZ/pallas.git?rev=454b3bcf32cdc238aba65e4c3e4656a352480ec1#454b3bcf32cdc238aba65e4c3e4656a352480ec1"
dependencies = [ dependencies = [
"hex", "hex",
"itertools 0.13.0", "itertools 0.13.0",

View File

@ -49,11 +49,11 @@ x86_64-unknown-linux-gnu = "ubuntu-22.04"
walkdir = "2.3.2" walkdir = "2.3.2"
insta = { version = "1.30.0", features = ["yaml", "json", "redactions"] } insta = { version = "1.30.0", features = ["yaml", "json", "redactions"] }
miette = { version = "7.2.0", features = ["fancy"] } miette = { version = "7.2.0", features = ["fancy"] }
pallas-addresses = { git = "https://github.com/KtorZ/pallas.git", rev = "7e5c90694c760e91fc7ac4d553db0f649b6a53a2" } pallas-addresses = { git = "https://github.com/KtorZ/pallas.git", rev = "454b3bcf32cdc238aba65e4c3e4656a352480ec1" }
pallas-codec = { git = "https://github.com/KtorZ/pallas.git", rev = "7e5c90694c760e91fc7ac4d553db0f649b6a53a2", features = ["num-bigint"] } pallas-codec = { git = "https://github.com/KtorZ/pallas.git", rev = "454b3bcf32cdc238aba65e4c3e4656a352480ec1", features = ["num-bigint"] }
pallas-crypto = { git = "https://github.com/KtorZ/pallas.git", rev = "7e5c90694c760e91fc7ac4d553db0f649b6a53a2" } pallas-crypto = { git = "https://github.com/KtorZ/pallas.git", rev = "454b3bcf32cdc238aba65e4c3e4656a352480ec1" }
pallas-primitives = { git = "https://github.com/KtorZ/pallas.git", rev = "7e5c90694c760e91fc7ac4d553db0f649b6a53a2" } pallas-primitives = { git = "https://github.com/KtorZ/pallas.git", rev = "454b3bcf32cdc238aba65e4c3e4656a352480ec1" }
pallas-traverse = { git = "https://github.com/KtorZ/pallas.git", rev = "7e5c90694c760e91fc7ac4d553db0f649b6a53a2" } pallas-traverse = { git = "https://github.com/KtorZ/pallas.git", rev = "454b3bcf32cdc238aba65e4c3e4656a352480ec1" }
[profile.dev.package.insta] [profile.dev.package.insta]
opt-level = 3 opt-level = 3

File diff suppressed because it is too large Load Diff

View File

@ -6,16 +6,17 @@ use crate::{
machine::runtime::{convert_constr_to_tag, ANY_TAG}, machine::runtime::{convert_constr_to_tag, ANY_TAG},
tx::script_context::from_alonzo_output, tx::script_context::from_alonzo_output,
}; };
use num_integer::Integer;
use pallas_addresses::{ use pallas_addresses::{
Address, ShelleyDelegationPart, ShelleyPaymentPart, StakeAddress, StakePayload, Address, ShelleyDelegationPart, ShelleyPaymentPart, StakeAddress, StakePayload,
}; };
use pallas_codec::utils::{AnyUInt, Bytes, Int, KeyValuePairs, NonEmptyKeyValuePairs, Nullable}; use pallas_codec::utils::{AnyUInt, Bytes, Int, KeyValuePairs, NonEmptyKeyValuePairs, Nullable};
use pallas_crypto::hash::Hash; use pallas_crypto::hash::Hash;
use pallas_primitives::conway::{ use pallas_primitives::conway::{
AssetName, BigInt, Certificate, Coin, Constitution, Constr, DatumOption, GovAction, AssetName, BigInt, Certificate, Coin, Constitution, Constr, DRepVotingThresholds, DatumOption,
GovActionId, Mint, PlutusData, PolicyId, ProposalProcedure, ProtocolParamUpdate, PseudoScript, ExUnitPrices, ExUnits, GovAction, GovActionId, Mint, PlutusData, PolicyId,
RationalNumber, Redeemer, ScriptRef, StakeCredential, TransactionInput, TransactionOutput, PoolVotingThresholds, ProposalProcedure, ProtocolParamUpdate, PseudoScript, RationalNumber,
Value, Redeemer, ScriptRef, StakeCredential, TransactionInput, TransactionOutput, Value,
}; };
use pallas_traverse::ComputeHash; use pallas_traverse::ComputeHash;
@ -44,6 +45,8 @@ struct WithZeroAdaAsset<'a, T>(&'a T);
struct WithOptionDatum<'a, T>(&'a T); struct WithOptionDatum<'a, T>(&'a T);
struct WithArrayRational<'a, T>(&'a T);
pub trait ToPlutusData { pub trait ToPlutusData {
fn to_plutus_data(&self) -> PlutusData; fn to_plutus_data(&self) -> PlutusData;
} }
@ -816,7 +819,181 @@ impl ToPlutusData for GovActionId {
impl ToPlutusData for ProtocolParamUpdate { impl ToPlutusData for ProtocolParamUpdate {
fn to_plutus_data(&self) -> PlutusData { fn to_plutus_data(&self) -> PlutusData {
todo!("ToPlutusData for ProtocolParamUpdate") let mut pparams = Vec::with_capacity(30);
let mut push = |ix: usize, p: PlutusData| {
pparams.push((ix.to_plutus_data(), p));
};
if let Some(p) = self.minfee_a {
push(0, p.to_plutus_data());
}
if let Some(p) = self.minfee_b {
push(1, p.to_plutus_data());
}
if let Some(p) = self.max_block_body_size {
push(2, p.to_plutus_data());
}
if let Some(p) = self.max_transaction_size {
push(3, p.to_plutus_data());
}
if let Some(p) = self.max_block_header_size {
push(4, p.to_plutus_data());
}
if let Some(p) = self.key_deposit {
push(5, p.to_plutus_data());
}
if let Some(p) = self.pool_deposit {
push(6, p.to_plutus_data());
}
if let Some(p) = self.maximum_epoch {
push(7, p.to_plutus_data());
}
if let Some(p) = self.desired_number_of_stake_pools {
push(8, p.to_plutus_data());
}
if let Some(ref p) = self.pool_pledge_influence {
push(9, WithArrayRational(p).to_plutus_data());
}
if let Some(ref p) = self.expansion_rate {
push(10, WithArrayRational(p).to_plutus_data());
}
if let Some(ref p) = self.treasury_growth_rate {
push(11, WithArrayRational(p).to_plutus_data());
}
if let Some(p) = self.min_pool_cost {
push(16, p.to_plutus_data());
}
if let Some(p) = self.ada_per_utxo_byte {
push(17, p.to_plutus_data());
}
#[allow(clippy::redundant_pattern_matching)]
if let Some(_) = self.cost_models_for_script_languages {
unimplemented!("TODO: ToPlutusData for cost models.");
}
if let Some(ref p) = self.execution_costs {
push(19, p.to_plutus_data());
}
if let Some(p) = self.max_tx_ex_units {
push(20, p.to_plutus_data());
}
if let Some(p) = self.max_block_ex_units {
push(21, p.to_plutus_data());
}
if let Some(p) = self.max_value_size {
push(22, p.to_plutus_data());
}
if let Some(p) = self.collateral_percentage {
push(23, p.to_plutus_data());
}
if let Some(p) = self.max_collateral_inputs {
push(24, p.to_plutus_data());
}
if let Some(ref p) = self.pool_voting_thresholds {
push(25, p.to_plutus_data());
}
if let Some(ref p) = self.drep_voting_thresholds {
push(26, p.to_plutus_data());
}
if let Some(p) = self.min_committee_size {
push(27, p.to_plutus_data());
}
if let Some(p) = self.committee_term_limit {
push(28, p.to_plutus_data());
}
if let Some(p) = self.governance_action_validity_period {
push(29, p.to_plutus_data());
}
if let Some(p) = self.governance_action_deposit {
push(30, p.to_plutus_data());
}
if let Some(p) = self.drep_deposit {
push(31, p.to_plutus_data());
}
if let Some(p) = self.drep_inactivity_period {
push(32, p.to_plutus_data());
}
if let Some(ref p) = self.minfee_refscript_cost_per_byte {
push(33, WithArrayRational(p).to_plutus_data());
}
Data::map(pparams)
}
}
impl ToPlutusData for PoolVotingThresholds {
fn to_plutus_data(&self) -> PlutusData {
vec![
WithArrayRational(&self.motion_no_confidence).to_plutus_data(),
WithArrayRational(&self.committee_normal).to_plutus_data(),
WithArrayRational(&self.committee_no_confidence).to_plutus_data(),
WithArrayRational(&self.hard_fork_initiation).to_plutus_data(),
WithArrayRational(&self.security_voting_threshold).to_plutus_data(),
]
.to_plutus_data()
}
}
impl ToPlutusData for DRepVotingThresholds {
fn to_plutus_data(&self) -> PlutusData {
vec![
WithArrayRational(&self.motion_no_confidence).to_plutus_data(),
WithArrayRational(&self.committee_normal).to_plutus_data(),
WithArrayRational(&self.committee_no_confidence).to_plutus_data(),
WithArrayRational(&self.update_constitution).to_plutus_data(),
WithArrayRational(&self.hard_fork_initiation).to_plutus_data(),
WithArrayRational(&self.pp_network_group).to_plutus_data(),
WithArrayRational(&self.pp_economic_group).to_plutus_data(),
WithArrayRational(&self.pp_technical_group).to_plutus_data(),
WithArrayRational(&self.pp_governance_group).to_plutus_data(),
WithArrayRational(&self.treasury_withdrawal).to_plutus_data(),
]
.to_plutus_data()
}
}
impl ToPlutusData for ExUnitPrices {
fn to_plutus_data(&self) -> PlutusData {
vec![
WithArrayRational(&self.mem_price).to_plutus_data(),
WithArrayRational(&self.step_price).to_plutus_data(),
]
.to_plutus_data()
}
}
impl ToPlutusData for ExUnits {
fn to_plutus_data(&self) -> PlutusData {
vec![self.mem.to_plutus_data(), self.steps.to_plutus_data()].to_plutus_data()
} }
} }
@ -890,7 +1067,15 @@ impl ToPlutusData for Constitution {
impl ToPlutusData for RationalNumber { impl ToPlutusData for RationalNumber {
fn to_plutus_data(&self) -> PlutusData { fn to_plutus_data(&self) -> PlutusData {
(self.numerator, self.denominator).to_plutus_data() let gcd = self.numerator.gcd(&self.denominator);
(self.numerator / gcd, self.denominator / gcd).to_plutus_data()
}
}
impl<'a> ToPlutusData for WithArrayRational<'a, RationalNumber> {
fn to_plutus_data(&self) -> PlutusData {
let gcd = self.0.numerator.gcd(&self.0.denominator);
vec![self.0.numerator / gcd, self.0.denominator / gcd].to_plutus_data()
} }
} }

View File

@ -132,36 +132,36 @@ for convenience.
- [ ] SPO - [ ] SPO
- ChangedParameters - ChangedParameters
- [ ] 0: coin - [x] txFeePerByte
- [ ] 1 : coin - [x] txFeeFixed
- [ ] 2 : uint .size 4 - [x] maxBlockBodySize
- [ ] 3 : uint .size 4 - [x] maxTxSize
- [ ] 4 : uint .size 2 - [x] maxBlockHeaderSize
- [ ] 5 : coin - [x] stakeAddressDeposit
- [ ] 6 : coin - [x] stakePoolDeposit
- [ ] 7 : epoch_interval - [x] poolRetireMaxEpoch
- [ ] 8 : uint .size 2 - [x] stakePoolTargetNum
- [ ] 9 : nonnegative_interval - [x] poolPledgeInfluence
- [ ] 10 : unit_interval - [x] monetaryExpansion
- [ ] 11 : unit_interval - [x] treasuryCut
- [ ] 16 : coin - [x] minPoolCost
- [ ] 17 : coin - [x] utxoCostPerByte
- [ ] 18 : costmdls - [ ] costModels
- [ ] 19 : ex_unit_prices - [x] executionUnitPrices
- [ ] 20 : ex_units - [x] maxTxExecutionUnits
- [ ] 21 : ex_units - [x] maxBlockExecutionUnits
- [ ] 22 : uint .size 4 - [x] maxValueSize
- [ ] 23 : uint .size 2 - [x] collateralPercentage
- [ ] 24 : uint .size 2 - [x] maxCollateralInputs
- [ ] 25 : pool_voting_thresholds - [x] poolVotingThresholds
- [ ] 26 : drep_voting_thresholds - [x] dRepVotingThresholds
- [ ] 27 : uint .size 2 - [x] committeeMinSize
- [ ] 28 : epoch_interval - [x] committeeMaxTermLength
- [ ] 29 : epoch_interval - [x] govActionLifetime
- [ ] 30 : coin - [x] govActionDeposit
- [ ] 31 : coin - [x] dRepDeposit
- [ ] 32 : epoch_interval - [x] dRepActivity
- [ ] 33 : nonnegative_interval} - [x] minFeeRefScriptCostPerByte
- Constitution - Constitution
- [x] with guardrail script - [x] with guardrail script

View File

@ -1,7 +1,16 @@
# This file was generated by Aiken # This file was generated by Aiken
# You typically do not need to edit this file # You typically do not need to edit this file
[[requirements]]
name = "logicalmechanism/stdlib"
version = "plutus-v3"
source = "github"
[[packages]]
name = "logicalmechanism/stdlib"
version = "plutus-v3"
requirements = [] requirements = []
packages = [] source = "github"
[etags] [etags]
"logicalmechanism/stdlib@plutus-v3" = [{ secs_since_epoch = 1723394635, nanos_since_epoch = 36770000 }, "097396ab7dedd5e38c558f35b2fb34a2d0f058bb0da0635949f5fcbb36f1310e"]

View File

@ -1,5 +1,11 @@
name = "script_context/v3" name = "script_context/v3"
version = "0.0.0" version = "0.0.0"
compiler = "v1.0.31-alpha"
plutus = "v3" plutus = "v3"
license = "Apache-2.0" license = "Apache-2.0"
description = "Aiken contracts for project 'script_context/v3'" description = "Aiken contracts for project 'script_context/v3'"
[[dependencies]]
name = "logicalmechanism/stdlib"
version = "plutus-v3"
source = "github"

View File

@ -0,0 +1,5 @@
[
{ 0: h'6000000000000000000000000000000000000000000000000000000000'
, 1: 1000000
}
]

View File

@ -0,0 +1,83 @@
[
{ 0:
[ [h'0000000000000000000000000000000000000000000000000000000000000000', 0]
]
, 1:
[]
, 2: 42
, 20: 258(
[
[ 2000000
, h'F000000000000000000000000000000000000000000000000000000000'
, [ 0
, null
, { 0: 44
, 1: 155381
, 7: 18
, 8: 500
, 9: 30([3, 10])
, 10: 30([3, 1000])
, 11: 30([2, 10])
, 2: 90112
, 3: 16384
, 4: 1100
, 5: 2000000
, 6: 500000000
, 16: 340
, 17: 4310
, 19: [30([577, 1000]), 30([721, 1000000])]
, 20: [14000000, 10000000000]
, 21: [62000000, 20000000000]
, 22: 5000
, 23: 150
, 24: 3
, 25:
[ 30([51, 100])
, 30([52, 100])
, 30([53, 100])
, 30([54, 100])
, 30([55, 100])
]
, 26:
[ 30([67, 100])
, 30([67, 100])
, 30([60, 100])
, 30([75, 100])
, 30([60, 100])
, 30([67, 100])
, 30([67, 100])
, 30([67, 100])
, 30([75, 100])
, 30([67, 100])
]
, 27: 7
, 28: 146
, 29: 6
, 30: 100000000000
, 31: 500000000
, 32: 20
, 33: 30([15, 1])
}
, h'{{ proposing_pparams.guardrails.hash }}'
]
, [ "https://aiken-lang.org"
, h'0000000000000000000000000000000000000000000000000000000000000000'
]
]
]
)
},
{ 5: [[5, 0, 121([]), [1000000, 100000000]]]
, 7: [h'{{ proposing_pparams.guardrails.cbor }}']
},
true,
null
]

View File

@ -1 +0,0 @@
../../../../../stdlib/lib

File diff suppressed because one or more lines are too long

View File

@ -3,7 +3,7 @@ use aiken/math/rational
use cardano/credential.{Script, VerificationKey} use cardano/credential.{Script, VerificationKey}
use cardano/governance.{ use cardano/governance.{
Constitution, ConstitutionalCommittee, GovernanceAction, GovernanceActionId, Constitution, ConstitutionalCommittee, GovernanceAction, GovernanceActionId,
HardForkInitiation, NewConstitution, NicePoll, NoConfidence, ProposalProcedure, HardFork, NewConstitution, NicePoll, NoConfidence, ProposalProcedure,
ProtocolVersion, TreasuryWithdrawal, ProtocolVersion, TreasuryWithdrawal,
} }
use cardano/transaction.{Propose, Redeemer, ScriptContext, ScriptPurpose} use cardano/transaction.{Propose, Redeemer, ScriptContext, ScriptPurpose}
@ -23,10 +23,7 @@ validator {
list.at(procedures, 0), list.at(procedures, 0),
fn(action) { fn(action) {
expect expect
HardForkInitiation { HardFork { ancestor: None, new_version: ProtocolVersion(10, 0) } == action
ancestor: None,
new_version: ProtocolVersion(10, 0),
} == action
Void Void
}, },
) )
@ -35,7 +32,7 @@ validator {
list.at(procedures, 1), list.at(procedures, 1),
fn(action) { fn(action) {
expect expect
HardForkInitiation { HardFork {
ancestor: Some(GovernanceActionId(null32, 0)), ancestor: Some(GovernanceActionId(null32, 0)),
new_version: ProtocolVersion(11, 0), new_version: ProtocolVersion(11, 0),
} == action } == action

View File

@ -0,0 +1,173 @@
use aiken/math/rational.{Rational}
use cardano/governance.{ProposalProcedure, ProtocolParameters}
use cardano/governance/protocol_parameters.{
ConstitutionalCommitteeThresholds, DelegateRepresentativeVotingThresholds,
ExecutionUnits, ProtocolParametersThresholds, ScriptExecutionPrices,
StakePoolOperatorVotingThresholds, collateral_percentage, cost_models,
delegate_representative_deposit, delegate_representative_max_idle_time,
delegate_representative_voting_thresholds, desired_number_of_stake_pools,
governance_proposal_deposit, governance_proposal_lifetime, max_block_body_size,
max_block_execution_units, max_block_header_size, max_collateral_inputs,
max_constitutional_committee_mandate, max_transaction_execution_units,
max_transaction_size, max_value_size, min_constitutional_committee_size,
min_fee_coefficient, min_fee_constant, min_stake_pool_cost,
min_utxo_deposit_coefficient, monetary_expansion,
reference_scripts_tier_fee_initial_factor, script_execution_prices,
stake_credential_deposit, stake_pool_deposit,
stake_pool_operator_voting_thresholds, stake_pool_pledge_influence,
stake_pool_retirement_horizon, treasury_expansion,
}
use cardano/transaction.{Proposing, ScriptContext}
validator {
fn guardrails(_tmp1: Void, ctx: ScriptContext) -> Bool {
expect Proposing(
0,
ProposalProcedure {
governance_action: ProtocolParameters {
ancestor: None,
guardrails: Some(..),
new_parameters,
},
..
},
) = ctx.info
expect ( new_parameters |> min_fee_coefficient ) == Some(44)
expect ( new_parameters |> min_fee_constant ) == Some(155_381)
expect ( new_parameters |> max_block_body_size ) == Some(90_112)
expect ( new_parameters |> max_transaction_size ) == Some(16_384)
expect ( new_parameters |> max_block_header_size ) == Some(1_100)
expect ( new_parameters |> stake_credential_deposit ) == Some(2_000_000)
expect ( new_parameters |> stake_pool_deposit ) == Some(500_000_000)
expect ( new_parameters |> stake_pool_retirement_horizon ) == Some(18)
expect ( new_parameters |> desired_number_of_stake_pools ) == Some(500)
expect
( new_parameters |> stake_pool_pledge_influence ) == Some(
expect_rational(3, 10),
)
expect
( new_parameters |> monetary_expansion ) == Some(
expect_rational(3, 1_000),
)
expect
( new_parameters |> treasury_expansion ) == Some(expect_rational(1, 5))
expect ( new_parameters |> min_stake_pool_cost ) == Some(340)
expect ( new_parameters |> min_utxo_deposit_coefficient ) == Some(4310)
expect ( new_parameters |> cost_models ) == None
expect
( new_parameters |> script_execution_prices ) == Some(
ScriptExecutionPrices {
memory: expect_rational(577, 1_000),
cpu: expect_rational(721, 1_000_000),
},
)
expect
( new_parameters |> max_transaction_execution_units ) == Some(
ExecutionUnits { memory: 14000000, cpu: 10000000000 },
)
expect
( new_parameters |> max_block_execution_units ) == Some(
ExecutionUnits { memory: 62000000, cpu: 20000000000 },
)
expect ( new_parameters |> max_value_size ) == Some(5000)
expect ( new_parameters |> collateral_percentage ) == Some(150)
expect ( new_parameters |> max_collateral_inputs ) == Some(3)
expect
( new_parameters |> stake_pool_operator_voting_thresholds ) == Some(
spo_thresholds(),
)
expect
( new_parameters |> delegate_representative_voting_thresholds ) == Some(
drep_thresholds(),
)
expect ( new_parameters |> min_constitutional_committee_size ) == Some(7)
expect
( new_parameters |> max_constitutional_committee_mandate ) == Some(146)
expect ( new_parameters |> governance_proposal_lifetime ) == Some(6)
expect
( new_parameters |> governance_proposal_deposit ) == Some(100_000_000_000)
expect
( new_parameters |> delegate_representative_deposit ) == Some(500_000_000)
expect
( new_parameters |> delegate_representative_max_idle_time ) == Some(20)
expect
( new_parameters |> reference_scripts_tier_fee_initial_factor ) == Some(
expect_rational(15, 1),
)
True
}
}
fn expect_rational(numerator: Int, denominator: Int) -> Rational {
expect Some(r) = rational.new(numerator, denominator)
r
}
fn spo_thresholds() -> StakePoolOperatorVotingThresholds {
StakePoolOperatorVotingThresholds {
motion_of_no_confidence: expect_rational(51, 100),
constitutional_committee: ConstitutionalCommitteeThresholds {
default: expect_rational(13, 25),
under_no_confidence: expect_rational(53, 100),
},
hard_fork: expect_rational(27, 50),
protocol_parameters: ProtocolParametersThresholds {
security_group: expect_rational(11, 20),
network_group: Void,
economic_group: Void,
technical_group: Void,
governance_group: Void,
},
}
}
fn drep_thresholds() -> DelegateRepresentativeVotingThresholds {
DelegateRepresentativeVotingThresholds {
motion_of_no_confidence: expect_rational(67, 100),
constitutional_committee: ConstitutionalCommitteeThresholds {
default: expect_rational(67, 100),
under_no_confidence: expect_rational(3, 5),
},
constitution: expect_rational(3, 4),
hard_fork: expect_rational(3, 5),
protocol_parameters: ProtocolParametersThresholds {
security_group: Void,
network_group: expect_rational(67, 100),
economic_group: expect_rational(67, 100),
technical_group: expect_rational(67, 100),
governance_group: expect_rational(3, 4),
},
treasury_withdrawal: expect_rational(67, 100),
}
}