14
14
package tech .pegasys .teku .spec .genesis ;
15
15
16
16
import static tech .pegasys .teku .spec .config .SpecConfig .GENESIS_EPOCH ;
17
+ import static tech .pegasys .teku .spec .config .SpecConfigElectra .UNSET_DEPOSIT_RECEIPTS_START_INDEX ;
17
18
18
19
import it .unimi .dsi .fastutil .objects .Object2IntMap ;
19
20
import it .unimi .dsi .fastutil .objects .Object2IntOpenHashMap ;
29
30
import tech .pegasys .teku .spec .SpecMilestone ;
30
31
import tech .pegasys .teku .spec .SpecVersion ;
31
32
import tech .pegasys .teku .spec .config .SpecConfig ;
32
- import tech .pegasys .teku .spec .config .SpecConfigElectra ;
33
33
import tech .pegasys .teku .spec .datastructures .blocks .BeaconBlockHeader ;
34
34
import tech .pegasys .teku .spec .datastructures .blocks .Eth1Data ;
35
35
import tech .pegasys .teku .spec .datastructures .execution .ExecutionPayloadHeader ;
@@ -95,7 +95,7 @@ public void updateCandidateState(
95
95
// Process deposits
96
96
deposits .forEach (
97
97
deposit -> {
98
- LOG .trace ("About to process deposit: {}" , depositDataList :: size );
98
+ LOG .trace ("About to process deposit: {}" , depositDataList . size () );
99
99
depositDataList .append (deposit .getData ());
100
100
101
101
// Skip verifying the merkle proof as these deposits come directly from an Eth1 event.
@@ -123,17 +123,19 @@ private void consumePendingBalance(
123
123
genesisSpec .beaconStateAccessors (),
124
124
schemaDefinitionsElectra );
125
125
final List <PendingBalanceDeposit > pendingBalanceDeposits =
126
- stateElectra .getPendingBalanceDeposits ().stream (). toList ();
126
+ stateElectra .getPendingBalanceDeposits ().asList ();
127
127
128
128
final UInt64 depositAmount =
129
129
pendingBalanceDeposits .stream ()
130
130
.filter (z -> z .getIndex () == validatorIndex )
131
- .map (z -> z . getAmount () )
131
+ .map (PendingBalanceDeposit :: getAmount )
132
132
.reduce (UInt64 ::plus )
133
- .get ();
134
- if (depositAmount .isGreaterThanOrEqualTo (
135
- SpecConfigElectra .required (specConfig ).getMinActivationBalance ())) {
136
- mutatorsElectra .increaseBalance (state , validatorIndex , depositAmount );
133
+ .orElse (UInt64 .ZERO );
134
+ mutatorsElectra .increaseBalance (state , validatorIndex , depositAmount );
135
+ if (pendingBalanceDeposits .isEmpty ()) {
136
+ stateElectra .setPendingBalanceDeposits (
137
+ schemaDefinitionsElectra .getPendingBalanceDepositsSchema ().createFromElements (List .of ()));
138
+ } else {
137
139
stateElectra .setPendingBalanceDeposits (
138
140
schemaDefinitionsElectra
139
141
.getPendingBalanceDepositsSchema ()
@@ -150,7 +152,7 @@ private void processActivation(final Deposit deposit) {
150
152
// Could be absent if the deposit was invalid
151
153
return ;
152
154
}
153
- Validator validator = state .getValidators ().get (index );
155
+ final Validator validator = state .getValidators ().get (index );
154
156
if (validator .getActivationEpoch ().equals (GENESIS_EPOCH )) {
155
157
// Validator is already activated (and thus already has the max effective balance)
156
158
return ;
@@ -159,6 +161,8 @@ private void processActivation(final Deposit deposit) {
159
161
if (genesisSpec .getMilestone ().equals (SpecMilestone .ELECTRA )) {
160
162
consumePendingBalance (
161
163
MutableBeaconStateElectra .required (state ), specConfig , genesisSpec , index );
164
+ MutableBeaconStateElectra .required (state )
165
+ .setDepositReceiptsStartIndex (UNSET_DEPOSIT_RECEIPTS_START_INDEX );
162
166
}
163
167
final UInt64 balance = state .getBalances ().getElement (index );
164
168
final UInt64 effectiveBalance =
0 commit comments