Skip to content

Commit

Permalink
Remove unused native VP address associated type
Browse files Browse the repository at this point in the history
  • Loading branch information
sug0 committed Jul 14, 2023
1 parent 1a5966b commit b4f4b8a
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 36 deletions.
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 @@ -14,7 +14,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 @@ -65,8 +65,6 @@ where
{
type Error = Error;

const ADDR: InternalAddress = InternalAddress::Ibc;

fn validate_tx(
&self,
tx_data: &Tx,
Expand Down Expand Up @@ -307,8 +305,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/native_vp/ethereum_bridge/bridge_pool_vp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,6 @@ where
{
type Error = Error;

const ADDR: InternalAddress = InternalAddress::EthBridgePool;

fn validate_tx(
&self,
tx: &Tx,
Expand Down
10 changes: 4 additions & 6 deletions shared/src/ledger/native_vp/ethereum_bridge/nut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use eyre::WrapErr;
use namada_core::ledger::storage as ledger_storage;
use namada_core::ledger::storage::traits::StorageHasher;
use namada_core::types::address::{Address, InternalAddress};
use namada_core::types::ethereum_events::EthAddress;
use namada_core::types::storage::Key;
use namada_core::types::token::Amount;

Expand Down Expand Up @@ -34,9 +33,6 @@ where
pub ctx: Ctx<'ctx, DB, H, CA>,
}

// TODO: this address is probably not correct. change it to something else
const VP_ADDR: InternalAddress = InternalAddress::Nut(EthAddress([0; 20]));

impl<'a, DB, H, CA> NativeVp for NonUsableTokens<'a, DB, H, CA>
where
DB: 'static + ledger_storage::DB + for<'iter> ledger_storage::DBIter<'iter>,
Expand All @@ -45,8 +41,6 @@ where
{
type Error = Error;

const ADDR: InternalAddress = VP_ADDR;

fn validate_tx(
&self,
_: &Tx,
Expand Down Expand Up @@ -132,6 +126,7 @@ mod test_nuts {
use namada_core::ledger::storage_api::StorageWrite;
use namada_core::types::address::testing::arb_non_internal_address;
use namada_core::types::ethereum_events::testing::DAI_ERC20_ETH_ADDRESS;
use namada_core::types::ethereum_events::EthAddress;
use namada_core::types::storage::TxIndex;
use namada_core::types::token::balance_key;
use namada_core::types::transaction::TxType;
Expand Down Expand Up @@ -188,6 +183,9 @@ mod test_nuts {
v
};

const VP_ADDR: InternalAddress =
InternalAddress::Nut(EthAddress([0; 20]));

let tx = Tx::new(TxType::Raw);
let ctx = Ctx::<_, _, WasmCacheRwAccess>::new(
&Address::Internal(VP_ADDR),
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 @@ -109,8 +109,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 @@ -22,7 +22,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 @@ -37,9 +37,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
2 changes: 0 additions & 2 deletions shared/src/ledger/native_vp/multitoken.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ where
{
type Error = Error;

const ADDR: InternalAddress = InternalAddress::Multitoken;

fn validate_tx(
&self,
_tx: &Tx,
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

0 comments on commit b4f4b8a

Please sign in to comment.