feat: bump alloy (#12930)

Co-authored-by: Ryan Schneider <ryanleeschneider@gmail.com>
This commit is contained in:
Arsenii Kulikov
2024-12-02 04:55:17 +04:00
committed by GitHub
parent 890f082453
commit 7f88e62781
41 changed files with 386 additions and 204 deletions

View File

@ -1,12 +1,17 @@
use crate::{
capabilities::EngineCapabilities, metrics::EngineApiMetrics, EngineApiError, EngineApiResult,
};
use alloy_eips::{eip1898::BlockHashOrNumber, eip4844::BlobAndProofV1, eip7685::Requests};
use alloy_eips::{
eip1898::BlockHashOrNumber,
eip4844::BlobAndProofV1,
eip7685::{Requests, RequestsOrHash},
};
use alloy_primitives::{BlockHash, BlockNumber, B256, U64};
use alloy_rpc_types_engine::{
CancunPayloadFields, ClientVersionV1, ExecutionPayload, ExecutionPayloadBodiesV1,
ExecutionPayloadInputV2, ExecutionPayloadSidecar, ExecutionPayloadV1, ExecutionPayloadV3,
ForkchoiceState, ForkchoiceUpdated, PayloadId, PayloadStatus, TransitionConfiguration,
ForkchoiceState, ForkchoiceUpdated, PayloadId, PayloadStatus, PraguePayloadFields,
TransitionConfiguration,
};
use async_trait::async_trait;
use jsonrpsee_core::RpcResult;
@ -279,7 +284,11 @@ where
payload,
ExecutionPayloadSidecar::v4(
CancunPayloadFields { versioned_hashes, parent_beacon_block_root },
execution_requests,
PraguePayloadFields {
requests: RequestsOrHash::Requests(execution_requests),
// TODO: add as an argument and handle in `try_into_block`
target_blobs_per_block: 0,
},
),
)
.await

View File

@ -467,6 +467,7 @@ pub trait LoadPendingBlock:
extra_data: Default::default(),
parent_beacon_block_root,
requests_hash,
target_blobs_per_block: None,
};
// Convert Vec<Option<Receipt>> to Vec<Receipt>

View File

