Skip to content

Commit

Permalink
gov/pgf: fix VP post move
Browse files Browse the repository at this point in the history
  • Loading branch information
tzemanovic committed Jun 17, 2024
1 parent f7ab8c2 commit 9cca1a5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
1 change: 1 addition & 0 deletions crates/governance/src/vp/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Governance VP

pub mod pgf;
pub mod utils;

use std::collections::BTreeSet;
Expand Down
36 changes: 18 additions & 18 deletions crates/governance/src/vp/pgf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> = std::result::Result<T, Error>;
Expand All @@ -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<Key>,
verifiers: &BTreeSet<Address>,
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 9cca1a5

Please sign in to comment.