@@ -15,6 +15,7 @@ const processOperations = @import("./process_operations.zig").processOperations;
15
15
const processRandao = @import ("./process_randao.zig" ).processRandao ;
16
16
const processSyncAggregate = @import ("./process_sync_committee.zig" ).processSyncAggregate ;
17
17
const processWithdrawals = @import ("./process_withdrawals.zig" ).processWithdrawals ;
18
+ const getExpectedWithdrawals = @import ("./process_withdrawals.zig" ).getExpectedWithdrawals ;
18
19
const ProcessBlockOpts = @import ("./types.zig" ).ProcessBlockOpts ;
19
20
const isExecutionEnabled = @import ("../utils/execution.zig" ).isExecutionEnabled ;
20
21
// TODO: proposer reward api
@@ -27,7 +28,7 @@ pub fn processBlock(
27
28
// TODO: support BlindedBeaconBlock
28
29
block : * const SignedBlock ,
29
30
external_data : BlockExternalData ,
30
- opts : ? ProcessBlockOpts ,
31
+ opts : ProcessBlockOpts ,
31
32
// TODO: metrics
32
33
) ! void {
33
34
const state = cached_state .state ;
@@ -40,33 +41,45 @@ pub fn processBlock(
40
41
// TODO Deneb: Allow to disable withdrawals for interop testing
41
42
// https://github.com/ethereum/consensus-specs/blob/b62c9e877990242d63aa17a2a59a49bc649a2f2e/specs/eip4844/beacon-chain.md#disabling-withdrawals
42
43
if (state .isPostCapella ()) {
44
+ const expected_withdrawals_result = try getExpectedWithdrawals (allocator , cached_state );
45
+ const body = block .getBeaconBlockBody ();
46
+ switch (body ) {
47
+ .unblinded = > | b | {
48
+ const actual_withdrawals = b .getExecutionPayload ().getWithdrawals ();
49
+ std .debug .assert (expected_withdrawals_result .withdrawals .items .len == actual_withdrawals .items .len );
50
+ for (expected_withdrawals_result .withdrawals .items , actual_withdrawals .items ) | ew , pw | {
51
+ _ = ew ;
52
+ _ = pw ;
53
+ // TODO(bing): equals API
54
+ // assert(ew == pw)
55
+ }
56
+ },
57
+ .blinded = > | b | {
58
+ const header = b .getExecutionPayloadHeader ();
59
+ var expected : [32 ]u8 = undefined ;
60
+ try ssz .capella .Withdrawals .hashTreeRoot (allocator , & expected_withdrawals_result .withdrawals , & expected );
61
+ var actual = header .getWithdrawalsRoot ();
62
+ std .debug .assert (std .mem .eql (u8 , & expected , & actual ));
63
+ },
64
+ }
43
65
try processWithdrawals (
44
66
allocator ,
45
67
cached_state ,
46
- & block . getBeaconBlockBody (). getExecutionPayload () ,
68
+ expected_withdrawals_result ,
47
69
);
48
70
}
49
71
50
- switch (block ) {
51
- .signed_beacon_block = > | b | try processExecutionPayload (
52
- allocator ,
53
- cached_state ,
54
- b .getBeaconBlockBody (),
55
- external_data ,
56
- ),
57
- .signed_blinded_beacon_block = > | b | try processExecutionPayloadHeader (
58
- allocator ,
59
- cached_state ,
60
- b ,
61
- external_data ,
62
- ),
63
- }
64
- try processExecutionPayload ();
72
+ try processExecutionPayload (
73
+ allocator ,
74
+ cached_state ,
75
+ block .getBeaconBlockBody (),
76
+ external_data ,
77
+ );
65
78
}
66
79
67
- try processRandao (state , block , opts .verify_signature );
68
- try processEth1Data (state , block .getBeaconBlockBody ().getEth1Data ());
69
- try processOperations (cached_state , block .getBeaconBlockBody (), external_data );
80
+ try processRandao (cached_state , & block . getBeaconBlockBody (), block . getProposerIndex () , opts .verify_signature );
81
+ try processEth1Data (allocator , cached_state , block .getBeaconBlockBody ().getEth1Data ());
82
+ try processOperations (allocator , cached_state , & block .getBeaconBlockBody (), opts );
70
83
if (state .isPostAltair ()) {
71
84
try processSyncAggregate (cached_state , block , opts .verify_signature );
72
85
}
0 commit comments