diff --git a/crates/governance/src/finalize_block.rs b/crates/governance/src/finalize_block.rs index da5d75295fa..b49033f091c 100644 --- a/crates/governance/src/finalize_block.rs +++ b/crates/governance/src/finalize_block.rs @@ -32,10 +32,8 @@ use crate::{storage, ProposalVote, ADDRESS as GOV_ADDRESS}; /// Apply governance updates for a block. On a new epoch, this will look for /// proposals to tally completed proposals and execute accepted proposals. #[allow(clippy::too_many_arguments)] -pub fn finalize_block( +pub fn finalize_block( state: &mut S, - vp_wasm_cache: &mut VpCache, - tx_wasm_cache: &mut TxCache, events: &mut impl EmitEvents, current_epoch: Epoch, is_new_epoch: bool, @@ -46,7 +44,7 @@ where S: StateRead + State, Token: token::Read + token::Write + token::Events, PoS: proof_of_stake::Read, - FnTx: FnMut(&Tx, &mut S, &mut VpCache, &mut TxCache) -> Result, + FnTx: FnMut(&Tx, &mut S) -> Result, FnIbcTransfer: Fn(&mut S, &Address, &Address, &PGFIbcTarget) -> Result<()>, { if is_new_epoch { @@ -55,34 +53,14 @@ where Token, PoS, FnTx, - VpCache, - TxCache, FnIbcTransfer, - >( - state, - vp_wasm_cache, - tx_wasm_cache, - events, - current_epoch, - dispatch_tx, - transfer_over_ibc, - )?; + >(state, events, current_epoch, dispatch_tx, transfer_over_ibc)?; } Ok(()) } -fn load_and_execute_governance_proposals< - S, - Token, - PoS, - FnTx, - VpCache, - TxCache, - FnIbcTransfer, ->( +fn load_and_execute_governance_proposals( state: &mut S, - vp_wasm_cache: &mut VpCache, - tx_wasm_cache: &mut TxCache, events: &mut impl EmitEvents, current_epoch: Epoch, dispatch_tx: FnTx, @@ -92,23 +70,13 @@ where S: StateRead + State, Token: token::Read + token::Write + token::Events, PoS: proof_of_stake::Read, - FnTx: FnMut(&Tx, &mut S, &mut VpCache, &mut TxCache) -> Result, + FnTx: FnMut(&Tx, &mut S) -> Result, FnIbcTransfer: Fn(&mut S, &Address, &Address, &PGFIbcTarget) -> Result<()>, { let proposal_ids = load_proposals(state, current_epoch)?; - execute_governance_proposals::< - S, - Token, - PoS, - FnTx, - VpCache, - TxCache, - FnIbcTransfer, - >( + execute_governance_proposals::( state, - vp_wasm_cache, - tx_wasm_cache, events, proposal_ids, dispatch_tx, @@ -116,18 +84,8 @@ where ) } -fn execute_governance_proposals< - S, - Token, - PoS, - FnTx, - VpCache, - TxCache, - FnIbcTransfer, ->( +fn execute_governance_proposals( state: &mut S, - vp_wasm_cache: &mut VpCache, - tx_wasm_cache: &mut TxCache, events: &mut impl EmitEvents, proposal_ids: BTreeSet, mut dispatch_tx: FnTx, @@ -137,7 +95,7 @@ where S: StateRead + State, Token: token::Read + token::Write + token::Events, PoS: proof_of_stake::Read, - FnTx: FnMut(&Tx, &mut S, &mut VpCache, &mut TxCache) -> Result, + FnTx: FnMut(&Tx, &mut S) -> Result, FnIbcTransfer: Fn(&mut S, &Address, &Address, &PGFIbcTarget) -> Result<()>, { for id in proposal_ids { @@ -187,8 +145,6 @@ where .unwrap_or_default(); let result = execute_default_proposal( state, - vp_wasm_cache, - tx_wasm_cache, id, proposal_code.clone(), &mut dispatch_tx, @@ -405,17 +361,15 @@ where }) } -fn execute_default_proposal( +fn execute_default_proposal( state: &mut S, - vp_wasm_cache: &mut VpCache, - tx_wasm_cache: &mut TxCache, id: u64, proposal_code: Vec, dispatch_tx: &mut FnTx, ) -> Result where S: StateRead + State, - FnTx: FnMut(&Tx, &mut S, &mut VpCache, &mut TxCache) -> Result, + FnTx: FnMut(&Tx, &mut S) -> Result, { let pending_execution_key = keys::get_proposal_execution_key(id); state.write(&pending_execution_key, ())?; @@ -425,7 +379,7 @@ where tx.set_data(Data::new(encode(&id))); tx.set_code(Code::new(proposal_code, None)); - let dispatch_result = dispatch_tx(&tx, state, vp_wasm_cache, tx_wasm_cache); + let dispatch_result = dispatch_tx(&tx, state); state .delete(&pending_execution_key) .expect("Should be able to delete the storage."); diff --git a/crates/node/src/shell/finalize_block.rs b/crates/node/src/shell/finalize_block.rs index 23c20ea543f..68e4ffe17ca 100644 --- a/crates/node/src/shell/finalize_block.rs +++ b/crates/node/src/shell/finalize_block.rs @@ -1139,22 +1139,20 @@ where D: DB + for<'iter> DBIter<'iter> + Sync, H: StorageHasher + Sync, { + let vp_wasm_cache = &mut shell.vp_wasm_cache; + let tx_wasm_cache = &mut shell.tx_wasm_cache; governance::finalize_block::< _, token::Store<_>, proof_of_stake::Store<_>, _, _, - _, - _, >( &mut shell.state, - &mut shell.vp_wasm_cache, - &mut shell.tx_wasm_cache, emit_events, current_epoch, is_new_epoch, - |tx, state, vp_wasm_cache, tx_wasm_cache| { + |tx, state| { let dispatch_result = protocol::dispatch_tx( tx, protocol::DispatchArgs::Raw {