Skip to content

Commit

Permalink
Merge branch 'origin/main'
Browse files Browse the repository at this point in the history
* origin/main:
  Namada 0.31.5
  wasm: update checksums
  changelog: add #2563
  refactor conversion of token amount into voting power
  refactor validator set update to consensus engine
  simplest fix
  test a validator that becomes consensus and gets new consensus key at same epoch (fails)
  • Loading branch information
Gianmarco Fraccaroli committed Feb 19, 2024
2 parents 2454bcb + c733be2 commit f8b094c
Show file tree
Hide file tree
Showing 32 changed files with 303 additions and 224 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- Fixed a bug in the communication of validator set updates to
CometBFT after a change of validator consensus key that occurs
at the same epoch as a validator entering the consensus set.
([\#2653](https://github.com/anoma/namada/pull/2653))
2 changes: 2 additions & 0 deletions .changelog/v0.31.5/summary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Namada 0.31.5 is a patch release that fixes consensus validator set update for CometBFT.

11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# CHANGELOG

## v0.31.5

Namada 0.31.5 is a patch release that fixes consensus validator set update for CometBFT.

### BUG FIXES

- Fixed a bug in the communication of validator set updates to
CometBFT after a change of validator consensus key that occurs
at the same epoch as a validator entering the consensus set.
([\#2653](https://github.com/anoma/namada/pull/2653))

## v0.31.4

Namada 0.31.4 is a patch release that fixes the result query of an active governance proposal.
Expand Down
62 changes: 31 additions & 31 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ keywords = ["blockchain", "privacy", "crypto", "protocol", "network"]
license = "GPL-3.0"
readme = "README.md"
repository = "https://github.com/anoma/namada"
version = "0.31.4"
version = "0.31.5"

[workspace.dependencies]
ark-bls12-381 = {version = "0.3"}
Expand Down
13 changes: 3 additions & 10 deletions crates/apps/src/lib/node/ledger/shell/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ use namada::ethereum_bridge::protocol::validation::validator_set_update::validat
use namada::ledger::events::log::EventLog;
use namada::ledger::events::Event;
use namada::ledger::gas::{Gas, TxGasMeter};
use namada::ledger::pos::into_tm_voting_power;
use namada::ledger::pos::namada_proof_of_stake::types::{
ConsensusValidator, ValidatorSetUpdate,
};
Expand Down Expand Up @@ -1294,7 +1293,7 @@ where
let validator_set_update_fn = if is_genesis {
namada_proof_of_stake::genesis_validator_set_tendermint
} else {
namada_proof_of_stake::validator_set_update::validator_set_update_tendermint
namada_proof_of_stake::validator_set_update::validator_set_update_comet
};

validator_set_update_fn(
Expand All @@ -1305,14 +1304,8 @@ where
let (consensus_key, power) = match update {
ValidatorSetUpdate::Consensus(ConsensusValidator {
consensus_key,
bonded_stake,
}) => {
let power: i64 = into_tm_voting_power(
pos_params.tm_votes_per_token,
bonded_stake,
);
(consensus_key, power)
}
bonded_stake: power,
}) => (consensus_key, power),
ValidatorSetUpdate::Deactivated(consensus_key) => {
// Any validators that have been dropped from the
// consensus set must have voting power set to 0 to
Expand Down
5 changes: 4 additions & 1 deletion crates/proof_of_stake/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ use namada_storage::collections::lazy_map::{self, Collectable, LazyMap};
use namada_storage::{StorageRead, StorageWrite};
pub use namada_trans_token as token;
pub use parameters::{OwnedPosParams, PosParams};
use types::into_tm_voting_power;

use crate::queries::{find_bonds, has_bonds};
use crate::rewards::{
Expand Down Expand Up @@ -1843,9 +1844,11 @@ where
let consensus_key = validator_consensus_key_handle(&address)
.get(storage, current_epoch, params)?
.unwrap();
let new_tm_voting_power =
into_tm_voting_power(params.tm_votes_per_token, new_stake);
let converted = f(ValidatorSetUpdate::Consensus(ConsensusValidator {
consensus_key,
bonded_stake: new_stake,
bonded_stake: new_tm_voting_power,
}));
Ok(converted)
})
Expand Down
4 changes: 2 additions & 2 deletions crates/proof_of_stake/src/tests/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use proptest::strategy::{Just, Strategy};
use crate::parameters::testing::arb_pos_params;
use crate::types::{GenesisValidator, ValidatorSetUpdate};
use crate::validator_set_update::{
copy_validator_sets_and_positions, validator_set_update_tendermint,
copy_validator_sets_and_positions, validator_set_update_comet,
};
use crate::{
compute_and_store_total_consensus_stake, OwnedPosParams, PosParams,
Expand Down Expand Up @@ -57,7 +57,7 @@ pub fn get_tendermint_set_updates(
// the start of a new one too and so we give it the predecessor of the
// current epoch here to actually get the update for the current epoch.
let epoch = Epoch(epoch - 1);
validator_set_update_tendermint(s, params, epoch, |update| update).unwrap()
validator_set_update_comet(s, params, epoch, |update| update).unwrap()
}

/// Advance to the next epoch. Returns the new epoch.
Expand Down
Loading

0 comments on commit f8b094c

Please sign in to comment.