mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 01:05:47 +00:00
Remove use of ethers_core::RlpStream
This commit is contained in:
@@ -52,6 +52,8 @@ serde_json = { workspace = true }
|
||||
smallvec = { workspace = true }
|
||||
maplit = { workspace = true }
|
||||
strum = { workspace = true }
|
||||
alloy-rlp = { version = "0.3.4", features = ["derive"] }
|
||||
alloy-primitives = "0.6.2"
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = { workspace = true }
|
||||
@@ -68,4 +70,4 @@ sqlite = []
|
||||
# The `arbitrary-fuzz` feature is a no-op provided for backwards compatibility.
|
||||
# For simplicity `Arbitrary` is now derived regardless of the feature's presence.
|
||||
arbitrary-fuzz = []
|
||||
portable = ["bls/supranational-portable"]
|
||||
portable = ["bls/supranational-portable"]
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
use crate::{Address, EthSpec, ExecutionPayloadRef, Hash256, Hash64, Uint256};
|
||||
use alloy_rlp::RlpEncodable;
|
||||
use metastruct::metastruct;
|
||||
|
||||
/// Execution block header as used for RLP encoding and Keccak hashing.
|
||||
@@ -89,3 +90,62 @@ impl ExecutionBlockHeader {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, RlpEncodable)]
|
||||
#[rlp(trailing)]
|
||||
pub struct EncodableExecutionBlockHeader<'a> {
|
||||
pub parent_hash: &'a [u8],
|
||||
pub ommers_hash: &'a [u8],
|
||||
pub beneficiary: &'a [u8],
|
||||
pub state_root: &'a [u8],
|
||||
pub transactions_root: &'a [u8],
|
||||
pub receipts_root: &'a [u8],
|
||||
pub logs_bloom: &'a [u8],
|
||||
pub difficulty: u64,
|
||||
pub number: u64,
|
||||
pub gas_limit: u64,
|
||||
pub gas_used: u64,
|
||||
pub timestamp: u64,
|
||||
pub extra_data: &'a [u8],
|
||||
pub mix_hash: &'a [u8],
|
||||
pub nonce: &'a [u8],
|
||||
pub base_fee_per_gas: u64,
|
||||
pub withdrawals_root: Option<&'a [u8]>,
|
||||
pub blob_gas_used: Option<u64>,
|
||||
pub excess_blob_gas: Option<u64>,
|
||||
pub parent_beacon_block_root: Option<&'a [u8]>,
|
||||
}
|
||||
|
||||
impl<'a> From<&'a ExecutionBlockHeader> for EncodableExecutionBlockHeader<'a> {
|
||||
fn from(header: &'a ExecutionBlockHeader) -> Self {
|
||||
let mut encodable = Self {
|
||||
parent_hash: header.parent_hash.as_bytes(),
|
||||
ommers_hash: header.ommers_hash.as_bytes(),
|
||||
beneficiary: header.beneficiary.as_bytes(),
|
||||
state_root: header.state_root.as_bytes(),
|
||||
transactions_root: header.transactions_root.as_bytes(),
|
||||
receipts_root: header.receipts_root.as_bytes(),
|
||||
logs_bloom: header.logs_bloom.as_slice(),
|
||||
difficulty: header.difficulty.as_u64(), // TODO this might panic
|
||||
number: header.number.as_u64(), // TODO this might panic
|
||||
gas_limit: header.gas_limit.as_u64(), // TODO this might panic
|
||||
gas_used: header.gas_used.as_u64(), // TODO this might panic
|
||||
timestamp: header.timestamp,
|
||||
extra_data: header.extra_data.as_slice(),
|
||||
mix_hash: header.mix_hash.as_bytes(),
|
||||
nonce: header.nonce.as_bytes(),
|
||||
base_fee_per_gas: header.base_fee_per_gas.as_u64(), // TODO this might panic
|
||||
withdrawals_root: None,
|
||||
blob_gas_used: header.blob_gas_used,
|
||||
excess_blob_gas: header.excess_blob_gas,
|
||||
parent_beacon_block_root: None,
|
||||
};
|
||||
if let Some(withdrawals_root) = &header.withdrawals_root {
|
||||
encodable.withdrawals_root = Some(withdrawals_root.as_bytes());
|
||||
}
|
||||
if let Some(parent_beacon_block_root) = &header.parent_beacon_block_root {
|
||||
encodable.parent_beacon_block_root = Some(parent_beacon_block_root.as_bytes())
|
||||
}
|
||||
encodable
|
||||
}
|
||||
}
|
||||
|
||||
0
consensus/types/src/execution_transaction.rs
Normal file
0
consensus/types/src/execution_transaction.rs
Normal file
@@ -135,7 +135,7 @@ pub use crate::enr_fork_id::EnrForkId;
|
||||
pub use crate::eth1_data::Eth1Data;
|
||||
pub use crate::eth_spec::EthSpecId;
|
||||
pub use crate::execution_block_hash::ExecutionBlockHash;
|
||||
pub use crate::execution_block_header::ExecutionBlockHeader;
|
||||
pub use crate::execution_block_header::{EncodableExecutionBlockHeader, ExecutionBlockHeader};
|
||||
pub use crate::execution_payload::{
|
||||
ExecutionPayload, ExecutionPayloadCapella, ExecutionPayloadDeneb, ExecutionPayloadMerge,
|
||||
ExecutionPayloadRef, Transaction, Transactions, Withdrawals,
|
||||
|
||||
Reference in New Issue
Block a user