From 3dff0d37f05e9caffff5b805906c2675ec0060e2 Mon Sep 17 00:00:00 2001 From: ZhAnGeek Date: Tue, 12 Nov 2024 19:23:57 +0800 Subject: [PATCH] fix: removed unneccesary global mark --- Cargo.lock | 12 +++--- crates/precompile/Cargo.toml | 12 +++--- crates/precompile/src/lib.rs | 55 ++++++++++++++++++--------- crates/precompile/src/tm_secp256k1.rs | 3 +- 4 files changed, 50 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0a70a6e9..15280c2f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1104,7 +1104,7 @@ checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" [[package]] name = "cometbft" version = "0.1.0-alpha.2" -source = "git+https://github.com/bnb-chain/greenfield-cometbft-rs.git?rev=5582327#558232788fca6ade6ae2e16a7557af1982105c4f" +source = "git+https://github.com/bnb-chain/greenfield-cometbft-rs.git?rev=ccf58da#ccf58dabac222c7950aa52d8b700fc61beb9ae7f" dependencies = [ "bytes 1.7.1", "cometbft-proto", @@ -1131,7 +1131,7 @@ dependencies = [ [[package]] name = "cometbft-config" version = "0.1.0-alpha.2" -source = "git+https://github.com/bnb-chain/greenfield-cometbft-rs.git?rev=5582327#558232788fca6ade6ae2e16a7557af1982105c4f" +source = "git+https://github.com/bnb-chain/greenfield-cometbft-rs.git?rev=ccf58da#ccf58dabac222c7950aa52d8b700fc61beb9ae7f" dependencies = [ "cometbft", "flex-error", @@ -1144,7 +1144,7 @@ dependencies = [ [[package]] name = "cometbft-light-client" version = "0.1.0-alpha.2" -source = "git+https://github.com/bnb-chain/greenfield-cometbft-rs.git?rev=5582327#558232788fca6ade6ae2e16a7557af1982105c4f" +source = "git+https://github.com/bnb-chain/greenfield-cometbft-rs.git?rev=ccf58da#ccf58dabac222c7950aa52d8b700fc61beb9ae7f" dependencies = [ "cometbft", "cometbft-light-client-verifier", @@ -1166,7 +1166,7 @@ dependencies = [ [[package]] name = "cometbft-light-client-verifier" version = "0.1.0-alpha.2" -source = "git+https://github.com/bnb-chain/greenfield-cometbft-rs.git?rev=5582327#558232788fca6ade6ae2e16a7557af1982105c4f" +source = "git+https://github.com/bnb-chain/greenfield-cometbft-rs.git?rev=ccf58da#ccf58dabac222c7950aa52d8b700fc61beb9ae7f" dependencies = [ "cometbft", "derive_more 0.99.18", @@ -1178,7 +1178,7 @@ dependencies = [ [[package]] name = "cometbft-proto" version = "0.1.0-alpha.2" -source = "git+https://github.com/bnb-chain/greenfield-cometbft-rs.git?rev=5582327#558232788fca6ade6ae2e16a7557af1982105c4f" +source = "git+https://github.com/bnb-chain/greenfield-cometbft-rs.git?rev=ccf58da#ccf58dabac222c7950aa52d8b700fc61beb9ae7f" dependencies = [ "bytes 1.7.1", "flex-error", @@ -1195,7 +1195,7 @@ dependencies = [ [[package]] name = "cometbft-rpc" version = "0.1.0-alpha.2" -source = "git+https://github.com/bnb-chain/greenfield-cometbft-rs.git?rev=5582327#558232788fca6ade6ae2e16a7557af1982105c4f" +source = "git+https://github.com/bnb-chain/greenfield-cometbft-rs.git?rev=ccf58da#ccf58dabac222c7950aa52d8b700fc61beb9ae7f" dependencies = [ "async-trait", "bytes 1.7.1", diff --git a/crates/precompile/Cargo.toml b/crates/precompile/Cargo.toml index d1ab327c..27b5078f 100644 --- a/crates/precompile/Cargo.toml +++ b/crates/precompile/Cargo.toml @@ -38,14 +38,14 @@ secp256k1 = { version = ">=0.28, <=0.29", default-features = false, features = [ "rand", "global-context", ], optional = true } -cometbft = { git = "https://github.com/bnb-chain/greenfield-cometbft-rs.git", rev = "5582327" } -cometbft-light-client-verifier = { git = "https://github.com/bnb-chain/greenfield-cometbft-rs.git", rev = "5582327" } -cometbft-proto = { git = "https://github.com/bnb-chain/greenfield-cometbft-rs.git", rev = "5582327" } -cometbft-light-client = { git = "https://github.com/bnb-chain/greenfield-cometbft-rs.git", rev = "5582327", default-features = false } +cometbft = { git = "https://github.com/bnb-chain/greenfield-cometbft-rs.git", rev = "ccf58da" } +cometbft-light-client-verifier = { git = "https://github.com/bnb-chain/greenfield-cometbft-rs.git", rev = "ccf58da" } +cometbft-proto = { git = "https://github.com/bnb-chain/greenfield-cometbft-rs.git", rev = "ccf58da" } +cometbft-light-client = { git = "https://github.com/bnb-chain/greenfield-cometbft-rs.git", rev = "ccf58da", default-features = false } 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..ab2a605e 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,17 @@ 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 +257,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) }) diff --git a/crates/precompile/src/tm_secp256k1.rs b/crates/precompile/src/tm_secp256k1.rs index 955d825b..11db1b88 100644 --- a/crates/precompile/src/tm_secp256k1.rs +++ b/crates/precompile/src/tm_secp256k1.rs @@ -1,5 +1,6 @@ -#![allow(unused_imports)] #![allow(dead_code)] +#![cfg_attr(feature = "bsc", warn(dead_code))] + use crate::{Bytes, Error, Precompile, PrecompileError, PrecompileResult, PrecompileWithAddress}; use revm_primitives::PrecompileOutput; use secp256k1::{ecdsa, Message, PublicKey};