mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
Decode with EMPTY_STRING_CODE and buf.advance() (#7227)
This commit is contained in:
@ -127,7 +127,7 @@ where
|
||||
self.metrics.total_downloaded.increment(response_len as u64);
|
||||
|
||||
// TODO: Malicious peers often return a single block even if it does not exceed the soft
|
||||
// response limit (2MB). this could be penalized by checking if this block and the
|
||||
// response limit (2MB). This could be penalized by checking if this block and the
|
||||
// next one exceed the soft response limit, if not then peer either does not have the next
|
||||
// block or deliberately sent a single block.
|
||||
if bodies.is_empty() {
|
||||
|
||||
@ -79,7 +79,7 @@
|
||||
//! }
|
||||
//! }
|
||||
//!
|
||||
//! /// A [PayloadJob] is a a future that's being polled by the `PayloadBuilderService`
|
||||
//! /// A [PayloadJob] is a future that's being polled by the `PayloadBuilderService`
|
||||
//! impl Future for EmptyBlockPayloadJob {
|
||||
//! type Output = Result<(), PayloadBuilderError>;
|
||||
//!
|
||||
|
||||
@ -21,7 +21,7 @@ use std::convert::Infallible;
|
||||
///
|
||||
/// According to the [engine API specification](https://github.com/ethereum/execution-apis/blob/main/src/engine/README.md) the execution layer should build the initial version of the payload with an empty transaction set and then keep update it in order to maximize the revenue.
|
||||
/// Therefore, the empty-block here is always available and full-block will be set/updated
|
||||
/// afterwards.
|
||||
/// afterward.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct EthBuiltPayload {
|
||||
/// Identifier of the payload
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
//! it can be converted into the container type [`TypedTransactionRequest`].
|
||||
|
||||
use alloy_primitives::{Address, Bytes, B256, U256, U64};
|
||||
use alloy_rlp::{BufMut, Decodable, Encodable, Error as RlpError};
|
||||
use alloy_rlp::{Buf, BufMut, Decodable, Encodable, Error as RlpError, EMPTY_STRING_CODE};
|
||||
use alloy_rpc_types::{AccessList, BlobTransactionSidecar};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@ -165,8 +165,8 @@ impl Encodable for TransactionKind {
|
||||
impl Decodable for TransactionKind {
|
||||
fn decode(buf: &mut &[u8]) -> alloy_rlp::Result<Self> {
|
||||
if let Some(&first) = buf.first() {
|
||||
if first == 0x80 {
|
||||
*buf = &buf[1..];
|
||||
if first == EMPTY_STRING_CODE {
|
||||
buf.advance(1);
|
||||
Ok(TransactionKind::Create)
|
||||
} else {
|
||||
let addr = <Address as Decodable>::decode(buf)?;
|
||||
|
||||
Reference in New Issue
Block a user