diff --git a/Cargo.lock b/Cargo.lock index 4824765a..fdf3ef78 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1985,7 +1985,6 @@ dependencies = [ "cosmwasm-std", "ethereum-light-client", "ethereum-types 0.1.0", - "ethereum-utils", "hex", "ibc-proto 0.51.1 (registry+https://github.com/rust-lang/crates.io-index)", "prost", @@ -2503,7 +2502,6 @@ dependencies = [ "alloy-trie", "ethereum-trie-db", "ethereum-types 0.1.0", - "ethereum-utils", "hex", "milagro_bls", "schemars", @@ -2519,7 +2517,6 @@ name = "ethereum-trie-db" version = "0.1.0" dependencies = [ "alloy-primitives 0.8.15", - "ethereum-utils", "hash-db", "hash256-std-hasher", "hex", @@ -2561,10 +2558,6 @@ dependencies = [ "uint 0.9.5", ] -[[package]] -name = "ethereum-utils" -version = "0.1.0" - [[package]] name = "ethereum_serde_utils" version = "0.7.0" diff --git a/Cargo.toml b/Cargo.toml index 60860c12..4379c282 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,13 @@ [workspace] members = [ - "packages/*", + "packages/ethereum/ethereum-light-client", + "packages/ethereum/ethereum-trie-db", + "packages/ethereum/ethereum-types", + "packages/ethereum/tree_hash", + "packages/solidity", + "packages/relayer-lib", + "packages/sp1-ics07-tendermint-prover", + "packages/sp1-ics07-tendermint-utils", "programs/relayer", "programs/operator", @@ -23,11 +30,10 @@ sp1-ics07-tendermint-prover = { path = "packages/sp1-ics07-tendermint-pro sp1-ics07-tendermint-utils = { path = "packages/sp1-ics07-tendermint-utils", default-features = false } sp1-ics07-tendermint-update-client = { path = "programs/sp1-programs/update-client", default-features = false } sp1-ics07-tendermint-membership = { path = "programs/sp1-programs/membership", default-features = false } -ethereum-trie-db = { path = "packages/ethereum-trie-db", default-features = false } -ethereum-light-client = { path = "packages/ethereum-light-client", default-features = false } -ethereum-types = { path = "packages/ethereum-types", default-features = false } -ethereum-utils = { path = "packages/ethereum-utils", default-features = false } -tree_hash = { path = "packages/tree_hash", default-features = false } +ethereum-trie-db = { path = "packages/ethereum/ethereum-trie-db", default-features = false } +ethereum-light-client = { path = "packages/ethereum/ethereum-light-client", default-features = false } +ethereum-types = { path = "packages/ethereum/ethereum-types", default-features = false } +tree_hash = { path = "packages/ethereum/tree_hash", default-features = false } serde = { version = "1.0", default-features = false } serde_json = { version = "1.0", default-features = false } diff --git a/packages/ethereum-utils/Cargo.toml b/packages/ethereum-utils/Cargo.toml deleted file mode 100644 index 34e81c4c..000000000 --- a/packages/ethereum-utils/Cargo.toml +++ /dev/null @@ -1,7 +0,0 @@ -[package] -name = "ethereum-utils" -version = { workspace = true } -edition = { workspace = true } -repository = { workspace = true } - -[dependencies] diff --git a/packages/ethereum-utils/README.md b/packages/ethereum-utils/README.md deleted file mode 100644 index 5050b951..000000000 --- a/packages/ethereum-utils/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Utils - -Utils package with generic rust utilities diff --git a/packages/ethereum-utils/src/lib.rs b/packages/ethereum-utils/src/lib.rs deleted file mode 100644 index cc26879c..000000000 --- a/packages/ethereum-utils/src/lib.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! A collection of utilities for Rust projects. - -#![doc = include_str!("../README.md")] -#![deny( - clippy::nursery, - clippy::pedantic, - warnings, - missing_docs, - unused_crate_dependencies -)] - -/// Ensure that a condition is true, otherwise return an error. -#[macro_export] -macro_rules! ensure { - ($cond:expr, $err:expr) => { - if !$cond { - return Err($err); - } - }; -} diff --git a/packages/ethereum-light-client/Cargo.toml b/packages/ethereum/ethereum-light-client/Cargo.toml similarity index 95% rename from packages/ethereum-light-client/Cargo.toml rename to packages/ethereum/ethereum-light-client/Cargo.toml index 980b91ee..35e9a95f 100644 --- a/packages/ethereum-light-client/Cargo.toml +++ b/packages/ethereum/ethereum-light-client/Cargo.toml @@ -13,7 +13,6 @@ path = "src/bin/generate_json_schema.rs" [dependencies] ethereum-trie-db = { workspace = true } -ethereum-utils = { workspace = true } ethereum-types = { workspace = true } alloy-primitives = { workspace = true, features = ["serde", "hex-compat"] } diff --git a/packages/ethereum-light-client/README.md b/packages/ethereum/ethereum-light-client/README.md similarity index 100% rename from packages/ethereum-light-client/README.md rename to packages/ethereum/ethereum-light-client/README.md diff --git a/packages/ethereum-light-client/src/bin/generate_json_schema.rs b/packages/ethereum/ethereum-light-client/src/bin/generate_json_schema.rs similarity index 100% rename from packages/ethereum-light-client/src/bin/generate_json_schema.rs rename to packages/ethereum/ethereum-light-client/src/bin/generate_json_schema.rs diff --git a/packages/ethereum-light-client/src/client_state.rs b/packages/ethereum/ethereum-light-client/src/client_state.rs similarity index 100% rename from packages/ethereum-light-client/src/client_state.rs rename to packages/ethereum/ethereum-light-client/src/client_state.rs diff --git a/packages/ethereum-light-client/src/consensus_state.rs b/packages/ethereum/ethereum-light-client/src/consensus_state.rs similarity index 100% rename from packages/ethereum-light-client/src/consensus_state.rs rename to packages/ethereum/ethereum-light-client/src/consensus_state.rs diff --git a/packages/ethereum-light-client/src/error.rs b/packages/ethereum/ethereum-light-client/src/error.rs similarity index 99% rename from packages/ethereum-light-client/src/error.rs rename to packages/ethereum/ethereum-light-client/src/error.rs index 6b3b1c46..f5018e89 100644 --- a/packages/ethereum-light-client/src/error.rs +++ b/packages/ethereum/ethereum-light-client/src/error.rs @@ -25,7 +25,7 @@ pub enum EthereumIBCError { VerifyStorageProof(String), #[error("insufficient number of sync committee participants ({0})")] - InsufficientSyncCommitteeParticipants(usize), + InsufficientSyncCommitteeParticipants(u64), #[error("update header contains deneb specific information")] MustBeDeneb, diff --git a/packages/ethereum-light-client/src/header.rs b/packages/ethereum/ethereum-light-client/src/header.rs similarity index 100% rename from packages/ethereum-light-client/src/header.rs rename to packages/ethereum/ethereum-light-client/src/header.rs diff --git a/packages/ethereum-light-client/src/lib.rs b/packages/ethereum/ethereum-light-client/src/lib.rs similarity index 56% rename from packages/ethereum-light-client/src/lib.rs rename to packages/ethereum/ethereum-light-client/src/lib.rs index 02149316..242a92e8 100644 --- a/packages/ethereum-light-client/src/lib.rs +++ b/packages/ethereum/ethereum-light-client/src/lib.rs @@ -7,6 +7,16 @@ unused_crate_dependencies )] +/// Ensure that a condition is true, otherwise return an error. +/// This macro is used for precondition checks in the light client logic for readability. +macro_rules! ensure { + ($cond:expr, $err:expr) => { + if !$cond { + return Err($err); + } + }; +} + pub mod client_state; pub mod consensus_state; pub mod error; diff --git a/packages/ethereum-light-client/src/membership.rs b/packages/ethereum/ethereum-light-client/src/membership.rs similarity index 100% rename from packages/ethereum-light-client/src/membership.rs rename to packages/ethereum/ethereum-light-client/src/membership.rs diff --git a/packages/ethereum-light-client/src/test_utils/bls_verifier.rs b/packages/ethereum/ethereum-light-client/src/test_utils/bls_verifier.rs similarity index 100% rename from packages/ethereum-light-client/src/test_utils/bls_verifier.rs rename to packages/ethereum/ethereum-light-client/src/test_utils/bls_verifier.rs diff --git a/packages/ethereum-light-client/src/test_utils/fixtures.rs b/packages/ethereum/ethereum-light-client/src/test_utils/fixtures.rs similarity index 100% rename from packages/ethereum-light-client/src/test_utils/fixtures.rs rename to packages/ethereum/ethereum-light-client/src/test_utils/fixtures.rs diff --git a/packages/ethereum-light-client/src/test_utils/fixtures/TestICS20TransferERC20TokenfromEthereumToCosmosAndBack_Groth16.json b/packages/ethereum/ethereum-light-client/src/test_utils/fixtures/TestICS20TransferERC20TokenfromEthereumToCosmosAndBack_Groth16.json similarity index 100% rename from packages/ethereum-light-client/src/test_utils/fixtures/TestICS20TransferERC20TokenfromEthereumToCosmosAndBack_Groth16.json rename to packages/ethereum/ethereum-light-client/src/test_utils/fixtures/TestICS20TransferERC20TokenfromEthereumToCosmosAndBack_Groth16.json diff --git a/packages/ethereum-light-client/src/test_utils/fixtures/TestICS20TransferNativeCosmosCoinsToEthereumAndBack_Groth16.json b/packages/ethereum/ethereum-light-client/src/test_utils/fixtures/TestICS20TransferNativeCosmosCoinsToEthereumAndBack_Groth16.json similarity index 100% rename from packages/ethereum-light-client/src/test_utils/fixtures/TestICS20TransferNativeCosmosCoinsToEthereumAndBack_Groth16.json rename to packages/ethereum/ethereum-light-client/src/test_utils/fixtures/TestICS20TransferNativeCosmosCoinsToEthereumAndBack_Groth16.json diff --git a/packages/ethereum-light-client/src/test_utils/fixtures/TestICS20TransferTimeoutFromEthereumToCosmosChain_Groth16.json b/packages/ethereum/ethereum-light-client/src/test_utils/fixtures/TestICS20TransferTimeoutFromEthereumToCosmosChain_Groth16.json similarity index 100% rename from packages/ethereum-light-client/src/test_utils/fixtures/TestICS20TransferTimeoutFromEthereumToCosmosChain_Groth16.json rename to packages/ethereum/ethereum-light-client/src/test_utils/fixtures/TestICS20TransferTimeoutFromEthereumToCosmosChain_Groth16.json diff --git a/packages/ethereum-light-client/src/test_utils/mod.rs b/packages/ethereum/ethereum-light-client/src/test_utils/mod.rs similarity index 100% rename from packages/ethereum-light-client/src/test_utils/mod.rs rename to packages/ethereum/ethereum-light-client/src/test_utils/mod.rs diff --git a/packages/ethereum-light-client/src/trie.rs b/packages/ethereum/ethereum-light-client/src/trie.rs similarity index 100% rename from packages/ethereum-light-client/src/trie.rs rename to packages/ethereum/ethereum-light-client/src/trie.rs diff --git a/packages/ethereum-light-client/src/update.rs b/packages/ethereum/ethereum-light-client/src/update.rs similarity index 99% rename from packages/ethereum-light-client/src/update.rs rename to packages/ethereum/ethereum-light-client/src/update.rs index dd55d811..6d1a4a0a 100644 --- a/packages/ethereum-light-client/src/update.rs +++ b/packages/ethereum/ethereum-light-client/src/update.rs @@ -3,7 +3,6 @@ use ethereum_types::consensus::{ slot::compute_timestamp_at_slot, sync_committee::compute_sync_committee_period_at_slot, }; -use ethereum_utils::ensure; use crate::{ client_state::ClientState, consensus_state::ConsensusState, error::EthereumIBCError, diff --git a/packages/ethereum-light-client/src/verify.rs b/packages/ethereum/ethereum-light-client/src/verify.rs similarity index 98% rename from packages/ethereum-light-client/src/verify.rs rename to packages/ethereum/ethereum-light-client/src/verify.rs index c7df937d..71a599f3 100644 --- a/packages/ethereum-light-client/src/verify.rs +++ b/packages/ethereum/ethereum-light-client/src/verify.rs @@ -15,7 +15,6 @@ use ethereum_types::consensus::{ slot::{compute_epoch_at_slot, compute_slot_at_timestamp, GENESIS_SLOT}, sync_committee::compute_sync_committee_period_at_slot, }; -use ethereum_utils::ensure; use tree_hash::TreeHash; use crate::{ @@ -133,11 +132,9 @@ pub fn validate_light_client_update( ) -> Result<(), EthereumIBCError> { // Verify sync committee has sufficient participants ensure!( - update.sync_aggregate.num_sync_committe_participants() - >= client_state - .min_sync_committee_participants - .try_into() - .unwrap(), + update + .sync_aggregate + .has_sufficient_participants(client_state.min_sync_committee_participants), EthereumIBCError::InsufficientSyncCommitteeParticipants( update.sync_aggregate.num_sync_committe_participants(), ) diff --git a/packages/ethereum-trie-db/Cargo.toml b/packages/ethereum/ethereum-trie-db/Cargo.toml similarity index 94% rename from packages/ethereum-trie-db/Cargo.toml rename to packages/ethereum/ethereum-trie-db/Cargo.toml index 9f1a4e69..c1927f8b 100644 --- a/packages/ethereum-trie-db/Cargo.toml +++ b/packages/ethereum/ethereum-trie-db/Cargo.toml @@ -5,8 +5,6 @@ edition = { workspace = true } repository = { workspace = true } [dependencies] -ethereum-utils = { workspace = true } - hex = { workspace = true } trie-db = { workspace = true, features = ["std"] } hash-db = { workspace = true } diff --git a/packages/ethereum-trie-db/src/error.rs b/packages/ethereum/ethereum-trie-db/src/error.rs similarity index 100% rename from packages/ethereum-trie-db/src/error.rs rename to packages/ethereum/ethereum-trie-db/src/error.rs diff --git a/packages/ethereum-trie-db/src/lib.rs b/packages/ethereum/ethereum-trie-db/src/lib.rs similarity index 100% rename from packages/ethereum-trie-db/src/lib.rs rename to packages/ethereum/ethereum-trie-db/src/lib.rs diff --git a/packages/ethereum-trie-db/src/trie_db.rs b/packages/ethereum/ethereum-trie-db/src/trie_db.rs similarity index 93% rename from packages/ethereum-trie-db/src/trie_db.rs rename to packages/ethereum/ethereum-trie-db/src/trie_db.rs index 6c50745f..7380cede 100644 --- a/packages/ethereum-trie-db/src/trie_db.rs +++ b/packages/ethereum/ethereum-trie-db/src/trie_db.rs @@ -1,7 +1,6 @@ //! Defines the account trie and the account type. use alloy_primitives::{Address, B256}; -use ethereum_utils::ensure; use hash_db::HashDB; use memory_db::{HashKey, MemoryDB}; use primitive_types::{H160, H256, U256}; @@ -49,13 +48,12 @@ pub fn verify_account_storage_root( Some(account) => { let account = rlp::decode::(account.as_ref()).map_err(TrieDBError::RlpDecode)?; - ensure!( - account.storage_root == storage_root, - TrieDBError::ValueMismatch { + if account.storage_root != storage_root { + return Err(TrieDBError::ValueMismatch { expected: storage_root.as_ref().into(), actual: account.storage_root.as_ref().into(), - } - ); + }); + } Ok(()) } None => Err(TrieDBError::ValueMissing { diff --git a/packages/ethereum-trie-db/src/types.rs b/packages/ethereum/ethereum-trie-db/src/types.rs similarity index 100% rename from packages/ethereum-trie-db/src/types.rs rename to packages/ethereum/ethereum-trie-db/src/types.rs diff --git a/packages/ethereum-types/Cargo.toml b/packages/ethereum/ethereum-types/Cargo.toml similarity index 100% rename from packages/ethereum-types/Cargo.toml rename to packages/ethereum/ethereum-types/Cargo.toml diff --git a/packages/ethereum-types/README.md b/packages/ethereum/ethereum-types/README.md similarity index 100% rename from packages/ethereum-types/README.md rename to packages/ethereum/ethereum-types/README.md diff --git a/packages/ethereum-types/src/consensus/bls.rs b/packages/ethereum/ethereum-types/src/consensus/bls.rs similarity index 100% rename from packages/ethereum-types/src/consensus/bls.rs rename to packages/ethereum/ethereum-types/src/consensus/bls.rs diff --git a/packages/ethereum-types/src/consensus/domain.rs b/packages/ethereum/ethereum-types/src/consensus/domain.rs similarity index 100% rename from packages/ethereum-types/src/consensus/domain.rs rename to packages/ethereum/ethereum-types/src/consensus/domain.rs diff --git a/packages/ethereum-types/src/consensus/fork.rs b/packages/ethereum/ethereum-types/src/consensus/fork.rs similarity index 100% rename from packages/ethereum-types/src/consensus/fork.rs rename to packages/ethereum/ethereum-types/src/consensus/fork.rs diff --git a/packages/ethereum-types/src/consensus/light_client_header.rs b/packages/ethereum/ethereum-types/src/consensus/light_client_header.rs similarity index 100% rename from packages/ethereum-types/src/consensus/light_client_header.rs rename to packages/ethereum/ethereum-types/src/consensus/light_client_header.rs diff --git a/packages/ethereum-types/src/consensus/merkle.rs b/packages/ethereum/ethereum-types/src/consensus/merkle.rs similarity index 100% rename from packages/ethereum-types/src/consensus/merkle.rs rename to packages/ethereum/ethereum-types/src/consensus/merkle.rs diff --git a/packages/ethereum-types/src/consensus/mod.rs b/packages/ethereum/ethereum-types/src/consensus/mod.rs similarity index 100% rename from packages/ethereum-types/src/consensus/mod.rs rename to packages/ethereum/ethereum-types/src/consensus/mod.rs diff --git a/packages/ethereum-types/src/consensus/signing_data.rs b/packages/ethereum/ethereum-types/src/consensus/signing_data.rs similarity index 100% rename from packages/ethereum-types/src/consensus/signing_data.rs rename to packages/ethereum/ethereum-types/src/consensus/signing_data.rs diff --git a/packages/ethereum-types/src/consensus/slot.rs b/packages/ethereum/ethereum-types/src/consensus/slot.rs similarity index 100% rename from packages/ethereum-types/src/consensus/slot.rs rename to packages/ethereum/ethereum-types/src/consensus/slot.rs diff --git a/packages/ethereum-types/src/consensus/sync_committee.rs b/packages/ethereum/ethereum-types/src/consensus/sync_committee.rs similarity index 88% rename from packages/ethereum-types/src/consensus/sync_committee.rs rename to packages/ethereum/ethereum-types/src/consensus/sync_committee.rs index 170f1859..99adbd86 100644 --- a/packages/ethereum-types/src/consensus/sync_committee.rs +++ b/packages/ethereum/ethereum-types/src/consensus/sync_committee.rs @@ -35,16 +35,16 @@ pub struct SyncAggregate { impl SyncAggregate { /// Returns the number of bits that are set to `true`. #[must_use] - pub fn num_sync_committe_participants(&self) -> usize { + pub fn num_sync_committe_participants(&self) -> u64 { self.sync_committee_bits .iter() - .map(|byte| byte.count_ones()) - .sum::() as usize + .map(|byte| u64::from(byte.count_ones())) + .sum() } /// Returns the size of the sync committee. - pub fn sync_committee_size(&self) -> usize { - self.sync_committee_bits.len() * 8 + pub fn sync_committee_size(&self) -> u64 { + self.sync_committee_bits.len() as u64 * 8 } /// Returns if at least 2/3 of the sync committee signed @@ -53,6 +53,11 @@ impl SyncAggregate { pub fn validate_signature_supermajority(&self) -> bool { self.num_sync_committe_participants() * 3 >= self.sync_committee_size() * 2 } + + /// Returns if the sync committee has sufficient participants + pub fn has_sufficient_participants(&self, min_sync_committee_participants: u64) -> bool { + self.num_sync_committe_participants() >= min_sync_committee_participants + } } /// Returns the sync committee period at a given `epoch`. @@ -180,4 +185,21 @@ mod test { assert_eq!(sync_aggregate.sync_committee_size(), 32); assert!(sync_aggregate.validate_signature_supermajority()); } + + #[test] + fn test_has_sufficient_participants() { + let sync_aggregate = SyncAggregate { + sync_committee_bits: vec![0b00000001].into(), + sync_committee_signature: BlsSignature::default(), + }; + assert!(sync_aggregate.has_sufficient_participants(1)); + assert!(!sync_aggregate.has_sufficient_participants(2)); + + let sync_aggregate = SyncAggregate { + sync_committee_bits: vec![0b11111111, 0b11111111, 0b11111111, 0b11111111].into(), + sync_committee_signature: BlsSignature::default(), + }; + assert!(sync_aggregate.has_sufficient_participants(32)); + assert!(!sync_aggregate.has_sufficient_participants(33)); + } } diff --git a/packages/ethereum-types/src/execution/account_proof.rs b/packages/ethereum/ethereum-types/src/execution/account_proof.rs similarity index 100% rename from packages/ethereum-types/src/execution/account_proof.rs rename to packages/ethereum/ethereum-types/src/execution/account_proof.rs diff --git a/packages/ethereum-types/src/execution/mod.rs b/packages/ethereum/ethereum-types/src/execution/mod.rs similarity index 100% rename from packages/ethereum-types/src/execution/mod.rs rename to packages/ethereum/ethereum-types/src/execution/mod.rs diff --git a/packages/ethereum-types/src/execution/storage_proof.rs b/packages/ethereum/ethereum-types/src/execution/storage_proof.rs similarity index 100% rename from packages/ethereum-types/src/execution/storage_proof.rs rename to packages/ethereum/ethereum-types/src/execution/storage_proof.rs diff --git a/packages/ethereum-types/src/lib.rs b/packages/ethereum/ethereum-types/src/lib.rs similarity index 100% rename from packages/ethereum-types/src/lib.rs rename to packages/ethereum/ethereum-types/src/lib.rs diff --git a/packages/tree_hash/Cargo.toml b/packages/ethereum/tree_hash/Cargo.toml similarity index 100% rename from packages/tree_hash/Cargo.toml rename to packages/ethereum/tree_hash/Cargo.toml diff --git a/packages/tree_hash/src/impls.rs b/packages/ethereum/tree_hash/src/impls.rs similarity index 100% rename from packages/tree_hash/src/impls.rs rename to packages/ethereum/tree_hash/src/impls.rs diff --git a/packages/tree_hash/src/lib.rs b/packages/ethereum/tree_hash/src/lib.rs similarity index 100% rename from packages/tree_hash/src/lib.rs rename to packages/ethereum/tree_hash/src/lib.rs diff --git a/packages/tree_hash/src/merkle_hasher.rs b/packages/ethereum/tree_hash/src/merkle_hasher.rs similarity index 100% rename from packages/tree_hash/src/merkle_hasher.rs rename to packages/ethereum/tree_hash/src/merkle_hasher.rs diff --git a/packages/tree_hash/src/merkleize_padded.rs b/packages/ethereum/tree_hash/src/merkleize_padded.rs similarity index 100% rename from packages/tree_hash/src/merkleize_padded.rs rename to packages/ethereum/tree_hash/src/merkleize_padded.rs diff --git a/packages/tree_hash/src/merkleize_standard.rs b/packages/ethereum/tree_hash/src/merkleize_standard.rs similarity index 100% rename from packages/tree_hash/src/merkleize_standard.rs rename to packages/ethereum/tree_hash/src/merkleize_standard.rs diff --git a/packages/tree_hash/src/sha256.rs b/packages/ethereum/tree_hash/src/sha256.rs similarity index 100% rename from packages/tree_hash/src/sha256.rs rename to packages/ethereum/tree_hash/src/sha256.rs diff --git a/packages/tree_hash/tests/tests.rs b/packages/ethereum/tree_hash/tests/tests.rs similarity index 100% rename from packages/tree_hash/tests/tests.rs rename to packages/ethereum/tree_hash/tests/tests.rs diff --git a/programs/cw-ics08-wasm-eth/Cargo.toml b/programs/cw-ics08-wasm-eth/Cargo.toml index a736e666..e41842d3 100644 --- a/programs/cw-ics08-wasm-eth/Cargo.toml +++ b/programs/cw-ics08-wasm-eth/Cargo.toml @@ -11,7 +11,6 @@ crate-type = ["cdylib", "rlib"] ibc-proto = { workspace = true } ethereum-light-client = { workspace = true } ethereum-types = { workspace = true } -ethereum-utils = { workspace = true } alloy-primitives = { workspace = true, default-features = false } diff --git a/programs/cw-ics08-wasm-eth/src/custom_query.rs b/programs/cw-ics08-wasm-eth/src/custom_query.rs index d69bdbcc..90a7c5aa 100644 --- a/programs/cw-ics08-wasm-eth/src/custom_query.rs +++ b/programs/cw-ics08-wasm-eth/src/custom_query.rs @@ -4,7 +4,6 @@ use alloy_primitives::B256; use cosmwasm_std::{Binary, CustomQuery, QuerierWrapper, QueryRequest}; use ethereum_light_client::verify::BlsVerify; use ethereum_types::consensus::bls::{BlsPublicKey, BlsSignature}; -use ethereum_utils::ensure; use thiserror::Error; /// The custom query for the Ethereum light client @@ -81,14 +80,13 @@ impl BlsVerify for BlsVerifier<'_> { .query(&request) .map_err(|e| BlsVerifierError::FastAggregateVerify(e.to_string()))?; - ensure!( - is_valid, - BlsVerifierError::InvalidSignature { + if !is_valid { + return Err(BlsVerifierError::InvalidSignature { public_keys: public_keys.to_vec(), msg, signature, - } - ); + }); + } Ok(()) }