Search in sources :

Example 1 with ExecutionPayload

use of tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload in project teku by ConsenSys.

the class AbstractDatabaseTest method shouldNotRecordTransitionExecutionPayloadWhenNotOptimistic.

@Test
public void shouldNotRecordTransitionExecutionPayloadWhenNotOptimistic() {
    final SignedBlockAndState transitionBlock = generateChainWithFinalizableTransitionBlock();
    final List<SignedBlockAndState> newBlocks = chainBuilder.streamBlocksAndStates(genesisBlockAndState.getSlot().intValue()).collect(toList());
    // Save all blocks and states in a single transaction
    add(newBlocks);
    recentChainData.getUpdatableForkChoiceStrategy().orElseThrow().onExecutionPayloadResult(transitionBlock.getRoot(), PayloadStatus.VALID);
    // Then finalize
    final Checkpoint finalizedCheckpoint = chainBuilder.getCurrentCheckpointForEpoch(chainBuilder.getLatestEpoch());
    final StoreTransaction tx = recentChainData.startStoreTransaction();
    tx.setFinalizedCheckpoint(finalizedCheckpoint);
    assertThat(tx.commit()).isCompleted();
    final Optional<ExecutionPayload> transitionPayload = transitionBlock.getBlock().getMessage().getBody().getOptionalExecutionPayload();
    assertThat(transitionPayload).isPresent();
    assertThat(transitionPayload.get().isDefault()).isFalse();
    assertThat(recentChainData.getStore().getFinalizedOptimisticTransitionPayload()).isEmpty();
}
Also used : Checkpoint(tech.pegasys.teku.spec.datastructures.state.Checkpoint) StoreTransaction(tech.pegasys.teku.storage.store.UpdatableStore.StoreTransaction) SignedBlockAndState(tech.pegasys.teku.spec.datastructures.blocks.SignedBlockAndState) SlotAndExecutionPayload(tech.pegasys.teku.spec.datastructures.execution.SlotAndExecutionPayload) ExecutionPayload(tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload) Test(org.junit.jupiter.api.Test)

Example 2 with ExecutionPayload

use of tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload in project teku by ConsenSys.

the class BlockFactoryTest method shouldIncludeExecutionPayloadWhenBellatrixIsActive.

@Test
void shouldIncludeExecutionPayloadWhenBellatrixIsActive() throws Exception {
    final BeaconBlock block = assertBlockCreated(1, TestSpecFactory.createMinimalBellatrix());
    final ExecutionPayload result = getExecutionPayload(block);
    assertThat(result).isEqualTo(executionPayload);
}
Also used : BeaconBlock(tech.pegasys.teku.spec.datastructures.blocks.BeaconBlock) ExecutionPayload(tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload) Test(org.junit.jupiter.api.Test)

Example 3 with ExecutionPayload

use of tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload in project teku by ConsenSys.

the class BlockOperationSelectorFactoryTest method shouldIncludeNonDefaultExecutionPayload.

@Test
void shouldIncludeNonDefaultExecutionPayload() {
    final UInt64 slot = UInt64.ONE;
    final BeaconState blockSlotState = dataStructureUtil.randomBeaconState(slot);
    final Bytes8 payloadId = dataStructureUtil.randomBytes8();
    final ExecutionPayload randomExecutionPayload = dataStructureUtil.randomExecutionPayload();
    when(forkChoiceNotifier.getPayloadId(any(), any())).thenReturn(SafeFuture.completedFuture(Optional.of(payloadId)));
    when(executionEngine.getPayload(payloadId, slot)).thenReturn(SafeFuture.completedFuture(randomExecutionPayload));
    factory.createSelector(parentRoot, blockSlotState, dataStructureUtil.randomSignature(), Optional.empty()).accept(bodyBuilder);
    assertThat(bodyBuilder.executionPayload).isEqualTo(randomExecutionPayload);
}
Also used : Bytes8(tech.pegasys.teku.infrastructure.bytes.Bytes8) UInt64(tech.pegasys.teku.infrastructure.unsigned.UInt64) BeaconState(tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState) ExecutionPayload(tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload) Test(org.junit.jupiter.api.Test)

Example 4 with ExecutionPayload

use of tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload in project teku by ConsenSys.

the class OperationsTestExecutor method processOperation.

