Skip to content

Commit bfcd34e

Browse files
brentstonetzemanovic
authored andcommitted
cleanup after rebase (updated #677)
1 parent e43fb43 commit bfcd34e

File tree

7 files changed

+43
-39
lines changed

7 files changed

+43
-39
lines changed

core/src/ledger/storage/merkle_tree.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,4 +874,4 @@ mod test {
874874
);
875875
assert!(basetree_verification_res);
876876
}
877-
}
877+
}

proof_of_stake/src/lib.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ use parameters::PosParams;
3636
use rust_decimal::Decimal;
3737
use thiserror::Error;
3838
use types::{
39-
ActiveValidator, Bonds, CommissionRate, Epoch, GenesisValidator, GenesisValidator_NEW,
39+
ActiveValidator, Bonds, CommissionRates, GenesisValidator,
4040
Slash, SlashType, Slashes, TotalDeltas, Unbond, Unbonds,
4141
ValidatorConsensusKeys, ValidatorConsensusKeys_NEW, ValidatorSet,
4242
ValidatorSetUpdate, ValidatorSets, ValidatorState, ValidatorStates,
4343
ValidatorDeltas, ValidatorStates_NEW,
44-
ValidatorDeltas_NEW, ValidatorSets_NEW, BondId_NEW
44+
ValidatorDeltas_NEW, ValidatorSets_NEW
4545
};
4646

