This repository has been archived by the owner on Oct 22, 2024. It is now read-only.
forked from paritytech/polkadot-sdk
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
29df723
commit a956c9c
Showing
2 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
use std::convert::TryInto; | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-FileCopyrightText: 2023 Snowfork <[email protected]> | ||
use codec::{Decode, Encode, MaxEncodedLen}; | ||
|
@@ -367,6 +368,7 @@ pub struct CompactBeaconState { | |
pub enum VersionedExecutionPayloadHeader { | ||
Capella(ExecutionPayloadHeader), | ||
Deneb(deneb::ExecutionPayloadHeader), | ||
Electra(electra::ExecutionPayloadHeader), | ||
} | ||
|
||
impl VersionedExecutionPayloadHeader { | ||
|
@@ -380,6 +382,10 @@ impl VersionedExecutionPayloadHeader { | |
hash_tree_root::<crate::ssz::deneb::SSZExecutionPayloadHeader>( | ||
execution_payload_header.clone().try_into()?, | ||
), | ||
VersionedExecutionPayloadHeader::Electra(execution_payload_header) => | ||
hash_tree_root::<crate::ssz::electra::SSZExecutionPayloadHeader>( | ||
execution_payload_header.clone().try_into()?, | ||
), | ||
} | ||
} | ||
|
||
|
@@ -389,6 +395,8 @@ impl VersionedExecutionPayloadHeader { | |
execution_payload_header.block_hash, | ||
VersionedExecutionPayloadHeader::Deneb(execution_payload_header) => | ||
execution_payload_header.block_hash, | ||
VersionedExecutionPayloadHeader::Electra(execution_payload_header) => | ||
execution_payload_header.block_hash, | ||
} | ||
} | ||
|
||
|
@@ -398,6 +406,8 @@ impl VersionedExecutionPayloadHeader { | |
execution_payload_header.block_number, | ||
VersionedExecutionPayloadHeader::Deneb(execution_payload_header) => | ||
execution_payload_header.block_number, | ||
VersionedExecutionPayloadHeader::Electra(execution_payload_header) => | ||
execution_payload_header.block_number, | ||
} | ||
} | ||
|
||
|
@@ -407,6 +417,8 @@ impl VersionedExecutionPayloadHeader { | |
execution_payload_header.receipts_root, | ||
VersionedExecutionPayloadHeader::Deneb(execution_payload_header) => | ||
execution_payload_header.receipts_root, | ||
VersionedExecutionPayloadHeader::Electra(execution_payload_header) => | ||
execution_payload_header.receipts_root, | ||
} | ||
} | ||
} | ||
|
@@ -618,3 +630,59 @@ pub mod deneb { | |
pub excess_blob_gas: u64, // [New in Deneb:EIP4844] | ||
} | ||
} | ||
|
||
pub mod electra { | ||
use codec::{Decode, Encode}; | ||
use frame_support::{CloneNoBound, PartialEqNoBound, RuntimeDebugNoBound}; | ||
use scale_info::TypeInfo; | ||
#[cfg(feature = "std")] | ||
use serde::{Deserialize, Serialize}; | ||
use sp_core::{H160, H256, U256}; | ||
use sp_std::prelude::*; | ||
|
||
/// ExecutionPayloadHeader | ||
/// https://github.com/ethereum/consensus-specs/blob/dev/specs/electra/beacon-chain.md#executionpayloadheader | ||
#[derive( | ||
Default, Encode, Decode, CloneNoBound, PartialEqNoBound, RuntimeDebugNoBound, TypeInfo, | ||
)] | ||
#[cfg_attr( | ||
feature = "std", | ||
derive(Serialize, Deserialize), | ||
serde(deny_unknown_fields, bound(serialize = ""), bound(deserialize = "")) | ||
)] | ||
#[codec(mel_bound())] | ||
pub struct ExecutionPayloadHeader { | ||
pub parent_hash: H256, | ||
pub fee_recipient: H160, | ||
pub state_root: H256, | ||
pub receipts_root: H256, | ||
#[cfg_attr( | ||
feature = "std", | ||
serde(deserialize_with = "crate::serde_utils::from_hex_to_bytes") | ||
)] | ||
pub logs_bloom: Vec<u8>, | ||
pub prev_randao: H256, | ||
pub block_number: u64, | ||
pub gas_limit: u64, | ||
pub gas_used: u64, | ||
pub timestamp: u64, | ||
#[cfg_attr( | ||
feature = "std", | ||
serde(deserialize_with = "crate::serde_utils::from_hex_to_bytes") | ||
)] | ||
pub extra_data: Vec<u8>, | ||
#[cfg_attr( | ||
feature = "std", | ||
serde(deserialize_with = "crate::serde_utils::from_int_to_u256") | ||
)] | ||
pub base_fee_per_gas: U256, | ||
pub block_hash: H256, | ||
pub transactions_root: H256, | ||
pub withdrawals_root: H256, | ||
pub blob_gas_used: u64, | ||
pub excess_blob_gas: u64, | ||
pub deposit_requests_root: H256, // [New in Electra:EIP6110] | ||
pub withdrawal_requests_root: H256, // [New in Electra:EIP7002:EIP7251] | ||
pub consolidation_requests_root: H256, // [New in Electra:EIP7251] | ||
} | ||
} |