Skip to content

Commit

Permalink
Fix rebase issues
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov committed Oct 10, 2024
1 parent 571d0c6 commit 00fbe20
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 70 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title" : "BeaconStateEip7732",
"type" : "object",
"required" : [ "genesis_time", "genesis_validators_root", "slot", "fork", "latest_block_header", "block_roots", "state_roots", "historical_roots", "eth1_data", "eth1_data_votes", "eth1_deposit_index", "validators", "balances", "randao_mixes", "slashings", "previous_epoch_participation", "current_epoch_participation", "justification_bits", "previous_justified_checkpoint", "current_justified_checkpoint", "finalized_checkpoint", "inactivity_scores", "current_sync_committee", "next_sync_committee", "latest_execution_payload_header", "next_withdrawal_index", "next_withdrawal_validator_index", "historical_summaries", "deposit_requests_start_index", "deposit_balance_to_consume", "exit_balance_to_consume", "earliest_exit_epoch", "consolidation_balance_to_consume", "earliest_consolidation_epoch", "pending_balance_deposits", "pending_partial_withdrawals", "pending_consolidations", "latest_block_hash", "latest_full_slot", "latest_withdrawals_root" ],
"required" : [ "genesis_time", "genesis_validators_root", "slot", "fork", "latest_block_header", "block_roots", "state_roots", "historical_roots", "eth1_data", "eth1_data_votes", "eth1_deposit_index", "validators", "balances", "randao_mixes", "slashings", "previous_epoch_participation", "current_epoch_participation", "justification_bits", "previous_justified_checkpoint", "current_justified_checkpoint", "finalized_checkpoint", "inactivity_scores", "current_sync_committee", "next_sync_committee", "latest_execution_payload_header", "next_withdrawal_index", "next_withdrawal_validator_index", "historical_summaries", "deposit_requests_start_index", "deposit_balance_to_consume", "exit_balance_to_consume", "earliest_exit_epoch", "consolidation_balance_to_consume", "earliest_consolidation_epoch", "pending_deposits", "pending_partial_withdrawals", "pending_consolidations", "latest_block_hash", "latest_full_slot", "latest_withdrawals_root" ],
"properties" : {
"genesis_time" : {
"type" : "string",
Expand Down Expand Up @@ -207,10 +207,10 @@
"example" : "1",
"format" : "uint64"
},
"pending_balance_deposits" : {
"pending_deposits" : {
"type" : "array",
"items" : {
"$ref" : "#/components/schemas/PendingBalanceDeposit"
"$ref" : "#/components/schemas/PendingDeposit"
}
},
"pending_partial_withdrawals" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import tech.pegasys.teku.api.schema.altair.BeaconStateAltair;
import tech.pegasys.teku.api.schema.altair.SyncCommittee;
import tech.pegasys.teku.api.schema.capella.HistoricalSummary;
import tech.pegasys.teku.api.schema.electra.PendingBalanceDeposit;
import tech.pegasys.teku.api.schema.electra.PendingConsolidation;
import tech.pegasys.teku.api.schema.electra.PendingDeposit;
import tech.pegasys.teku.api.schema.electra.PendingPartialWithdrawal;
import tech.pegasys.teku.infrastructure.ssz.collections.SszBitvector;
import tech.pegasys.teku.infrastructure.ssz.schema.SszListSchema;
Expand Down Expand Up @@ -77,8 +77,8 @@ public class BeaconStateEip7732 extends BeaconStateAltair {
@JsonProperty("earliest_consolidation_epoch")
public final UInt64 earliestConsolidationEpoch;

@JsonProperty("pending_balance_deposits")
public final List<PendingBalanceDeposit> pendingBalanceDeposits;
@JsonProperty("pending_deposits")
public final List<PendingDeposit> pendingDeposits;

@JsonProperty("pending_partial_withdrawals")
public final List<PendingPartialWithdrawal> pendingPartialWithdrawals;
Expand Down Expand Up @@ -142,8 +142,7 @@ public BeaconStateEip7732(
@JsonProperty("earliest_exit_epoch") final UInt64 earliestExitEpoch,
@JsonProperty("consolidation_balance_to_consume") final UInt64 consolidationBalanceToConsume,
@JsonProperty("earliest_consolidation_epoch") final UInt64 earliestConsolidationEpoch,
@JsonProperty("pending_balance_deposits")
final List<PendingBalanceDeposit> pendingBalanceDeposits,
@JsonProperty("pending_deposits") final List<PendingDeposit> pendingDeposits,
@JsonProperty("pending_partial_withdrawals")
final List<PendingPartialWithdrawal> pendingPartialWithdrawals,
@JsonProperty("pending_consolidations")
Expand Down Expand Up @@ -186,7 +185,7 @@ public BeaconStateEip7732(
this.earliestExitEpoch = earliestExitEpoch;
this.consolidationBalanceToConsume = consolidationBalanceToConsume;
this.earliestConsolidationEpoch = earliestConsolidationEpoch;
this.pendingBalanceDeposits = pendingBalanceDeposits;
this.pendingDeposits = pendingDeposits;
this.pendingPartialWithdrawals = pendingPartialWithdrawals;
this.pendingConsolidations = pendingConsolidations;
this.latestBlockHash = latestBlockHash;
Expand All @@ -213,8 +212,7 @@ public BeaconStateEip7732(final BeaconState beaconState) {
this.earliestExitEpoch = eip7732.getEarliestExitEpoch();
this.consolidationBalanceToConsume = eip7732.getConsolidationBalanceToConsume();
this.earliestConsolidationEpoch = eip7732.getEarliestConsolidationEpoch();
this.pendingBalanceDeposits =
eip7732.getPendingBalanceDeposits().stream().map(PendingBalanceDeposit::new).toList();
this.pendingDeposits = eip7732.getPendingDeposits().stream().map(PendingDeposit::new).toList();
this.pendingPartialWithdrawals =
eip7732.getPendingPartialWithdrawals().stream().map(PendingPartialWithdrawal::new).toList();
this.pendingConsolidations =
Expand Down Expand Up @@ -245,7 +243,7 @@ protected void applyAdditionalFields(
.getHistoricalSummariesSchema(),
BeaconStateSchemaEip7732.required(
mutableBeaconStateEip7732.getBeaconStateSchema())
.getPendingBalanceDepositsSchema(),
.getPendingDepositsSchema(),
BeaconStateSchemaEip7732.required(
mutableBeaconStateEip7732.getBeaconStateSchema())
.getPendingPartialWithdrawalsSchema(),
Expand All @@ -264,8 +262,8 @@ protected static void applyEip7732Fields(
tech.pegasys.teku.spec.datastructures.state.versions.capella.HistoricalSummary, ?>
historicalSummariesSchema,
final SszListSchema<
tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingBalanceDeposit, ?>
pendingBalanceDepositsSchema,
tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingDeposit, ?>
pendingDepositsSchema,
final SszListSchema<
tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingPartialWithdrawal,
?>
Expand Down Expand Up @@ -295,12 +293,10 @@ protected static void applyEip7732Fields(
state.setEarliestExitEpoch(instance.earliestExitEpoch);
state.setConsolidationBalanceToConsume(instance.consolidationBalanceToConsume);
state.setEarliestConsolidationEpoch(instance.earliestConsolidationEpoch);
state.setPendingBalanceDeposits(
pendingBalanceDepositsSchema.createFromElements(
instance.pendingBalanceDeposits.stream()
.map(
pendingBalanceDeposit ->
pendingBalanceDeposit.asInternalPendingBalanceDeposit(specVersion))
state.setPendingDeposits(
pendingDepositsSchema.createFromElements(
instance.pendingDeposits.stream()
.map(pendingDeposit -> pendingDeposit.asInternalPendingDeposit(specVersion))
.toList()));
state.setPendingPartialWithdrawals(
pendingPartialWithdrawalsSchema.createFromElements(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public UInt64 getMaxEffectiveBalanceElectra() {
}

@Override
public int getPendingBalanceDepositsLimit() {
return specConfigElectra.getPendingBalanceDepositsLimit();
public int getPendingDepositsLimit() {
return specConfigElectra.getPendingDepositsLimit();
}

@Override
Expand Down Expand Up @@ -106,6 +106,11 @@ public int getMaxPendingPartialsPerWithdrawalsSweep() {
return specConfigElectra.getMaxPendingPartialsPerWithdrawalsSweep();
}

@Override
public int getMaxPendingDepositsPerEpoch() {
return specConfigElectra.getMaxPendingDepositsPerEpoch();
}

@Override
public Optional<SpecConfigElectra> toVersionElectra() {
return Optional.of(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import static tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.electra.BeaconStateSchemaElectra.EARLIEST_CONSOLIDATION_EPOCH_INDEX;
import static tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.electra.BeaconStateSchemaElectra.EARLIEST_EXIT_EPOCH_INDEX;
import static tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.electra.BeaconStateSchemaElectra.EXIT_BALANCE_TO_CONSUME_INDEX;
import static tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.electra.BeaconStateSchemaElectra.PENDING_BALANCE_DEPOSITS_INDEX;
import static tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.electra.BeaconStateSchemaElectra.PENDING_CONSOLIDATIONS_INDEX;
import static tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.electra.BeaconStateSchemaElectra.PENDING_DEPOSITS_INDEX;
import static tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.electra.BeaconStateSchemaElectra.PENDING_PARTIAL_WITHDRAWALS_INDEX;

import com.google.common.annotations.VisibleForTesting;
Expand All @@ -47,8 +47,8 @@
import tech.pegasys.teku.spec.datastructures.state.beaconstate.common.BeaconStateFields;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.altair.BeaconStateSchemaAltair;
import tech.pegasys.teku.spec.datastructures.state.versions.capella.HistoricalSummary;
import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingBalanceDeposit;
import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingConsolidation;
import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingDeposit;
import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingPartialWithdrawal;

public class BeaconStateSchemaEip7732
Expand All @@ -65,8 +65,8 @@ public class BeaconStateSchemaEip7732
private static List<SszField> getUniqueFields(final SpecConfig specConfig) {
final HistoricalSummary.HistoricalSummarySchema historicalSummarySchema =
new HistoricalSummary.HistoricalSummarySchema();
final PendingBalanceDeposit.PendingBalanceDepositSchema pendingBalanceDepositSchema =
new PendingBalanceDeposit.PendingBalanceDepositSchema();
final PendingDeposit.PendingDepositSchema pendingDepositSchema =
new PendingDeposit.PendingDepositSchema();
final PendingPartialWithdrawal.PendingPartialWithdrawalSchema pendingPartialWithdrawalSchema =
new PendingPartialWithdrawal.PendingPartialWithdrawalSchema();
final SpecConfigEip7732 specConfigEip7732 = SpecConfigEip7732.required(specConfig);
Expand Down Expand Up @@ -127,14 +127,13 @@ private static List<SszField> getUniqueFields(final SpecConfig specConfig) {
EARLIEST_CONSOLIDATION_EPOCH_INDEX,
BeaconStateFields.EARLIEST_CONSOLIDATION_EPOCH,
() -> SszPrimitiveSchemas.UINT64_SCHEMA);
final SszField pendingBalanceDepositsField =
final SszField pendingDepositsField =
new SszField(
PENDING_BALANCE_DEPOSITS_INDEX,
BeaconStateFields.PENDING_BALANCE_DEPOSITS,
PENDING_DEPOSITS_INDEX,
BeaconStateFields.PENDING_DEPOSITS,
() ->
SszListSchema.create(
pendingBalanceDepositSchema,
specConfigEip7732.getPendingBalanceDepositsLimit()));
pendingDepositSchema, specConfigEip7732.getPendingDepositsLimit()));
final SszField pendingPartialWithdrawalsField =
new SszField(
PENDING_PARTIAL_WITHDRAWALS_INDEX,
Expand Down Expand Up @@ -179,7 +178,7 @@ private static List<SszField> getUniqueFields(final SpecConfig specConfig) {
earliestExitEpochField,
consolidationBalanceToConsumeField,
earliestConsolidationEpochField,
pendingBalanceDepositsField,
pendingDepositsField,
pendingPartialWithdrawalsField,
pendingConsolidationsField,
latestBlockHashField,
Expand Down Expand Up @@ -253,9 +252,9 @@ public BeaconStateEip7732Impl createFromBackingNode(final TreeNode node) {
}

@SuppressWarnings("unchecked")
public SszListSchema<PendingBalanceDeposit, ?> getPendingBalanceDepositsSchema() {
return (SszListSchema<PendingBalanceDeposit, ?>)
getChildSchema(getFieldIndex(BeaconStateFields.PENDING_BALANCE_DEPOSITS));
public SszListSchema<PendingDeposit, ?> getPendingDepositsSchema() {
return (SszListSchema<PendingDeposit, ?>)
getChildSchema(getFieldIndex(BeaconStateFields.PENDING_DEPOSITS));
}

@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@

import static tech.pegasys.teku.spec.config.SpecConfig.FAR_FUTURE_EPOCH;

import java.util.Comparator;
import java.util.stream.IntStream;
import org.apache.tuweni.bytes.Bytes32;
import tech.pegasys.teku.infrastructure.ssz.SszMutableList;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.spec.config.SpecConfigEip7732;
import tech.pegasys.teku.spec.config.SpecConfigElectra;
Expand Down Expand Up @@ -111,31 +108,10 @@ public BeaconStateEip7732 upgrade(final BeaconState preState) {
beaconStateAccessors.getConsolidationChurnLimit(state));
state.setEarliestConsolidationEpoch(
miscHelpersElectra.computeActivationExitEpoch(epoch));

final SszMutableList<Validator> validators = state.getValidators();

// Add validators that are not yet active to pending balance deposits
IntStream.range(0, validators.size())
.filter(
index -> validators.get(index).getActivationEpoch().equals(FAR_FUTURE_EPOCH))
.boxed()
.sorted(
Comparator.comparing(
index -> validators.get(index).getActivationEligibilityEpoch()))
.forEach(
index ->
beaconStateMutators.queueEntireBalanceAndResetValidator(state, index));

// Ensure early adopters of compounding credentials go through the activation churn
IntStream.range(0, validators.size())
.forEach(
index -> {
if (predicatesElectra.hasCompoundingWithdrawalCredential(
validators.get(index))) {
beaconStateMutators.queueExcessActiveBalance(state, index);
}
});

state.setPendingDeposits(preStateElectra.getPendingDeposits());
state.setPendingPartialWithdrawals(preStateElectra.getPendingPartialWithdrawals());
state.setPendingConsolidations(preStateElectra.getPendingConsolidations());
// ePBS
state.setLatestBlockHash(
preStateElectra.getLatestExecutionPayloadHeader().getBlockHash());
state.setLatestFullSlot(preState.getSlot());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
import tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.eip7732.BeaconStateEip7732;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.eip7732.BeaconStateSchemaEip7732;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.eip7732.MutableBeaconStateEip7732;
import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingBalanceDeposit;
import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingConsolidation;
import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingDeposit;
import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingPartialWithdrawal;

public class BeaconStateBuilderEip7732
Expand All @@ -56,7 +56,7 @@ public class BeaconStateBuilderEip7732

private UInt64 earliestConsolidationEpoch;

private SszList<PendingBalanceDeposit> pendingBalanceDeposits;
private SszList<PendingDeposit> pendingDeposits;
private SszList<PendingPartialWithdrawal> pendingPartialWithdrawals;
private SszList<PendingConsolidation> pendingConsolidations;

Expand Down Expand Up @@ -93,7 +93,7 @@ protected void setUniqueFields(final MutableBeaconStateEip7732 state) {
state.setEarliestExitEpoch(earliestExitEpoch);
state.setConsolidationBalanceToConsume(consolidationBalanceToConsume);
state.setEarliestConsolidationEpoch(earliestConsolidationEpoch);
state.setPendingBalanceDeposits(pendingBalanceDeposits);
state.setPendingDeposits(pendingDeposits);
state.setPendingPartialWithdrawals(pendingPartialWithdrawals);
state.setPendingConsolidations(pendingConsolidations);
state.setLatestBlockHash(latestBlockHash);
Expand Down Expand Up @@ -180,8 +180,7 @@ protected void initDefaults() {
this.earliestExitEpoch = UInt64.ZERO;
this.consolidationBalanceToConsume = UInt64.ZERO;
this.earliestConsolidationEpoch = UInt64.ZERO;
this.pendingBalanceDeposits =
schema.getPendingBalanceDepositsSchema().createFromElements(List.of());
this.pendingDeposits = schema.getPendingDepositsSchema().createFromElements(List.of());
this.pendingPartialWithdrawals =
schema.getPendingPartialWithdrawalsSchema().createFromElements(List.of());
this.pendingConsolidations =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

import com.google.common.annotations.VisibleForTesting;
import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.List;
import org.hyperledger.besu.plugin.services.MetricsSystem;
import org.hyperledger.besu.plugin.services.metrics.Counter;
import org.hyperledger.besu.plugin.services.metrics.LabelledMetric;
Expand All @@ -30,8 +30,8 @@
import tech.pegasys.teku.spec.datastructures.attestation.ValidatableAttestation;
import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSidecar;
import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock;
import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel;
import tech.pegasys.teku.spec.datastructures.operations.PayloadAttestationMessage;
import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel;
import tech.pegasys.teku.statetransition.blobs.BlockBlobSidecarsTrackerFactory;
import tech.pegasys.teku.statetransition.block.BlockImportChannel;
import tech.pegasys.teku.statetransition.validation.BlobSidecarGossipValidator;
Expand Down

0 comments on commit 00fbe20

Please sign in to comment.