diff --git a/beacon_node/execution_layer/src/engine_api.rs b/beacon_node/execution_layer/src/engine_api.rs index 21ca2b299..8419de588 100644 --- a/beacon_node/execution_layer/src/engine_api.rs +++ b/beacon_node/execution_layer/src/engine_api.rs @@ -49,6 +49,7 @@ pub enum Error { UnsupportedForkVariant(String), BadConversion(String), RlpDecoderError(rlp::DecoderError), + BlobTxConversionError, } impl From for Error { diff --git a/beacon_node/execution_layer/src/lib.rs b/beacon_node/execution_layer/src/lib.rs index a8b60a4fd..c670b14c9 100644 --- a/beacon_node/execution_layer/src/lib.rs +++ b/beacon_node/execution_layer/src/lib.rs @@ -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 ExecutionLayer { 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::, 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::>() .map_err(ApiError::DeserializeTransaction)?, ) diff --git a/consensus/types/src/kzg_commitment.rs b/consensus/types/src/kzg_commitment.rs deleted file mode 100644 index e69de29bb..000000000 diff --git a/consensus/types/src/kzg_proof.rs b/consensus/types/src/kzg_proof.rs deleted file mode 100644 index e69de29bb..000000000 diff --git a/consensus/types/src/lib.rs b/consensus/types/src/lib.rs index 91d0dd008..c09b34f87 100644 --- a/consensus/types/src/lib.rs +++ b/consensus/types/src/lib.rs @@ -101,6 +101,7 @@ pub mod sqlite; pub mod blobs_sidecar; pub mod signed_block_and_blobs; +pub mod transaction; use ethereum_types::{H160, H256}; diff --git a/consensus/types/src/transaction.rs b/consensus/types/src/transaction.rs new file mode 100644 index 000000000..d1c3a797d --- /dev/null +++ b/consensus/types/src/transaction.rs @@ -0,0 +1,38 @@ +use crate::{Hash256, Transaction, Uint256, VersionedHash}; +use ethereum_types::Address; +use ssz_derive::{Decode, Encode}; +use ssz_types::typenum::U16777216; +use ssz_types::VariableList; + +pub type MaxCalldataSize = U16777216; +pub type MaxAccessListSize = U16777216; +pub type MaxVersionedHashesListSize = U16777216; +pub type MaxAccessListStorageKeys = U16777216; + +#[derive(Debug, Clone, PartialEq, Encode, Decode)] +pub struct BlobTransaction { + pub chain_id: Uint256, + pub nonce: u64, + pub max_priority_fee_per_gas: Uint256, + pub max_fee_per_gas: Uint256, + pub gas: u64, + pub to: Option
, + pub value: Uint256, + pub data: VariableList, + pub access_list: VariableList, + pub max_fee_per_data_gas: Uint256, + pub blob_versioned_hashes: VariableList, +} + +#[derive(Debug, Clone, PartialEq, Encode, Decode)] +pub struct AccessTuple { + pub address: Address, + pub storage_keys: VariableList, +} + +#[derive(Debug, Clone, PartialEq, Encode, Decode)] +pub struct EcdsaSignature { + y_parity: bool, + r: Uint256, + s: Uint256, +}