Skip to content

Commit

Permalink
Merge branch 'master' into p2p-dump
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyeh committed Apr 11, 2024
2 parents f1ddf82 + 91b4e3d commit 5abd7e0
Show file tree
Hide file tree
Showing 11 changed files with 395 additions and 39 deletions.
51 changes: 25 additions & 26 deletions ethereum/spec/src/main/java/tech/pegasys/teku/spec/Spec.java
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,10 @@ public int getSyncCommitteeSize(final UInt64 slot) {

// Genesis
public BeaconState initializeBeaconStateFromEth1(
Bytes32 eth1BlockHash,
UInt64 eth1Timestamp,
List<? extends Deposit> deposits,
Optional<ExecutionPayloadHeader> payloadHeader) {
final Bytes32 eth1BlockHash,
final UInt64 eth1Timestamp,
final List<? extends Deposit> deposits,
final Optional<ExecutionPayloadHeader> payloadHeader) {
final GenesisGenerator genesisGenerator = createGenesisGenerator();
genesisGenerator.updateCandidateState(eth1BlockHash, eth1Timestamp, deposits);
payloadHeader.ifPresent(genesisGenerator::updateExecutionPayloadHeader);
Expand Down Expand Up @@ -415,7 +415,7 @@ public UInt64 getPreviousEpoch(final BeaconState state) {
return atState(state).beaconStateAccessors().getPreviousEpoch(state);
}

public Bytes32 getSeed(BeaconState state, UInt64 epoch, Bytes4 domainType)
public Bytes32 getSeed(final BeaconState state, final UInt64 epoch, final Bytes4 domainType)
throws IllegalArgumentException {
return atState(state).beaconStateAccessors().getSeed(state, epoch, domainType);
}
Expand All @@ -429,38 +429,35 @@ public UInt64 computeEpochAtSlot(final UInt64 slot) {
}

public UInt64 computeTimeAtSlot(final BeaconState state, final UInt64 slot) {
return computeTimeAtSlot(state.getGenesisTime(), slot);
return atSlot(slot).miscHelpers().computeTimeAtSlot(state.getGenesisTime(), slot);
}

public UInt64 computeTimeAtSlot(final UInt64 genesisTime, final UInt64 slot) {
return atSlot(slot).miscHelpers().computeTimeAtSlot(genesisTime, slot);
}

public Bytes computeSigningRoot(BeaconBlock block, Bytes32 domain) {
public Bytes computeSigningRoot(final BeaconBlock block, final Bytes32 domain) {
return atBlock(block).miscHelpers().computeSigningRoot(block, domain);
}

public Bytes computeSigningRoot(BeaconBlockHeader blockHeader, Bytes32 domain) {
public Bytes computeSigningRoot(final BeaconBlockHeader blockHeader, final Bytes32 domain) {
return atSlot(blockHeader.getSlot()).miscHelpers().computeSigningRoot(blockHeader, domain);
}

public Bytes computeSigningRoot(AggregateAndProof proof, Bytes32 domain) {
public Bytes computeSigningRoot(final AggregateAndProof proof, final Bytes32 domain) {
return atSlot(proof.getAggregate().getData().getSlot())
.miscHelpers()
.computeSigningRoot(proof, domain);
}

public Bytes computeSigningRoot(UInt64 slot, Bytes32 domain) {
public Bytes computeSigningRoot(final UInt64 slot, final Bytes32 domain) {
return atSlot(slot).miscHelpers().computeSigningRoot(slot, domain);
}

public Bytes computeBuilderApplicationSigningRoot(UInt64 slot, Merkleizable object) {
public Bytes computeBuilderApplicationSigningRoot(final UInt64 slot, final Merkleizable object) {
final MiscHelpers miscHelpers = atSlot(slot).miscHelpers();
return miscHelpers.computeSigningRoot(
object, miscHelpers.computeDomain(Domain.APPLICATION_BUILDER));
}

public Bytes4 computeForkDigest(Bytes4 currentVersion, Bytes32 genesisValidatorsRoot) {
public Bytes4 computeForkDigest(
final Bytes4 currentVersion, final Bytes32 genesisValidatorsRoot) {
return atForkVersion(currentVersion)
.miscHelpers()
.computeForkDigest(currentVersion, genesisValidatorsRoot);
Expand Down Expand Up @@ -564,7 +561,7 @@ public UInt64 getCurrentSlotForMillis(UInt64 currentTimeMillis, UInt64 genesisTi
.getCurrentSlotForMillis(currentTimeMillis, genesisTimeMillis);
}

public UInt64 getCurrentSlot(ReadOnlyStore store) {
public UInt64 getCurrentSlot(final ReadOnlyStore store) {
return atTime(store.getGenesisTime(), store.getTimeSeconds())
.getForkChoiceUtil()
.getCurrentSlot(store);
Expand All @@ -574,36 +571,38 @@ public UInt64 getCurrentEpoch(final ReadOnlyStore store) {
return computeEpochAtSlot(getCurrentSlot(store));
}

public UInt64 getSlotStartTime(UInt64 slotNumber, UInt64 genesisTime) {
public UInt64 getSlotStartTime(final UInt64 slotNumber, final UInt64 genesisTime) {
return atSlot(slotNumber).getForkChoiceUtil().getSlotStartTime(slotNumber, genesisTime);
}

public UInt64 getSlotStartTimeMillis(UInt64 slotNumber, UInt64 genesisTimeMillis) {
public UInt64 getSlotStartTimeMillis(final UInt64 slotNumber, final UInt64 genesisTimeMillis) {
return atSlot(slotNumber)
.getForkChoiceUtil()
.getSlotStartTimeMillis(slotNumber, genesisTimeMillis);
}

public Optional<Bytes32> getAncestor(
ReadOnlyForkChoiceStrategy forkChoiceStrategy, Bytes32 root, UInt64 slot) {
final ReadOnlyForkChoiceStrategy forkChoiceStrategy, final Bytes32 root, final UInt64 slot) {
return forGetAncestor(forkChoiceStrategy, root, slot)
.getForkChoiceUtil()
.getAncestor(forkChoiceStrategy, root, slot);
}

public NavigableMap<UInt64, Bytes32> getAncestors(
ReadOnlyForkChoiceStrategy forkChoiceStrategy,
Bytes32 root,
UInt64 startSlot,
UInt64 step,
UInt64 count) {
final ReadOnlyForkChoiceStrategy forkChoiceStrategy,
final Bytes32 root,
final UInt64 startSlot,
final UInt64 step,
final UInt64 count) {
return forGetAncestor(forkChoiceStrategy, root, startSlot)
.getForkChoiceUtil()
.getAncestors(forkChoiceStrategy, root, startSlot, step, count);
}

public NavigableMap<UInt64, Bytes32> getAncestorsOnFork(
ReadOnlyForkChoiceStrategy forkChoiceStrategy, Bytes32 root, UInt64 startSlot) {
final ReadOnlyForkChoiceStrategy forkChoiceStrategy,
final Bytes32 root,
final UInt64 startSlot) {
return forGetAncestor(forkChoiceStrategy, root, startSlot)
.getForkChoiceUtil()
.getAncestorsOnFork(forkChoiceStrategy, root, startSlot);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,32 @@ static SpecConfigElectra required(final SpecConfig specConfig) {
+ specConfig.getClass().getSimpleName()));
}

UInt64 getMinActivationBalance();

UInt64 getMaxEffectiveBalanceElectra();

UInt64 getPendingBalanceDepositsLimit();

UInt64 getPendingPartialWithdrawalsLimit();

UInt64 getPendingConsolidationsLimit();

int getWhistleblowerRewardQuotientElectra();

int getMinSlashingPenaltyQuotientElectra();

int getMaxAttesterSlashingsElectra();

int getMaxAttestationsElectra();

int getMaxConsolidations();

int getMaxPartialWithdrawalsPerPayload();

UInt64 getMinPerEpochChurnLimitElectra();

UInt64 getMaxPerEpochActivationExitChurnLimit();

Bytes4 getElectraForkVersion();

UInt64 getElectraForkEpoch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,60 @@ public class SpecConfigElectraImpl extends DelegatingSpecConfigDeneb implements

private final Bytes4 electraForkVersion;
private final UInt64 electraForkEpoch;
private final UInt64 minPerEpochChurnLimitElectra;
private final UInt64 maxPerEpochActivationExitChurnLimit;

private final int maxDepositReceiptsPerPayload;
private final int maxExecutionLayerExits;
private final UInt64 minActivationBalance;
private final UInt64 maxEffectiveBalanceElectra;
private final UInt64 pendingBalanceDepositsLimit;
private final UInt64 pendingPartialWithdrawalsLimit;
private final UInt64 pendingConsolidationsLimit;
private final int whistleblowerRewardQuotientElectra;
private final int minSlashingPenaltyQuotientElectra;
private final int maxPartialWithdrawalsPerPayload;
private final int maxAttesterSlashingsElectra;
private final int maxAttestationsElectra;
private final int maxConsolidations;

public SpecConfigElectraImpl(
final SpecConfigDeneb specConfig,
final Bytes4 electraForkVersion,
final UInt64 electraForkEpoch,
final int maxDepositReceiptsPerPayload,
final int maxExecutionLayerExits) {
final int maxExecutionLayerExits,
final UInt64 minPerEpochChurnLimitElectra,
final UInt64 maxPerEpochActivationExitChurnLimit,
final UInt64 minActivationBalance,
final UInt64 maxEffectiveBalanceElectra,
final UInt64 pendingBalanceDepositsLimit,
final UInt64 pendingPartialWithdrawalsLimit,
final UInt64 pendingConsolidationsLimit,
final int whistleblowerRewardQuotientElectra,
final int minSlashingPenaltyQuotientElectra,
final int maxPartialWithdrawalsPerPayload,
final int maxAttesterSlashingsElectra,
final int maxAttestationsElectra,
final int maxConsolidations) {
super(specConfig);
this.electraForkVersion = electraForkVersion;
this.electraForkEpoch = electraForkEpoch;
this.maxDepositReceiptsPerPayload = maxDepositReceiptsPerPayload;
this.maxExecutionLayerExits = maxExecutionLayerExits;
this.minPerEpochChurnLimitElectra = minPerEpochChurnLimitElectra;
this.maxPerEpochActivationExitChurnLimit = maxPerEpochActivationExitChurnLimit;
this.minActivationBalance = minActivationBalance;
this.maxEffectiveBalanceElectra = maxEffectiveBalanceElectra;
this.pendingBalanceDepositsLimit = pendingBalanceDepositsLimit;
this.pendingPartialWithdrawalsLimit = pendingPartialWithdrawalsLimit;
this.pendingConsolidationsLimit = pendingConsolidationsLimit;
this.whistleblowerRewardQuotientElectra = whistleblowerRewardQuotientElectra;
this.minSlashingPenaltyQuotientElectra = minSlashingPenaltyQuotientElectra;
this.maxPartialWithdrawalsPerPayload = maxPartialWithdrawalsPerPayload;
this.maxAttesterSlashingsElectra = maxAttesterSlashingsElectra;
this.maxAttestationsElectra = maxAttestationsElectra;
this.maxConsolidations = maxConsolidations;
}

@Override
Expand All @@ -59,6 +98,71 @@ public int getMaxExecutionLayerExits() {
return maxExecutionLayerExits;
}

@Override
public UInt64 getMinActivationBalance() {
return minActivationBalance;
}

@Override
public UInt64 getMaxEffectiveBalanceElectra() {
return maxEffectiveBalanceElectra;
}

@Override
public UInt64 getPendingBalanceDepositsLimit() {
return pendingBalanceDepositsLimit;
}

@Override
public UInt64 getPendingPartialWithdrawalsLimit() {
return pendingPartialWithdrawalsLimit;
}

@Override
public UInt64 getPendingConsolidationsLimit() {
return pendingConsolidationsLimit;
}

@Override
public int getWhistleblowerRewardQuotientElectra() {
return whistleblowerRewardQuotientElectra;
}

@Override
public int getMinSlashingPenaltyQuotientElectra() {
return minSlashingPenaltyQuotientElectra;
}

@Override
public int getMaxAttesterSlashingsElectra() {
return maxAttesterSlashingsElectra;
}

@Override
public int getMaxAttestationsElectra() {
return maxAttestationsElectra;
}

@Override
public int getMaxConsolidations() {
return maxConsolidations;
}

@Override
public int getMaxPartialWithdrawalsPerPayload() {
return maxPartialWithdrawalsPerPayload;
}

@Override
public UInt64 getMinPerEpochChurnLimitElectra() {
return minPerEpochChurnLimitElectra;
}

@Override
public UInt64 getMaxPerEpochActivationExitChurnLimit() {
return maxPerEpochActivationExitChurnLimit;
}

@Override
public Optional<SpecConfigElectra> toVersionElectra() {
return Optional.of(this);
Expand Down
Loading

0 comments on commit 5abd7e0

Please sign in to comment.