Skip to content

Commit

Permalink
move core MembershipProof into merkle_tree crate
Browse files Browse the repository at this point in the history
  • Loading branch information
tzemanovic committed Dec 19, 2023
1 parent 13f396d commit 06955dc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 24 deletions.
22 changes: 0 additions & 22 deletions core/src/types/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ use arse_merkle_tree::InternalKey;
use borsh::{BorshDeserialize, BorshSchema, BorshSerialize};
use borsh_ext::BorshSerializeExt;
use data_encoding::{BASE32HEX_NOPAD, HEXUPPER};
use ics23::CommitmentProof;
use index_set::vec::VecIndexSet;
use serde::{Deserialize, Serialize};
use thiserror::Error;

use super::key::common;
use crate::bytes::ByteBuf;
use crate::hints;
use crate::ledger::eth_bridge::storage::bridge_pool::BridgePoolProof;
use crate::types::address::{self, Address};
use crate::types::ethereum_events::{GetEventNonce, TransfersToNamada, Uint};
use crate::types::hash::Hash;
Expand Down Expand Up @@ -498,26 +496,6 @@ impl From<TreeBytes> for Vec<u8> {
}
}

/// Type of membership proof from a merkle tree
pub enum MembershipProof {
/// ICS23 compliant membership proof
ICS23(CommitmentProof),
/// Bespoke membership proof for the Ethereum bridge pool
BridgePool(BridgePoolProof),
}

impl From<CommitmentProof> for MembershipProof {
fn from(proof: CommitmentProof) -> Self {
Self::ICS23(proof)
}
}

impl From<BridgePoolProof> for MembershipProof {
fn from(proof: BridgePoolProof) -> Self {
Self::BridgePool(proof)
}
}

impl Key {
/// Parses string and returns a key
pub fn parse(string: impl AsRef<str>) -> Result<Self> {
Expand Down
25 changes: 23 additions & 2 deletions merkle_tree/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use borsh::{BorshDeserialize, BorshSerialize};
use borsh_ext::BorshSerializeExt;
use ics23::commitment_proof::Proof as Ics23Proof;
use ics23::{CommitmentProof, ExistenceProof, NonExistenceProof};
use namada_core::ledger::eth_bridge::storage::bridge_pool::BridgePoolProof;
use thiserror::Error;

use super::traits::{StorageHasher, SubTreeRead, SubTreeWrite};
Expand All @@ -24,10 +25,30 @@ use crate::types::address::{Address, InternalAddress};
use crate::types::hash::Hash;
use crate::types::keccak::KeccakHash;
use crate::types::storage::{
self, DbKeySeg, Error as StorageError, Key, MembershipProof, StringKey,
TreeBytes, TreeKeyError, IBC_KEY_LIMIT,
self, DbKeySeg, Error as StorageError, Key, StringKey, TreeBytes,
TreeKeyError, IBC_KEY_LIMIT,
};

/// Type of membership proof from a merkle tree
pub enum MembershipProof {
/// ICS23 compliant membership proof
ICS23(CommitmentProof),
/// Bespoke membership proof for the Ethereum bridge pool
BridgePool(BridgePoolProof),
}

impl From<CommitmentProof> for MembershipProof {
fn from(proof: CommitmentProof) -> Self {
Self::ICS23(proof)
}
}

impl From<BridgePoolProof> for MembershipProof {
fn from(proof: BridgePoolProof) -> Self {
Self::BridgePool(proof)
}
}

#[allow(missing_docs)]
#[derive(Error, Debug)]
pub enum Error {
Expand Down

0 comments on commit 06955dc

Please sign in to comment.