fix(alonzo): Apply correct codec for protocol param updates (#18)
This commit is contained in:
parent
7a5e17a7ba
commit
ac9f4d916f
2 changed files with 97 additions and 4 deletions
|
|
@ -108,6 +108,8 @@ pub struct TransactionInput {
|
|||
pub index: u64,
|
||||
}
|
||||
|
||||
pub type Nonce = SkipCbor<55>;
|
||||
|
||||
pub type ScriptHash = ByteVec;
|
||||
|
||||
pub type PolicyId = ScriptHash;
|
||||
|
|
@ -182,8 +184,8 @@ pub type Hash32 = ByteVec;
|
|||
|
||||
pub type PoolKeyhash = Hash28;
|
||||
pub type Epoch = u64;
|
||||
pub type Genesishash = SkipCbor<5>;
|
||||
pub type GenesisDelegateHash = SkipCbor<6>;
|
||||
pub type Genesishash = ByteVec;
|
||||
pub type GenesisDelegateHash = ByteVec;
|
||||
pub type VrfKeyhash = Hash32;
|
||||
|
||||
/* move_instantaneous_reward = [ 0 / 1, { * stake_credential => delta_coin } / coin ]
|
||||
|
|
@ -278,7 +280,6 @@ pub struct MoveInstantaneousReward {
|
|||
pub target: InstantaneousRewardTarget,
|
||||
}
|
||||
|
||||
pub type Margin = SkipCbor<9>;
|
||||
pub type RewardAccount = ByteVec;
|
||||
pub type PoolOwners = SkipCbor<11>;
|
||||
|
||||
|
|
@ -393,6 +394,8 @@ impl minicbor::encode::Encode for RationalNumber {
|
|||
|
||||
pub type UnitInterval = RationalNumber;
|
||||
|
||||
pub type PositiveInterval = RationalNumber;
|
||||
|
||||
#[derive(Debug, PartialEq, PartialOrd, Eq, Ord)]
|
||||
pub enum StakeCredential {
|
||||
AddrKeyhash(AddrKeyhash),
|
||||
|
|
@ -614,6 +617,81 @@ pub enum NetworkId {
|
|||
Two,
|
||||
}
|
||||
|
||||
#[derive(Encode, Decode, Debug, PartialEq)]
|
||||
#[cbor(index_only)]
|
||||
pub enum Language {
|
||||
#[n(0)]
|
||||
PlutusV1,
|
||||
}
|
||||
|
||||
pub type CostModel = Vec<i32>;
|
||||
|
||||
pub type CostMdls = KeyValuePairs<Language, CostModel>;
|
||||
|
||||
pub type ProtocolVersion = (u32, u32);
|
||||
|
||||
#[derive(Encode, Decode, Debug, PartialEq)]
|
||||
#[cbor(map)]
|
||||
pub struct ProtocolParamUpdate {
|
||||
#[n(0)]
|
||||
pub minfee_a: Option<u32>,
|
||||
#[n(1)]
|
||||
pub minfee_b: Option<u32>,
|
||||
#[n(2)]
|
||||
pub max_block_body_size: Option<u32>,
|
||||
#[n(3)]
|
||||
pub max_transaction_size: Option<u32>,
|
||||
#[n(4)]
|
||||
pub max_block_header_size: Option<u32>,
|
||||
#[n(5)]
|
||||
pub key_deposit: Option<Coin>,
|
||||
#[n(6)]
|
||||
pub pool_deposit: Option<Coin>,
|
||||
#[n(7)]
|
||||
pub maximum_epoch: Option<Epoch>,
|
||||
#[n(8)]
|
||||
pub desired_number_of_stake_pools: Option<u32>,
|
||||
#[n(9)]
|
||||
pub pool_pledge_influence: Option<RationalNumber>,
|
||||
#[n(10)]
|
||||
pub expansion_rate: Option<UnitInterval>,
|
||||
#[n(11)]
|
||||
pub treasury_growth_rate: Option<UnitInterval>,
|
||||
#[n(12)]
|
||||
pub decentralization_constant: Option<UnitInterval>,
|
||||
#[n(13)]
|
||||
pub extra_entropy: Option<Nonce>,
|
||||
#[n(14)]
|
||||
pub protocol_version: Option<Vec<ProtocolVersion>>,
|
||||
#[n(16)]
|
||||
pub min_pool_cost: Option<Coin>,
|
||||
#[n(17)]
|
||||
pub ada_per_utxo_byte: Option<Coin>,
|
||||
#[n(18)]
|
||||
pub cost_models_for_script_languages: Option<CostMdls>,
|
||||
#[n(19)]
|
||||
pub execution_costs: Option<ExUnitPrices>,
|
||||
#[n(20)]
|
||||
pub max_tx_ex_units: Option<ExUnits>,
|
||||
#[n(21)]
|
||||
pub max_block_ex_units: Option<ExUnits>,
|
||||
#[n(22)]
|
||||
pub max_value_size: Option<u32>,
|
||||
#[n(23)]
|
||||
pub collateral_percentage: Option<u32>,
|
||||
#[n(24)]
|
||||
pub max_collateral_inputs: Option<u32>,
|
||||
}
|
||||
|
||||
#[derive(Encode, Decode, Debug, PartialEq)]
|
||||
pub struct Update {
|
||||
#[n(0)]
|
||||
pub proposed_protocol_parameter_updates: KeyValuePairs<Genesishash, ProtocolParamUpdate>,
|
||||
|
||||
#[n(1)]
|
||||
pub epoch: Epoch,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum TransactionBodyComponent {
|
||||
Inputs(MaybeIndefArray<TransactionInput>),
|
||||
|
|
@ -622,7 +700,7 @@ pub enum TransactionBodyComponent {
|
|||
Ttl(u64),
|
||||
Certificates(Vec<Certificate>),
|
||||
Withdrawals(KeyValuePairs<RewardAccount, Coin>),
|
||||
Update(Option<SkipCbor<22>>),
|
||||
Update(Update),
|
||||
AuxiliaryDataHash(ByteVec),
|
||||
ValidityIntervalStart(u64),
|
||||
Mint(Multiasset<i64>),
|
||||
|
|
@ -1063,6 +1141,15 @@ pub struct ExUnits {
|
|||
pub steps: u32,
|
||||
}
|
||||
|
||||
#[derive(Encode, Decode, Debug, PartialEq)]
|
||||
pub struct ExUnitPrices {
|
||||
#[n(0)]
|
||||
mem_price: PositiveInterval,
|
||||
|
||||
#[n(1)]
|
||||
step_price: PositiveInterval,
|
||||
}
|
||||
|
||||
#[derive(Encode, Decode, Debug, PartialEq)]
|
||||
#[cbor(index_only)]
|
||||
pub enum RedeemerTag {
|
||||
|
|
@ -1332,14 +1419,19 @@ mod tests {
|
|||
include_str!("test_data/test7.block"),
|
||||
include_str!("test_data/test8.block"),
|
||||
include_str!("test_data/test9.block"),
|
||||
// old block without invalid_transactions fields
|
||||
include_str!("test_data/test10.block"),
|
||||
// peculiar block with protocol update params
|
||||
include_str!("test_data/test11.block"),
|
||||
];
|
||||
|
||||
for (idx, block_str) in test_blocks.iter().enumerate() {
|
||||
println!("decoding test block {}", idx + 1);
|
||||
let bytes = hex::decode(block_str).expect(&format!("bad block file {}", idx));
|
||||
|
||||
let block = BlockWrapper::decode_fragment(&bytes[..])
|
||||
.expect(&format!("error decoding cbor for file {}", idx));
|
||||
|
||||
let bytes2 =
|
||||
to_vec(block).expect(&format!("error encoding block cbor for file {}", idx));
|
||||
|
||||
|
|
|
|||
1
pallas-alonzo/src/test_data/test11.block
Normal file
1
pallas-alonzo/src/test_data/test11.block
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue