Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ADDR associated type from native VPs #1725

Merged
merged 2 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Removed the associated type for an address from `trait NativeVp`.
([\#1725](https://github.com/anoma/namada/pull/1725))
6 changes: 2 additions & 4 deletions shared/src/ledger/ibc/vp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use namada_core::ledger::ibc::{
use namada_core::ledger::storage::write_log::StorageModification;
use namada_core::ledger::storage::{self as ledger_storage, StorageHasher};
use namada_core::proto::Tx;
use namada_core::types::address::{Address, InternalAddress};
use namada_core::types::address::Address;
use namada_core::types::storage::Key;
use namada_proof_of_stake::read_pos_params;
use thiserror::Error;
Expand Down Expand Up @@ -68,8 +68,6 @@ where
{
type Error = Error;

const ADDR: InternalAddress = InternalAddress::Ibc;

fn validate_tx(
&self,
tx_data: &Tx,
Expand Down Expand Up @@ -283,8 +281,8 @@ mod tests {
};
use super::{get_dummy_header, *};
use crate::core::ledger::storage::testing::TestWlStorage;
use crate::core::types::address::nam;
use crate::core::types::address::testing::established_address_1;
use crate::core::types::address::{nam, InternalAddress};
use crate::core::types::storage::Epoch;
use crate::ibc::applications::transfer::acknowledgement::TokenTransferAcknowledgement;
use crate::ibc::applications::transfer::coin::PrefixedCoin;
Expand Down
2 changes: 0 additions & 2 deletions shared/src/ledger/ibc/vp/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ where
{
type Error = Error;

const ADDR: InternalAddress = InternalAddress::IbcBurn;

fn validate_tx(
&self,
tx_data: &Tx,
Expand Down
2 changes: 0 additions & 2 deletions shared/src/ledger/native_vp/ethereum_bridge/bridge_pool_vp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,6 @@ where
{
type Error = Error;

const ADDR: InternalAddress = InternalAddress::EthBridgePool;

fn validate_tx(
&self,
tx: &Tx,
Expand Down
4 changes: 1 addition & 3 deletions shared/src/ledger/native_vp/ethereum_bridge/vp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use namada_core::ledger::eth_bridge::storage::{
};
use namada_core::ledger::storage::traits::StorageHasher;
use namada_core::ledger::{eth_bridge, storage as ledger_storage};
use namada_core::types::address::{Address, InternalAddress};
use namada_core::types::address::Address;
use namada_core::types::storage::Key;
use namada_core::types::token::{balance_key, Amount, Change};

Expand Down Expand Up @@ -110,8 +110,6 @@ where
{
type Error = Error;

const ADDR: InternalAddress = eth_bridge::INTERNAL_ADDRESS;

/// Validate that a wasm transaction is permitted to change keys under this
/// account.
///
Expand Down
4 changes: 1 addition & 3 deletions shared/src/ledger/native_vp/governance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::ledger::native_vp::{Ctx, NativeVp};
use crate::ledger::storage_api::StorageRead;
use crate::ledger::{native_vp, pos};
use crate::proto::Tx;
use crate::types::address::{Address, InternalAddress};
use crate::types::address::Address;
use crate::types::storage::{Epoch, Key};
use crate::types::token;
use crate::vm::WasmCacheAccess;
Expand Down Expand Up @@ -50,8 +50,6 @@ where
{
type Error = Error;

const ADDR: InternalAddress = InternalAddress::Governance;

fn validate_tx(
&self,
tx_data: &Tx,
Expand Down
5 changes: 1 addition & 4 deletions shared/src/ledger/native_vp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::ledger::storage;
use crate::ledger::storage::write_log::WriteLog;
use crate::ledger::storage::{Storage, StorageHasher};
use crate::proto::Tx;
use crate::types::address::{Address, InternalAddress};
use crate::types::address::Address;
use crate::types::hash::Hash;
use crate::types::storage::{
BlockHash, BlockHeight, Epoch, Header, Key, TxIndex,
Expand All @@ -36,9 +36,6 @@ pub type Error = storage_api::Error;

/// A native VP module should implement its validation logic using this trait.
pub trait NativeVp {
/// The address of this VP
const ADDR: InternalAddress;

/// Error type for the methods' results.
type Error: std::error::Error;

Expand Down
4 changes: 1 addition & 3 deletions shared/src/ledger/native_vp/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::collections::BTreeSet;

use namada_core::ledger::storage;
use namada_core::proto::Tx;
use namada_core::types::address::{Address, InternalAddress};
use namada_core::types::address::Address;
use namada_core::types::storage::Key;
use thiserror::Error;

Expand Down Expand Up @@ -41,8 +41,6 @@ where
{
type Error = Error;

const ADDR: InternalAddress = InternalAddress::Parameters;

fn validate_tx(
&self,
tx_data: &Tx,
Expand Down
4 changes: 1 addition & 3 deletions shared/src/ledger/native_vp/replay_protection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use std::collections::BTreeSet;

use namada_core::ledger::storage;
use namada_core::types::address::{Address, InternalAddress};
use namada_core::types::address::Address;
use namada_core::types::storage::Key;
use thiserror::Error;

Expand Down Expand Up @@ -40,8 +40,6 @@ where
{
type Error = Error;

const ADDR: InternalAddress = InternalAddress::ReplayProtection;

fn validate_tx(
&self,
_tx_data: &Tx,
Expand Down
4 changes: 1 addition & 3 deletions shared/src/ledger/native_vp/slash_fund.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::ledger::native_vp::{self, governance, Ctx, NativeVp};
use crate::ledger::storage::{self as ledger_storage, StorageHasher};
use crate::ledger::storage_api::StorageRead;
use crate::proto::Tx;
use crate::types::address::{Address, InternalAddress};
use crate::types::address::Address;
use crate::types::storage::Key;
use crate::types::token;
use crate::vm::WasmCacheAccess;
Expand Down Expand Up @@ -45,8 +45,6 @@ where
{
type Error = Error;

const ADDR: InternalAddress = InternalAddress::SlashFund;

fn validate_tx(
&self,
tx_data: &Tx,
Expand Down
4 changes: 1 addition & 3 deletions shared/src/ledger/pos/vp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ where
{
type Error = Error;

const ADDR: InternalAddress = InternalAddress::PoS;

fn validate_tx(
&self,
tx_data: &Tx,
Expand All @@ -101,7 +99,7 @@ where
// use validation::DataUpdate::{self, *};
// use validation::ValidatorUpdate::*;

let addr = Address::Internal(Self::ADDR);
let addr = Address::Internal(InternalAddress::PoS);
// let mut changes: Vec<DataUpdate> = vec![];
let _current_epoch = self.ctx.pre().get_block_epoch()?;

Expand Down
Loading