private void processOperation(final TestDefinition testDefinition, final MutableBeaconState state, final OperationProcessor processor) throws Exception {
    switch(operation) {
        case ATTESTER_SLASHING:
            final AttesterSlashing attesterSlashing = loadSsz(testDefinition, dataFileName, testDefinition.getSpec().getGenesisSchemaDefinitions().getAttesterSlashingSchema());
            processor.processAttesterSlashing(state, attesterSlashing);
            break;
        case PROPOSER_SLASHING:
            final ProposerSlashing proposerSlashing = loadSsz(testDefinition, dataFileName, ProposerSlashing.SSZ_SCHEMA);
            processor.processProposerSlashing(state, proposerSlashing);
            break;
        case PROCESS_BLOCK_HEADER:
            final BeaconBlockSummary blockHeader = loadSsz(testDefinition, dataFileName, testDefinition.getSpec().getGenesisSchemaDefinitions().getBeaconBlockSchema());
            processor.processBlockHeader(state, blockHeader);
            break;
        case DEPOSIT:
            final Deposit deposit = loadSsz(testDefinition, dataFileName, Deposit.SSZ_SCHEMA);
            processor.processDeposit(state, deposit);
            break;
        case VOLUNTARY_EXIT:
            final SignedVoluntaryExit voluntaryExit = loadSsz(testDefinition, dataFileName, SignedVoluntaryExit.SSZ_SCHEMA);
            processor.processVoluntaryExit(state, voluntaryExit);
            break;
        case ATTESTATION:
            final Attestation attestation = loadSsz(testDefinition, dataFileName, testDefinition.getSpec().getGenesisSchemaDefinitions().getAttestationSchema());
            processor.processAttestation(state, attestation);
            break;
        case SYNC_AGGREGATE:
            final SyncAggregate syncAggregate = loadSsz(testDefinition, dataFileName, BeaconBlockBodySchemaAltair.required(testDefinition.getSpec().getGenesisSchemaDefinitions().getBeaconBlockBodySchema()).getSyncAggregateSchema());
            processor.processSyncCommittee(state, syncAggregate);
            break;
        case EXECUTION_PAYLOAD:
            final ExecutionMeta executionMeta = loadYaml(testDefinition, "execution.yaml", ExecutionMeta.class);
            final ExecutionPayload payload = loadSsz(testDefinition, dataFileName, testDefinition.getSpec().getGenesisSchemaDefinitions().toVersionBellatrix().orElseThrow().getExecutionPayloadSchema());
            processor.processExecutionPayload(state, payload, (latestExecutionPayloadHeader, payloadToExecute) -> executionMeta.executionValid);
            break;
    }
}
Also used : Deposit(tech.pegasys.teku.spec.datastructures.operations.Deposit) SignedVoluntaryExit(tech.pegasys.teku.spec.datastructures.operations.SignedVoluntaryExit) AttesterSlashing(tech.pegasys.teku.spec.datastructures.operations.AttesterSlashing) SyncAggregate(tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.altair.SyncAggregate) ProposerSlashing(tech.pegasys.teku.spec.datastructures.operations.ProposerSlashing) BeaconBlockSummary(tech.pegasys.teku.spec.datastructures.blocks.BeaconBlockSummary) Attestation(tech.pegasys.teku.spec.datastructures.operations.Attestation) ExecutionPayload(tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload)

Example 5 with ExecutionPayload

use of tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload in project teku by ConsenSys.

the class Web3JExecutionEngineClientTest method shouldSerializeDeserializeExecutionPayloadV1.

@TestTemplate
void shouldSerializeDeserializeExecutionPayloadV1() throws IOException {
    ExecutionPayload internalExecutionPayload = dataStructureUtil.randomExecutionPayload();
    ExecutionPayloadV1 executionPayloadV1Orig = ExecutionPayloadV1.fromInternalExecutionPayload(internalExecutionPayload);
    String executionPayloadV1OrigSerialized = objectMapper.writeValueAsString(executionPayloadV1Orig);
    ExecutionPayloadV1 executionPayloadV1New = objectMapper.readValue(executionPayloadV1OrigSerialized, ExecutionPayloadV1.class);
    assertThat(executionPayloadV1Orig).isEqualTo(executionPayloadV1New);
    assertThat(executionPayloadV1Orig.asInternalExecutionPayload(internalExecutionPayload.getSchema())).isEqualTo(internalExecutionPayload);
}
Also used : ExecutionPayloadV1(tech.pegasys.teku.ethereum.executionlayer.client.schema.ExecutionPayloadV1) ExecutionPayload(tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload) TestTemplate(org.junit.jupiter.api.TestTemplate)

Aggregations

ExecutionPayload (tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload)7 Test (org.junit.jupiter.api.Test)3 UInt64 (tech.pegasys.teku.infrastructure.unsigned.UInt64)2 BeaconBlock (tech.pegasys.teku.spec.datastructures.blocks.BeaconBlock)2 SignedBeaconBlock (tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock)2 SlotAndExecutionPayload (tech.pegasys.teku.spec.datastructures.execution.SlotAndExecutionPayload)2 Checkpoint (tech.pegasys.teku.spec.datastructures.state.Checkpoint)2 BeaconState (tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 HashMap (java.util.HashMap)1 Bytes32 (org.apache.tuweni.bytes.Bytes32)1 TestTemplate (org.junit.jupiter.api.TestTemplate)1 ExecutionPayloadV1 (tech.pegasys.teku.ethereum.executionlayer.client.schema.ExecutionPayloadV1)1 StoredBlockMetadata (tech.pegasys.teku.ethereum.forkchoice.StoredBlockMetadata)1 Bytes8 (tech.pegasys.teku.infrastructure.bytes.Bytes8)1 BeaconBlockSummary (tech.pegasys.teku.spec.datastructures.blocks.BeaconBlockSummary)1 BlockAndCheckpointEpochs (tech.pegasys.teku.spec.datastructures.blocks.BlockAndCheckpointEpochs)1 CheckpointEpochs (tech.pegasys.teku.spec.datastructures.blocks.CheckpointEpochs)1 SignedBlockAndState (tech.pegasys.teku.spec.datastructures.blocks.SignedBlockAndState)1 StateAndBlockSummary (tech.pegasys.teku.spec.datastructures.blocks.StateAndBlockSummary)1