@ -282,7 +282,7 @@ pub trait EthTransactions: LoadTransaction<Provider: BlockReaderIdExt> {
block
.transactions_with_sender()
.enumerate()
.find(|(_, (signer, tx))| **signer == sender && tx.nonce() == nonce)
.find(|(_, (signer, tx))| **signer == sender && (*tx).nonce() == nonce)
.map(|(index, (signer, tx))| {
let tx_info = TransactionInfo {
hash: Some(tx.hash()),

View File

@ -14,7 +14,7 @@ pub fn build_receipt<T>(
meta: TransactionMeta,
receipt: &Receipt,
all_receipts: &[Receipt],
build_envelope: impl FnOnce(ReceiptWithBloom<Log>) -> T,
build_envelope: impl FnOnce(ReceiptWithBloom<alloy_consensus::Receipt<Log>>) -> T,
) -> EthResult<TransactionReceipt<T>> {
// Note: we assume this transaction is valid, because it's mined (or part of pending block)
// and we don't need to check for pre EIP-2

View File

@ -5,7 +5,6 @@ use alloy_consensus::{constants::MAXIMUM_EXTRA_DATA_SIZE, Header, EMPTY_OMMER_RO
use alloy_eips::{
eip2718::{Decodable2718, Encodable2718},
eip4895::Withdrawals,
eip7685::Requests,
};
use alloy_primitives::{B256, U256};
use alloy_rpc_types_engine::{
@ -77,6 +76,7 @@ pub fn try_payload_v1_to_block(payload: ExecutionPayloadV1) -> Result<Block, Pay
ommers_hash: EMPTY_OMMER_ROOT_HASH,
difficulty: Default::default(),
nonce: Default::default(),
target_blobs_per_block: None,
};
Ok(Block { header, body: BlockBody { transactions, ..Default::default() } })
@ -270,7 +270,7 @@ pub fn try_into_block(
};
base_payload.header.parent_beacon_block_root = sidecar.parent_beacon_block_root();
base_payload.header.requests_hash = sidecar.requests().map(Requests::requests_hash);
base_payload.header.requests_hash = sidecar.requests_hash();
Ok(base_payload)
}

View File

@ -384,10 +384,22 @@ where
// <https://github.com/rust-lang/rust/issues/100013>
let db = db.0;
let tx_info = TransactionInfo {
block_number: Some(
env.block.number.try_into().unwrap_or_default(),
),
base_fee: Some(
env.block.basefee.try_into().unwrap_or_default(),
),
hash: None,
block_hash: None,
index: None,
};
let (res, _) =
this.eth_api().inspect(&mut *db, env, &mut inspector)?;
let frame = inspector
.try_into_mux_frame(&res, db)
.try_into_mux_frame(&res, db, tx_info)
.map_err(Eth::Error::from_eth_err)?;
Ok(frame.into())
})
@ -658,6 +670,17 @@ where
) -> Result<(GethTrace, revm_primitives::EvmState), Eth::Error> {
let GethDebugTracingOptions { config, tracer, tracer_config, .. } = opts;
let tx_info = TransactionInfo {
hash: transaction_context.as_ref().map(|c| c.tx_hash).unwrap_or_default(),
index: transaction_context
.as_ref()
.map(|c| c.tx_index.map(|i| i as u64))
.unwrap_or_default(),
block_hash: transaction_context.as_ref().map(|c| c.block_hash).unwrap_or_default(),
block_number: Some(env.block.number.try_into().unwrap_or_default()),
base_fee: Some(env.block.basefee.try_into().unwrap_or_default()),
};
if let Some(tracer) = tracer {
return match tracer {
GethDebugTracerType::BuiltInTracer(tracer) => match tracer {
@ -723,7 +746,7 @@ where
let (res, _) = self.eth_api().inspect(&mut *db, env, &mut inspector)?;
let frame = inspector
.try_into_mux_frame(&res, db)
.try_into_mux_frame(&res, db, tx_info)
.map_err(Eth::Error::from_eth_err)?;
return Ok((frame.into(), res.state))
}
@ -738,14 +761,6 @@ where
);
let (res, env) = self.eth_api().inspect(db, env, &mut inspector)?;
let tx_info = TransactionInfo {
hash: transaction_context.unwrap().tx_hash,
index: transaction_context.unwrap().tx_index.map(|index| index as u64),
block_hash: transaction_context.unwrap().block_hash,
block_number: Some(env.block.number.try_into().unwrap_or_default()),
base_fee: Some(env.block.basefee.try_into().unwrap_or_default()),
};
let frame: FlatCallFrame = inspector
.with_transaction_gas_limit(env.tx.gas_limit)
.into_parity_builder()

View File

@ -55,7 +55,9 @@ where
let EthCallBundle {
txs,
block_number,
coinbase,
state_block_number,
timeout: _,
timestamp,
gas_limit,
difficulty,
@ -106,6 +108,10 @@ where
// Note: the block number is considered the `parent` block: <https://github.com/flashbots/mev-geth/blob/fddf97beec5877483f879a77b7dea2e58a58d653/internal/ethapi/api.go#L2104>
let (cfg, mut block_env, at) = self.eth_api().evm_env_at(block_id).await?;
if let Some(coinbase) = coinbase {
block_env.coinbase = coinbase;
}
// need to adjust the timestamp for the next block
if let Some(timestamp) = timestamp {
block_env.timestamp = U256::from(timestamp);
@ -117,8 +123,16 @@ where
block_env.difficulty = U256::from(difficulty);
}
// default to call gas limit unless user requests a smaller limit
block_env.gas_limit = U256::from(self.inner.eth_api.call_gas_limit());
if let Some(gas_limit) = gas_limit {
block_env.gas_limit = U256::from(gas_limit);
let gas_limit = U256::from(gas_limit);
if gas_limit > block_env.gas_limit {
return Err(
EthApiError::InvalidTransaction(RpcInvalidTransactionError::GasTooHigh).into()
)
}
block_env.gas_limit = gas_limit;
}
if let Some(base_fee) = base_fee {

View File

@ -1,11 +1,12 @@
use alloy_consensus::{BlobTransactionValidationError, EnvKzgSettings, Transaction, TxReceipt};
use alloy_eips::eip4844::kzg_to_versioned_hash;
use alloy_eips::{eip4844::kzg_to_versioned_hash, eip7685::RequestsOrHash};
use alloy_rpc_types_beacon::relay::{
BidTrace, BuilderBlockValidationRequest, BuilderBlockValidationRequestV2,
BuilderBlockValidationRequestV3, BuilderBlockValidationRequestV4,
};
use alloy_rpc_types_engine::{
BlobsBundleV1, CancunPayloadFields, ExecutionPayload, ExecutionPayloadSidecar, PayloadError,
PraguePayloadFields,
};
use async_trait::async_trait;
use jsonrpsee::core::RpcResult;
@ -386,7 +387,12 @@ where
versioned_hashes: self
.validate_blobs_bundle(request.request.blobs_bundle)?,
},
request.request.execution_requests.into(),
PraguePayloadFields {
requests: RequestsOrHash::Requests(
request.request.execution_requests.into(),
),
target_blobs_per_block: request.request.target_blobs_per_block,
},
),
)?
.try_seal_with_senders()