mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: update el requests for devnet 4 (#11865)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@ -64,4 +64,4 @@ arbitrary = [
|
||||
"dep:proptest",
|
||||
"dep:proptest-arbitrary-interop",
|
||||
]
|
||||
serde-bincode-compat = ["serde_with", "alloy-consensus/serde-bincode-compat"]
|
||||
serde-bincode-compat = ["serde_with", "alloy-consensus/serde-bincode-compat"]
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
|
||||
use alloc::{fmt, vec::Vec};
|
||||
|
||||
use alloy_consensus::{BlockHeader, Request, Transaction, TxType};
|
||||
use alloy_eips::eip4895::Withdrawal;
|
||||
use alloy_consensus::{BlockHeader, Transaction, TxType};
|
||||
use alloy_eips::{eip4895::Withdrawal, eip7685::Requests};
|
||||
use alloy_primitives::{Address, B256};
|
||||
|
||||
use crate::Block;
|
||||
@ -30,9 +30,6 @@ pub trait BlockBody:
|
||||
/// Withdrawals in block.
|
||||
type Withdrawals: Iterator<Item = Withdrawal>;
|
||||
|
||||
/// Requests in block.
|
||||
type Requests: Iterator<Item = Request>;
|
||||
|
||||
/// Returns reference to transactions in block.
|
||||
fn transactions(&self) -> &[Self::SignedTransaction];
|
||||
|
||||
@ -43,8 +40,8 @@ pub trait BlockBody:
|
||||
/// Returns reference to uncle block headers.
|
||||
fn ommers(&self) -> &[Self::Header];
|
||||
|
||||
/// Returns [`Request`] in block, if any.
|
||||
fn requests(&self) -> Option<&Self::Requests>;
|
||||
/// Returns [`Requests`] in block, if any.
|
||||
fn requests(&self) -> Option<&Requests>;
|
||||
|
||||
/// Create a [`Block`] from the body and its header.
|
||||
fn into_block<T: Block<Header = Self::Header, Body = Self>>(self, header: Self::Header) -> T {
|
||||
@ -63,12 +60,6 @@ pub trait BlockBody:
|
||||
// `Withdrawals` and `Withdrawals` moved to alloy
|
||||
fn calculate_withdrawals_root(&self) -> Option<B256>;
|
||||
|
||||
/// Calculate the requests root for the block body, if requests exist. If there are no
|
||||
/// requests, this will return `None`.
|
||||
// todo: can be default impl if `calculate_requests_root` made into a method on
|
||||
// `Requests` and `Requests` moved to alloy
|
||||
fn calculate_requests_root(&self) -> Option<B256>;
|
||||
|
||||
/// Recover signer addresses for all transactions in the block body.
|
||||
fn recover_signers(&self) -> Option<Vec<Address>>;
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ pub const fn generate_valid_header(
|
||||
}
|
||||
|
||||
// Placeholder for future EIP adjustments
|
||||
header.requests_root = None;
|
||||
header.requests_hash = None;
|
||||
|
||||
header
|
||||
}
|
||||
|
||||
@ -29,9 +29,6 @@ pub use transaction::{signed::SignedTransaction, Transaction};
|
||||
mod integer_list;
|
||||
pub use integer_list::{IntegerList, IntegerListError};
|
||||
|
||||
pub mod request;
|
||||
pub use request::{Request, Requests};
|
||||
|
||||
pub mod block;
|
||||
pub use block::{body::BlockBody, Block};
|
||||
|
||||
|
||||
@ -1,58 +0,0 @@
|
||||
//! EIP-7685 requests.
|
||||
|
||||
use alloc::vec::Vec;
|
||||
pub use alloy_consensus::Request;
|
||||
use alloy_eips::eip7685::{Decodable7685, Encodable7685};
|
||||
use alloy_rlp::{Decodable, Encodable};
|
||||
use derive_more::{Deref, DerefMut, From, IntoIterator};
|
||||
use reth_codecs::{add_arbitrary_tests, Compact};
|
||||
use revm_primitives::Bytes;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// A list of EIP-7685 requests.
|
||||
#[derive(
|
||||
Debug,
|
||||
Clone,
|
||||
PartialEq,
|
||||
Eq,
|
||||
Default,
|
||||
Hash,
|
||||
Deref,
|
||||
DerefMut,
|
||||
From,
|
||||
IntoIterator,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
Compact,
|
||||
)]
|
||||
#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))]
|
||||
#[add_arbitrary_tests(compact)]
|
||||
pub struct Requests(pub Vec<Request>);
|
||||
|
||||
impl Encodable for Requests {
|
||||
fn encode(&self, out: &mut dyn bytes::BufMut) {
|
||||
let mut h = alloy_rlp::Header { list: true, payload_length: 0 };
|
||||
|
||||
let mut encoded = Vec::new();
|
||||
for req in &self.0 {
|
||||
let encoded_req = req.encoded_7685();
|
||||
h.payload_length += encoded_req.len();
|
||||
encoded.push(Bytes::from(encoded_req));
|
||||
}
|
||||
|
||||
h.encode(out);
|
||||
for req in encoded {
|
||||
req.encode(out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for Requests {
|
||||
fn decode(buf: &mut &[u8]) -> alloy_rlp::Result<Self> {
|
||||
Ok(<Vec<Bytes> as Decodable>::decode(buf)?
|
||||
.into_iter()
|
||||
.map(|bytes| Request::decode_7685(&mut bytes.as_ref()))
|
||||
.collect::<Result<Vec<_>, alloy_eips::eip7685::Eip7685Error>>()
|
||||
.map(Self)?)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user