use of tech.pegasys.teku.spec.logic.common.util.ForkChoiceUtil in project teku by ConsenSys.
the class SpecLogicPhase0 method create.
public static SpecLogicPhase0 create(final SpecConfig config, final SchemaDefinitions schemaDefinitions) {
// Helpers
final Predicates predicates = new Predicates();
final MiscHelpers miscHelpers = new MiscHelpers(config);
final BeaconStateAccessors beaconStateAccessors = new BeaconStateAccessorsPhase0(config, predicates, miscHelpers);
final BeaconStateMutators beaconStateMutators = new BeaconStateMutators(config, miscHelpers, beaconStateAccessors);
// Operation validaton
final OperationSignatureVerifier operationSignatureVerifier = new OperationSignatureVerifier(miscHelpers, beaconStateAccessors);
// Util
final ValidatorsUtil validatorsUtil = new ValidatorsUtil(config, miscHelpers, beaconStateAccessors);
final BeaconStateUtil beaconStateUtil = new BeaconStateUtil(config, schemaDefinitions, predicates, miscHelpers, beaconStateAccessors);
final AttestationUtil attestationUtil = new AttestationUtil(schemaDefinitions, beaconStateAccessors, miscHelpers);
final OperationValidator operationValidator = OperationValidator.create(config, predicates, miscHelpers, beaconStateAccessors, attestationUtil);
final ValidatorStatusFactoryPhase0 validatorStatusFactory = new ValidatorStatusFactoryPhase0(config, beaconStateUtil, attestationUtil, beaconStateAccessors, predicates);
final EpochProcessorPhase0 epochProcessor = new EpochProcessorPhase0(config, miscHelpers, beaconStateAccessors, beaconStateMutators, validatorsUtil, beaconStateUtil, validatorStatusFactory, schemaDefinitions);
final BlockProcessorPhase0 blockProcessor = new BlockProcessorPhase0(config, predicates, miscHelpers, beaconStateAccessors, beaconStateMutators, operationSignatureVerifier, beaconStateUtil, attestationUtil, validatorsUtil, operationValidator);
final ForkChoiceUtil forkChoiceUtil = new ForkChoiceUtil(config, beaconStateAccessors, attestationUtil, miscHelpers);
final BlockProposalUtil blockProposalUtil = new BlockProposalUtil(schemaDefinitions, blockProcessor);
return new SpecLogicPhase0(predicates, miscHelpers, beaconStateAccessors, beaconStateMutators, operationSignatureVerifier, validatorsUtil, beaconStateUtil, attestationUtil, operationValidator, validatorStatusFactory, epochProcessor, blockProcessor, forkChoiceUtil, blockProposalUtil);
}
use of tech.pegasys.teku.spec.logic.common.util.ForkChoiceUtil in project teku by ConsenSys.
the class ForkChoice method onBlock.
/**
* Import a block to the store. The supplied blockSlotState must already have empty slots
* processed to the same slot as the block.
*/
private SafeFuture<BlockImportResult> onBlock(final SignedBeaconBlock block, final Optional<BeaconState> blockSlotState, final ExecutionEngineChannel executionEngine) {
if (blockSlotState.isEmpty()) {
return SafeFuture.completedFuture(BlockImportResult.FAILED_UNKNOWN_PARENT);
}
checkArgument(block.getSlot().equals(blockSlotState.get().getSlot()), "State must have processed slots up to the block slot. Block slot %s, state slot %s", block.getSlot(), blockSlotState.get().getSlot());
final ForkChoicePayloadExecutor payloadExecutor = ForkChoicePayloadExecutor.create(spec, recentChainData, block, executionEngine);
final ForkChoiceUtil forkChoiceUtil = spec.atSlot(block.getSlot()).getForkChoiceUtil();
final BlockImportResult preconditionCheckResult = forkChoiceUtil.checkOnBlockConditions(block, blockSlotState.get(), recentChainData.getStore());
if (!preconditionCheckResult.isSuccessful()) {
reportInvalidBlock(block, preconditionCheckResult);
return SafeFuture.completedFuture(preconditionCheckResult);
}
final CapturingIndexedAttestationCache indexedAttestationCache = IndexedAttestationCache.capturing();
final BeaconState postState;
try {
postState = spec.getBlockProcessor(block.getSlot()).processAndValidateBlock(block, blockSlotState.get(), indexedAttestationCache, payloadExecutor);
} catch (final StateTransitionException e) {
final BlockImportResult result = BlockImportResult.failedStateTransition(e);
reportInvalidBlock(block, result);
return SafeFuture.completedFuture(result);
}
return payloadExecutor.getExecutionResult().thenApplyAsync(payloadResult -> importBlockAndState(block, blockSlotState.get(), forkChoiceUtil, indexedAttestationCache, postState, payloadResult), forkChoiceExecutor);
}
use of tech.pegasys.teku.spec.logic.common.util.ForkChoiceUtil in project teku by ConsenSys.
the class SpecLogicBellatrix method create.
public static SpecLogicBellatrix create(final SpecConfigBellatrix config, final SchemaDefinitionsBellatrix schemaDefinitions) {
// Helpers
final Predicates predicates = new Predicates();
final MiscHelpersBellatrix miscHelpers = new MiscHelpersBellatrix(config);
final BeaconStateAccessorsBellatrix beaconStateAccessors = new BeaconStateAccessorsBellatrix(config, predicates, miscHelpers);
final BeaconStateMutatorsBellatrix beaconStateMutators = new BeaconStateMutatorsBellatrix(config, miscHelpers, beaconStateAccessors);
// Operation validaton
final OperationSignatureVerifier operationSignatureVerifier = new OperationSignatureVerifier(miscHelpers, beaconStateAccessors);
// Util
final ValidatorsUtil validatorsUtil = new ValidatorsUtil(config, miscHelpers, beaconStateAccessors);
final BeaconStateUtil beaconStateUtil = new BeaconStateUtil(config, schemaDefinitions, predicates, miscHelpers, beaconStateAccessors);
final AttestationUtil attestationUtil = new AttestationUtil(schemaDefinitions, beaconStateAccessors, miscHelpers);
final OperationValidator operationValidator = OperationValidator.create(config, predicates, miscHelpers, beaconStateAccessors, attestationUtil);
final ValidatorStatusFactoryAltair validatorStatusFactory = new ValidatorStatusFactoryAltair(config, beaconStateUtil, attestationUtil, predicates, miscHelpers, beaconStateAccessors);
final EpochProcessorBellatrix epochProcessor = new EpochProcessorBellatrix(config, miscHelpers, beaconStateAccessors, beaconStateMutators, validatorsUtil, beaconStateUtil, validatorStatusFactory, schemaDefinitions);
final SyncCommitteeUtil syncCommitteeUtil = new SyncCommitteeUtil(beaconStateAccessors, validatorsUtil, config, miscHelpers, schemaDefinitions);
final BlockProcessorBellatrix blockProcessor = new BlockProcessorBellatrix(config, predicates, miscHelpers, syncCommitteeUtil, beaconStateAccessors, beaconStateMutators, operationSignatureVerifier, beaconStateUtil, attestationUtil, validatorsUtil, operationValidator, schemaDefinitions);
final ForkChoiceUtil forkChoiceUtil = new ForkChoiceUtil(config, beaconStateAccessors, attestationUtil, miscHelpers);
final BlockProposalUtil blockProposalUtil = new BlockProposalUtil(schemaDefinitions, blockProcessor);
// State upgrade
final BellatrixStateUpgrade stateUpgrade = new BellatrixStateUpgrade(config, schemaDefinitions, beaconStateAccessors);
final BellatrixTransitionHelpers bellatrixTransitionHelpers = new BellatrixTransitionHelpers(config, miscHelpers);
return new SpecLogicBellatrix(config, predicates, miscHelpers, beaconStateAccessors, beaconStateMutators, operationSignatureVerifier, validatorsUtil, beaconStateUtil, attestationUtil, operationValidator, validatorStatusFactory, epochProcessor, blockProcessor, forkChoiceUtil, blockProposalUtil, syncCommitteeUtil, stateUpgrade, bellatrixTransitionHelpers);
}
use of tech.pegasys.teku.spec.logic.common.util.ForkChoiceUtil in project teku by ConsenSys.
the class SpecLogicAltair method create.
public static SpecLogicAltair create(final SpecConfigAltair config, final SchemaDefinitionsAltair schemaDefinitions) {
// Helpers
final Predicates predicates = new Predicates();
final MiscHelpersAltair miscHelpers = new MiscHelpersAltair(config);
final BeaconStateAccessorsAltair beaconStateAccessors = new BeaconStateAccessorsAltair(config, predicates, miscHelpers);
final BeaconStateMutatorsAltair beaconStateMutators = new BeaconStateMutatorsAltair(config, miscHelpers, beaconStateAccessors);
// Operation validaton
final OperationSignatureVerifier operationSignatureVerifier = new OperationSignatureVerifier(miscHelpers, beaconStateAccessors);
// Util
final ValidatorsUtil validatorsUtil = new ValidatorsUtil(config, miscHelpers, beaconStateAccessors);
final BeaconStateUtil beaconStateUtil = new BeaconStateUtil(config, schemaDefinitions, predicates, miscHelpers, beaconStateAccessors);
final AttestationUtil attestationUtil = new AttestationUtil(schemaDefinitions, beaconStateAccessors, miscHelpers);
final OperationValidator operationValidator = OperationValidator.create(config, predicates, miscHelpers, beaconStateAccessors, attestationUtil);
final ValidatorStatusFactoryAltair validatorStatusFactory = new ValidatorStatusFactoryAltair(config, beaconStateUtil, attestationUtil, predicates, miscHelpers, beaconStateAccessors);
final EpochProcessorAltair epochProcessor = new EpochProcessorAltair(config, miscHelpers, beaconStateAccessors, beaconStateMutators, validatorsUtil, beaconStateUtil, validatorStatusFactory, schemaDefinitions);
final SyncCommitteeUtil syncCommitteeUtil = new SyncCommitteeUtil(beaconStateAccessors, validatorsUtil, config, miscHelpers, schemaDefinitions);
final BlockProcessorAltair blockProcessor = new BlockProcessorAltair(config, predicates, miscHelpers, syncCommitteeUtil, beaconStateAccessors, beaconStateMutators, operationSignatureVerifier, beaconStateUtil, attestationUtil, validatorsUtil, operationValidator);
final ForkChoiceUtil forkChoiceUtil = new ForkChoiceUtil(config, beaconStateAccessors, attestationUtil, miscHelpers);
final BlockProposalUtil blockProposalUtil = new BlockProposalUtil(schemaDefinitions, blockProcessor);
// State upgrade
final AltairStateUpgrade stateUpgrade = new AltairStateUpgrade(config, schemaDefinitions, beaconStateAccessors, attestationUtil, miscHelpers);
return new SpecLogicAltair(config, predicates, miscHelpers, beaconStateAccessors, beaconStateMutators, operationSignatureVerifier, validatorsUtil, beaconStateUtil, attestationUtil, operationValidator, validatorStatusFactory, epochProcessor, blockProcessor, forkChoiceUtil, blockProposalUtil, syncCommitteeUtil, stateUpgrade);
}
Aggregations