Skip to content

Commit

Permalink
chore: resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonberg1997 committed Jul 10, 2024
1 parent c7cac63 commit 8ca7cb9
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 39 deletions.
43 changes: 27 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions crates/precompile/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ rust_2018_idioms = "deny"
all = "warn"

[dependencies]
alloy-rlp = { version = "0.3.4", default-features = false, features = [
alloy-rlp = { version = "0.3.7", default-features = false, features = [
"arrayvec",
"derive",
] }
alloy-primitives = {version = "0.7.2"}

revm-primitives = { path = "../primitives", version = "6.0.0", default-features = false }
once_cell = { version = "1.19", default-features = false, features = ["alloc"] }
Expand All @@ -43,7 +42,7 @@ cometbft = { git = "https://github.com/bnb-chain/greenfield-cometbft-rs.git", re
cometbft-light-client-verifier = { git = "https://github.com/bnb-chain/greenfield-cometbft-rs.git", rev = "1282547" }
cometbft-proto = { git = "https://github.com/bnb-chain/greenfield-cometbft-rs.git", rev = "1282547" }
cometbft-light-client = { git = "https://github.com/bnb-chain/greenfield-cometbft-rs.git", rev = "1282547" }
prost = { version = "0.12.3" }
prost = { version = "0.12.6" }
bls_on_arkworks = "0.3.0"
tendermint = { git = "https://github.com/bnb-chain/tendermint-rs-parlia", tag = "v0.1.0-beta.1", features = ["secp256k1"] }
parity-bytes = { version = "0.1.2", default-features = false }
Expand Down
3 changes: 1 addition & 2 deletions crates/precompile/src/double_sign.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use crate::secp256k1;
use crate::{Bytes, Error, Precompile, PrecompileResult, PrecompileWithAddress};
use alloy_primitives::{BlockNumber, ChainId, U256};
use alloy_rlp::{Decodable, RlpDecodable, RlpEncodable};
use core::cmp::Ordering;
use revm_primitives::alloy_primitives::B512;
use revm_primitives::alloy_primitives::{BlockNumber, ChainId, B512, U256};
use revm_primitives::{keccak256, PrecompileOutput, B256};

/// Double sign evidence validation precompile for BSC.
Expand Down
6 changes: 3 additions & 3 deletions crates/precompile/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ mod bls;
#[cfg(feature = "blst")]
pub mod bls12_381;
pub mod bn128;
pub mod fatal_precompile;
pub mod hash;
mod cometbft;
mod double_sign;
pub mod fatal_precompile;
pub mod hash;
mod iavl;
pub mod identity;
#[cfg(feature = "c-kzg")]
Expand Down Expand Up @@ -274,7 +274,7 @@ impl Precompiles {
static INSTANCE: OnceBox<Precompiles> = OnceBox::new();
INSTANCE.get_or_init(|| {
#[cfg(feature = "bsc")]
let precompiles = Self::feynman().clone();
let mut precompiles = Self::feynman().clone();
#[cfg(not(feature = "bsc"))]
let mut precompiles = Self::berlin().clone();

Expand Down
2 changes: 1 addition & 1 deletion crates/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ rust_2018_idioms = "deny"
all = "warn"

[dependencies]
alloy-eips = { version = "0.1", default-features = false, features = ["k256"]}
alloy-eips = { version = "0.1.4", default-features = false, features = ["k256"]}
alloy-primitives = { version = "0.7.2", default-features = false, features = [
"rlp",
] }
Expand Down
8 changes: 4 additions & 4 deletions crates/revm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ ethers-providers = { version = "2.0", optional = true }
ethers-core = { version = "2.0", optional = true }

# alloydb
alloy-provider = { version = "0.1", optional = true, default-features = false }
alloy-eips = { version = "0.1", optional = true, default-features = false }
alloy-transport = { version = "0.1", optional = true, default-features = false }
alloy-provider = { version = "0.1.4", optional = true, default-features = false }
alloy-eips = { version = "0.1.4", optional = true, default-features = false }
alloy-transport = { version = "0.1.4", optional = true, default-features = false }

[dev-dependencies]
alloy-sol-types = { version = "0.7.0", default-features = false, features = [
Expand All @@ -64,7 +64,7 @@ indicatif = "0.17"
reqwest = { version = "0.12" }
rstest = "0.21.0"

alloy-provider = "0.1"
alloy-provider = "0.1.4"

[features]
default = ["std", "c-kzg", "secp256k1", "portable", "blst"]
Expand Down
39 changes: 29 additions & 10 deletions crates/revm/src/bsc/handler_register.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Handler related to BNB-Smart-chain

use crate::primitives::KECCAK_EMPTY;
use crate::{
handler::register::EvmHandler,
interpreter::Gas,
Expand Down Expand Up @@ -35,9 +36,20 @@ pub fn validate_initial_tx_gas<SPEC: Spec, DB: Database>(
let input = &env.tx.data;
let is_create = env.tx.transact_to.is_create();
let access_list = &env.tx.access_list;

let initial_gas_spend =
gas::validate_initial_tx_gas(SPEC::SPEC_ID, input, is_create, access_list);
let authorization_list_num = env
.tx
.authorization_list
.as_ref()
.map(|l| l.len() as u64)
.unwrap_or_default();

let initial_gas_spend = gas::validate_initial_tx_gas(
SPEC::SPEC_ID,
input,
is_create,
access_list,
authorization_list_num,
);

// Additional check to see if limit is big enough to cover initial gas.
if initial_gas_spend > env.tx.gas_limit {
Expand Down Expand Up @@ -84,7 +96,7 @@ pub fn output<EXT, DB: Database>(
context: &mut Context<EXT, DB>,
result: FrameResult,
) -> Result<ResultAndState, EVMError<DB::Error>> {
core::mem::replace(&mut context.evm.error, Ok(()))?;
context.evm.take_error()?;
// used gas with refund calculated.
let gas_refunded = if context
.evm
Expand All @@ -103,7 +115,17 @@ pub fn output<EXT, DB: Database>(
let instruction_result = result.into_interpreter_result();

// reset journal and return present state.
let (state, logs) = context.evm.journaled_state.finalize();
let (mut state, logs) = context.evm.journaled_state.finalize();

// clear code of authorized accounts.
for authorized in core::mem::take(&mut context.evm.inner.valid_authorizations).into_iter() {
let account = state
.get_mut(&authorized)
.expect("Authorized account must exist");
account.info.code = None;
account.info.code_hash = KECCAK_EMPTY;
account.storage.clear();
}

let result = match instruction_result.result.into() {
SuccessOrHalt::Success(reason) => ExecutionResult::Success {
Expand All @@ -121,11 +143,8 @@ pub fn output<EXT, DB: Database>(
reason,
gas_used: final_gas_used,
},
// Only three internal return flags.
flag @ (SuccessOrHalt::FatalExternalError
| SuccessOrHalt::Internal(InternalResult::InternalContinue)
| SuccessOrHalt::Internal(InternalResult::InternalCallOrCreate)
| SuccessOrHalt::Internal(InternalResult::CreateInitCodeStartingEF00)) => {
// Only two internal return flags.
flag @ (SuccessOrHalt::FatalExternalError | SuccessOrHalt::Internal(_)) => {
panic!(
"Encountered unexpected internal return flag: {:?} with instruction result: {:?}",
flag, instruction_result
Expand Down

0 comments on commit 8ca7cb9

Please sign in to comment.