diff --git a/crates/governance/src/lib.rs b/crates/governance/src/lib.rs index 33d93a53358..293515dc178 100644 --- a/crates/governance/src/lib.rs +++ b/crates/governance/src/lib.rs @@ -51,12 +51,7 @@ impl Read for Store where S: StorageRead, { - type Err = namada_state::StorageError; - - fn is_proposal_accepted( - storage: &S, - tx_data: &[u8], - ) -> Result { + fn is_proposal_accepted(storage: &S, tx_data: &[u8]) -> Result { storage::is_proposal_accepted(storage, tx_data) } } diff --git a/crates/governance/src/vp/mod.rs b/crates/governance/src/vp/mod.rs index 9ac7d068d70..d6c828ccec6 100644 --- a/crates/governance/src/vp/mod.rs +++ b/crates/governance/src/vp/mod.rs @@ -66,10 +66,7 @@ where S: StateRead, CA: 'static + Clone, EVAL: 'static + VpEvaluator<'ctx, S, CA, EVAL>, - PoS: proof_of_stake::Read< - CtxPreStorageRead<'view, 'ctx, S, CA, EVAL>, - Err = namada_state::StorageError, - >, + PoS: proof_of_stake::Read>, TokenKeys: token::Keys, { type Error = Error; @@ -220,10 +217,7 @@ where S: StateRead, CA: 'static + Clone, EVAL: 'static + VpEvaluator<'ctx, S, CA, EVAL>, - PoS: proof_of_stake::Read< - CtxPreStorageRead<'view, 'ctx, S, CA, EVAL>, - Err = namada_state::StorageError, - >, + PoS: proof_of_stake::Read>, TokenKeys: token::Keys, { /// Instantiate a Governance VP diff --git a/crates/ibc/src/vp/context.rs b/crates/ibc/src/vp/context.rs index 82fc8f1bcd1..38e57ff64ac 100644 --- a/crates/ibc/src/vp/context.rs +++ b/crates/ibc/src/vp/context.rs @@ -11,6 +11,7 @@ use namada_core::storage::{BlockHeight, Epoch, Epochs, Header, Key, TxIndex}; use namada_events::Event; use namada_gas::MEMORY_ACCESS_GAS_PER_BYTE; use namada_state::write_log::StorageModification; +pub use namada_state::StorageResult as Result; use namada_state::{ PrefixIter, StateRead, StorageError, StorageRead, StorageWrite, }; @@ -22,9 +23,6 @@ use crate::event::IbcEvent; use crate::storage::is_ibc_key; use crate::{IbcCommonContext, IbcStorageContext}; -/// Result of a storage API call. -pub type Result = std::result::Result; - /// Pseudo execution environment context for ibc native vp #[derive(Debug)] pub struct PseudoExecutionContext<'view, 'a, S, CA, EVAL, Token> @@ -214,10 +212,7 @@ where EVAL: 'static + VpEvaluator<'a, S, CA, EVAL>, CA: 'static + Clone, Token: token::Keys - + token::Write< - PseudoExecutionStorage<'view, 'a, S, CA, EVAL>, - Err = StorageError, - >, + + token::Write>, { type Storage = PseudoExecutionStorage<'view, 'a, S, CA, EVAL>; @@ -288,10 +283,7 @@ where CA: 'static + Clone, EVAL: 'static + VpEvaluator<'a, S, CA, EVAL>, Token: token::Keys - + token::Write< - PseudoExecutionStorage<'view, 'a, S, CA, EVAL>, - Err = StorageError, - >, + + token::Write>, { } diff --git a/crates/ibc/src/vp/mod.rs b/crates/ibc/src/vp/mod.rs index 6539a8ea57d..5a40e3437f4 100644 --- a/crates/ibc/src/vp/mod.rs +++ b/crates/ibc/src/vp/mod.rs @@ -18,7 +18,7 @@ use namada_core::collections::HashSet; use namada_core::storage::Key; use namada_gas::{IBC_ACTION_EXECUTE_GAS, IBC_ACTION_VALIDATE_GAS}; use namada_state::write_log::StorageModification; -use namada_state::{StateRead, StorageError}; +use namada_state::StateRead; use namada_systems::trans_token::{self as token, Amount}; use namada_systems::{governance, parameters, proof_of_stake}; use namada_tx::BatchedTxRef; @@ -83,24 +83,13 @@ where S: 'static + StateRead, EVAL: 'static + VpEvaluator<'ctx, S, CA, EVAL> + Debug, CA: 'static + Clone + Debug, - Gov: governance::Read< - CtxPreStorageRead<'view, 'ctx, S, CA, EVAL>, - Err = StorageError, - >, + Gov: governance::Read>, Params: parameters::Keys - + parameters::Read< - CtxPreStorageRead<'view, 'ctx, S, CA, EVAL>, - Err = StorageError, - >, + + parameters::Read>, Token: token::Keys - + token::Write< - PseudoExecutionStorage<'view, 'ctx, S, CA, EVAL>, - Err = StorageError, - > + Debug, - PoS: proof_of_stake::Read< - CtxPreStorageRead<'view, 'ctx, S, CA, EVAL>, - Err = StorageError, - >, + + token::Write> + + Debug, + PoS: proof_of_stake::Read>, { type Error = Error; @@ -150,19 +139,11 @@ where EVAL: 'static + VpEvaluator<'ctx, S, CA, EVAL> + Debug, CA: 'static + Clone + Debug, Params: parameters::Keys - + parameters::Read< - CtxPreStorageRead<'view, 'ctx, S, CA, EVAL>, - Err = StorageError, - >, + + parameters::Read>, Token: token::Keys - + token::Write< - PseudoExecutionStorage<'view, 'ctx, S, CA, EVAL>, - Err = StorageError, - > + Debug, - PoS: proof_of_stake::Read< - CtxPreStorageRead<'view, 'ctx, S, CA, EVAL>, - Err = StorageError, - >, + + token::Write> + + Debug, + PoS: proof_of_stake::Read>, { /// Instantiate IBC VP pub fn new(ctx: Ctx<'ctx, S, CA, EVAL>) -> Self { diff --git a/crates/parameters/src/lib.rs b/crates/parameters/src/lib.rs index 73af873a3c6..e9bac31d552 100644 --- a/crates/parameters/src/lib.rs +++ b/crates/parameters/src/lib.rs @@ -47,29 +47,23 @@ impl Read for Store where S: StorageRead, { - type Err = namada_storage::Error; - - fn read(storage: &S) -> Result { + fn read(storage: &S) -> Result { read(storage) } - fn masp_epoch_multiplier(storage: &S) -> Result { + fn masp_epoch_multiplier(storage: &S) -> Result { read_masp_epoch_multiplier_parameter(storage) } - fn epoch_duration_parameter( - storage: &S, - ) -> Result { + fn epoch_duration_parameter(storage: &S) -> Result { read_epoch_duration_parameter(storage) } - fn max_signatures_per_transaction( - storage: &S, - ) -> Result, Self::Err> { + fn max_signatures_per_transaction(storage: &S) -> Result> { max_signatures_per_transaction(storage) } - fn is_native_token_transferable(storage: &S) -> Result { + fn is_native_token_transferable(storage: &S) -> Result { storage::is_native_token_transferable(storage) } } @@ -78,10 +72,7 @@ impl Write for Store where S: StorageRead + StorageWrite, { - fn write( - storage: &mut S, - parameters: &Parameters, - ) -> Result<(), Self::Err> { + fn write(storage: &mut S, parameters: &Parameters) -> Result<()> { init_storage(parameters, storage) } } diff --git a/crates/parameters/src/vp.rs b/crates/parameters/src/vp.rs index 7b5b4e20821..26b7c5c8e57 100644 --- a/crates/parameters/src/vp.rs +++ b/crates/parameters/src/vp.rs @@ -6,7 +6,7 @@ use std::marker::PhantomData; use namada_core::address::Address; use namada_core::booleans::BoolResultUnitExt; use namada_core::storage::Key; -use namada_state::{StateRead, StorageError}; +use namada_state::StateRead; use namada_systems::governance; use namada_tx::BatchedTxRef; use namada_vp::native_vp::{ @@ -44,10 +44,7 @@ where S: 'static + StateRead, CA: 'static + Clone, EVAL: 'static + VpEvaluator<'ctx, S, CA, EVAL>, - Gov: governance::Read< - CtxPreStorageRead<'view, 'ctx, S, CA, EVAL>, - Err = StorageError, - >, + Gov: governance::Read>, { type Error = Error; @@ -92,10 +89,7 @@ where S: 'static + StateRead, CA: 'static + Clone, EVAL: 'static + VpEvaluator<'ctx, S, CA, EVAL>, - Gov: governance::Read< - CtxPreStorageRead<'ctx, 'ctx, S, CA, EVAL>, - Err = StorageError, - >, + Gov: governance::Read>, { /// Instantiate parameters VP pub fn new(ctx: Ctx<'ctx, S, CA, EVAL>) -> Self { diff --git a/crates/proof_of_stake/src/lib.rs b/crates/proof_of_stake/src/lib.rs index fe148c40dd4..fa48008ba29 100644 --- a/crates/proof_of_stake/src/lib.rs +++ b/crates/proof_of_stake/src/lib.rs @@ -117,9 +117,7 @@ impl Read for Store where S: StorageRead, { - type Err = namada_storage::Error; - - fn is_validator(storage: &S, address: &Address) -> Result { + fn is_validator(storage: &S, address: &Address) -> Result { is_validator(storage, address) } @@ -127,11 +125,11 @@ where storage: &S, address: &Address, epoch: Option, - ) -> Result { + ) -> Result { is_delegator(storage, address, epoch) } - fn pipeline_len(storage: &S) -> Result { + fn pipeline_len(storage: &S) -> Result { let params = storage::read_owned_pos_params(storage)?; Ok(params.pipeline_len) } @@ -156,7 +154,7 @@ pub fn init_genesis( storage: &mut S, params: &OwnedPosParams, current_epoch: Epoch, -) -> namada_storage::Result<()> +) -> Result<()> where S: StorageRead + StorageWrite, { @@ -182,7 +180,7 @@ pub fn copy_genesis_validator_sets( storage: &mut S, params: &OwnedPosParams, current_epoch: Epoch, -) -> namada_storage::Result<()> +) -> Result<()> where S: StorageRead + StorageWrite, { @@ -201,10 +199,7 @@ where } /// Check if the provided address is a validator address -pub fn is_validator( - storage: &S, - address: &Address, -) -> namada_storage::Result +pub fn is_validator(storage: &S, address: &Address) -> Result where S: StorageRead, { @@ -221,7 +216,7 @@ pub fn is_delegator( storage: &S, address: &Address, epoch: Option, -) -> namada_storage::Result +) -> Result where S: StorageRead, { @@ -266,7 +261,7 @@ pub fn bond_tokens( amount: token::Amount, current_epoch: Epoch, offset_opt: Option, -) -> namada_storage::Result<()> +) -> Result<()> where S: StorageRead + StorageWrite, { @@ -373,7 +368,7 @@ where fn compute_total_consensus_stake( storage: &S, epoch: Epoch, -) -> namada_storage::Result +) -> Result where S: StorageRead, { @@ -398,7 +393,7 @@ where pub fn compute_and_store_total_consensus_stake( storage: &mut S, epoch: Epoch, -) -> namada_storage::Result<()> +) -> Result<()> where S: StorageRead + StorageWrite, { @@ -423,7 +418,7 @@ pub fn unbond_tokens( amount: token::Amount, current_epoch: Epoch, is_redelegation: bool, -) -> namada_storage::Result +) -> Result where S: StorageRead + StorageWrite, { @@ -553,7 +548,7 @@ where }; Ok((epoch, value)) }) - .collect::>>()?; + .collect::>>()?; // `updatedBonded` // Remove bonds for all the full unbonds. @@ -860,7 +855,7 @@ fn fold_and_slash_redelegated_bonds( start_epoch: Epoch, list_slashes: &[Slash], slash_epoch_filter: impl Fn(Epoch) -> bool, -) -> namada_storage::Result +) -> Result where S: StorageRead, { @@ -871,7 +866,7 @@ where let validator_slashes: Vec = validator_slashes_handle(src_validator) .iter(storage)? - .collect::>>()?; + .collect::>>()?; // Merge the two lists of slashes let mut merged: Vec = validator_slashes .into_iter() @@ -918,12 +913,12 @@ fn find_bonds_to_remove( storage: &S, bonds_handle: &LazyMap, amount: token::Amount, -) -> namada_storage::Result +) -> Result where S: StorageRead, { #[allow(clippy::needless_collect)] - let bonds: Vec> = bonds_handle.iter(storage)?.collect(); + let bonds: Vec> = bonds_handle.iter(storage)?.collect(); let mut bonds_for_removal = BondsForRemovalRes::default(); let mut remaining = amount; @@ -962,7 +957,7 @@ fn compute_modified_redelegation( redelegated_bonds: &RedelegatedTokens, start_epoch: Epoch, amount_to_unbond: token::Amount, -) -> namada_storage::Result +) -> Result where S: StorageRead, { @@ -1003,7 +998,7 @@ where let (_, amount) = res?; Ok(amount) }) - .collect::>>()? + .collect::>>()? .into_iter(), ) .ok_or_err_msg("token amount overflow")?; @@ -1061,7 +1056,7 @@ fn update_redelegated_bonds( storage: &mut S, redelegated_bonds: &RedelegatedTokens, modified_redelegation: &ModifiedRedelegation, -) -> namada_storage::Result<()> +) -> Result<()> where S: StorageRead + StorageWrite, { @@ -1137,7 +1132,7 @@ fn compute_new_redelegated_unbonds( redelegated_bonds: &RedelegatedBondsOrUnbonds, epochs_to_remove: &BTreeSet, modified: &ModifiedRedelegation, -) -> namada_storage::Result +) -> Result where S: StorageRead + StorageWrite, { @@ -1259,7 +1254,7 @@ where Ok((start, rbonds)) } }) - .collect::>()?; + .collect::>()?; Ok(new_redelegated_unbonds) } @@ -1294,7 +1289,7 @@ pub struct BecomeValidator<'a> { pub fn become_validator( storage: &mut S, args: BecomeValidator<'_>, -) -> namada_storage::Result<()> +) -> Result<()> where S: StorageRead + StorageWrite, { @@ -1417,7 +1412,7 @@ pub fn change_consensus_key( validator: &Address, consensus_key: &common::PublicKey, current_epoch: Epoch, -) -> namada_storage::Result<()> +) -> Result<()> where S: StorageRead + StorageWrite, { @@ -1455,7 +1450,7 @@ pub fn withdraw_tokens( source: Option<&Address>, validator: &Address, current_epoch: Epoch, -) -> namada_storage::Result +) -> Result where S: StorageRead + StorageWrite, { @@ -1594,7 +1589,7 @@ pub fn change_validator_commission_rate( validator: &Address, new_rate: Dec, current_epoch: Epoch, -) -> namada_storage::Result<()> +) -> Result<()> where S: StorageRead + StorageWrite, { @@ -1655,7 +1650,7 @@ fn bond_amounts_for_query( params: &PosParams, bond_id: &BondId, epoch: Epoch, -) -> namada_storage::Result> +) -> Result> where S: StorageRead, { @@ -1773,7 +1768,7 @@ pub fn raw_bond_amount( storage: &S, bond_id: &BondId, epoch: Epoch, -) -> namada_storage::Result +) -> Result where S: StorageRead, { @@ -1790,7 +1785,7 @@ pub fn bond_amount( storage: &S, bond_id: &BondId, epoch: Epoch, -) -> namada_storage::Result +) -> Result where S: StorageRead, { @@ -1867,7 +1862,7 @@ pub fn bond_amounts_for_rewards( bond_id: &BondId, claim_start: Epoch, claim_end: Epoch, -) -> namada_storage::Result> +) -> Result> where S: StorageRead, { @@ -1972,7 +1967,7 @@ pub fn genesis_validator_set_tendermint( params: &PosParams, current_epoch: Epoch, mut f: impl FnMut(ValidatorSetUpdate) -> T, -) -> namada_storage::Result> +) -> Result> where S: StorageRead, { @@ -2007,7 +2002,7 @@ pub fn unjail_validator( storage: &mut S, validator: &Address, current_epoch: Epoch, -) -> namada_storage::Result<()> +) -> Result<()> where S: StorageRead + StorageWrite, { @@ -2075,7 +2070,7 @@ pub fn is_validator_frozen( validator: &Address, current_epoch: Epoch, params: &PosParams, -) -> namada_storage::Result +) -> Result where S: StorageRead, { @@ -2096,7 +2091,7 @@ pub fn get_total_consensus_stake( storage: &S, epoch: Epoch, params: &PosParams, -) -> namada_storage::Result +) -> Result where S: StorageRead, { @@ -2113,7 +2108,7 @@ pub fn redelegate_tokens( dest_validator: &Address, current_epoch: Epoch, amount: token::Amount, -) -> namada_storage::Result<()> +) -> Result<()> where S: StorageRead + StorageWrite, { @@ -2339,7 +2334,7 @@ pub fn deactivate_validator( storage: &mut S, validator: &Address, current_epoch: Epoch, -) -> namada_storage::Result<()> +) -> Result<()> where S: StorageRead + StorageWrite, { @@ -2420,7 +2415,7 @@ pub fn reactivate_validator( storage: &mut S, validator: &Address, current_epoch: Epoch, -) -> namada_storage::Result<()> +) -> Result<()> where S: StorageRead + StorageWrite, { @@ -2483,7 +2478,7 @@ where pub fn prune_liveness_data( storage: &mut S, current_epoch: Epoch, -) -> namada_storage::Result<()> +) -> Result<()> where S: StorageRead + StorageWrite, { @@ -2520,7 +2515,7 @@ pub fn record_liveness_data( votes_epoch: Epoch, votes_height: BlockHeight, pos_params: &PosParams, -) -> namada_storage::Result<()> +) -> Result<()> where S: StorageRead + StorageWrite, { @@ -2602,7 +2597,7 @@ pub fn jail_for_liveness( params: &PosParams, current_epoch: Epoch, jail_epoch: Epoch, -) -> namada_storage::Result<()> +) -> Result<()> where S: StorageRead + StorageWrite, { @@ -2672,7 +2667,7 @@ pub mod test_utils { params: &PosParams, validators: impl Iterator, current_epoch: namada_core::storage::Epoch, - ) -> namada_storage::Result<()> + ) -> Result<()> where S: StorageRead + StorageWrite, { @@ -2735,7 +2730,7 @@ pub mod test_utils { owned: OwnedPosParams, validators: impl Iterator + Clone, current_epoch: namada_core::storage::Epoch, - ) -> namada_storage::Result + ) -> Result where S: StorageRead + StorageWrite, { @@ -2828,7 +2823,7 @@ pub fn change_validator_metadata( name: Option, commission_rate: Option, current_epoch: Epoch, -) -> namada_storage::Result<()> +) -> Result<()> where S: StorageRead + StorageWrite, { @@ -2868,7 +2863,7 @@ pub fn claim_reward_tokens( source: Option<&Address>, validator: &Address, current_epoch: Epoch, -) -> namada_storage::Result +) -> Result where S: StorageRead + StorageWrite, { @@ -2905,7 +2900,7 @@ pub fn query_reward_tokens( source: Option<&Address>, validator: &Address, current_epoch: Epoch, -) -> namada_storage::Result +) -> Result where S: StorageRead, { @@ -2933,7 +2928,7 @@ pub fn jail_validator( validator: &Address, current_epoch: Epoch, validator_set_update_epoch: Epoch, -) -> namada_storage::Result<()> +) -> Result<()> where S: StorageRead + StorageWrite, { @@ -3029,7 +3024,7 @@ pub fn finalize_block( validator_set_update_epoch: Epoch, votes: Vec, byzantine_validators: Vec, -) -> namada_storage::Result<()> +) -> Result<()> where S: StorageWrite + StorageRead, { @@ -3136,7 +3131,7 @@ fn add_delegation_target( validator: &Address, epoch: Epoch, _current_epoch: Epoch, -) -> namada_storage::Result<()> +) -> Result<()> where S: StorageRead + StorageWrite, { @@ -3185,7 +3180,7 @@ fn remove_delegation_target( validator: &Address, epoch: Epoch, current_epoch: Epoch, -) -> namada_storage::Result<()> +) -> Result<()> where S: StorageRead + StorageWrite, { @@ -3211,7 +3206,7 @@ fn prune_old_delegations( params: &PosParams, delegations: &mut DelegationEpochs, current_epoch: Epoch, -) -> namada_storage::Result<()> { +) -> Result<()> { let delta = crate::epoched::OffsetMaxProposalPeriodOrSlashProcessingLenPlus::value( params, diff --git a/crates/proof_of_stake/src/vp.rs b/crates/proof_of_stake/src/vp.rs index 2c82ca8211e..869f733e18d 100644 --- a/crates/proof_of_stake/src/vp.rs +++ b/crates/proof_of_stake/src/vp.rs @@ -6,7 +6,7 @@ use std::marker::PhantomData; use namada_core::address::Address; use namada_core::booleans::BoolResultUnitExt; use namada_core::storage::Key; -use namada_state::{StateRead, StorageError}; +use namada_state::StateRead; use namada_systems::governance; use namada_tx::action::{ Action, Bond, ClaimRewards, PosAction, Read, Redelegation, Unbond, Withdraw, @@ -54,10 +54,7 @@ where S: StateRead, CA: 'static + Clone, EVAL: 'static + VpEvaluator<'ctx, S, CA, EVAL>, - Gov: governance::Read< - CtxPreStorageRead<'view, 'ctx, S, CA, EVAL>, - Err = StorageError, - >, + Gov: governance::Read>, { type Error = Error; diff --git a/crates/shielded_token/src/vp.rs b/crates/shielded_token/src/vp.rs index 72d504dd9c5..f4e87742052 100644 --- a/crates/shielded_token/src/vp.rs +++ b/crates/shielded_token/src/vp.rs @@ -22,9 +22,7 @@ use namada_core::masp::{encode_asset_type, MaspEpoch}; use namada_core::storage::Key; use namada_core::uint::I320; use namada_gas::GasMetering; -use namada_state::{ - ConversionState, OptionExt, ResultExt, StateRead, StorageError, -}; +use namada_state::{ConversionState, OptionExt, ResultExt, StateRead}; use namada_systems::trans_token::{Amount, MaspDigitPos}; use namada_systems::{governance, parameters, trans_token as token}; use namada_trans_token::read_denom; @@ -86,14 +84,8 @@ where S: 'static + StateRead, CA: 'static + Clone, EVAL: 'static + VpEvaluator<'ctx, S, CA, EVAL>, - Params: parameters::Read< - CtxPreStorageRead<'view, 'ctx, S, CA, EVAL>, - Err = StorageError, - >, - Gov: governance::Read< - CtxPreStorageRead<'view, 'ctx, S, CA, EVAL>, - Err = StorageError, - >, + Params: parameters::Read>, + Gov: governance::Read>, { /// Instantiate MASP VP pub fn new(ctx: Ctx<'ctx, S, CA, EVAL>) -> Self { @@ -853,14 +845,8 @@ where S: 'static + StateRead, CA: 'static + Clone, EVAL: 'static + VpEvaluator<'ctx, S, CA, EVAL>, - Params: parameters::Read< - CtxPreStorageRead<'view, 'ctx, S, CA, EVAL>, - Err = StorageError, - >, - Gov: governance::Read< - CtxPreStorageRead<'view, 'ctx, S, CA, EVAL>, - Err = StorageError, - >, + Params: parameters::Read>, + Gov: governance::Read>, { type Error = Error; diff --git a/crates/systems/src/governance.rs b/crates/systems/src/governance.rs index fb2d53970ab..b6857b0eb56 100644 --- a/crates/systems/src/governance.rs +++ b/crates/systems/src/governance.rs @@ -1,13 +1,9 @@ //! Governance abstract interfaces +pub use namada_storage::Result; + /// Abstract governance storage read interface pub trait Read { - /// Storage error - type Err; - /// Check if an accepted proposal is being executed - fn is_proposal_accepted( - storage: &S, - tx_data: &[u8], - ) -> Result; + fn is_proposal_accepted(storage: &S, tx_data: &[u8]) -> Result; } diff --git a/crates/systems/src/parameters.rs b/crates/systems/src/parameters.rs index 3f6d1136dc7..d95df343119 100644 --- a/crates/systems/src/parameters.rs +++ b/crates/systems/src/parameters.rs @@ -2,6 +2,7 @@ pub use namada_core::parameters::*; use namada_core::storage; +pub use namada_storage::Result; /// Abstract parameters storage keys interface pub trait Keys { @@ -11,33 +12,25 @@ pub trait Keys { /// Abstract parameters storage read interface pub trait Read { - /// Storage error - type Err; - /// Read all parameters - fn read(storage: &S) -> Result; + fn read(storage: &S) -> Result; /// Read MASP epoch multiplier - fn masp_epoch_multiplier(storage: &S) -> Result; + fn masp_epoch_multiplier(storage: &S) -> Result; /// Read the the epoch duration parameter from store - fn epoch_duration_parameter( - storage: &S, - ) -> Result; + fn epoch_duration_parameter(storage: &S) -> Result; /// Get the max signatures per transactio parameter - fn max_signatures_per_transaction( - storage: &S, - ) -> Result, Self::Err>; + fn max_signatures_per_transaction(storage: &S) -> Result>; /// Helper function to retrieve the `is_native_token_transferable` protocol /// parameter from storage - fn is_native_token_transferable(storage: &S) -> Result; + fn is_native_token_transferable(storage: &S) -> Result; } /// Abstract parameters storage write interface pub trait Write: Read { /// Write all parameters - fn write(storage: &mut S, parameters: &Parameters) - -> Result<(), Self::Err>; + fn write(storage: &mut S, parameters: &Parameters) -> Result<()>; } diff --git a/crates/systems/src/proof_of_stake.rs b/crates/systems/src/proof_of_stake.rs index 12e7af1f138..170bc498628 100644 --- a/crates/systems/src/proof_of_stake.rs +++ b/crates/systems/src/proof_of_stake.rs @@ -2,14 +2,12 @@ use namada_core::address::Address; use namada_core::storage; +pub use namada_storage::Result; /// Abstract PoS storage read interface pub trait Read { - /// Storage error - type Err; - /// Check if the provided address is a validator address - fn is_validator(storage: &S, address: &Address) -> Result; + fn is_validator(storage: &S, address: &Address) -> Result; /// Check if the provided address is a delegator address, optionally at a /// particular epoch. Returns `false` if the address is a validator. @@ -17,8 +15,8 @@ pub trait Read { storage: &S, address: &Address, epoch: Option, - ) -> Result; + ) -> Result; /// Read PoS pipeline length parameter - fn pipeline_len(storage: &S) -> Result; + fn pipeline_len(storage: &S) -> Result; } diff --git a/crates/systems/src/trans_token.rs b/crates/systems/src/trans_token.rs index 6eac8a19763..3399809a198 100644 --- a/crates/systems/src/trans_token.rs +++ b/crates/systems/src/trans_token.rs @@ -3,6 +3,7 @@ use namada_core::address::Address; use namada_core::storage; pub use namada_core::token::*; +pub use namada_storage::Result; /// Abstract token keys interface pub trait Keys { @@ -25,10 +26,7 @@ pub trait Keys { } /// Abstract token storage read interface -pub trait Read { - /// Storage error - type Err; -} +pub trait Read {} /// Abstract token storage write interface pub trait Write: Read { @@ -41,7 +39,7 @@ pub trait Write: Read { src: &Address, dest: &Address, amount: Amount, - ) -> Result<(), Self::Err>; + ) -> Result<()>; /// Burn a specified amount of tokens from some address. If the burn amount /// is larger than the total balance of the given address, then the @@ -52,7 +50,7 @@ pub trait Write: Read { token: &Address, source: &Address, amount: Amount, - ) -> Result<(), Self::Err>; + ) -> Result<()>; /// Credit tokens to an account, to be used only by protocol. In /// transactions, this would get rejected by the default `vp_token`. @@ -61,5 +59,5 @@ pub trait Write: Read { token: &Address, dest: &Address, amount: Amount, - ) -> Result<(), Self::Err>; + ) -> Result<()>; } diff --git a/crates/token/src/lib.rs b/crates/token/src/lib.rs index 289f4f4708c..47e3a5115c1 100644 --- a/crates/token/src/lib.rs +++ b/crates/token/src/lib.rs @@ -43,7 +43,7 @@ pub mod storage_key { use namada_core::address::Address; use namada_events::EmitEvents; -use namada_storage::{Result, StorageRead, StorageWrite}; +use namada_storage::{StorageRead, StorageWrite}; /// Initialize parameters for the token in storage during the genesis block. pub fn write_params( diff --git a/crates/trans_token/src/lib.rs b/crates/trans_token/src/lib.rs index da7ccb9c52a..50e37b1a55c 100644 --- a/crates/trans_token/src/lib.rs +++ b/crates/trans_token/src/lib.rs @@ -59,12 +59,7 @@ impl Keys for Store { } } -impl Read for Store -where - S: StorageRead, -{ - type Err = namada_storage::Error; -} +impl Read for Store where S: StorageRead {} impl Write for Store where @@ -76,7 +71,7 @@ where src: &Address, dest: &Address, amount: Amount, - ) -> Result<(), Self::Err> { + ) -> Result<()> { storage::transfer(storage, token, src, dest, amount) } @@ -85,7 +80,7 @@ where token: &Address, source: &Address, amount: Amount, - ) -> Result<(), Self::Err> { + ) -> Result<()> { storage::burn_tokens(storage, token, source, amount) } @@ -94,7 +89,7 @@ where token: &Address, dest: &Address, amount: Amount, - ) -> Result<(), Self::Err> { + ) -> Result<()> { storage::credit_tokens(storage, token, dest, amount) } } diff --git a/crates/trans_token/src/vp.rs b/crates/trans_token/src/vp.rs index cd5b5d39318..fc9739cb3dd 100644 --- a/crates/trans_token/src/vp.rs +++ b/crates/trans_token/src/vp.rs @@ -8,7 +8,7 @@ use namada_core::booleans::BoolResultUnitExt; use namada_core::collections::HashMap; use namada_core::storage::{Key, KeySeg}; use namada_core::token::Amount; -use namada_state::{StateRead, StorageError}; +use namada_state::StateRead; use namada_storage::StorageRead; use namada_systems::{governance, parameters}; use namada_tx::action::{ @@ -63,14 +63,8 @@ where S: 'static + StateRead, CA: 'static + Clone, EVAL: 'static + VpEvaluator<'ctx, S, CA, EVAL>, - Params: parameters::Read< - CtxPreStorageRead<'view, 'ctx, S, CA, EVAL>, - Err = StorageError, - >, - Gov: governance::Read< - CtxPreStorageRead<'view, 'ctx, S, CA, EVAL>, - Err = StorageError, - >, + Params: parameters::Read>, + Gov: governance::Read>, { type Error = Error; @@ -300,14 +294,8 @@ where S: 'static + StateRead, CA: 'static + Clone, EVAL: 'static + VpEvaluator<'ctx, S, CA, EVAL>, - Params: parameters::Read< - CtxPreStorageRead<'view, 'ctx, S, CA, EVAL>, - Err = StorageError, - >, - Gov: governance::Read< - CtxPreStorageRead<'view, 'ctx, S, CA, EVAL>, - Err = StorageError, - >, + Params: parameters::Read>, + Gov: governance::Read>, { /// Instantiate token VP pub fn new(ctx: Ctx<'ctx, S, CA, EVAL>) -> Self {