use of tech.pegasys.teku.spec.datastructures.operations.versions.bellatrix.BeaconPreparableProposer in project teku by ConsenSys.
the class ForkChoiceNotifierTest method withProposerForTwoSlots.
private List<PayloadAttributes> withProposerForTwoSlots(final BeaconState headState, final UInt64 blockSlot1, UInt64 blockSlot2) {
final int block2Proposer1 = spec.getBeaconProposerIndex(headState, blockSlot1);
final int block2Proposer2 = spec.getBeaconProposerIndex(headState, blockSlot2);
final PayloadAttributes payloadAttributes1 = getExpectedPayloadAttributes(headState, blockSlot1, Optional.empty());
final PayloadAttributes payloadAttributes2 = getExpectedPayloadAttributes(headState, blockSlot2, Optional.empty());
if (block2Proposer1 == block2Proposer2) {
throw new UnsupportedOperationException("unsupported test scenario: with same proposer for different slots");
}
notifier.onUpdatePreparableProposers(List.of(new BeaconPreparableProposer(UInt64.valueOf(block2Proposer1), payloadAttributes1.getFeeRecipient()), new BeaconPreparableProposer(UInt64.valueOf(block2Proposer2), payloadAttributes2.getFeeRecipient())));
return List.of(payloadAttributes1, payloadAttributes2);
}
use of tech.pegasys.teku.spec.datastructures.operations.versions.bellatrix.BeaconPreparableProposer in project teku by ConsenSys.
the class BeaconProposerPreparerTest method should_useDefaultFeeRecipientWhenExceptionInConfigProvider.
@TestTemplate
void should_useDefaultFeeRecipientWhenExceptionInConfigProvider() {
when(proposerConfigProvider.getProposerConfig()).thenReturn(SafeFuture.failedFuture(new RuntimeException("error")));
ArgumentCaptor<Collection<BeaconPreparableProposer>> captor = doCall();
assertThat(captor.getValue()).containsExactlyInAnyOrder(new BeaconPreparableProposer(UInt64.valueOf(validator1Index), defaultFeeRecipient), new BeaconPreparableProposer(UInt64.valueOf(validator2Index), defaultFeeRecipient));
}
use of tech.pegasys.teku.spec.datastructures.operations.versions.bellatrix.BeaconPreparableProposer in project teku by ConsenSys.
the class BeaconProposerPreparerTest method should_callPrepareBeaconProposerAtBeginningOfEpoch.
@TestTemplate
void should_callPrepareBeaconProposerAtBeginningOfEpoch() {
ArgumentCaptor<Collection<BeaconPreparableProposer>> captor = doCall();
assertThat(captor.getValue()).containsExactlyInAnyOrder(new BeaconPreparableProposer(UInt64.valueOf(validator1Index), validator1FeeRecipientConfig), new BeaconPreparableProposer(UInt64.valueOf(validator2Index), defaultFeeRecipientConfig));
}
use of tech.pegasys.teku.spec.datastructures.operations.versions.bellatrix.BeaconPreparableProposer in project teku by ConsenSys.
the class BeaconProposerPreparerTest method should_useDefaultFeeRecipientWhenNoConfig.
@TestTemplate
void should_useDefaultFeeRecipientWhenNoConfig() {
when(proposerConfigProvider.getProposerConfig()).thenReturn(SafeFuture.completedFuture(Optional.empty()));
ArgumentCaptor<Collection<BeaconPreparableProposer>> captor = doCall();
assertThat(captor.getValue()).containsExactlyInAnyOrder(new BeaconPreparableProposer(UInt64.valueOf(validator1Index), defaultFeeRecipient), new BeaconPreparableProposer(UInt64.valueOf(validator2Index), defaultFeeRecipient));
}
use of tech.pegasys.teku.spec.datastructures.operations.versions.bellatrix.BeaconPreparableProposer in project teku by ConsenSys.
the class PayloadAttributesCalculator method updateProposers.
public void updateProposers(final Collection<BeaconPreparableProposer> proposers, final UInt64 currentSlot) {
// Remove expired validators
proposerInfoByValidatorIndex.values().removeIf(info -> info.hasExpired(currentSlot));
// Update validators
final UInt64 expirySlot = currentSlot.plus(spec.getSlotsPerEpoch(currentSlot) * MAX_PROPOSER_SEEN_EPOCHS);
for (BeaconPreparableProposer proposer : proposers) {
proposerInfoByValidatorIndex.put(proposer.getValidatorIndex(), new ProposerInfo(expirySlot, proposer.getFeeRecipient()));
}
}
Aggregations