mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-02 16:21:42 +00:00
blob decoding
This commit is contained in:
@@ -49,6 +49,7 @@ pub enum Error {
|
||||
UnsupportedForkVariant(String),
|
||||
BadConversion(String),
|
||||
RlpDecoderError(rlp::DecoderError),
|
||||
BlobTxConversionError,
|
||||
}
|
||||
|
||||
impl From<reqwest::Error> for Error {
|
||||
|
||||
@@ -22,12 +22,14 @@ use serde::{Deserialize, Serialize};
|
||||
use slog::{crit, debug, error, info, trace, warn, Logger};
|
||||
use slot_clock::SlotClock;
|
||||
use std::collections::HashMap;
|
||||
use std::default::default;
|
||||
use std::fmt;
|
||||
use std::future::Future;
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
|
||||
use ethers_core::types::transaction::eip2930::AccessListItem;
|
||||
use strum::AsRefStr;
|
||||
use task_executor::TaskExecutor;
|
||||
use tokio::{
|
||||
@@ -35,6 +37,8 @@ use tokio::{
|
||||
time::sleep,
|
||||
};
|
||||
use tokio_stream::wrappers::WatchStream;
|
||||
use types::consts::eip4844::BLOB_TX_TYPE;
|
||||
use types::transaction::{AccessTuple, BlobTransaction};
|
||||
use types::{AbstractExecPayload, BeaconStateError, Blob, ExecPayload, KzgCommitment};
|
||||
use types::{
|
||||
BlindedPayload, BlockType, ChainSpec, Epoch, ExecutionBlockHash, ForkName,
|
||||
@@ -1616,7 +1620,59 @@ impl<T: EthSpec> ExecutionLayer<T> {
|
||||
block
|
||||
.transactions()
|
||||
.iter()
|
||||
.map(|transaction| VariableList::new(transaction.rlp().to_vec()))
|
||||
.map(|transaction: Transaction| {
|
||||
let tx_type = transaction
|
||||
.transaction_type
|
||||
.ok_or(ApiError::BlobTxConversionError)?.as_u64();
|
||||
let tx = if BLOB_TX_TYPE as u64 == tx_type {
|
||||
let chain_id = transaction
|
||||
.chain_id
|
||||
.ok_or(ApiError::BlobTxConversionError)?;
|
||||
let nonce = transaction.nonce.as_u64();
|
||||
let max_priority_fee_per_gas = transaction
|
||||
.max_priority_fee_per_gas
|
||||
.ok_or(ApiError::BlobTxConversionError)?;
|
||||
let max_fee_per_gas = transaction
|
||||
.max_fee_per_gas
|
||||
.ok_or(ApiError::BlobTxConversionError)?;
|
||||
let gas = transaction.gas.as_u64();
|
||||
let to = transaction.to;
|
||||
let value = transaction.value;
|
||||
let data = VariableList::from(transaction.input.to_vec());
|
||||
let access_list = VariableList::from(transaction
|
||||
.access_list
|
||||
.ok_or(ApiError::BlobTxConversionError)?
|
||||
.0
|
||||
.into_iter().map(|access_tuple| Ok(AccessTuple {
|
||||
address: access_tuple.address,
|
||||
storage_keys: VariableList::from(
|
||||
access_tuple
|
||||
.storage_keys,
|
||||
),
|
||||
}))
|
||||
.collect::<Result<Vec<AccessTuple>, ApiError>>()?);
|
||||
let max_fee_per_data_gas = transaction.other.get("max_fee_per_data_gas").ok_or(ApiError::BlobTxConversionError)?;
|
||||
let data_str = max_fee_per_data_gas.as_str().ok_or(ApiError::BlobTxConversionError)?;
|
||||
let blob_versioned_hashes = transaction.other.get("blob_versioned_hashes").ok_or(ApiError::BlobTxConversionError)?;
|
||||
Ok(BlobTransaction {
|
||||
chain_id,
|
||||
nonce,
|
||||
max_priority_fee_per_gas,
|
||||
max_fee_per_gas,
|
||||
gas,
|
||||
to,
|
||||
value,
|
||||
data,
|
||||
access_list,
|
||||
max_fee_per_data_gas,
|
||||
blob_versioned_hashes,
|
||||
});
|
||||
vec![]
|
||||
} else {
|
||||
transaction.rlp().to_vec()
|
||||
};
|
||||
VariableList::new(tx)
|
||||
})
|
||||
.collect::<Result<_, _>>()
|
||||
.map_err(ApiError::DeserializeTransaction)?,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user