mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore(rpc): use alloy's Keccak256 hasher instead of manually concatenating hash bytes (#11298)
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use alloy_primitives::{keccak256, U256};
|
use alloy_primitives::{Keccak256, U256};
|
||||||
use alloy_rpc_types_mev::{EthCallBundle, EthCallBundleResponse, EthCallBundleTransactionResult};
|
use alloy_rpc_types_mev::{EthCallBundle, EthCallBundleResponse, EthCallBundleTransactionResult};
|
||||||
use jsonrpsee::core::RpcResult;
|
use jsonrpsee::core::RpcResult;
|
||||||
use reth_chainspec::EthChainSpec;
|
use reth_chainspec::EthChainSpec;
|
||||||
@ -161,7 +161,7 @@ where
|
|||||||
let mut coinbase_balance_after_tx = initial_coinbase;
|
let mut coinbase_balance_after_tx = initial_coinbase;
|
||||||
let mut total_gas_used = 0u64;
|
let mut total_gas_used = 0u64;
|
||||||
let mut total_gas_fess = U256::ZERO;
|
let mut total_gas_fess = U256::ZERO;
|
||||||
let mut hash_bytes = Vec::with_capacity(32 * transactions.len());
|
let mut hasher = Keccak256::new();
|
||||||
|
|
||||||
let mut evm = Call::evm_config(ð_api).evm_with_env(db, env);
|
let mut evm = Call::evm_config(ð_api).evm_with_env(db, env);
|
||||||
|
|
||||||
@ -179,7 +179,7 @@ where
|
|||||||
|
|
||||||
let tx = tx.into_transaction();
|
let tx = tx.into_transaction();
|
||||||
|
|
||||||
hash_bytes.extend_from_slice(tx.hash().as_slice());
|
hasher.update(tx.hash());
|
||||||
let gas_price = tx
|
let gas_price = tx
|
||||||
.effective_tip_per_gas(basefee)
|
.effective_tip_per_gas(basefee)
|
||||||
.ok_or_else(|| RpcInvalidTransactionError::FeeCapTooLow)
|
.ok_or_else(|| RpcInvalidTransactionError::FeeCapTooLow)
|
||||||
@ -244,7 +244,7 @@ where
|
|||||||
coinbase_diff.checked_div(U256::from(total_gas_used)).unwrap_or_default();
|
coinbase_diff.checked_div(U256::from(total_gas_used)).unwrap_or_default();
|
||||||
let res = EthCallBundleResponse {
|
let res = EthCallBundleResponse {
|
||||||
bundle_gas_price,
|
bundle_gas_price,
|
||||||
bundle_hash: keccak256(&hash_bytes),
|
bundle_hash: hasher.finalize(),
|
||||||
coinbase_diff,
|
coinbase_diff,
|
||||||
eth_sent_to_coinbase,
|
eth_sent_to_coinbase,
|
||||||
gas_fees: total_gas_fess,
|
gas_fees: total_gas_fess,
|
||||||
|
|||||||
Reference in New Issue
Block a user