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();
}
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);
}
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);
}
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;
}
}
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);
}
Aggregations