Skip to content

Commit

Permalink
fixup! Merge branch 'brent/tune-storage-past-epochs' (#1944)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fraccaman committed Oct 23, 2023
1 parent 802a791 commit 9e97e99
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
1 change: 1 addition & 0 deletions apps/src/lib/node/ledger/shell/finalize_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3832,6 +3832,7 @@ mod test_finalize_block {
let (mut shell, _recv, _, _) = setup_with_cfg(SetupCfg {
last_height: 0,
num_validators,
..Default::default()
});
let mut params = read_pos_params(&shell.wl_storage).unwrap();
params.owned.unbonding_len = 4;
Expand Down
15 changes: 14 additions & 1 deletion proof_of_stake/src/tests/state_machine_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1875,6 +1875,8 @@ enum Transition {
#[derivative(Debug = "ignore")]
consensus_key: PublicKey,
#[derivative(Debug = "ignore")]
protocol_key: PublicKey,
#[derivative(Debug = "ignore")]
eth_cold_key: PublicKey,
#[derivative(Debug = "ignore")]
eth_hot_key: PublicKey,
Expand Down Expand Up @@ -1981,6 +1983,7 @@ impl StateMachineTest for ConcretePosState {
Transition::InitValidator {
address,
consensus_key,
protocol_key,
eth_cold_key,
eth_hot_key,
commission_rate,
Expand All @@ -1994,6 +1997,7 @@ impl StateMachineTest for ConcretePosState {
params: &params,
address: &address,
consensus_key: &consensus_key,
protocol_key: &protocol_key,
eth_cold_key: &eth_cold_key,
eth_hot_key: &eth_hot_key,
current_epoch,
Expand Down Expand Up @@ -3570,7 +3574,10 @@ impl ReferenceStateMachine for AbstractPosState {
let epoch = Epoch::default();
let mut state = Self {
epoch,
params,
params: PosParams {
owned: params,
..Default::default()
},
genesis_validators: genesis_validators
.into_iter()
// Sorted by stake to fill in the consensus set first
Expand All @@ -3592,6 +3599,7 @@ impl ReferenceStateMachine for AbstractPosState {
address,
tokens,
consensus_key: _,
protocol_key: _,
eth_cold_key: _,
eth_hot_key: _,
commission_rate: _,
Expand Down Expand Up @@ -3712,6 +3720,7 @@ impl ReferenceStateMachine for AbstractPosState {
1 => (
address::testing::arb_established_address(),
key::testing::arb_common_keypair(),
key::testing::arb_common_keypair(),
key::testing::arb_common_secp256k1_keypair(),
key::testing::arb_common_secp256k1_keypair(),
arb_rate(),
Expand All @@ -3721,6 +3730,7 @@ impl ReferenceStateMachine for AbstractPosState {
|(
addr,
consensus_key,
protocol_key,
eth_hot_key,
eth_cold_key,
commission_rate,
Expand All @@ -3729,6 +3739,7 @@ impl ReferenceStateMachine for AbstractPosState {
Transition::InitValidator {
address: Address::Established(addr),
consensus_key: consensus_key.to_public(),
protocol_key: protocol_key.to_public(),
eth_hot_key: eth_hot_key.to_public(),
eth_cold_key: eth_cold_key.to_public(),
commission_rate,
Expand Down Expand Up @@ -3871,6 +3882,7 @@ impl ReferenceStateMachine for AbstractPosState {
Transition::InitValidator {
address,
consensus_key: _,
protocol_key: _,
eth_cold_key: _,
eth_hot_key: _,
commission_rate: _,
Expand Down Expand Up @@ -4214,6 +4226,7 @@ impl ReferenceStateMachine for AbstractPosState {
Transition::InitValidator {
address,
consensus_key: _,
protocol_key: _,
eth_cold_key: _,
eth_hot_key: _,
commission_rate: _,
Expand Down
12 changes: 8 additions & 4 deletions wasm/wasm_source/src/tx_redelegate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn apply_tx(ctx: &mut Ctx, tx_data: Tx) -> TxResult {
mod tests {
use std::collections::BTreeSet;

use namada::ledger::pos::{PosParams, PosVP};
use namada::ledger::pos::{OwnedPosParams, PosVP};
use namada::proof_of_stake::types::{GenesisValidator, WeightedValidator};
use namada::proof_of_stake::{
bond_handle, read_consensus_validator_set_addresses_with_stake,
Expand Down Expand Up @@ -68,17 +68,18 @@ mod tests {
initial_stake: token::Amount,
redelegation: transaction::pos::Redelegation,
key: key::common::SecretKey,
pos_params: PosParams,
pos_params: OwnedPosParams,
) -> TxResult {
// Remove the validator stake threshold for simplicity
let pos_params = PosParams {
let pos_params = OwnedPosParams {
validator_stake_threshold: token::Amount::zero(),
..pos_params
};
dbg!(&initial_stake, &redelegation);

let consensus_key_1 = key::testing::keypair_1().ref_to();
let consensus_key_2 = key::testing::keypair_2().ref_to();
let protocol_key = key::testing::keypair_2().ref_to();
let eth_cold_key = key::testing::keypair_3().ref_to();
let eth_hot_key = key::testing::keypair_4().ref_to();
let commission_rate = Dec::new(5, 2).expect("Cannot fail");
Expand All @@ -89,6 +90,7 @@ mod tests {
address: redelegation.src_validator.clone(),
tokens: token::Amount::zero(),
consensus_key: consensus_key_1,
protocol_key: protocol_key.clone(),
eth_cold_key: eth_cold_key.clone(),
eth_hot_key: eth_hot_key.clone(),
commission_rate,
Expand All @@ -98,14 +100,16 @@ mod tests {
address: redelegation.dest_validator.clone(),
tokens: token::Amount::zero(),
consensus_key: consensus_key_2,
protocol_key,
eth_cold_key,
eth_hot_key,
commission_rate,
max_commission_rate_change,
},
];

init_pos(&genesis_validators[..], &pos_params, Epoch(0));
let pos_params =
init_pos(&genesis_validators[..], &pos_params, Epoch(0));

let native_token = tx_host_env::with(|tx_env| {
let native_token = tx_env.wl_storage.storage.native_token.clone();
Expand Down

0 comments on commit 9e97e99

Please sign in to comment.