Search in sources :

Example 1 with BeaconPreparableProposer

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);
}
Also used : PayloadAttributes(tech.pegasys.teku.spec.executionengine.PayloadAttributes) BeaconPreparableProposer(tech.pegasys.teku.spec.datastructures.operations.versions.bellatrix.BeaconPreparableProposer)

Example 2 with BeaconPreparableProposer

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));
}
Also used : Collection(java.util.Collection) BeaconPreparableProposer(tech.pegasys.teku.spec.datastructures.operations.versions.bellatrix.BeaconPreparableProposer) TestTemplate(org.junit.jupiter.api.TestTemplate)

Example 3 with BeaconPreparableProposer

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));
}
Also used : Collection(java.util.Collection) BeaconPreparableProposer(tech.pegasys.teku.spec.datastructures.operations.versions.bellatrix.BeaconPreparableProposer) TestTemplate(org.junit.jupiter.api.TestTemplate)

Example 4 with BeaconPreparableProposer

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));
}
Also used : Collection(java.util.Collection) BeaconPreparableProposer(tech.pegasys.teku.spec.datastructures.operations.versions.bellatrix.BeaconPreparableProposer) TestTemplate(org.junit.jupiter.api.TestTemplate)

Example 5 with BeaconPreparableProposer

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()));
    }
}
Also used : BeaconPreparableProposer(tech.pegasys.teku.spec.datastructures.operations.versions.bellatrix.BeaconPreparableProposer) UInt64(tech.pegasys.teku.infrastructure.unsigned.UInt64)

Aggregations

BeaconPreparableProposer (tech.pegasys.teku.spec.datastructures.operations.versions.bellatrix.BeaconPreparableProposer)7 Collection (java.util.Collection)3 TestTemplate (org.junit.jupiter.api.TestTemplate)3 UInt64 (tech.pegasys.teku.infrastructure.unsigned.UInt64)2 PayloadAttributes (tech.pegasys.teku.spec.executionengine.PayloadAttributes)2 Test (org.junit.jupiter.api.Test)1 BeaconState (tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState)1 ForkChoiceState (tech.pegasys.teku.spec.executionengine.ForkChoiceState)1