4747
use crate::btree_set::BTreeSetShims;
@@ -1703,7 +1703,7 @@ pub fn validator_state_handle(
17031703
pub fn validator_deltas_handle(
17041704
validator: &Address
17051705
) -> ValidatorDeltas_NEW {
1706-
let key = storage::validator_total_deltas_key(&validator);
1706+
let key = storage::validator_deltas_key(&validator);
17071707
crate::epoched_new::EpochedDelta::open(key)
17081708
}
17091709

@@ -1712,7 +1712,7 @@ pub fn bond_handle(
17121712
source: &Address,
17131713
validator: &Address
17141714
) -> LazyMap<Epoch, token::Amount> {
1715-
let bond_id = BondId_NEW {source: source.clone(), validator: validator.clone()};
1715+
let bond_id = BondId {source: source.clone(), validator: validator.clone()};
17161716
let key = storage::bond_key(&bond_id);
17171717
LazyMap::open(key)
17181718
}
@@ -1721,7 +1721,7 @@ pub fn bond_handle(
17211721
pub fn init_genesis_NEW<S>(
17221722
storage: &mut S,
17231723
params: &PosParams,
1724-
validators: impl Iterator<Item = GenesisValidator_NEW> + Clone,
1724+
validators: impl Iterator<Item = GenesisValidator> + Clone,
17251725
current_epoch: namada_core::types::storage::Epoch,
17261726
) -> storage_api::Result<()>
17271727
where
@@ -1732,6 +1732,8 @@ where
17321732
address,
17331733
tokens,
17341734
consensus_key,
1735+
commission_rate,
1736+
max_commission_rate_change
17351737
} in validators
17361738
{
17371739
validator_consensus_key_handle(&address).init_at_genesis(
@@ -1761,7 +1763,7 @@ pub fn read_validator_consensus_key<S>(
17611763
params: &PosParams,
17621764
validator: &Address,
17631765
epoch: namada_core::types::storage::Epoch,
1764-
) -> storage_api::Result<Option<key::common::PublicKey>>
1766+
) -> storage_api::Result<Option<common::PublicKey>>
17651767
where
17661768
S: for<'iter> StorageRead<'iter>,
17671769
{
@@ -1774,7 +1776,7 @@ pub fn write_validator_consensus_key<S>(
17741776
storage: &mut S,
17751777
params: &PosParams,
17761778
validator: &Address,
1777-
consensus_key: key::common::PublicKey,
1779+
consensus_key: common::PublicKey,
17781780
current_epoch: namada_core::types::storage::Epoch,
17791781
) -> storage_api::Result<()>
17801782
where

proof_of_stake/src/storage.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use namada_core::ledger::storage::types::{decode, encode};
44
use namada_core::ledger::storage::{self, Storage, StorageHasher};
5-
use namada_core::types::address::{self, Address};
5+
use namada_core::types::address::Address;
66
use namada_core::types::storage::{DbKeySeg, Key, KeySeg};
77
use namada_core::types::{key, token};
88
use rust_decimal::Decimal;
@@ -17,7 +17,7 @@ const VALIDATOR_STORAGE_PREFIX: &str = "validator_NEW";
1717
const VALIDATOR_ADDRESS_RAW_HASH: &str = "address_raw_hash_NEW";
1818
const VALIDATOR_CONSENSUS_KEY_STORAGE_KEY: &str = "consensus_key_NEW";
1919
const VALIDATOR_STATE_STORAGE_KEY: &str = "state_NEW";
20-
const VALIDATOR_ELTAS_STORAGE_KEY: &str = "validator_deltas_NEW";
20+
const VALIDATOR_DELTAS_STORAGE_KEY: &str = "validator_deltas_NEW";
2121
const VALIDATOR_COMMISSION_RATE_STORAGE_KEY: &str = "commission_rate_NEW";
2222
const VALIDATOR_MAX_COMMISSION_CHANGE_STORAGE_KEY: &str =
2323
"max_commission_rate_change_NEW";
@@ -27,8 +27,6 @@ const UNBOND_STORAGE_KEY: &str = "unbond_NEW";
2727
const VALIDATOR_SET_STORAGE_KEY: &str = "validator_set_NEW";
2828
const TOTAL_DELTAS_STORAGE_KEY: &str = "total_deltas_NEW";
2929

30-
const ADDRESS: Address = address::POS;
31-
3230
/// Is the given key a PoS storage key?
3331
pub fn is_pos_key(key: &Key) -> bool {
3432
match &key.segments.get(0) {

proof_of_stake/src/types.rs

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub type ValidatorStates_NEW = crate::epoched_new::Epoched<
3737

3838
/// Epoched validator sets.
3939
pub type ValidatorSets_NEW = crate::epoched_new::Epoched<
40-
ValidatorSet_NEW,
40+
ValidatorSet,
4141
crate::epoched_new::OffsetPipelineLen,
4242
0
4343
>;
@@ -100,8 +100,6 @@ pub struct GenesisValidator {
100100
/// Maximum change in commission rate permitted per epoch
101101
pub max_commission_rate_change: Decimal,
102102
}
103-
pub type GenesisValidator_NEW =
104-
GenesisValidator<Address, token::Amount, key::common::PublicKey>;
105103

106104
/// An update of the active and inactive validator set.
107105
#[derive(Debug, Clone)]
@@ -141,26 +139,6 @@ pub struct BondId {
141139
pub validator: Address,
142140
}
143141

144-
/// ID of a bond and/or an unbond.
145-
#[derive(
146-
Debug,
147-
Clone,
148-
PartialEq,
149-
Eq,
150-
PartialOrd,
151-
Ord,
152-
Hash,
153-
BorshDeserialize,
154-
BorshSerialize,
155-
BorshSchema,
156-
)]
157-
pub struct BondId_NEW {
158-
/// (Un)bond's source address is the owner of the bonded tokens.
159-
pub source: Address,
160-
/// (Un)bond's validator address.
161-
pub validator: Address,
162-
}
163-
164142
/// Validator's address with its voting power.
165143
#[derive(
166144
Debug,
@@ -213,8 +191,6 @@ pub struct ValidatorSet {
213191
pub inactive: BTreeSet<WeightedValidator>,
214192
}
215193

216-
pub type ValidatorSet_NEW = ValidatorSet<Address>;
217-
218194
/// Validator's state.
219195
#[derive(
220196
Debug,

shared/src/ledger/pos/mod.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ use crate::ledger::storage::{self as ledger_storage, Storage, StorageHasher};
1414
use crate::types::address::{Address, InternalAddress};
1515
use crate::types::storage::Epoch;
1616

17+
pub use namada_core::types::key::common;
18+
pub use namada_core::types::token;
19+
pub use namada_core::ledger::storage_api;
20+
21+
1722
/// Address of the PoS account implemented as a native VP
1823
pub const ADDRESS: Address = Address::Internal(InternalAddress::PoS);
1924

@@ -64,3 +69,26 @@ pub fn init_genesis_storage_NEW<DB, H>(
6469
)
6570
.expect("Initialize PoS genesis storage");
6671
}
72+
73+
/// Alias for a PoS type with the same name with concrete type parameters
74+
pub type ValidatorConsensusKeys =
75+
namada_proof_of_stake::types::ValidatorConsensusKeys;
76+
77+
/// Alias for a PoS type with the same name with concrete type parameters
78+
pub type ValidatorDeltas =
79+
namada_proof_of_stake::types::ValidatorDeltas;
80+
81+
/// Alias for a PoS type with the same name with concrete type parameters
82+
pub type Bonds = namada_proof_of_stake::types::Bonds;
83+
84+
/// Alias for a PoS type with the same name with concrete type parameters
85+
pub type Unbonds = namada_proof_of_stake::types::Unbonds;
86+
87+
/// Alias for a PoS type with the same name with concrete type parameters
88+
pub type ValidatorSets = namada_proof_of_stake::types::ValidatorSets;
89+
90+
/// Alias for a PoS type with the same name with concrete type parameters
91+
pub type BondId = namada_proof_of_stake::types::BondId;
92+
93+
/// Alias for a PoS type with the same name with concrete type parameters
94+
pub type GenesisValidator = namada_proof_of_stake::types::GenesisValidator;

shared/src/types/key/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
//! Cryptographic keys
22
3-
pub use namada_core::types::key::*;
3+
pub use namada_core::types::key::*;

tests/src/native_vp/pos.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
101101
use namada::ledger::pos::namada_proof_of_stake::PosBase;
102102
use namada::proof_of_stake::storage::GenesisValidator;
103-
use namada::proof_of_stake::PosParams;
103+
use namada::proof_of_stake::parameters::PosParams;
104104
use namada::types::storage::Epoch;
105105

106106
use crate::tx::tx_host_env;

0 commit comments

Comments
 (0)