diff --git a/crates/governance/src/finalize_block.rs b/crates/governance/src/finalize_block.rs index e947e735e9e..da5d75295fa 100644 --- a/crates/governance/src/finalize_block.rs +++ b/crates/governance/src/finalize_block.rs @@ -1,8 +1,6 @@ //! Governance logic applied on an end of a block. -use std::borrow::Cow; use std::collections::BTreeSet; -use std::fmt::Display; use std::str::FromStr; use borsh::BorshDeserialize; @@ -43,7 +41,7 @@ pub fn finalize_block( is_new_epoch: bool, dispatch_tx: FnTx, transfer_over_ibc: FnIbcTransfer, -) -> Result> +) -> Result<()> where S: StateRead + State, Token: token::Read + token::Write + token::Events, @@ -52,7 +50,7 @@ where FnIbcTransfer: Fn(&mut S, &Address, &Address, &PGFIbcTarget) -> Result<()>, { if is_new_epoch { - let result = load_and_execute_governance_proposals::< + load_and_execute_governance_proposals::< S, Token, PoS, @@ -69,49 +67,8 @@ where dispatch_tx, transfer_over_ibc, )?; - if result.passed.is_empty() && result.rejected.is_empty() { - return Ok(None); - } - return Ok(Some(result)); } - Ok(None) -} - -/// Count of passed and rejected proposals. -#[derive(Default)] -pub struct ProposalsResult { - passed: Vec, - rejected: Vec, -} - -impl Display for ProposalsResult { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!( - f, - "{}{}", - if self.passed.is_empty() { - Cow::Owned(format!("Passed IDs: {}. ", fmt_ids(&self.passed))) - } else { - Cow::Borrowed("") - }, - if self.rejected.is_empty() { - Cow::Owned(format!( - "Rejected IDs: {}.", - fmt_ids(&self.rejected) - )) - } else { - Cow::Borrowed("") - } - ) - } -} - -fn fmt_ids(ids: &[u64]) -> String { - itertools::intersperse( - ids.iter().map(|s| Cow::Owned(s.to_string())), - Cow::Borrowed(", "), - ) - .collect::() + Ok(()) } fn load_and_execute_governance_proposals< @@ -130,7 +87,7 @@ fn load_and_execute_governance_proposals< current_epoch: Epoch, dispatch_tx: FnTx, transfer_over_ibc: FnIbcTransfer, -) -> Result +) -> Result<()> where S: StateRead + State, Token: token::Read + token::Write + token::Events, @@ -140,7 +97,7 @@ where { let proposal_ids = load_proposals(state, current_epoch)?; - let proposals_result = execute_governance_proposals::< + execute_governance_proposals::< S, Token, PoS, @@ -156,9 +113,7 @@ where proposal_ids, dispatch_tx, transfer_over_ibc, - )?; - - Ok(proposals_result) + ) } fn execute_governance_proposals< @@ -177,7 +132,7 @@ fn execute_governance_proposals< proposal_ids: BTreeSet, mut dispatch_tx: FnTx, mut transfer_over_ibc: FnIbcTransfer, -) -> Result +) -> Result<()> where S: StateRead + State, Token: token::Read + token::Write + token::Events, @@ -185,8 +140,6 @@ where FnTx: FnMut(&Tx, &mut S, &mut VpCache, &mut TxCache) -> Result, FnIbcTransfer: Fn(&mut S, &Address, &Address, &PGFIbcTarget) -> Result<()>, { - let mut proposals_result = ProposalsResult::default(); - for id in proposal_ids { let proposal_funds_key = keys::get_funds_key(id); let proposal_end_epoch_key = keys::get_voting_end_epoch_key(id); @@ -285,7 +238,6 @@ where } }; events.emit(proposal_event); - proposals_result.passed.push(id); // Take events that could have been emitted by PGF // over IBC, governance proposal execution, etc @@ -322,7 +274,6 @@ where matches!(proposal_type, ProposalType::DefaultWithWasm(_)), ); events.emit(proposal_event); - proposals_result.rejected.push(id); tracing::info!( "Governance proposal {} has been executed and rejected.", @@ -369,7 +320,7 @@ where } } - Ok(proposals_result) + Ok(()) } fn compute_proposal_votes( diff --git a/crates/governance/src/lib.rs b/crates/governance/src/lib.rs index 1c6624508e3..ec2ea7e5a02 100644 --- a/crates/governance/src/lib.rs +++ b/crates/governance/src/lib.rs @@ -35,7 +35,7 @@ pub mod storage; pub mod utils; pub mod vp; -pub use finalize_block::{finalize_block, ProposalsResult}; +pub use finalize_block::finalize_block; use namada_state::{StorageRead, StorageWrite}; pub use namada_systems::governance::*; use parameters::GovernanceParameters; diff --git a/crates/node/src/shell/finalize_block.rs b/crates/node/src/shell/finalize_block.rs index d4564a5344a..23c20ea543f 100644 --- a/crates/node/src/shell/finalize_block.rs +++ b/crates/node/src/shell/finalize_block.rs @@ -98,11 +98,7 @@ where // Sub-system updates: // - Governance - applied first in case a proposal changes any of the // other syb-systems - if let Some(proposals_result) = - gov_finalize_block(self, emit_events, current_epoch, new_epoch)? - { - tracing::info!("Governance proposals result: {proposals_result}"); - } + gov_finalize_block(self, emit_events, current_epoch, new_epoch)?; // - Token token_finalize_block(&mut self.state, emit_events, is_masp_new_epoch)?; // - PoS @@ -1138,7 +1134,7 @@ fn gov_finalize_block( emit_events: &mut Vec, current_epoch: Epoch, is_new_epoch: bool, -) -> Result> +) -> Result<()> where D: DB + for<'iter> DBIter<'iter> + Sync, H: StorageHasher + Sync,