Skip to content

Commit

Permalink
Merge pull request #566 from Emurgo/release/11.2.1
Browse files Browse the repository at this point in the history
Release 11.2.1 "Unbelievable protocol params"
  • Loading branch information
lisicky authored Dec 19, 2022
2 parents f90602b + 977470c commit cdecf67
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cardano-serialization-lib",
"version": "11.2.0",
"version": "11.2.1",
"description": "(De)serialization functions for the Cardano blockchain along with related utility functions",
"scripts": {
"rust:build-nodejs": "(rimraf ./rust/pkg && cd rust; wasm-pack build --target=nodejs; cd ..; npm run js:ts-json-gen; cd rust; wasm-pack pack) && npm run js:flowgen",
Expand Down
2 changes: 1 addition & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cardano-serialization-lib"
version = "11.2.0"
version = "11.2.1"
edition = "2018"
authors = ["EMURGO"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion rust/json-gen/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3695,6 +3695,7 @@ impl From<&NativeScripts> for RequiredSignersSet {

#[cfg(test)]
mod tests {
use crate::tx_builder_constants::TxBuilderConstants;
use super::*;

#[test]
Expand Down Expand Up @@ -3946,4 +3947,39 @@ mod tests {
assert!(pks4.contains(&keyhash2));
assert!(pks4.contains(&keyhash3));
}

#[test]
fn protocol_params_update_cbor_roundtrip() {
let mut orig_ppu = ProtocolParamUpdate::new();
orig_ppu.set_max_tx_size(1234);
orig_ppu.set_max_block_body_size(5678);
orig_ppu.set_max_block_header_size(91011);
orig_ppu.set_minfee_a(&Coin::from(1u32));
orig_ppu.set_minfee_b(&Coin::from(2u32));
orig_ppu.set_key_deposit(&Coin::from(3u32));
orig_ppu.set_pool_deposit(&Coin::from(4u32));
orig_ppu.set_max_epoch(5);
orig_ppu.set_n_opt(6);
orig_ppu.set_pool_pledge_influence(&Rational::new(&BigNum::from(7u32), &BigNum::from(77u32)));
orig_ppu.set_expansion_rate(&UnitInterval::new(&BigNum::from(8u32), &BigNum::from(9u32)));
orig_ppu.set_treasury_growth_rate(&UnitInterval::new(&BigNum::from(10u32), &BigNum::from(11u32)));
orig_ppu.set_protocol_version(&ProtocolVersion::new(12u32,13u32));
orig_ppu.set_min_pool_cost(&Coin::from(14u32));
orig_ppu.set_ada_per_utxo_byte(&Coin::from(15u32));
orig_ppu.set_cost_models(&TxBuilderConstants::plutus_vasil_cost_models());
orig_ppu.set_execution_costs(&ExUnitPrices::new(
&SubCoin::new(&BigNum::from(16u32), &BigNum::from(17u32)),
&SubCoin::new(&BigNum::from(18u32), &BigNum::from(19u32))));
orig_ppu.set_max_tx_ex_units(&ExUnits::new(&BigNum::from(20u32), &BigNum::from(21u32)));
orig_ppu.set_max_block_ex_units(&ExUnits::new(&BigNum::from(22u32), &BigNum::from(23u32)));
orig_ppu.set_max_value_size(24);
orig_ppu.set_collateral_percentage(25);
orig_ppu.set_max_collateral_inputs(25);

let encoded = orig_ppu.to_bytes();
let dencoded = ProtocolParamUpdate::from_bytes(encoded).unwrap();

assert_eq!(dencoded, orig_ppu);
assert_eq!(dencoded.to_bytes(), orig_ppu.to_bytes());
}
}
6 changes: 6 additions & 0 deletions rust/src/serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3722,6 +3722,12 @@ impl cbor_event::se::Serialize for ProtocolParamUpdate {
} + match &self.max_value_size {
Some(_) => 1,
None => 0,
} + match &self.collateral_percentage {
Some(_) => 1,
None => 0,
} + match &self.max_collateral_inputs {
Some(_) => 1,
None => 0,
},
))?;
if let Some(field) = &self.minfee_a {
Expand Down

0 comments on commit cdecf67

Please sign in to comment.