1use bytes::Bytes;
11use libssz::{SszDecode, SszEncode};
12use libssz_derive::{HashTreeRoot, SszDecode, SszEncode};
13use libssz_merkle::{
14 HashTreeRoot, Node, Sha256Hasher, merkleize_progressive, mix_in_active_fields,
15};
16use libssz_types::{ProgressiveList, SszList, SszVector};
17
18use super::requests::EncodedRequests;
19
20const MAX_EXTRA_DATA_BYTES: usize = 32;
28
29const DEPOSIT_REQUEST_TYPE: u8 = 0x00;
32const WITHDRAWAL_REQUEST_TYPE: u8 = 0x01;
33const CONSOLIDATION_REQUEST_TYPE: u8 = 0x02;
34const BUILDER_DEPOSIT_REQUEST_TYPE: u8 = 0x03;
35const BUILDER_EXIT_REQUEST_TYPE: u8 = 0x04;
36
37#[derive(Debug, Clone, Copy, PartialEq, Eq)]
45#[repr(transparent)]
46pub struct Bytes20(pub [u8; 20]);
47
48impl SszEncode for Bytes20 {
49 fn is_fixed_size() -> bool {
50 true
51 }
52 fn fixed_size() -> usize {
53 20
54 }
55 fn encoded_len(&self) -> usize {
56 20
57 }
58 fn ssz_append(&self, buf: &mut Vec<u8>) {
59 self.0.ssz_append(buf);
60 }
61}
62
63impl SszDecode for Bytes20 {
64 fn is_fixed_size() -> bool {
65 true
66 }
67 fn fixed_size() -> usize {
68 20
69 }
70 fn from_ssz_bytes(bytes: &[u8]) -> Result<Self, libssz::DecodeError> {
71 <[u8; 20]>::from_ssz_bytes(bytes).map(Self)
72 }
73}
74
75impl HashTreeRoot for Bytes20 {
76 fn hash_tree_root(&self, _hasher: &impl Sha256Hasher) -> libssz_merkle::Node {
77 let mut node = [0u8; 32];
78 node[..20].copy_from_slice(&self.0);
79 node
80 }
81}
82
83impl From<[u8; 20]> for Bytes20 {
84 fn from(bytes: [u8; 20]) -> Self {
85 Self(bytes)
86 }
87}
88
89impl From<Bytes20> for [u8; 20] {
90 fn from(b: Bytes20) -> Self {
91 b.0
92 }
93}
94
95pub const BYTES_PER_LOGS_BLOOM: usize = 256;
102
103pub type LogsBloom = SszVector<u8, BYTES_PER_LOGS_BLOOM>;
105
106#[derive(Debug, Clone, PartialEq, Eq, SszEncode, SszDecode, HashTreeRoot)]
110pub struct Withdrawal {
111 pub index: u64,
112 pub validator_index: u64,
113 pub address: Bytes20,
114 pub amount: u64,
115}
116
117#[derive(Debug, Clone, PartialEq, Eq, SszEncode, SszDecode, HashTreeRoot)]
119pub struct DepositRequest {
120 pub pubkey: [u8; 48],
121 pub withdrawal_credentials: [u8; 32],
122 pub amount: u64,
123 pub signature: [u8; 96],
124 pub index: u64,
125}
126
127#[derive(Debug, Clone, PartialEq, Eq, SszEncode, SszDecode, HashTreeRoot)]
129pub struct WithdrawalRequest {
130 pub source_address: Bytes20,
131 pub validator_pubkey: [u8; 48],
132 pub amount: u64,
133}
134
135#[derive(Debug, Clone, PartialEq, Eq, SszEncode, SszDecode, HashTreeRoot)]
137pub struct ConsolidationRequest {
138 pub source_address: Bytes20,
139 pub source_pubkey: [u8; 48],
140 pub target_pubkey: [u8; 48],
141}
142
143#[derive(Debug, Clone, PartialEq, Eq, SszEncode, SszDecode, HashTreeRoot)]
145pub struct BuilderDepositRequest {
146 pub pubkey: [u8; 48],
147 pub withdrawal_credentials: [u8; 32],
148 pub amount: u64,
149 pub signature: [u8; 96],
150}
151
152#[derive(Debug, Clone, PartialEq, Eq, SszEncode, SszDecode, HashTreeRoot)]
154pub struct BuilderExitRequest {
155 pub source_address: Bytes20,
156 pub pubkey: [u8; 48],
157}
158
159#[derive(Debug, Clone, PartialEq, Eq, SszEncode, SszDecode)]
169pub struct ExecutionPayload {
170 pub parent_hash: [u8; 32],
171 pub fee_recipient: Bytes20,
172 pub state_root: [u8; 32],
173 pub receipts_root: [u8; 32],
174 pub logs_bloom: LogsBloom,
175 pub prev_randao: [u8; 32],
176 pub block_number: u64,
177 pub gas_limit: u64,
178 pub gas_used: u64,
179 pub timestamp: u64,
180 pub extra_data: SszList<u8, MAX_EXTRA_DATA_BYTES>,
181 pub base_fee_per_gas: [u8; 32],
183 pub block_hash: [u8; 32],
184 pub transactions: ProgressiveList<ProgressiveList<u8>>,
185 pub withdrawals: ProgressiveList<Withdrawal>,
186 pub blob_gas_used: u64,
187 pub excess_blob_gas: u64,
188 pub block_access_list: ProgressiveList<u8>,
190 pub slot_number: u64,
194}
195
196fn progressive_container_root<const N: usize>(
207 hasher: &impl Sha256Hasher,
208 field_roots: [Node; N],
209) -> Node {
210 let root = merkleize_progressive(hasher, &field_roots);
211 mix_in_active_fields(hasher, &root, &[true; N])
212}
213
214impl HashTreeRoot for ExecutionPayload {
215 fn hash_tree_root(&self, hasher: &impl Sha256Hasher) -> Node {
216 let Self {
221 parent_hash,
222 fee_recipient,
223 state_root,
224 receipts_root,
225 logs_bloom,
226 prev_randao,
227 block_number,
228 gas_limit,
229 gas_used,
230 timestamp,
231 extra_data,
232 base_fee_per_gas,
233 block_hash,
234 transactions,
235 withdrawals,
236 blob_gas_used,
237 excess_blob_gas,
238 block_access_list,
239 slot_number,
240 } = self;
241 progressive_container_root(
242 hasher,
243 [
244 parent_hash.hash_tree_root(hasher),
245 fee_recipient.hash_tree_root(hasher),
246 state_root.hash_tree_root(hasher),
247 receipts_root.hash_tree_root(hasher),
248 logs_bloom.hash_tree_root(hasher),
249 prev_randao.hash_tree_root(hasher),
250 block_number.hash_tree_root(hasher),
251 gas_limit.hash_tree_root(hasher),
252 gas_used.hash_tree_root(hasher),
253 timestamp.hash_tree_root(hasher),
254 extra_data.hash_tree_root(hasher),
255 base_fee_per_gas.hash_tree_root(hasher),
256 block_hash.hash_tree_root(hasher),
257 transactions.hash_tree_root(hasher),
258 withdrawals.hash_tree_root(hasher),
259 blob_gas_used.hash_tree_root(hasher),
260 excess_blob_gas.hash_tree_root(hasher),
261 block_access_list.hash_tree_root(hasher),
262 slot_number.hash_tree_root(hasher),
263 ],
264 )
265 }
266}
267
268#[derive(Debug, Clone, PartialEq, Eq, SszEncode, SszDecode)]
276pub struct ExecutionRequests {
277 pub deposits: ProgressiveList<DepositRequest>,
278 pub withdrawals: ProgressiveList<WithdrawalRequest>,
279 pub consolidations: ProgressiveList<ConsolidationRequest>,
280 pub builder_deposits: ProgressiveList<BuilderDepositRequest>,
281 pub builder_exits: ProgressiveList<BuilderExitRequest>,
282}
283
284impl ExecutionRequests {
285 pub fn to_encoded_requests(&self) -> Vec<EncodedRequests> {
292 fn encode<T: SszEncode>(
293 type_byte: u8,
294 items: impl IntoIterator<Item = T>,
295 ) -> EncodedRequests {
296 let mut buf = Vec::new();
297 buf.push(type_byte);
298 for item in items {
299 item.ssz_append(&mut buf);
300 }
301 EncodedRequests(Bytes::from(buf))
302 }
303
304 vec![
305 encode(DEPOSIT_REQUEST_TYPE, self.deposits.iter().cloned()),
306 encode(WITHDRAWAL_REQUEST_TYPE, self.withdrawals.iter().cloned()),
307 encode(
308 CONSOLIDATION_REQUEST_TYPE,
309 self.consolidations.iter().cloned(),
310 ),
311 encode(
312 BUILDER_DEPOSIT_REQUEST_TYPE,
313 self.builder_deposits.iter().cloned(),
314 ),
315 encode(
316 BUILDER_EXIT_REQUEST_TYPE,
317 self.builder_exits.iter().cloned(),
318 ),
319 ]
320 }
321}
322
323impl HashTreeRoot for ExecutionRequests {
324 fn hash_tree_root(&self, hasher: &impl Sha256Hasher) -> Node {
325 let Self {
327 deposits,
328 withdrawals,
329 consolidations,
330 builder_deposits,
331 builder_exits,
332 } = self;
333 progressive_container_root(
334 hasher,
335 [
336 deposits.hash_tree_root(hasher),
337 withdrawals.hash_tree_root(hasher),
338 consolidations.hash_tree_root(hasher),
339 builder_deposits.hash_tree_root(hasher),
340 builder_exits.hash_tree_root(hasher),
341 ],
342 )
343 }
344}
345
346pub const MAX_BLOB_COMMITMENTS_PER_BLOCK: usize = 4096;
350
351#[derive(Debug, Clone, PartialEq, Eq, SszEncode, SszDecode)]
362pub struct NewPayloadRequest {
363 pub execution_payload: ExecutionPayload,
364 pub versioned_hashes: SszList<[u8; 32], MAX_BLOB_COMMITMENTS_PER_BLOCK>,
365 pub parent_beacon_block_root: [u8; 32],
366 pub execution_requests: ExecutionRequests,
367}
368
369impl HashTreeRoot for NewPayloadRequest {
370 fn hash_tree_root(&self, hasher: &impl Sha256Hasher) -> Node {
371 let Self {
373 execution_payload,
374 versioned_hashes,
375 parent_beacon_block_root,
376 execution_requests,
377 } = self;
378 progressive_container_root(
379 hasher,
380 [
381 execution_payload.hash_tree_root(hasher),
382 versioned_hashes.hash_tree_root(hasher),
383 parent_beacon_block_root.hash_tree_root(hasher),
384 execution_requests.hash_tree_root(hasher),
385 ],
386 )
387 }
388}
389
390#[derive(Debug, Clone, PartialEq, Eq, SszEncode, SszDecode, HashTreeRoot)]
395pub struct PublicInput {
396 pub new_payload_request_root: [u8; 32],
397}
398
399impl NewPayloadRequest {
400 pub fn public_input(&self, hasher: &impl Sha256Hasher) -> PublicInput {
403 PublicInput {
404 new_payload_request_root: self.hash_tree_root(hasher),
405 }
406 }
407}
408
409const MAX_BYTES_PER_WITNESS_NODE: usize = 1_048_576; const MAX_BYTES_PER_CODE: usize = 16_777_216; const MAX_WITNESS_HEADERS: usize = 256;
426const MAX_BYTES_PER_HEADER: usize = 1_024; pub const STATELESS_INPUT_SCHEMA_ID: u16 = 0x1501;
456
457pub const STATELESS_INPUT_SCHEMA_ID_SIZE: usize = 2;
459
460#[derive(Debug, Clone, PartialEq, Eq, SszEncode, SszDecode, HashTreeRoot)]
471pub struct SszExecutionWitness {
472 pub state: ProgressiveList<SszList<u8, MAX_BYTES_PER_WITNESS_NODE>>,
473 pub codes: ProgressiveList<SszList<u8, MAX_BYTES_PER_CODE>>,
474 pub headers: SszList<SszList<u8, MAX_BYTES_PER_HEADER>, MAX_WITNESS_HEADERS>,
475}
476
477#[derive(Debug, Clone, PartialEq, Eq, SszEncode, SszDecode, HashTreeRoot)]
484pub struct SszStatelessInput {
485 pub new_payload_request: NewPayloadRequest,
486 pub witness: SszExecutionWitness,
487 pub chain_id: u64,
491}
492
493#[derive(Debug, Clone, Default, PartialEq, Eq, SszEncode, SszDecode)]
501pub struct SszStatelessValidationResult {
502 pub new_payload_request_root: [u8; 32],
503 pub successful_validation: bool,
504 pub chain_id: u64,
507 pub schema_id: u16,
511}
512
513impl HashTreeRoot for SszStatelessValidationResult {
514 fn hash_tree_root(&self, hasher: &impl Sha256Hasher) -> Node {
515 let Self {
517 new_payload_request_root,
518 successful_validation,
519 chain_id,
520 schema_id,
521 } = self;
522 progressive_container_root(
523 hasher,
524 [
525 new_payload_request_root.hash_tree_root(hasher),
526 successful_validation.hash_tree_root(hasher),
527 chain_id.hash_tree_root(hasher),
528 schema_id.hash_tree_root(hasher),
529 ],
530 )
531 }
532}
533
534impl SszExecutionWitness {
537 pub fn codes_as_vecs(&self) -> Vec<Vec<u8>> {
539 self.codes.iter().map(|c| c.to_vec()).collect()
540 }
541
542 pub fn headers_as_vecs(&self) -> Vec<Vec<u8>> {
544 self.headers.iter().map(|h| h.to_vec()).collect()
545 }
546
547 pub fn state_as_vecs(&self) -> Vec<Vec<u8>> {
549 self.state.iter().map(|n| n.to_vec()).collect()
550 }
551}
552
553#[cfg(test)]
554mod tests {
555 use super::*;
556 use libssz_merkle::Sha2Hasher;
557
558 const HASHER: Sha2Hasher = Sha2Hasher;
559
560 fn sample_payload() -> ExecutionPayload {
563 ExecutionPayload {
564 parent_hash: [1u8; 32],
565 fee_recipient: Bytes20([2u8; 20]),
566 state_root: [3u8; 32],
567 receipts_root: [4u8; 32],
568 logs_bloom: vec![0u8; 256].try_into().expect("logs_bloom length"),
569 prev_randao: [5u8; 32],
570 block_number: 42,
571 gas_limit: 30_000_000,
572 gas_used: 21_000,
573 timestamp: 1_700_000_000,
574 extra_data: vec![0xAB, 0xCD].try_into().expect("extra_data fits"),
575 base_fee_per_gas: {
576 let mut b = [0u8; 32];
577 b[0] = 7; b
579 },
580 block_hash: [6u8; 32],
581 transactions: vec![
582 vec![0xDE, 0xAD, 0xBE, 0xEF]
583 .try_into()
584 .expect("tx bytes fit"),
585 ]
586 .try_into()
587 .expect("txs fit"),
588 withdrawals: vec![Withdrawal {
589 index: 0,
590 validator_index: 1,
591 address: Bytes20([7u8; 20]),
592 amount: 1_000_000,
593 }]
594 .try_into()
595 .expect("withdrawals fit"),
596 blob_gas_used: 0,
597 excess_blob_gas: 0,
598 block_access_list: ProgressiveList::new(), slot_number: 0,
600 }
601 }
602
603 fn empty_requests() -> ExecutionRequests {
604 ExecutionRequests {
605 deposits: Vec::new().into(),
606 withdrawals: Vec::new().into(),
607 consolidations: Vec::new().into(),
608 builder_deposits: Vec::new().into(),
609 builder_exits: Vec::new().into(),
610 }
611 }
612
613 fn sample_request() -> NewPayloadRequest {
614 NewPayloadRequest {
615 execution_payload: sample_payload(),
616 versioned_hashes: SszList::new(),
617 parent_beacon_block_root: [8u8; 32],
618 execution_requests: empty_requests(),
619 }
620 }
621
622 #[test]
623 fn test_ssz_root_changes_with_different_data() {
624 let request1 = sample_request();
625 let mut request2 = sample_request();
626 request2.execution_payload.block_number = 99;
627
628 assert_ne!(
629 request1.hash_tree_root(&HASHER),
630 request2.hash_tree_root(&HASHER),
631 "Different payloads must produce different roots"
632 );
633 }
634
635 #[test]
636 fn test_ssz_root_is_deterministic() {
637 let request = sample_request();
638 let root1 = request.hash_tree_root(&HASHER);
639 let root2 = request.hash_tree_root(&HASHER);
640 assert_eq!(root1, root2, "Same request must produce same root");
641 }
642
643 #[test]
644 fn test_execution_requests_to_encoded_bytes() {
645 let requests = ExecutionRequests {
646 deposits: vec![DepositRequest {
647 pubkey: [0x11; 48],
648 withdrawal_credentials: [0x22; 32],
649 amount: 32_000_000_000,
650 signature: [0x33; 96],
651 index: 7,
652 }]
653 .into(),
654 withdrawals: vec![WithdrawalRequest {
655 source_address: Bytes20([0x44; 20]),
656 validator_pubkey: [0x55; 48],
657 amount: 1_000_000,
658 }]
659 .into(),
660 consolidations: vec![ConsolidationRequest {
661 source_address: Bytes20([0x66; 20]),
662 source_pubkey: [0x77; 48],
663 target_pubkey: [0x88; 48],
664 }]
665 .into(),
666 builder_deposits: ProgressiveList::new(),
667 builder_exits: ProgressiveList::new(),
668 };
669
670 let encoded = requests.to_encoded_requests();
671 assert_eq!(encoded.len(), 5, "must emit 5 EIP-7685 entries");
675
676 assert_eq!(encoded[0].0[0], DEPOSIT_REQUEST_TYPE);
678 assert_eq!(encoded[0].0.len(), 1 + 192);
679
680 assert_eq!(encoded[1].0[0], WITHDRAWAL_REQUEST_TYPE);
682 assert_eq!(encoded[1].0.len(), 1 + 76);
683
684 assert_eq!(encoded[2].0[0], CONSOLIDATION_REQUEST_TYPE);
686 assert_eq!(encoded[2].0.len(), 1 + 116);
687 }
688
689 fn list<T: SszEncode + SszDecode, const N: usize>(items: Vec<T>) -> SszList<T, N> {
692 let mut list = SszList::new();
693 for item in items {
694 list.push(item).expect("test list capacity exceeded");
695 }
696 list
697 }
698
699 fn round_trip<T: SszEncode + SszDecode + PartialEq + std::fmt::Debug>(value: &T) {
700 let mut buf = Vec::new();
701 value.ssz_append(&mut buf);
702 let decoded = T::from_ssz_bytes(&buf).expect("SSZ decode failed");
703 assert_eq!(*value, decoded, "round-trip mismatch");
704 }
705
706 #[test]
707 fn ssz_execution_witness_round_trip() {
708 let witness = SszExecutionWitness {
709 state: vec![list(vec![1u8, 2, 3]), list(vec![4u8, 5])].into(),
710 codes: vec![list(vec![0x60u8, 0x00, 0x60, 0x00, 0xf3])].into(),
711 headers: list(vec![list(vec![0xf9u8, 0x02, 0x11])]),
712 };
713 round_trip(&witness);
714 }
715
716 #[test]
717 fn ssz_execution_witness_empty_round_trip() {
718 let witness = SszExecutionWitness {
719 state: ProgressiveList::new(),
720 codes: ProgressiveList::new(),
721 headers: SszList::new(),
722 };
723 round_trip(&witness);
724 }
725
726 #[test]
727 fn ssz_execution_payload_has_block_access_list_round_trip() {
728 let payload = ExecutionPayload {
729 parent_hash: [0x11; 32],
730 fee_recipient: Bytes20([0x22; 20]),
731 state_root: [0x33; 32],
732 receipts_root: [0x44; 32],
733 logs_bloom: vec![0u8; 256].try_into().expect("logs_bloom length"),
734 prev_randao: [0x55; 32],
735 block_number: 7,
736 gas_limit: 30_000_000,
737 gas_used: 21_000,
738 timestamp: 1_700_000_000,
739 extra_data: list(vec![0xde, 0xad]),
740 base_fee_per_gas: [0u8; 32],
741 block_hash: [0x66; 32],
742 transactions: ProgressiveList::new(),
743 withdrawals: ProgressiveList::new(),
744 blob_gas_used: 0,
745 excess_blob_gas: 0,
746 block_access_list: vec![0x01u8, 0x02, 0x03].into(),
747 slot_number: 0,
748 };
749 round_trip(&payload);
750 assert_eq!(payload.block_access_list.len(), 3);
751 }
752
753 #[test]
754 fn ssz_stateless_validation_result_round_trip() {
755 let result = SszStatelessValidationResult {
756 new_payload_request_root: [0xab; 32],
757 successful_validation: true,
758 chain_id: 42,
759 schema_id: 0x1501,
760 };
761 round_trip(&result);
762
763 let result_false = SszStatelessValidationResult {
764 new_payload_request_root: [0x00; 32],
765 successful_validation: false,
766 chain_id: 1,
767 schema_id: 0x1501,
768 };
769 round_trip(&result_false);
770 }
771
772 const SOL_RESULT_SUCCESS_OFFSET: usize = 32;
780 const SOL_RESULT_CHAIN_ID_OFFSET: usize = 33;
784 const SOL_RESULT_SCHEMA_ID_OFFSET: usize = 41;
785 const SOL_RESULT_FIXED_LEN: usize = 43;
786 const SOL_EP_STATE_ROOT_OFFSET: usize = 52;
787 const SOL_EP_BLOCK_NUMBER_OFFSET: usize = 404;
788 const SOL_EP_GAS_LIMIT_OFFSET: usize = 412;
789 const SOL_EP_BLOCK_HASH_OFFSET: usize = 472;
790 const SOL_EP_BAL_OFFSET_POS: usize = 528;
793 const SOL_EP_SLOT_NUMBER_OFFSET: usize = 532;
794 const SOL_EP_FIXED_PREFIX_LEN: usize = 540;
795
796 fn u32_le(bytes: &[u8], off: usize) -> usize {
797 (bytes[off] as usize)
798 | ((bytes[off + 1] as usize) << 8)
799 | ((bytes[off + 2] as usize) << 16)
800 | ((bytes[off + 3] as usize) << 24)
801 }
802
803 fn sample_execution_payload() -> ExecutionPayload {
804 ExecutionPayload {
805 parent_hash: [0x11; 32],
806 fee_recipient: Bytes20([0x22; 20]),
807 state_root: [0x33; 32],
808 receipts_root: [0x44; 32],
809 logs_bloom: vec![0u8; 256].try_into().expect("bloom"),
810 prev_randao: [0x55; 32],
811 block_number: 7,
812 gas_limit: 30_000_000,
813 gas_used: 21_000,
814 timestamp: 1_700_000_000,
815 extra_data: SszList::new(),
816 base_fee_per_gas: [0u8; 32],
817 block_hash: [0x66; 32],
818 transactions: ProgressiveList::new(),
819 withdrawals: ProgressiveList::new(),
820 blob_gas_used: 0,
821 excess_blob_gas: 0,
822 block_access_list: ProgressiveList::new(),
823 slot_number: 0x7843,
824 }
825 }
826
827 #[test]
828 fn nativerollup_sol_result_layout_matches() {
829 let result = SszStatelessValidationResult {
833 new_payload_request_root: [0xAA; 32],
834 successful_validation: true,
835 chain_id: 0x1122334455667788,
836 schema_id: 0x1501,
837 };
838 let mut buf = Vec::new();
839 result.ssz_append(&mut buf);
840
841 assert_eq!(
842 buf.len(),
843 SOL_RESULT_FIXED_LEN,
844 "result must be exactly 43 fixed bytes; a variable tail means \
845 ChainConfig is still in there"
846 );
847 assert_eq!(
848 buf[SOL_RESULT_SUCCESS_OFFSET], 1,
849 "successful_validation must be byte 32"
850 );
851 let chain_id = u64::from_le_bytes(
852 buf[SOL_RESULT_CHAIN_ID_OFFSET..SOL_RESULT_CHAIN_ID_OFFSET + 8]
853 .try_into()
854 .unwrap(),
855 );
856 assert_eq!(
857 chain_id, 0x1122334455667788,
858 "chain_id must be a direct u64 LE read at 33"
859 );
860 let schema_id = u16::from_le_bytes(
861 buf[SOL_RESULT_SCHEMA_ID_OFFSET..SOL_RESULT_SCHEMA_ID_OFFSET + 2]
862 .try_into()
863 .unwrap(),
864 );
865 assert_eq!(schema_id, 0x1501, "schema_id must be a u16 LE read at 41");
866 }
867
868 #[test]
869 fn nativerollup_sol_ep_offsets_match() {
870 let ep = sample_execution_payload();
873 let npr = NewPayloadRequest {
874 execution_payload: ep,
875 versioned_hashes: SszList::new(),
876 parent_beacon_block_root: [0x00; 32],
877 execution_requests: ExecutionRequests {
878 deposits: ProgressiveList::new(),
879 withdrawals: ProgressiveList::new(),
880 consolidations: ProgressiveList::new(),
881 builder_deposits: ProgressiveList::new(),
882 builder_exits: ProgressiveList::new(),
883 },
884 };
885 let input = SszStatelessInput {
886 new_payload_request: npr,
887 witness: SszExecutionWitness {
888 state: ProgressiveList::new(),
889 codes: ProgressiveList::new(),
890 headers: SszList::new(),
891 },
892 chain_id: 1,
893 };
894 let mut buf = Vec::new();
895 input.ssz_append(&mut buf);
896
897 let npr_abs = u32_le(&buf, 0);
902 let ep_abs = npr_abs + u32_le(&buf, npr_abs);
904 let actual_block_number = u64::from_le_bytes(
906 buf[ep_abs + SOL_EP_BLOCK_NUMBER_OFFSET..ep_abs + SOL_EP_BLOCK_NUMBER_OFFSET + 8]
907 .try_into()
908 .unwrap(),
909 );
910 assert_eq!(
911 actual_block_number, 7,
912 "block_number must be at EP offset 404, actual offset produces: {}",
913 actual_block_number
914 );
915 let actual_gas_limit = u64::from_le_bytes(
916 buf[ep_abs + SOL_EP_GAS_LIMIT_OFFSET..ep_abs + SOL_EP_GAS_LIMIT_OFFSET + 8]
917 .try_into()
918 .unwrap(),
919 );
920 assert_eq!(
921 actual_gas_limit, 30_000_000,
922 "gas_limit must be at EP offset 412, actual offset produces: {}",
923 actual_gas_limit
924 );
925 assert_eq!(
926 &buf[ep_abs + SOL_EP_STATE_ROOT_OFFSET..ep_abs + SOL_EP_STATE_ROOT_OFFSET + 32],
927 &[0x33; 32],
928 "state_root @52"
929 );
930 assert_eq!(
931 &buf[ep_abs + SOL_EP_BLOCK_HASH_OFFSET..ep_abs + SOL_EP_BLOCK_HASH_OFFSET + 32],
932 &[0x66; 32],
933 "block_hash @472"
934 );
935 assert_eq!(
940 u32_le(&buf, ep_abs + SOL_EP_BAL_OFFSET_POS),
941 SOL_EP_FIXED_PREFIX_LEN,
942 "block_access_list offset slot @EP+528 must equal the EP fixed-prefix length (540)",
943 );
944 assert_eq!(
946 u64::from_le_bytes(
947 buf[ep_abs + SOL_EP_SLOT_NUMBER_OFFSET..ep_abs + SOL_EP_SLOT_NUMBER_OFFSET + 8]
948 .try_into()
949 .unwrap()
950 ),
951 0x7843,
952 "slot_number must be readable at EP+532",
953 );
954 }
955}