diff --git a/crates/precompile/Cargo.toml b/crates/precompile/Cargo.toml index d1ab327c..aa49c1a9 100644 --- a/crates/precompile/Cargo.toml +++ b/crates/precompile/Cargo.toml @@ -45,7 +45,7 @@ cometbft-light-client = { git = "https://github.com/bnb-chain/greenfield-cometb prost = { version = "0.12.6" } bls_on_arkworks = "0.3.0" tendermint = { git = "https://github.com/bnb-chain/tendermint-rs-parlia", rev = "8c21ccbd58a174e07eed2c9343e63ccd00f0fbd5", optional = true, features = ["secp256k1"] } -parity-bytes = { version = "0.1.2", default-features = false } +parity-bytes = { version = "0.1.2", default-features = false, optional = true } # SHA2-256 and RIPEMD-160 sha2 = { version = "0.10", default-features = false } @@ -99,7 +99,7 @@ std = [ hashbrown = ["revm-primitives/hashbrown"] asm-keccak = ["revm-primitives/asm-keccak"] -bsc = ["revm-primitives/bsc", "secp256k1", "secp256r1", "tendermint"] +bsc = ["revm-primitives/bsc", "secp256k1", "secp256r1", "tendermint", "parity-bytes"] optimism = ["revm-primitives/optimism", "secp256r1"] # Optimism default handler enabled Optimism handler register by default in EvmBuilder. diff --git a/crates/precompile/src/lib.rs b/crates/precompile/src/lib.rs index bd4d3354..31e21aa9 100644 --- a/crates/precompile/src/lib.rs +++ b/crates/precompile/src/lib.rs @@ -3,8 +3,6 @@ //! Implementations of EVM precompiled contracts. #![cfg_attr(not(test), warn(unused_crate_dependencies))] #![cfg_attr(not(feature = "std"), no_std)] -#![allow(unused_mut)] -#![allow(unused_crate_dependencies)] #[macro_use] #[cfg(not(feature = "std"))] @@ -185,12 +183,17 @@ impl Precompiles { pub fn nano() -> &'static Self { static INSTANCE: OnceBox = OnceBox::new(); INSTANCE.get_or_init(|| { - let mut precompiles = Self::istanbul().clone(); + let precompiles = Self::istanbul().clone(); + #[cfg(feature = "bsc")] - precompiles.extend([ - tendermint::TENDERMINT_HEADER_VALIDATION_NANO, - iavl::IAVL_PROOF_VALIDATION_NANO, - ]); + let precompiles = { + let mut precompiles = precompiles; + precompiles.extend([ + tendermint::TENDERMINT_HEADER_VALIDATION_NANO, + iavl::IAVL_PROOF_VALIDATION_NANO, + ]); + precompiles + }; Box::new(precompiles) }) @@ -200,12 +203,17 @@ impl Precompiles { pub fn moran() -> &'static Self { static INSTANCE: OnceBox = OnceBox::new(); INSTANCE.get_or_init(|| { - let mut precompiles = Self::istanbul().clone(); + let precompiles = Self::istanbul().clone(); #[cfg(feature = "bsc")] - precompiles.extend([ - tendermint::TENDERMINT_HEADER_VALIDATION, - iavl::IAVL_PROOF_VALIDATION_MORAN, - ]); + let precompiles = { + let mut precompiles = precompiles; + precompiles.extend([ + tendermint::TENDERMINT_HEADER_VALIDATION, + iavl::IAVL_PROOF_VALIDATION_MORAN, + ]); + precompiles + }; + Box::new(precompiles) }) @@ -215,12 +223,16 @@ impl Precompiles { pub fn planck() -> &'static Self { static INSTANCE: OnceBox = OnceBox::new(); INSTANCE.get_or_init(|| { - let mut precompiles = Self::istanbul().clone(); + let precompiles = Self::istanbul().clone(); #[cfg(feature = "bsc")] - precompiles.extend([ - tendermint::TENDERMINT_HEADER_VALIDATION, - iavl::IAVL_PROOF_VALIDATION_PLANCK, - ]); + let precompiles = { + let mut precompiles = precompiles; + precompiles.extend([ + tendermint::TENDERMINT_HEADER_VALIDATION, + iavl::IAVL_PROOF_VALIDATION_PLANCK, + ]); + precompiles + }; Box::new(precompiles) }) @@ -244,9 +256,13 @@ impl Precompiles { pub fn plato() -> &'static Self { static INSTANCE: OnceBox = OnceBox::new(); INSTANCE.get_or_init(|| { - let mut precompiles = Self::luban().clone(); + let precompiles = Self::luban().clone(); #[cfg(feature = "bsc")] - precompiles.extend([iavl::IAVL_PROOF_VALIDATION_PLATO]); + let precompiles = { + let mut precompiles = precompiles; + precompiles.extend([iavl::IAVL_PROOF_VALIDATION_PLATO]); + precompiles + }; Box::new(precompiles) })