diff --git a/crates/precompile/src/bls.rs b/crates/precompile/src/bls.rs index eca4651b..179602b4 100644 --- a/crates/precompile/src/bls.rs +++ b/crates/precompile/src/bls.rs @@ -38,7 +38,7 @@ fn bls_signature_validation_run(input: &Bytes, gas_limit: u64) -> PrecompileResu let pub_keys_data = &input[msg_and_sig_length as usize..].to_vec(); // check signature format - if let Err(_) = bls::signature_to_point(&signature.to_vec()) { + if bls::signature_to_point(&signature.to_vec()).is_err() { return Ok((cost, Bytes::default())); } diff --git a/crates/revm/src/context/evm_context.rs b/crates/revm/src/context/evm_context.rs index f375b9be..633f526e 100644 --- a/crates/revm/src/context/evm_context.rs +++ b/crates/revm/src/context/evm_context.rs @@ -13,6 +13,7 @@ use core::{ fmt, ops::{Deref, DerefMut}, }; +use revm_precompile::u64_to_address; use std::boxed::Box; /// EVM context that contains the inner EVM context and precompiles. @@ -123,7 +124,7 @@ impl EvmContext { if result.gas.record_cost(gas_used) { // to keep align with bsc, revert if data is empty. // revert will not cost all gas - if data.is_empty() { + if is_bsc_precompile(address) && data.is_empty() { result.result = InstructionResult::Revert; } else { result.result = InstructionResult::Return; @@ -226,6 +227,14 @@ impl EvmContext { } } +// Helper to check if the address is some specific bsc precompile address. +fn is_bsc_precompile(address: Address) -> bool { + let bls_sig_validation = u64_to_address(102); + let double_sign_evidence_validation = u64_to_address(104); + + address == bls_sig_validation || address == double_sign_evidence_validation +} + /// Test utilities for the [`EvmContext`]. #[cfg(any(test, feature = "test-utils"))] pub(crate) mod test_utils {