@@ -10,7 +10,10 @@ use alloy::{
10
10
} ;
11
11
use anyhow:: { anyhow, ensure} ;
12
12
use ethportal_api:: {
13
- consensus:: execution_payload:: ExecutionPayloadDeneb ,
13
+ consensus:: {
14
+ execution_payload:: { ExecutionPayloadDeneb , ExecutionPayloadElectra } ,
15
+ execution_requests:: ExecutionRequests ,
16
+ } ,
14
17
types:: {
15
18
consensus:: execution_payload:: { ExecutionPayloadBellatrix , ExecutionPayloadCapella } ,
16
19
execution:: accumulator:: EpochAccumulator ,
@@ -134,6 +137,46 @@ pub fn post_deneb_execution_payload_to_header(
134
137
Ok ( header)
135
138
}
136
139
140
+ pub fn post_electra_execution_payload_to_header (
141
+ payload : & ExecutionPayloadElectra ,
142
+ parent_beacon_block_root : B256 ,
143
+ transactions : & [ TxEnvelope ] ,
144
+ withdrawals : & [ Withdrawal ] ,
145
+ _requests : & ExecutionRequests ,
146
+ ) -> anyhow:: Result < Header > {
147
+ let transactions_root = calculate_transaction_root ( transactions) ;
148
+ let withdrawals_root = calculate_withdrawals_root ( withdrawals) ;
149
+ let header = Header {
150
+ parent_hash : payload. parent_hash ,
151
+ ommers_hash : EMPTY_UNCLE_ROOT_HASH ,
152
+ beneficiary : payload. fee_recipient ,
153
+ state_root : payload. state_root ,
154
+ transactions_root,
155
+ receipts_root : payload. receipts_root ,
156
+ logs_bloom : Bloom :: from_slice ( payload. logs_bloom . to_vec ( ) . as_slice ( ) ) ,
157
+ difficulty : U256 :: ZERO ,
158
+ number : payload. block_number ,
159
+ gas_limit : payload. gas_limit ,
160
+ gas_used : payload. gas_used ,
161
+ timestamp : payload. timestamp ,
162
+ extra_data : payload. extra_data . to_vec ( ) . into ( ) ,
163
+ mix_hash : payload. prev_randao ,
164
+ nonce : B64 :: ZERO ,
165
+ base_fee_per_gas : Some ( payload. base_fee_per_gas . to ( ) ) ,
166
+ withdrawals_root : Some ( withdrawals_root) ,
167
+ blob_gas_used : Some ( payload. blob_gas_used ) ,
168
+ excess_blob_gas : Some ( payload. excess_blob_gas ) ,
169
+ parent_beacon_block_root : Some ( parent_beacon_block_root) ,
170
+ requests_hash : None , // TODO
171
+ } ;
172
+
173
+ ensure ! (
174
+ payload. block_hash == header. hash_slow( ) ,
175
+ "Block hash mismatch"
176
+ ) ;
177
+ Ok ( header)
178
+ }
179
+
137
180
/// Lookup the epoch accumulator & epoch hash for the given epoch index.
138
181
pub async fn lookup_epoch_acc (
139
182
epoch_index : u64 ,
0 commit comments