From 9cca1a5d49444a50225c37f112cd554f501f516d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Mon, 17 Jun 2024 18:32:26 +0100 Subject: [PATCH] gov/pgf: fix VP post move --- crates/governance/src/vp/mod.rs | 1 + crates/governance/src/vp/pgf.rs | 36 ++++++++++++++++----------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/crates/governance/src/vp/mod.rs b/crates/governance/src/vp/mod.rs index 5120be26b45..06b37c56a56 100644 --- a/crates/governance/src/vp/mod.rs +++ b/crates/governance/src/vp/mod.rs @@ -1,5 +1,6 @@ //! Governance VP +pub mod pgf; pub mod utils; use std::collections::BTreeSet; diff --git a/crates/governance/src/vp/pgf.rs b/crates/governance/src/vp/pgf.rs index d7548c1cfb6..9ab436c24eb 100644 --- a/crates/governance/src/vp/pgf.rs +++ b/crates/governance/src/vp/pgf.rs @@ -3,18 +3,16 @@ use std::collections::BTreeSet; use namada_core::booleans::BoolResultUnitExt; -use namada_governance::pgf::storage::keys as pgf_storage; -use namada_governance::{is_proposal_accepted, pgf}; +use namada_core::storage::Key; use namada_state::StateRead; use namada_tx::action::{Action, PgfAction, Read}; use namada_tx::BatchedTxRef; +use namada_vp::native_vp::{self, Ctx, NativeVp, VpEvaluator}; use thiserror::Error; use crate::address::{Address, InternalAddress}; -use crate::ledger::native_vp; -use crate::ledger::native_vp::{Ctx, NativeVp}; -use crate::storage::Key; -use crate::vm::WasmCacheAccess; +use crate::pgf::storage::keys as pgf_storage; +use crate::{is_proposal_accepted, pgf}; /// for handling Pgf NativeVP errors pub type Result = std::result::Result; @@ -34,24 +32,25 @@ pub enum Error { } /// Pgf VP -pub struct PgfVp<'a, S, CA> +pub struct PgfVp<'a, S, CA, EVAL> where - S: StateRead, - CA: WasmCacheAccess, + S: 'static + StateRead, + EVAL: VpEvaluator<'a, S, CA, EVAL>, { /// Context to interact with the host structures. - pub ctx: Ctx<'a, S, CA>, + pub ctx: Ctx<'a, S, CA, EVAL>, } -impl<'a, S, CA> NativeVp for PgfVp<'a, S, CA> +impl<'a, S, CA, EVAL> NativeVp<'a> for PgfVp<'a, S, CA, EVAL> where - S: StateRead, - CA: 'static + WasmCacheAccess, + S: 'static + StateRead, + CA: 'static + Clone, + EVAL: 'static + VpEvaluator<'a, S, CA, EVAL>, { type Error = Error; fn validate_tx( - &self, + &'a self, batched_tx: &BatchedTxRef<'_>, keys_changed: &BTreeSet, verifiers: &BTreeSet
, @@ -208,14 +207,15 @@ where } } -impl<'a, S, CA> PgfVp<'a, S, CA> +impl<'a, S, CA, EVAL> PgfVp<'a, S, CA, EVAL> where - S: StateRead, - CA: 'static + WasmCacheAccess, + S: 'static + StateRead, + CA: 'static + Clone, + EVAL: 'static + VpEvaluator<'a, S, CA, EVAL>, { /// Validate a governance parameter pub fn is_valid_parameter_change( - &self, + &'a self, batched_tx: &BatchedTxRef<'_>, ) -> Result<()> { batched_tx.tx.data(batched_tx.cmt).map_or_else(