diff --git a/crates/core/src/chain.rs b/crates/core/src/chain.rs index 22774dff61e..419089d14d3 100644 --- a/crates/core/src/chain.rs +++ b/crates/core/src/chain.rs @@ -523,7 +523,7 @@ impl Epochs { #[derive( Clone, Debug, BorshSerialize, BorshDeserialize, BorshDeserializer, Default, )] -pub struct Header { +pub struct BlockHeader { /// Merkle root hash of block pub hash: Hash, /// Timestamp associated to block @@ -532,7 +532,7 @@ pub struct Header { pub next_validators_hash: Hash, } -impl Header { +impl BlockHeader { /// The number of bytes when this header is encoded pub fn encoded_len(&self) -> usize { self.serialize_to_vec().len() @@ -729,9 +729,9 @@ pub mod testing { } /// A dummy header used for testing - pub fn get_dummy_header() -> Header { + pub fn get_dummy_header() -> BlockHeader { use crate::time::DurationSecs; - Header { + BlockHeader { hash: Hash([0; 32]), #[allow( clippy::disallowed_methods, diff --git a/crates/ibc/src/actions.rs b/crates/ibc/src/actions.rs index 74e5cd2bd24..51400163a74 100644 --- a/crates/ibc/src/actions.rs +++ b/crates/ibc/src/actions.rs @@ -79,7 +79,7 @@ where fn get_block_header( &self, height: BlockHeight, - ) -> StorageResult> { + ) -> StorageResult> { StorageRead::get_block_header(self.state, height) } diff --git a/crates/ibc/src/vp/context.rs b/crates/ibc/src/vp/context.rs index 95c5698e214..e196b3ee9bb 100644 --- a/crates/ibc/src/vp/context.rs +++ b/crates/ibc/src/vp/context.rs @@ -5,7 +5,7 @@ use std::marker::PhantomData; use namada_core::address::Address; use namada_core::arith::checked; -use namada_core::chain::{BlockHeight, Epoch, Epochs, Header}; +use namada_core::chain::{BlockHeader, BlockHeight, Epoch, Epochs}; use namada_core::collections::{HashMap, HashSet}; use namada_core::storage::{Key, TxIndex}; use namada_events::Event; @@ -152,7 +152,10 @@ Self: 'iter; self.ctx.get_block_height() } - fn get_block_header(&self, height: BlockHeight) -> Result> { + fn get_block_header( + &self, + height: BlockHeight, + ) -> Result> { self.ctx.get_block_header(height) } @@ -339,7 +342,10 @@ where self.ctx.get_block_height() } - fn get_block_header(&self, height: BlockHeight) -> Result> { + fn get_block_header( + &self, + height: BlockHeight, + ) -> Result> { self.ctx.get_block_header(height) } diff --git a/crates/node/src/shell/finalize_block.rs b/crates/node/src/shell/finalize_block.rs index ae72f4cc05f..50eda190c83 100644 --- a/crates/node/src/shell/finalize_block.rs +++ b/crates/node/src/shell/finalize_block.rs @@ -20,7 +20,7 @@ use namada_sdk::state::write_log::StorageModification; use namada_sdk::state::{ ResultExt, StorageResult, StorageWrite, EPOCH_SWITCH_BLOCKS_DELAY, }; -use namada_sdk::storage::{BlockResults, Epoch, Header}; +use namada_sdk::storage::{BlockHeader, BlockResults, Epoch}; use namada_sdk::tx::data::protocol::ProtocolTxType; use namada_sdk::tx::data::VpStatusFlags; use namada_sdk::tx::event::{Batch, Code}; @@ -215,7 +215,7 @@ where /// validator changes, and evidence of byzantine behavior. Applies slashes /// if necessary. Returns a boolean indicating if a new epoch and the height /// of the new block. - fn update_state(&mut self, header: Header) -> (BlockHeight, bool) { + fn update_state(&mut self, header: BlockHeader) -> (BlockHeight, bool) { let height = self.state.in_mem().get_last_block_height().next_height(); self.state diff --git a/crates/node/src/shell/mod.rs b/crates/node/src/shell/mod.rs index 7330ebb692c..fa29d58052d 100644 --- a/crates/node/src/shell/mod.rs +++ b/crates/node/src/shell/mod.rs @@ -1462,7 +1462,7 @@ pub mod test_utils { use namada_sdk::proof_of_stake::storage::validator_consensus_key_handle; use namada_sdk::state::mockdb::MockDB; use namada_sdk::state::{LastBlock, StorageWrite}; - use namada_sdk::storage::{Epoch, Header}; + use namada_sdk::storage::{BlockHeader, Epoch}; use namada_sdk::tendermint::abci::types::VoteInfo; use tempfile::tempdir; use tokio::sync::mpsc::{Sender, UnboundedReceiver}; @@ -1904,7 +1904,7 @@ pub mod test_utils { impl Default for FinalizeBlock { fn default() -> Self { FinalizeBlock { - header: Header { + header: BlockHeader { hash: Hash([0; 32]), #[allow(clippy::disallowed_methods)] time: DateTimeUtc::now(), @@ -1965,7 +1965,7 @@ pub mod test_utils { byzantine_validators: Option>, ) { // Let the header time be always ahead of the next epoch min start time - let header = Header { + let header = BlockHeader { time: shell.state.in_mem().next_epoch_min_start_time.next_second(), ..Default::default() }; diff --git a/crates/node/src/shell/testing/node.rs b/crates/node/src/shell/testing/node.rs index 86af6d494d0..24e324441ae 100644 --- a/crates/node/src/shell/testing/node.rs +++ b/crates/node/src/shell/testing/node.rs @@ -11,7 +11,7 @@ use data_encoding::HEXUPPER; use itertools::Either; use lazy_static::lazy_static; use namada_sdk::address::Address; -use namada_sdk::chain::{BlockHeight, Epoch, Header}; +use namada_sdk::chain::{BlockHeader, BlockHeight, Epoch}; use namada_sdk::collections::HashMap; use namada_sdk::control_flow::time::Duration; use namada_sdk::eth_bridge::oracle::config::Config as OracleConfig; @@ -483,7 +483,7 @@ impl MockNode { }; // build finalize block abci request let req = FinalizeBlock { - header: Header { + header: BlockHeader { hash: Hash([0; 32]), #[allow(clippy::disallowed_methods)] time: DateTimeUtc::now(), @@ -602,7 +602,7 @@ impl MockNode { // process proposal succeeded, now run finalize block let req = FinalizeBlock { - header: Header { + header: BlockHeader { hash: Hash([0; 32]), #[allow(clippy::disallowed_methods)] time: DateTimeUtc::now(), diff --git a/crates/node/src/shims/abcipp_shim_types.rs b/crates/node/src/shims/abcipp_shim_types.rs index e6b847aa133..e7cde202213 100644 --- a/crates/node/src/shims/abcipp_shim_types.rs +++ b/crates/node/src/shims/abcipp_shim_types.rs @@ -170,7 +170,7 @@ pub mod shim { use bytes::Bytes; use namada_sdk::hash::Hash; - use namada_sdk::storage::Header; + use namada_sdk::storage::BlockHeader; use namada_sdk::tendermint::abci::types::CommitInfo; use namada_sdk::tendermint::account::Id; use namada_sdk::tendermint::block::Height; @@ -193,7 +193,7 @@ pub mod shim { #[derive(Debug, Clone)] pub struct FinalizeBlock { - pub header: Header, + pub header: BlockHeader, pub block_hash: Hash, pub byzantine_validators: Vec, pub txs: Vec, @@ -217,7 +217,7 @@ pub mod shim { fn from(req: tm_request::BeginBlock) -> FinalizeBlock { let header = req.header; FinalizeBlock { - header: Header { + header: BlockHeader { hash: Hash::try_from(header.app_hash.as_bytes()) .unwrap_or_default(), time: DateTimeUtc::try_from(header.time).unwrap(), diff --git a/crates/node/src/storage/rocksdb.rs b/crates/node/src/storage/rocksdb.rs index facb1f79f78..b7395e07c15 100644 --- a/crates/node/src/storage/rocksdb.rs +++ b/crates/node/src/storage/rocksdb.rs @@ -71,7 +71,7 @@ use namada_sdk::state::{ StoreType, DB, }; use namada_sdk::storage::{ - BlockHeight, DbColFam, Epoch, Header, Key, KeySeg, BLOCK_CF, DIFFS_CF, + BlockHeader, BlockHeight, DbColFam, Epoch, Key, KeySeg, BLOCK_CF, DIFFS_CF, REPLAY_PROTECTION_CF, ROLLBACK_CF, STATE_CF, SUBSPACE_CF, }; use namada_sdk::{decode, encode, ethereum_events}; @@ -1265,7 +1265,10 @@ impl DB for RocksDB { Ok(()) } - fn read_block_header(&self, height: BlockHeight) -> Result> { + fn read_block_header( + &self, + height: BlockHeight, + ) -> Result> { let block_cf = self.get_column_family(BLOCK_CF)?; let header_key = format!("{}/{BLOCK_HEADER_KEY_SEGMENT}", height.raw()); self.read_value(block_cf, header_key) diff --git a/crates/parameters/src/lib.rs b/crates/parameters/src/lib.rs index 5d644a7fbed..e5b68ac6ccd 100644 --- a/crates/parameters/src/lib.rs +++ b/crates/parameters/src/lib.rs @@ -629,7 +629,7 @@ where #[cfg(test)] mod tests { - use namada_core::chain::Header; + use namada_core::chain::BlockHeader; use namada_core::time::DateTimeUtc; use namada_storage::testing::TestStorage; @@ -721,7 +721,7 @@ mod tests { storage.set_mock_block_header( height, - Header { + BlockHeader { time: DateTimeUtc::from_unix_timestamp(timestamp).unwrap(), ..Default::default() }, @@ -744,7 +744,7 @@ mod tests { storage.set_mock_block_header( height, - Header { + BlockHeader { time: DateTimeUtc::from_unix_timestamp(timestamp).unwrap(), ..Default::default() }, @@ -777,7 +777,7 @@ mod tests { storage.set_mock_block_header( height, - Header { + BlockHeader { time: DateTimeUtc::from_unix_timestamp(timestamp).unwrap(), ..Default::default() }, @@ -801,7 +801,7 @@ mod tests { for height in 1u64..=2 { storage.set_mock_block_header( BlockHeight(height), - Header { + BlockHeader { time: DateTimeUtc::unix_epoch(), ..Default::default() }, @@ -824,7 +824,7 @@ mod tests { storage.set_mock_block_header( height, - Header { + BlockHeader { time: DateTimeUtc::from_unix_timestamp(timestamp).unwrap(), ..Default::default() }, diff --git a/crates/sdk/src/queries/shell.rs b/crates/sdk/src/queries/shell.rs index 001c155853e..52132f703c8 100644 --- a/crates/sdk/src/queries/shell.rs +++ b/crates/sdk/src/queries/shell.rs @@ -10,7 +10,7 @@ use masp_primitives::sapling::Node; use namada_account::{Account, AccountPublicKeysMap}; use namada_core::address::Address; use namada_core::arith::checked; -use namada_core::chain::{BlockHeight, Epoch, Header}; +use namada_core::chain::{BlockHeader, BlockHeight, Epoch}; use namada_core::dec::Dec; use namada_core::hash::Hash; use namada_core::hints; @@ -120,7 +120,7 @@ router! {SHELL, ( "ibc_packet" / [event_type: IbcEventType] / [source_port: PortId] / [source_channel: ChannelId] / [destination_port: PortId] / [destination_channel: ChannelId] / [sequence: Sequence]) -> Option = ibc_packet, // Get the block header associated with the requested height - ( "block_header" / [height: BlockHeight] ) -> Option
= block_header, + ( "block_header" / [height: BlockHeight] ) -> Option = block_header, // Return an estimate of the maximum time taken to decide a block ( "max_block_time" ) -> DurationSecs = max_block_time, @@ -161,7 +161,7 @@ where fn block_header( ctx: RequestCtx<'_, D, H, V, T>, height: BlockHeight, -) -> namada_storage::Result> +) -> namada_storage::Result> where D: 'static + DB + for<'iter> DBIter<'iter> + Sync, H: 'static + StorageHasher + Sync, diff --git a/crates/state/src/in_memory.rs b/crates/state/src/in_memory.rs index d8d58406d34..a2807d520d5 100644 --- a/crates/state/src/in_memory.rs +++ b/crates/state/src/in_memory.rs @@ -17,7 +17,7 @@ use namada_storage::conversion_state::ConversionState; use namada_storage::tx_queue::ExpiredTxsQueue; use namada_storage::types::CommitOnlyData; use namada_storage::{ - BlockHeight, BlockResults, Epoch, Epochs, EthEventsQueue, Header, Key, + BlockHeader, BlockHeight, BlockResults, Epoch, Epochs, EthEventsQueue, Key, KeySeg, StorageHasher, TxIndex, EPOCH_TYPE_LENGTH, }; @@ -39,7 +39,7 @@ where /// During `FinalizeBlock`, this is the header of the block that is /// going to be committed. After a block is committed, this is reset to /// `None` until the next `FinalizeBlock` phase is reached. - pub header: Option
, + pub header: Option, /// The most recently committed block, if any. pub last_block: Option, /// The epoch of the most recently committed block. If it is `Epoch(0)`, @@ -189,7 +189,7 @@ where /// Set the block header. /// The header is not in the Merkle tree as it's tracked by Tendermint. /// Hence, we don't update the tree when this is set. - pub fn set_header(&mut self, header: Header) -> Result<()> { + pub fn set_header(&mut self, header: BlockHeader) -> Result<()> { self.header = Some(header); Ok(()) } diff --git a/crates/state/src/lib.rs b/crates/state/src/lib.rs index 616573b0e23..f591dd13f34 100644 --- a/crates/state/src/lib.rs +++ b/crates/state/src/lib.rs @@ -33,7 +33,7 @@ pub use in_memory::{ use namada_core::address::Address; use namada_core::arith::{self, checked}; pub use namada_core::chain::{ - BlockHash, BlockHeight, Epoch, Epochs, Header, BLOCK_HASH_LENGTH, + BlockHash, BlockHeader, BlockHeight, Epoch, Epochs, BLOCK_HASH_LENGTH, BLOCK_HEIGHT_LENGTH, }; use namada_core::eth_bridge_pool::is_pending_transfer_key; @@ -167,7 +167,7 @@ pub trait StateRead: StorageRead + Debug { fn get_block_header( &self, height: Option, - ) -> Result<(Option
, u64)> { + ) -> Result<(Option, u64)> { match height { Some(h) if h == self.in_mem().get_block_height().0 => { let header = self.in_mem().header.clone(); @@ -313,7 +313,7 @@ macro_rules! impl_storage_read { fn get_block_header( &self, height: BlockHeight, - ) -> std::result::Result, namada_storage::Error> + ) -> std::result::Result, namada_storage::Error> { let (header, gas) = StateRead::get_block_header(self, Some(height)).into_storage_result()?; diff --git a/crates/state/src/wl_state.rs b/crates/state/src/wl_state.rs index df43a057df3..833f07226ca 100644 --- a/crates/state/src/wl_state.rs +++ b/crates/state/src/wl_state.rs @@ -4,7 +4,7 @@ use std::ops::{Deref, DerefMut}; use namada_core::address::Address; use namada_core::arith::checked; use namada_core::borsh::BorshSerializeExt; -use namada_core::chain::{ChainId, Header}; +use namada_core::chain::{BlockHeader, ChainId}; use namada_core::masp::MaspEpoch; use namada_core::parameters::{EpochDuration, Parameters}; use namada_core::storage; @@ -567,7 +567,7 @@ where #[cfg(any(test, feature = "testing", feature = "benches"))] { if self.in_mem.header.is_none() { - self.in_mem.header = Some(Header { + self.in_mem.header = Some(BlockHeader { hash: Hash::default(), #[allow(clippy::disallowed_methods)] time: DateTimeUtc::now(), diff --git a/crates/storage/src/db.rs b/crates/storage/src/db.rs index f69fa513867..ce8c36e644c 100644 --- a/crates/storage/src/db.rs +++ b/crates/storage/src/db.rs @@ -2,7 +2,7 @@ use std::fmt::Debug; use std::num::TryFromIntError; use namada_core::address::EstablishedAddressGen; -use namada_core::chain::{BlockHeight, Epoch, Epochs, Header}; +use namada_core::chain::{BlockHeader, BlockHeight, Epoch, Epochs}; use namada_core::hash::{Error as HashError, Hash}; use namada_core::storage::{BlockResults, DbColFam, EthEventsQueue, Key}; use namada_core::time::DateTimeUtc; @@ -85,7 +85,7 @@ pub struct BlockStateWrite<'a> { /// Merkle tree stores pub merkle_tree_stores: MerkleTreeStoresWrite<'a>, /// Header of the block - pub header: Option<&'a Header>, + pub header: Option<&'a BlockHeader>, /// Height of the block pub height: BlockHeight, /// Time of the block @@ -154,7 +154,10 @@ pub trait DB: Debug { ) -> Result<()>; /// Read the block header with the given height from the DB - fn read_block_header(&self, height: BlockHeight) -> Result>; + fn read_block_header( + &self, + height: BlockHeight, + ) -> Result>; /// Read the merkle tree stores with the given epoch. If a store_type is /// given, it reads only the specified tree. Otherwise, it reads all diff --git a/crates/storage/src/lib.rs b/crates/storage/src/lib.rs index 93ca831a737..07379c5dbdf 100644 --- a/crates/storage/src/lib.rs +++ b/crates/storage/src/lib.rs @@ -30,7 +30,9 @@ pub use db::{Error as DbError, Result as DbResult, *}; pub use error::{CustomError, Error, OptionExt, Result, ResultExt}; use namada_core::address::Address; use namada_core::borsh::{BorshDeserialize, BorshSerialize, BorshSerializeExt}; -pub use namada_core::chain::{BlockHash, BlockHeight, Epoch, Epochs, Header}; +pub use namada_core::chain::{ + BlockHash, BlockHeader, BlockHeight, Epoch, Epochs, +}; pub use namada_core::hash::StorageHasher; pub use namada_core::storage::*; @@ -97,7 +99,10 @@ pub trait StorageRead { fn get_block_height(&self) -> Result; /// Getting the block header. - fn get_block_header(&self, height: BlockHeight) -> Result>; + fn get_block_header( + &self, + height: BlockHeight, + ) -> Result>; /// Getting the block epoch. The epoch is that of the block to which the /// current transaction is being applied. @@ -324,7 +329,7 @@ pub mod testing { native_token: Address, conversion_state: ConversionState, merkle_tree_key_filter: fn(&Key) -> bool, - mock_block_headers: HashMap, + mock_block_headers: HashMap, } fn merklize_all_keys(_key: &Key) -> bool { @@ -353,7 +358,7 @@ pub mod testing { pub fn set_mock_block_header( &mut self, height: BlockHeight, - header: Header, + header: BlockHeader, ) { self.mock_block_headers.insert(height, header); } @@ -398,7 +403,7 @@ pub mod testing { fn get_block_header( &self, height: BlockHeight, - ) -> Result> { + ) -> Result> { Ok(self.mock_block_headers.get(&height).cloned()) } diff --git a/crates/storage/src/mockdb.rs b/crates/storage/src/mockdb.rs index 782b88701f3..00d38d662b4 100644 --- a/crates/storage/src/mockdb.rs +++ b/crates/storage/src/mockdb.rs @@ -8,7 +8,7 @@ use std::path::Path; use itertools::Either; use namada_core::borsh::{BorshDeserialize, BorshSerialize}; -use namada_core::chain::{BlockHeight, Epoch, Header}; +use namada_core::chain::{BlockHeader, BlockHeight, Epoch}; use namada_core::hash::Hash; use namada_core::storage::{DbColFam, Key, KeySeg, KEY_SEGMENT_SEPARATOR}; use namada_core::{decode, encode, ethereum_events}; @@ -281,7 +281,10 @@ impl DB for MockDB { Ok(()) } - fn read_block_header(&self, height: BlockHeight) -> Result> { + fn read_block_header( + &self, + height: BlockHeight, + ) -> Result> { let header_key = format!("{}/{BLOCK_HEADER_KEY_SEGMENT}", height.raw()); self.read_value(header_key) } diff --git a/crates/test_utils/src/ibc.rs b/crates/test_utils/src/ibc.rs index d9820ef2b10..50fc8c99a5b 100644 --- a/crates/test_utils/src/ibc.rs +++ b/crates/test_utils/src/ibc.rs @@ -11,7 +11,7 @@ use namada_core::ibc::clients::tendermint::types::{ use namada_core::ibc::core::client::types::Height; use namada_core::ibc::primitives::proto::Any; use namada_state::ics23_specs::ibc_proof_specs; -use namada_state::{Header, Sha256Hasher}; +use namada_state::{BlockHeader, Sha256Hasher}; use prost::Message; pub fn make_new_client_state_bytes(height: u64) -> Vec { @@ -41,7 +41,7 @@ pub fn make_new_client_state_bytes(height: u64) -> Vec { Any::from(client_state).encode_to_vec() } -pub fn make_new_consensus_state_bytes(header: Header) -> Vec { +pub fn make_new_consensus_state_bytes(header: BlockHeader) -> Vec { let consensus_state: TmConsensusState = TmConsensusStateType { timestamp: header .time diff --git a/crates/tx_prelude/src/lib.rs b/crates/tx_prelude/src/lib.rs index ff1c25a0c60..8b8d9d409a7 100644 --- a/crates/tx_prelude/src/lib.rs +++ b/crates/tx_prelude/src/lib.rs @@ -31,7 +31,7 @@ pub use namada_core::borsh::{ }; use namada_core::chain::CHAIN_ID_LENGTH; pub use namada_core::chain::{ - BlockHash, BlockHeight, Epoch, Header, BLOCK_HASH_LENGTH, + BlockHash, BlockHeader, BlockHeight, Epoch, BLOCK_HASH_LENGTH, }; pub use namada_core::ethereum_events::EthAddress; use namada_core::internal::HostEnvResult; @@ -182,11 +182,11 @@ impl StorageRead for Ctx { fn get_block_header( &self, height: BlockHeight, - ) -> Result, Error> { + ) -> Result, Error> { let read_result = unsafe { namada_tx_get_block_header(height.0) }; match read_from_buffer(read_result, namada_tx_result_buffer) { Some(value) => Ok(Some( - Header::try_from_slice(&value[..]) + BlockHeader::try_from_slice(&value[..]) .expect("The conversion shouldn't fail"), )), None => Ok(None), diff --git a/crates/vp/src/native_vp.rs b/crates/vp/src/native_vp.rs index 93ee12a23c9..6ab01f7817f 100644 --- a/crates/vp/src/native_vp.rs +++ b/crates/vp/src/native_vp.rs @@ -17,8 +17,8 @@ use namada_gas::{GasMetering, VpGasMeter}; use namada_state as state; use namada_state::prefix_iter::PrefixIterators; use namada_state::{ - BlockHeight, Epoch, Header, Key, ResultExt, StorageRead, StorageResult, - TxIndex, + BlockHeader, BlockHeight, Epoch, Key, ResultExt, StorageRead, + StorageResult, TxIndex, }; use namada_tx::{BatchedTxRef, Tx, TxCommitments}; pub use namada_vp_env::VpEnv; @@ -228,7 +228,7 @@ where fn get_block_header( &self, height: BlockHeight, - ) -> Result, state::StorageError> { + ) -> Result, state::StorageError> { self.ctx.get_block_header(height) } @@ -306,7 +306,7 @@ where fn get_block_header( &self, height: BlockHeight, - ) -> Result, state::StorageError> { + ) -> Result, state::StorageError> { self.ctx.get_block_header(height) } @@ -375,7 +375,7 @@ where fn get_block_header( &self, height: BlockHeight, - ) -> Result, state::StorageError> { + ) -> Result, state::StorageError> { vp_host_fns::get_block_header(self.gas_meter, self.state, height) .into_storage_result() } diff --git a/crates/vp/src/vp_host_fns.rs b/crates/vp/src/vp_host_fns.rs index 9634611c269..35cb8258255 100644 --- a/crates/vp/src/vp_host_fns.rs +++ b/crates/vp/src/vp_host_fns.rs @@ -6,7 +6,7 @@ use std::num::TryFromIntError; use namada_core::address::{Address, ESTABLISHED_ADDRESS_BYTES_LEN}; use namada_core::arith::{self, checked}; -use namada_core::chain::{BlockHeight, Epoch, Epochs, Header}; +use namada_core::chain::{BlockHeader, BlockHeight, Epoch, Epochs}; use namada_core::hash::{Hash, HASH_LENGTH}; use namada_core::storage::{Key, TxIndex, TX_INDEX_LENGTH}; use namada_events::{Event, EventTypeBuilder}; @@ -244,7 +244,7 @@ pub fn get_block_header( gas_meter: &RefCell, state: &S, height: BlockHeight, -) -> EnvResult> +) -> EnvResult> where S: StateRead + Debug, { diff --git a/crates/vp_env/src/lib.rs b/crates/vp_env/src/lib.rs index d750e8dbdf1..36cc0f1575b 100644 --- a/crates/vp_env/src/lib.rs +++ b/crates/vp_env/src/lib.rs @@ -22,7 +22,7 @@ pub mod collection_validation; use namada_core::address::Address; use namada_core::borsh::BorshDeserialize; -use namada_core::chain::{BlockHeight, Epoch, Epochs, Header}; +use namada_core::chain::{BlockHeader, BlockHeight, Epoch, Epochs}; use namada_core::hash::Hash; use namada_core::storage::{Key, TxIndex}; use namada_events::{Event, EventType}; @@ -77,7 +77,7 @@ where fn get_block_header( &self, height: BlockHeight, - ) -> Result, namada_storage::Error>; + ) -> Result, namada_storage::Error>; /// Getting the block epoch. The epoch is that of the block to which the /// current transaction is being applied. diff --git a/crates/vp_prelude/src/lib.rs b/crates/vp_prelude/src/lib.rs index 9d48f9827c0..8fd7e70e0ae 100644 --- a/crates/vp_prelude/src/lib.rs +++ b/crates/vp_prelude/src/lib.rs @@ -28,7 +28,9 @@ pub use namada_core::address::Address; pub use namada_core::borsh::{ BorshDeserialize, BorshSerialize, BorshSerializeExt, }; -use namada_core::chain::{BlockHeight, Epoch, Epochs, Header, CHAIN_ID_LENGTH}; +use namada_core::chain::{ + BlockHeader, BlockHeight, Epoch, Epochs, CHAIN_ID_LENGTH, +}; pub use namada_core::collections::HashSet; use namada_core::hash::{Hash, HASH_LENGTH}; use namada_core::internal::HostEnvResult; @@ -308,7 +310,7 @@ impl<'view> VpEnv<'view> for Ctx { fn get_block_header( &self, height: BlockHeight, - ) -> Result, StorageError> { + ) -> Result, StorageError> { // Both `CtxPreStorageRead` and `CtxPostStorageRead` have the same impl get_block_header(height) } @@ -463,7 +465,7 @@ impl StorageRead for CtxPreStorageRead<'_> { fn get_block_header( &self, height: BlockHeight, - ) -> Result, StorageError> { + ) -> Result, StorageError> { get_block_header(height) } @@ -536,7 +538,7 @@ impl StorageRead for CtxPostStorageRead<'_> { fn get_block_header( &self, height: BlockHeight, - ) -> Result, StorageError> { + ) -> Result, StorageError> { get_block_header(height) } @@ -596,11 +598,11 @@ fn get_block_height() -> Result { fn get_block_header( height: BlockHeight, -) -> Result, StorageError> { +) -> Result, StorageError> { let read_result = unsafe { namada_vp_get_block_header(height.0) }; match read_from_buffer(read_result, namada_vp_result_buffer) { Some(value) => Ok(Some( - Header::try_from_slice(&value[..]) + BlockHeader::try_from_slice(&value[..]) .expect("The conversion shouldn't fail"), )), None => Ok(None),