|
1 | 1 | //! Payload related types
|
2 | 2 |
|
3 |
| -use alloy_eips::eip4895::{Withdrawal, Withdrawals}; |
4 |
| -use alloy_primitives::{Address, Bytes, B256, U256}; |
5 |
| -use alloy_rlp::{Encodable, RlpDecodable, RlpEncodable}; |
6 |
| -use alloy_rpc_types_engine::{ExecutionPayload, ExecutionPayloadV2, PayloadAttributes, PayloadId}; |
| 3 | +use alloy_eips::eip4895::Withdrawals; |
| 4 | +use alloy_primitives::{Address, B256, U256}; |
| 5 | +use alloy_rlp::Encodable; |
| 6 | +use alloy_rpc_types_engine::{ExecutionPayloadV2, PayloadId}; |
7 | 7 | use reth_ethereum_engine_primitives::{EthBuiltPayload, EthPayloadBuilderAttributes};
|
8 | 8 | use reth_payload_primitives::PayloadBuilderAttributes;
|
9 | 9 | use reth_rpc_types_compat::engine::payload::block_to_payload_v2;
|
| 10 | +use reth_taiko_engine_types::{BlockMetadata, TaikoPayloadAttributes}; |
10 | 11 | use reth_taiko_primitives::L1Origin;
|
11 | 12 | use serde::{Deserialize, Serialize};
|
12 |
| -use serde_with::{base64::Base64, serde_as}; |
13 | 13 | use std::convert::Infallible;
|
14 | 14 |
|
15 |
| -/// Taiko Payload Attributes |
16 |
| -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] |
17 |
| -#[serde(rename_all = "camelCase")] |
18 |
| -pub struct TaikoPayloadAttributes { |
19 |
| - /// The payload attributes |
20 |
| - #[serde(flatten)] |
21 |
| - pub payload_attributes: PayloadAttributes, |
22 |
| - /// EIP1559 base fee |
23 |
| - pub base_fee_per_gas: U256, |
24 |
| - /// Data from l1 contract |
25 |
| - pub block_metadata: BlockMetadata, |
26 |
| - /// l1 anchor information |
27 |
| - pub l1_origin: L1Origin, |
28 |
| -} |
29 |
| - |
30 |
| -impl reth_payload_primitives::PayloadAttributes for TaikoPayloadAttributes { |
31 |
| - fn timestamp(&self) -> u64 { |
32 |
| - self.payload_attributes.timestamp() |
33 |
| - } |
34 |
| - |
35 |
| - fn withdrawals(&self) -> Option<&Vec<Withdrawal>> { |
36 |
| - self.payload_attributes.withdrawals() |
37 |
| - } |
38 |
| - |
39 |
| - fn parent_beacon_block_root(&self) -> Option<B256> { |
40 |
| - self.payload_attributes.parent_beacon_block_root() |
41 |
| - } |
42 |
| -} |
43 |
| - |
44 |
| -/// This structure contains the information from l1 contract storage |
45 |
| -#[serde_as] |
46 |
| -#[derive( |
47 |
| - Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, RlpDecodable, RlpEncodable, |
48 |
| -)] |
49 |
| -#[serde(rename_all = "camelCase")] |
50 |
| -pub struct BlockMetadata { |
51 |
| - /// The Keccak 256-bit hash of the parent |
52 |
| - /// block’s header, in its entirety; formally Hp. |
53 |
| - pub beneficiary: Address, |
54 |
| - /// A scalar value equal to the current limit of gas expenditure per block; formally Hl. |
55 |
| - pub gas_limit: u64, |
56 |
| - /// Timestamp in l1 |
57 |
| - #[serde(with = "alloy_serde::quantity")] |
58 |
| - pub timestamp: u64, |
59 |
| - /// A 256-bit hash which, combined with the |
60 |
| - /// nonce, proves that a sufficient amount of computation has been carried out on this block; |
61 |
| - /// formally Hm. |
62 |
| - pub mix_hash: B256, |
63 |
| - /// The origin transactions data |
64 |
| - pub tx_list: Bytes, |
65 |
| - /// An arbitrary byte array containing data relevant to this block. This must be 32 bytes or |
66 |
| - /// fewer; formally Hx. |
67 |
| - #[serde_as(as = "Base64")] |
68 |
| - pub extra_data: Vec<u8>, |
69 |
| -} |
70 |
| - |
71 | 15 | /// Taiko Payload Builder Attributes
|
72 | 16 | #[derive(Debug, Clone, PartialEq, Eq)]
|
73 | 17 | pub struct TaikoPayloadBuilderAttributes {
|
@@ -191,59 +135,6 @@ impl From<EthBuiltPayload> for TaikoExecutionPayloadEnvelopeV2 {
|
191 | 135 | }
|
192 | 136 | }
|
193 | 137 |
|
194 |
| -/// An tiako execution payload |
195 |
| -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] |
196 |
| -#[serde(rename_all = "camelCase")] |
197 |
| -pub struct TaikoExecutionPayload { |
198 |
| - /// Inner V3 payload |
199 |
| - #[serde(flatten)] |
200 |
| - pub payload_inner: ExecutionPayload, |
201 |
| - |
202 |
| - /// Allow passing txHash directly instead of transactions list |
203 |
| - pub tx_hash: B256, |
204 |
| - /// Allow passing `WithdrawalsHash` directly instead of withdrawals |
205 |
| - pub withdrawals_hash: B256, |
206 |
| -} |
207 |
| - |
208 |
| -impl TaikoExecutionPayload { |
209 |
| - /// Returns the block hash |
210 |
| - pub const fn block_hash(&self) -> B256 { |
211 |
| - self.payload_inner.block_hash() |
212 |
| - } |
213 |
| - |
214 |
| - /// Returns the block number |
215 |
| - pub const fn block_number(&self) -> u64 { |
216 |
| - self.payload_inner.block_number() |
217 |
| - } |
218 |
| - |
219 |
| - /// Returns the parent hash |
220 |
| - pub const fn parent_hash(&self) -> B256 { |
221 |
| - self.payload_inner.parent_hash() |
222 |
| - } |
223 |
| - |
224 |
| - /// Returns the withdrawals |
225 |
| - pub const fn withdrawals(&self) -> Option<&Vec<Withdrawal>> { |
226 |
| - self.payload_inner.withdrawals() |
227 |
| - } |
228 |
| - |
229 |
| - /// Returns the timestamp |
230 |
| - pub const fn timestamp(&self) -> u64 { |
231 |
| - self.payload_inner.timestamp() |
232 |
| - } |
233 |
| -} |
234 |
| - |
235 |
| -impl From<(ExecutionPayload, B256, B256)> for TaikoExecutionPayload { |
236 |
| - fn from((payload_inner, tx_hash, withdrawals_hash): (ExecutionPayload, B256, B256)) -> Self { |
237 |
| - Self { payload_inner, tx_hash, withdrawals_hash } |
238 |
| - } |
239 |
| -} |
240 |
| - |
241 |
| -impl From<ExecutionPayload> for TaikoExecutionPayload { |
242 |
| - fn from(value: ExecutionPayload) -> Self { |
243 |
| - Self { payload_inner: value, tx_hash: B256::default(), withdrawals_hash: B256::default() } |
244 |
| - } |
245 |
| -} |
246 |
| - |
247 | 138 | /// Generates the payload id for the configured payload from the [`PayloadAttributes`].
|
248 | 139 | ///
|
249 | 140 | /// Returns an 8-byte identifier by hashing the payload components with sha256 hash.
|
|
0 commit comments