From 4e5912a23ee60e387d52e4bc6a2e0fec91522177 Mon Sep 17 00:00:00 2001 From: Stefan Bratanov Date: Wed, 4 May 2022 18:16:14 +0300 Subject: [PATCH] Implement builder_status and scheduled polling --- .../teku/beacon/sync/SyncingNodeManager.java | 8 +- .../BlockOperationSelectorFactory.java | 16 +- .../coordinator/BlockFactoryTest.java | 18 +-- .../BlockOperationSelectorFactoryTest.java | 18 +-- ...tractDataBackedRestAPIIntegrationTest.java | 4 +- .../benchmarks/EpochTransitionBenchmark.java | 6 +- .../pegasys/teku/benchmarks/ProfilingRun.java | 10 +- .../teku/benchmarks/TransitionBenchmark.java | 6 +- .../forkchoice/ForkChoiceTestExecutor.java | 24 +-- .../ExecutionClientProvider.java | 8 +- .../Web3JExecutionEngineClientTest.java | 2 +- ...pl.java => ExecutionLayerChannelImpl.java} | 103 +++++++++---- .../ThrottlingExecutionBuilderClient.java | 70 +++++++++ .../ThrottlingExecutionEngineClient.java} | 61 ++++---- .../client/schema/ForkChoiceStateV1.java | 2 +- .../schema/ForkChoiceUpdatedResult.java | 4 +- .../client/schema/PayloadAttributesV1.java | 2 +- .../client/schema/PayloadStatusV1.java | 4 +- .../schema/TransitionConfigurationV1.java | 2 +- .../Web3JExecutionEngineClientTest.java | 18 +-- .../pegasys/teku/spec/config/Constants.java | 1 + .../execution/BuilderStatus.java | 59 ++++++++ .../ExecutionLayerChannel.java} | 41 ++++-- .../ExecutionLayerChannelStub.java} | 28 ++-- .../ExecutionPayloadStatus.java | 2 +- .../ForkChoiceState.java | 2 +- .../ForkChoiceUpdatedResult.java | 2 +- .../PayloadAttributes.java | 2 +- .../PayloadStatus.java | 2 +- .../TransitionConfiguration.java | 2 +- .../helpers/BellatrixTransitionHelpers.java | 24 +-- .../BellatrixTransitionHelpersTest.java | 22 +-- .../teku/spec/util/DataStructureUtil.java | 2 +- .../AttestationManagerIntegrationTest.java | 4 +- .../statetransition/block/BlockImporter.java | 10 +- .../forkchoice/ForkChoice.java | 14 +- .../forkchoice/ForkChoiceNotifier.java | 2 +- .../forkchoice/ForkChoiceNotifierImpl.java | 18 +-- .../forkchoice/ForkChoicePayloadExecutor.java | 20 +-- .../forkchoice/ForkChoiceUpdateData.java | 12 +- .../ForkChoiceUpdatedResultSubscriber.java | 4 +- .../MergeTransitionBlockValidator.java | 12 +- .../MergeTransitionConfigCheck.java | 14 +- .../PayloadAttributesCalculator.java | 2 +- .../forkchoice/PayloadValidationResult.java | 2 +- .../forkchoice/TerminalPowBlockMonitor.java | 20 +-- .../block/BlockImporterTest.java | 20 +-- .../block/BlockManagerTest.java | 20 +-- .../forkchoice/ForkChoiceNotifierTest.java | 131 +++++++++-------- .../ForkChoicePayloadExecutorTest.java | 34 ++--- .../forkchoice/ForkChoiceTest.java | 52 +++---- .../MergeTransitionBlockValidatorTest.java | 28 ++-- .../MergeTransitionConfigCheckTest.java | 16 +- .../TerminalPowBlockMonitorTest.java | 74 +++++----- .../teku/statetransition/BeaconChainUtil.java | 12 +- .../forkchoice/StubForkChoiceNotifier.java | 4 +- .../ForkChoiceIntegrationTest.java | 8 +- .../infrastructure/logging/EventLogger.java | 4 +- .../beaconchain/BeaconChainController.java | 18 +-- .../ExecutionEngineConfiguration.java | 116 --------------- .../ExecutionEngineService.java | 88 ----------- .../ExecutionLayerConfiguration.java | 115 +++++++++++++++ .../executionlayer/ExecutionLayerService.java | 139 ++++++++++++++++++ .../ExecutionLayerConfigurationTest.java} | 18 +-- .../protoarray/ForkChoiceStrategy.java | 6 +- .../protoarray/ForkChoiceStrategyTest.java | 2 +- .../storage/server/AbstractDatabaseTest.java | 2 +- .../teku/storage/client/ChainUpdater.java | 2 +- .../pegasys/teku/cli/BeaconNodeCommand.java | 8 +- ...ptions.java => ExecutionLayerOptions.java} | 55 ++----- .../teku/config/TekuConfiguration.java | 24 +-- .../services/BeaconNodeServiceController.java | 12 +- .../teku/cli/BeaconNodeCommandTest.java | 4 +- .../cli/options/Eth2NetworkOptionsTest.java | 2 +- ...st.java => ExecutionLayerOptionsTest.java} | 57 ++++--- ...yaml => executionLayerOptions_config.yaml} | 0 76 files changed, 1013 insertions(+), 767 deletions(-) rename ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/{ExecutionEngineChannelImpl.java => ExecutionLayerChannelImpl.java} (66%) create mode 100644 ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/client/ThrottlingExecutionBuilderClient.java rename ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/{ThrottlingExecutionEngineChannel.java => client/ThrottlingExecutionEngineClient.java} (54%) create mode 100644 ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/BuilderStatus.java rename ethereum/spec/src/main/java/tech/pegasys/teku/spec/{executionengine/ExecutionEngineChannel.java => executionlayer/ExecutionLayerChannel.java} (67%) rename ethereum/spec/src/main/java/tech/pegasys/teku/spec/{executionengine/ExecutionEngineChannelStub.java => executionlayer/ExecutionLayerChannelStub.java} (93%) rename ethereum/spec/src/main/java/tech/pegasys/teku/spec/{executionengine => executionlayer}/ExecutionPayloadStatus.java (96%) rename ethereum/spec/src/main/java/tech/pegasys/teku/spec/{executionengine => executionlayer}/ForkChoiceState.java (98%) rename ethereum/spec/src/main/java/tech/pegasys/teku/spec/{executionengine => executionlayer}/ForkChoiceUpdatedResult.java (97%) rename ethereum/spec/src/main/java/tech/pegasys/teku/spec/{executionengine => executionlayer}/PayloadAttributes.java (97%) rename ethereum/spec/src/main/java/tech/pegasys/teku/spec/{executionengine => executionlayer}/PayloadStatus.java (98%) rename ethereum/spec/src/main/java/tech/pegasys/teku/spec/{executionengine => executionlayer}/TransitionConfiguration.java (98%) delete mode 100644 services/executionengine/src/main/java/tech/pegasys/teku/services/executionengine/ExecutionEngineConfiguration.java delete mode 100644 services/executionengine/src/main/java/tech/pegasys/teku/services/executionengine/ExecutionEngineService.java create mode 100644 services/executionengine/src/main/java/tech/pegasys/teku/services/executionlayer/ExecutionLayerConfiguration.java create mode 100644 services/executionengine/src/main/java/tech/pegasys/teku/services/executionlayer/ExecutionLayerService.java rename services/executionengine/src/test/java/tech/pegasys/teku/services/{executionengine/ExecutionEngineConfigurationTest.java => executionlayer/ExecutionLayerConfigurationTest.java} (68%) rename teku/src/main/java/tech/pegasys/teku/cli/options/{ExecutionEngineOptions.java => ExecutionLayerOptions.java} (54%) rename teku/src/test/java/tech/pegasys/teku/cli/options/{ExecutionEngineOptionsTest.java => ExecutionLayerOptionsTest.java} (60%) rename teku/src/test/resources/{executionEngineOptions_config.yaml => executionLayerOptions_config.yaml} (100%) diff --git a/beacon/sync/src/testFixtures/java/tech/pegasys/teku/beacon/sync/SyncingNodeManager.java b/beacon/sync/src/testFixtures/java/tech/pegasys/teku/beacon/sync/SyncingNodeManager.java index 73251657f94..f6b85fcb401 100644 --- a/beacon/sync/src/testFixtures/java/tech/pegasys/teku/beacon/sync/SyncingNodeManager.java +++ b/beacon/sync/src/testFixtures/java/tech/pegasys/teku/beacon/sync/SyncingNodeManager.java @@ -44,8 +44,8 @@ import tech.pegasys.teku.spec.Spec; import tech.pegasys.teku.spec.TestSpecFactory; import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannelStub; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannelStub; import tech.pegasys.teku.statetransition.BeaconChainUtil; import tech.pegasys.teku.statetransition.block.BlockImportChannel; import tech.pegasys.teku.statetransition.block.BlockImportNotifications; @@ -101,7 +101,7 @@ public static SyncingNodeManager create( chainUtil.initializeStorage(); final MergeTransitionBlockValidator transitionBlockValidator = - new MergeTransitionBlockValidator(spec, recentChainData, ExecutionEngineChannel.NOOP); + new MergeTransitionBlockValidator(spec, recentChainData, ExecutionLayerChannel.NOOP); ForkChoice forkChoice = new ForkChoice( spec, @@ -116,7 +116,7 @@ public static SyncingNodeManager create( recentChainData, forkChoice, WeakSubjectivityFactory.lenientValidator(), - new ExecutionEngineChannelStub(spec, false)); + new ExecutionLayerChannelStub(spec, false)); BlockValidator blockValidator = new BlockValidator(spec, recentChainData); final PendingPool pendingBlocks = diff --git a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java index c4d07a06f21..69d5a94f17a 100644 --- a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java +++ b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java @@ -38,7 +38,7 @@ import tech.pegasys.teku.spec.datastructures.operations.ProposerSlashing; import tech.pegasys.teku.spec.datastructures.operations.SignedVoluntaryExit; import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel; import tech.pegasys.teku.spec.schemas.SchemaDefinitionsBellatrix; import tech.pegasys.teku.statetransition.OperationPool; import tech.pegasys.teku.statetransition.attestation.AggregatingAttestationPool; @@ -59,7 +59,7 @@ public class BlockOperationSelectorFactory { private final Eth1DataCache eth1DataCache; private final Bytes32 graffiti; private final ForkChoiceNotifier forkChoiceNotifier; - private final ExecutionEngineChannel executionEngineChannel; + private final ExecutionLayerChannel executionLayerChannel; private final boolean isMevBoostEnabled; public BlockOperationSelectorFactory( @@ -73,7 +73,7 @@ public BlockOperationSelectorFactory( final Eth1DataCache eth1DataCache, final Bytes32 graffiti, final ForkChoiceNotifier forkChoiceNotifier, - final ExecutionEngineChannel executionEngineChannel, + final ExecutionLayerChannel executionLayerChannel, final boolean isMevBoostEnabled) { this.spec = spec; this.attestationPool = attestationPool; @@ -85,7 +85,7 @@ public BlockOperationSelectorFactory( this.eth1DataCache = eth1DataCache; this.graffiti = graffiti; this.forkChoiceNotifier = forkChoiceNotifier; - this.executionEngineChannel = executionEngineChannel; + this.executionLayerChannel = executionLayerChannel; this.isMevBoostEnabled = isMevBoostEnabled; } @@ -156,7 +156,7 @@ public Consumer createSelector( .getExecutionPayloadHeaderSchema() .getHeaderOfDefaultPayload(), (payloadId) -> - executionEngineChannel + executionLayerChannel .getPayloadHeader(payloadId, blockSlotState.getSlot()) .join())); return; @@ -185,7 +185,9 @@ public Consumer createSelector( .getExecutionPayloadSchema() .getDefault(), (payloadId) -> - executionEngineChannel.getPayload(payloadId, blockSlotState.getSlot()).join())); + executionLayerChannel + .engineGetPayload(payloadId, blockSlotState.getSlot()) + .join())); }; } @@ -235,7 +237,7 @@ public Consumer createUnblinderSelector() { } else { bodyUnblinder.setExecutionPayloadSupplier( () -> - executionEngineChannel.proposeBlindedBlock( + executionLayerChannel.proposeBlindedBlock( bodyUnblinder.getSignedBlindedBeaconBlock())); } }; diff --git a/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockFactoryTest.java b/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockFactoryTest.java index 0f81406498c..2d21ecbc361 100644 --- a/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockFactoryTest.java +++ b/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockFactoryTest.java @@ -51,7 +51,7 @@ import tech.pegasys.teku.spec.datastructures.operations.SignedVoluntaryExit; import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState; import tech.pegasys.teku.spec.datastructures.util.BeaconBlockBodyLists; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel; import tech.pegasys.teku.spec.logic.common.statetransition.exceptions.StateTransitionException; import tech.pegasys.teku.spec.schemas.SchemaDefinitionsBellatrix; import tech.pegasys.teku.spec.util.DataStructureUtil; @@ -72,7 +72,7 @@ class BlockFactoryTest { final OperationPool proposerSlashingPool = mock(OperationPool.class); final OperationPool voluntaryExitPool = mock(OperationPool.class); final ForkChoiceNotifier forkChoiceNotifier = mock(ForkChoiceNotifier.class); - final ExecutionEngineChannel executionEngine = mock(ExecutionEngineChannel.class); + final ExecutionLayerChannel executionLayer = mock(ExecutionLayerChannel.class); final SyncCommitteeContributionPool syncCommitteeContributionPool = mock(SyncCommitteeContributionPool.class); final DepositProvider depositProvider = mock(DepositProvider.class); @@ -310,7 +310,7 @@ private BeaconBlock assertBlockCreated( eth1DataCache, graffiti, forkChoiceNotifier, - executionEngine, + executionLayer, isMevBoostEnabled)); when(depositProvider.getDeposits(any(), any())).thenReturn(deposits); @@ -321,9 +321,9 @@ private BeaconBlock assertBlockCreated( when(eth1DataCache.getEth1Vote(any())).thenReturn(ETH1_DATA); when(forkChoiceNotifier.getPayloadId(any(), any())) .thenReturn(SafeFuture.completedFuture(Optional.of(Bytes8.fromHexStringLenient("0x0")))); - when(executionEngine.getPayload(any(), any())) + when(executionLayer.engineGetPayload(any(), any())) .thenReturn(SafeFuture.completedFuture(executionPayload)); - when(executionEngine.getPayloadHeader(any(), any())) + when(executionLayer.getPayloadHeader(any(), any())) .thenReturn(SafeFuture.completedFuture(executionPayloadHeader)); beaconChainUtil.initializeStorage(); @@ -366,16 +366,16 @@ private SignedBeaconBlock assertBlockUnblinded( final SignedBeaconBlock beaconBlock, final Spec spec, final boolean isMevBoostEnabled) { final BlockFactory blockFactory = createBlockFactory(spec, isMevBoostEnabled); - when(executionEngine.proposeBlindedBlock(beaconBlock)) + when(executionLayer.proposeBlindedBlock(beaconBlock)) .thenReturn(SafeFuture.completedFuture(executionPayload)); final SignedBeaconBlock block = blockFactory.unblindSignedBeaconBlockIfBlinded(beaconBlock).join(); if (!beaconBlock.getMessage().getBody().isBlinded()) { - verifyNoInteractions(executionEngine); + verifyNoInteractions(executionLayer); } else { - verify(executionEngine).proposeBlindedBlock(beaconBlock); + verify(executionLayer).proposeBlindedBlock(beaconBlock); } assertThat(block).isNotNull(); @@ -419,7 +419,7 @@ private BlockFactory createBlockFactory(final Spec spec, final boolean isMevBoos eth1DataCache, graffiti, forkChoiceNotifier, - executionEngine, + executionLayer, isMevBoostEnabled)); } } diff --git a/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactoryTest.java b/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactoryTest.java index 701a156787c..09327e727b3 100644 --- a/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactoryTest.java +++ b/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactoryTest.java @@ -53,7 +53,7 @@ import tech.pegasys.teku.spec.datastructures.operations.SignedVoluntaryExit; import tech.pegasys.teku.spec.datastructures.operations.versions.altair.SignedContributionAndProof; import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel; import tech.pegasys.teku.spec.logic.common.operations.validation.AttesterSlashingValidator.AttesterSlashingInvalidReason; import tech.pegasys.teku.spec.logic.common.operations.validation.ProposerSlashingValidator.ProposerSlashingInvalidReason; import tech.pegasys.teku.spec.logic.common.operations.validation.VoluntaryExitValidator.ExitInvalidReason; @@ -122,7 +122,7 @@ class BlockOperationSelectorFactoryTest { private final BLSSignature randaoReveal = dataStructureUtil.randomSignature(); private final ForkChoiceNotifier forkChoiceNotifier = mock(ForkChoiceNotifier.class); - private final ExecutionEngineChannel executionEngine = mock(ExecutionEngineChannel.class); + private final ExecutionLayerChannel executionLayer = mock(ExecutionLayerChannel.class); private final ExecutionPayload defaultExecutionPayload = SchemaDefinitionsBellatrix.required(spec.getGenesisSpec().getSchemaDefinitions()) @@ -147,7 +147,7 @@ class BlockOperationSelectorFactoryTest { eth1DataCache, defaultGraffiti, forkChoiceNotifier, - executionEngine, + executionLayer, false); private final BlockOperationSelectorFactory factoryWithMevBoost = @@ -162,7 +162,7 @@ class BlockOperationSelectorFactoryTest { eth1DataCache, defaultGraffiti, forkChoiceNotifier, - executionEngine, + executionLayer, true); @BeforeEach @@ -309,7 +309,7 @@ void shouldIncludeNonDefaultExecutionPayload() { when(forkChoiceNotifier.getPayloadId(any(), any())) .thenReturn(SafeFuture.completedFuture(Optional.of(payloadId))); - when(executionEngine.getPayload(payloadId, slot)) + when(executionLayer.engineGetPayload(payloadId, slot)) .thenReturn(SafeFuture.completedFuture(randomExecutionPayload)); factory @@ -331,7 +331,7 @@ void shouldIncludeExecutionPayloadHeaderIfMevBoostEnabledAndBlindedBlockRequeste when(forkChoiceNotifier.getPayloadId(any(), any())) .thenReturn(SafeFuture.completedFuture(Optional.of(payloadId))); - when(executionEngine.getPayloadHeader(payloadId, slot)) + when(executionLayer.getPayloadHeader(payloadId, slot)) .thenReturn(SafeFuture.completedFuture(randomExecutionPayloadHeader)); factoryWithMevBoost @@ -352,7 +352,7 @@ void shouldIncludeExecutionPayloadIfMevBoostEnabledButNoBlindedBlockRequested() when(forkChoiceNotifier.getPayloadId(any(), any())) .thenReturn(SafeFuture.completedFuture(Optional.of(payloadId))); - when(executionEngine.getPayload(payloadId, slot)) + when(executionLayer.engineGetPayload(payloadId, slot)) .thenReturn(SafeFuture.completedFuture(randomExecutionPayload)); factoryWithMevBoost @@ -370,7 +370,7 @@ void shouldUnblindSignedBlindedBeaconBlockIfMevBoostEnabled() { final CapturingBeaconBlockUnblinder blockUnblinder = new CapturingBeaconBlockUnblinder(spec.getGenesisSchemaDefinitions(), blindedSignedBlock); - when(executionEngine.proposeBlindedBlock(blindedSignedBlock)) + when(executionLayer.proposeBlindedBlock(blindedSignedBlock)) .thenReturn(SafeFuture.completedFuture(randomExecutionPayload)); factoryWithMevBoost.createUnblinderSelector().accept(blockUnblinder); @@ -385,7 +385,7 @@ void shouldThrowUnblindSignedBlindedBeaconBlockIfMevBoostDisabled() { final CapturingBeaconBlockUnblinder blockUnblinder = new CapturingBeaconBlockUnblinder(spec.getGenesisSchemaDefinitions(), blindedSignedBlock); - when(executionEngine.proposeBlindedBlock(blindedSignedBlock)) + when(executionLayer.proposeBlindedBlock(blindedSignedBlock)) .thenReturn(SafeFuture.completedFuture(randomExecutionPayload)); assertThatThrownBy(() -> factory.createUnblinderSelector().accept(blockUnblinder)) diff --git a/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/AbstractDataBackedRestAPIIntegrationTest.java b/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/AbstractDataBackedRestAPIIntegrationTest.java index a5959925483..774c5622a9d 100644 --- a/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/AbstractDataBackedRestAPIIntegrationTest.java +++ b/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/AbstractDataBackedRestAPIIntegrationTest.java @@ -55,7 +55,7 @@ import tech.pegasys.teku.spec.datastructures.operations.AttesterSlashing; import tech.pegasys.teku.spec.datastructures.operations.ProposerSlashing; import tech.pegasys.teku.spec.datastructures.operations.SignedVoluntaryExit; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel; import tech.pegasys.teku.statetransition.OperationPool; import tech.pegasys.teku.statetransition.attestation.AggregatingAttestationPool; import tech.pegasys.teku.statetransition.attestation.AttestationManager; @@ -163,7 +163,7 @@ private void setupStorage( recentChainData, new StubForkChoiceNotifier(), new MergeTransitionBlockValidator( - spec, recentChainData, ExecutionEngineChannel.NOOP)); + spec, recentChainData, ExecutionLayerChannel.NOOP)); } private void setupAndStartRestAPI(BeaconRestApiConfig config) { diff --git a/eth-benchmark-tests/src/jmh/java/tech/pegasys/teku/benchmarks/EpochTransitionBenchmark.java b/eth-benchmark-tests/src/jmh/java/tech/pegasys/teku/benchmarks/EpochTransitionBenchmark.java index 57d28dc5927..894d2b9731a 100644 --- a/eth-benchmark-tests/src/jmh/java/tech/pegasys/teku/benchmarks/EpochTransitionBenchmark.java +++ b/eth-benchmark-tests/src/jmh/java/tech/pegasys/teku/benchmarks/EpochTransitionBenchmark.java @@ -42,7 +42,7 @@ import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock; import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState; import tech.pegasys.teku.spec.datastructures.state.beaconstate.MutableBeaconState; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel; import tech.pegasys.teku.spec.logic.common.block.AbstractBlockProcessor; import tech.pegasys.teku.spec.logic.common.statetransition.epoch.EpochProcessor; import tech.pegasys.teku.spec.logic.common.statetransition.epoch.RewardAndPenaltyDeltas; @@ -109,7 +109,7 @@ public void init() throws Exception { recentChainData = MemoryOnlyRecentChainData.create(spec); final MergeTransitionBlockValidator transitionBlockValidator = - new MergeTransitionBlockValidator(spec, recentChainData, ExecutionEngineChannel.NOOP); + new MergeTransitionBlockValidator(spec, recentChainData, ExecutionLayerChannel.NOOP); ForkChoice forkChoice = new ForkChoice( spec, @@ -127,7 +127,7 @@ public void init() throws Exception { recentChainData, forkChoice, wsValidator, - ExecutionEngineChannel.NOOP); + ExecutionLayerChannel.NOOP); blockIterator = BlockIO.createResourceReader(spec, blocksFile).iterator(); System.out.println("Importing 63 blocks from " + blocksFile); diff --git a/eth-benchmark-tests/src/jmh/java/tech/pegasys/teku/benchmarks/ProfilingRun.java b/eth-benchmark-tests/src/jmh/java/tech/pegasys/teku/benchmarks/ProfilingRun.java index 4854903f256..138382a48e3 100644 --- a/eth-benchmark-tests/src/jmh/java/tech/pegasys/teku/benchmarks/ProfilingRun.java +++ b/eth-benchmark-tests/src/jmh/java/tech/pegasys/teku/benchmarks/ProfilingRun.java @@ -38,7 +38,7 @@ import tech.pegasys.teku.spec.datastructures.state.Validator; import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState; import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconStateSchema; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel; import tech.pegasys.teku.spec.logic.common.block.AbstractBlockProcessor; import tech.pegasys.teku.spec.logic.common.statetransition.results.BlockImportResult; import tech.pegasys.teku.spec.util.DataStructureUtil; @@ -90,7 +90,7 @@ public void importBlocks() throws Exception { RecentChainData recentChainData = MemoryOnlyRecentChainData.create(spec); recentChainData.initializeFromGenesis(initialState, UInt64.ZERO); final MergeTransitionBlockValidator transitionBlockValidator = - new MergeTransitionBlockValidator(spec, recentChainData, ExecutionEngineChannel.NOOP); + new MergeTransitionBlockValidator(spec, recentChainData, ExecutionLayerChannel.NOOP); ForkChoice forkChoice = new ForkChoice( spec, @@ -107,7 +107,7 @@ public void importBlocks() throws Exception { recentChainData, forkChoice, wsValidator, - ExecutionEngineChannel.NOOP); + ExecutionLayerChannel.NOOP); System.out.println("Start blocks import from " + blocksFile); int blockCount = 0; @@ -180,7 +180,7 @@ public void importBlocksMemProfiling() throws Exception { recentChainData.initializeFromGenesis(initialState, UInt64.ZERO); initialState = null; final MergeTransitionBlockValidator transitionBlockValidator = - new MergeTransitionBlockValidator(spec, recentChainData, ExecutionEngineChannel.NOOP); + new MergeTransitionBlockValidator(spec, recentChainData, ExecutionLayerChannel.NOOP); ForkChoice forkChoice = new ForkChoice( spec, @@ -195,7 +195,7 @@ public void importBlocksMemProfiling() throws Exception { recentChainData, forkChoice, wsValidator, - ExecutionEngineChannel.NOOP); + ExecutionLayerChannel.NOOP); System.out.println("Start blocks import from " + blocksFile); int counter = 1; diff --git a/eth-benchmark-tests/src/jmh/java/tech/pegasys/teku/benchmarks/TransitionBenchmark.java b/eth-benchmark-tests/src/jmh/java/tech/pegasys/teku/benchmarks/TransitionBenchmark.java index 972ae8d99d4..34d2db2d8dc 100644 --- a/eth-benchmark-tests/src/jmh/java/tech/pegasys/teku/benchmarks/TransitionBenchmark.java +++ b/eth-benchmark-tests/src/jmh/java/tech/pegasys/teku/benchmarks/TransitionBenchmark.java @@ -37,7 +37,7 @@ import tech.pegasys.teku.spec.Spec; import tech.pegasys.teku.spec.TestSpecFactory; import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel; import tech.pegasys.teku.spec.logic.common.block.AbstractBlockProcessor; import tech.pegasys.teku.spec.logic.common.statetransition.results.BlockImportResult; import tech.pegasys.teku.statetransition.BeaconChainUtil; @@ -89,7 +89,7 @@ public void init() throws Exception { wsValidator = WeakSubjectivityFactory.lenientValidator(); recentChainData = MemoryOnlyRecentChainData.create(spec); final MergeTransitionBlockValidator transitionBlockValidator = - new MergeTransitionBlockValidator(spec, recentChainData, ExecutionEngineChannel.NOOP); + new MergeTransitionBlockValidator(spec, recentChainData, ExecutionLayerChannel.NOOP); ForkChoice forkChoice = new ForkChoice( spec, @@ -107,7 +107,7 @@ public void init() throws Exception { recentChainData, forkChoice, wsValidator, - ExecutionEngineChannel.NOOP); + ExecutionLayerChannel.NOOP); blockIterator = BlockIO.createResourceReader(spec, blocksFile).iterator(); System.out.println("Importing blocks from " + blocksFile); } diff --git a/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/phase0/forkchoice/ForkChoiceTestExecutor.java b/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/phase0/forkchoice/ForkChoiceTestExecutor.java index 0fa2e44836b..bfb39b85f82 100644 --- a/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/phase0/forkchoice/ForkChoiceTestExecutor.java +++ b/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/phase0/forkchoice/ForkChoiceTestExecutor.java @@ -46,8 +46,8 @@ import tech.pegasys.teku.spec.datastructures.state.AnchorPoint; import tech.pegasys.teku.spec.datastructures.state.Checkpoint; import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannelStub; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannelStub; import tech.pegasys.teku.spec.logic.common.statetransition.results.BlockImportResult; import tech.pegasys.teku.statetransition.forkchoice.ForkChoice; import tech.pegasys.teku.statetransition.forkchoice.MergeTransitionBlockValidator; @@ -98,7 +98,7 @@ spec, new SignedBlockAndState(anchorBlock, anchorState)), spec.getSlotStartTime(anchorBlock.getSlot(), anchorState.getGenesisTime())); final MergeTransitionBlockValidator transitionBlockValidator = - new MergeTransitionBlockValidator(spec, recentChainData, ExecutionEngineChannel.NOOP); + new MergeTransitionBlockValidator(spec, recentChainData, ExecutionLayerChannel.NOOP); final ForkChoice forkChoice = new ForkChoice( spec, @@ -107,9 +107,9 @@ spec, new SignedBlockAndState(anchorBlock, anchorState)), new StubForkChoiceNotifier(), transitionBlockValidator, true); - final ExecutionEngineChannelStub executionEngine = new ExecutionEngineChannelStub(spec, false); + final ExecutionLayerChannelStub executionLayer = new ExecutionLayerChannelStub(spec, false); - runSteps(testDefinition, spec, recentChainData, forkChoice, executionEngine); + runSteps(testDefinition, spec, recentChainData, forkChoice, executionLayer); } /** @@ -133,7 +133,7 @@ private void runSteps( final Spec spec, final RecentChainData recentChainData, final ForkChoice forkChoice, - final ExecutionEngineChannelStub executionEngine) + final ExecutionLayerChannelStub executionLayer) throws java.io.IOException { final List> steps = loadSteps(testDefinition); for (Map step : steps) { @@ -145,13 +145,13 @@ private void runSteps( forkChoice.onTick(secondsToMillis(getUInt64(step, "tick"))); } else if (step.containsKey("block")) { - applyBlock(testDefinition, spec, forkChoice, step, executionEngine); + applyBlock(testDefinition, spec, forkChoice, step, executionLayer); } else if (step.containsKey("attestation")) { applyAttestation(testDefinition, forkChoice, step); } else if (step.containsKey("pow_block")) { - applyPowBlock(testDefinition, step, executionEngine); + applyPowBlock(testDefinition, step, executionLayer); } else { throw new UnsupportedOperationException("Unsupported step: " + step); @@ -162,11 +162,11 @@ private void runSteps( private void applyPowBlock( final TestDefinition testDefinition, final Map step, - final ExecutionEngineChannelStub executionEngine) { + final ExecutionLayerChannelStub executionLayer) { final String filename = (String) step.get("pow_block"); final PowBlock block = TestDataUtils.loadSsz(testDefinition, filename + ".ssz_snappy", this::parsePowBlock); - executionEngine.addPowBlock(block); + executionLayer.addPowBlock(block); } private PowBlock parsePowBlock(final Bytes data) { @@ -207,7 +207,7 @@ private void applyBlock( final Spec spec, final ForkChoice forkChoice, final Map step, - final ExecutionEngineChannelStub executionEngine) { + final ExecutionLayerChannelStub executionLayer) { final String blockName = get(step, "block"); final boolean valid = !step.containsKey("valid") || (boolean) step.get("valid"); final SignedBeaconBlock block = @@ -219,7 +219,7 @@ private void applyBlock( block.getSlot(), block.getParentRoot()); final SafeFuture result = - forkChoice.onBlock(block, Optional.empty(), executionEngine); + forkChoice.onBlock(block, Optional.empty(), executionLayer); assertThat(result).isCompleted(); final BlockImportResult importResult = result.join(); assertThat(importResult) diff --git a/ethereum/executionengine/src/main/java/tech/pegasys/teku/ethereum/executionengine/ExecutionClientProvider.java b/ethereum/executionengine/src/main/java/tech/pegasys/teku/ethereum/executionengine/ExecutionClientProvider.java index 0bb89620251..cda9d73997d 100644 --- a/ethereum/executionengine/src/main/java/tech/pegasys/teku/ethereum/executionengine/ExecutionClientProvider.java +++ b/ethereum/executionengine/src/main/java/tech/pegasys/teku/ethereum/executionengine/ExecutionClientProvider.java @@ -13,7 +13,7 @@ package tech.pegasys.teku.ethereum.executionengine; -import static tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel.STUB_ENDPOINT_IDENTIFIER; +import static tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel.STUB_ENDPOINT_IDENTIFIER; import java.nio.file.Path; import java.time.Duration; @@ -47,16 +47,16 @@ public boolean isStub() { }; static ExecutionClientProvider create( - final String eeEndpoint, + final String endpoint, final TimeProvider timeProvider, final Duration timeout, final Optional jwtSecretFile, final Path beaconDataDirectory) { - if (eeEndpoint.equals(STUB_ENDPOINT_IDENTIFIER)) { + if (endpoint.equals(STUB_ENDPOINT_IDENTIFIER)) { return STUB; } else { return new DefaultExecutionClientProvider( - eeEndpoint, timeProvider, timeout, jwtSecretFile, beaconDataDirectory); + endpoint, timeProvider, timeout, jwtSecretFile, beaconDataDirectory); } } diff --git a/ethereum/executionlayer/src/integration-test/java/tech/pegasys/teku/ethereum/executionlayer/client/Web3JExecutionEngineClientTest.java b/ethereum/executionlayer/src/integration-test/java/tech/pegasys/teku/ethereum/executionlayer/client/Web3JExecutionEngineClientTest.java index fa5c8b47a86..6178e715833 100644 --- a/ethereum/executionlayer/src/integration-test/java/tech/pegasys/teku/ethereum/executionlayer/client/Web3JExecutionEngineClientTest.java +++ b/ethereum/executionlayer/src/integration-test/java/tech/pegasys/teku/ethereum/executionlayer/client/Web3JExecutionEngineClientTest.java @@ -50,7 +50,7 @@ import tech.pegasys.teku.spec.SpecMilestone; import tech.pegasys.teku.spec.TestSpecContext; import tech.pegasys.teku.spec.TestSpecInvocationContextProvider.SpecContext; -import tech.pegasys.teku.spec.executionengine.PayloadStatus; +import tech.pegasys.teku.spec.executionlayer.PayloadStatus; import tech.pegasys.teku.spec.util.DataStructureUtil; @TestSpecContext(milestone = SpecMilestone.BELLATRIX) diff --git a/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/ExecutionEngineChannelImpl.java b/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/ExecutionLayerChannelImpl.java similarity index 66% rename from ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/ExecutionEngineChannelImpl.java rename to ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/ExecutionLayerChannelImpl.java index a6c82aa02fc..b225defe1b9 100644 --- a/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/ExecutionEngineChannelImpl.java +++ b/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/ExecutionLayerChannelImpl.java @@ -15,14 +15,21 @@ import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; +import static tech.pegasys.teku.spec.config.Constants.MAXIMUM_CONCURRENT_EB_REQUESTS; +import static tech.pegasys.teku.spec.config.Constants.MAXIMUM_CONCURRENT_EE_REQUESTS; import java.util.Optional; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes32; +import org.hyperledger.besu.plugin.services.MetricsSystem; import tech.pegasys.teku.ethereum.executionengine.Web3JClient; import tech.pegasys.teku.ethereum.executionengine.schema.Response; +import tech.pegasys.teku.ethereum.executionlayer.client.ExecutionBuilderClient; import tech.pegasys.teku.ethereum.executionlayer.client.ExecutionEngineClient; +import tech.pegasys.teku.ethereum.executionlayer.client.ThrottlingExecutionBuilderClient; +import tech.pegasys.teku.ethereum.executionlayer.client.ThrottlingExecutionEngineClient; +import tech.pegasys.teku.ethereum.executionlayer.client.Web3JExecutionBuilderClient; import tech.pegasys.teku.ethereum.executionlayer.client.Web3JExecutionEngineClient; import tech.pegasys.teku.ethereum.executionlayer.client.schema.ExecutionPayloadHeaderV1; import tech.pegasys.teku.ethereum.executionlayer.client.schema.ExecutionPayloadV1; @@ -37,40 +44,68 @@ import tech.pegasys.teku.infrastructure.unsigned.UInt64; import tech.pegasys.teku.spec.Spec; import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock; +import tech.pegasys.teku.spec.datastructures.execution.BuilderStatus; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeader; import tech.pegasys.teku.spec.datastructures.execution.PowBlock; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel; -import tech.pegasys.teku.spec.executionengine.ForkChoiceState; -import tech.pegasys.teku.spec.executionengine.PayloadAttributes; -import tech.pegasys.teku.spec.executionengine.PayloadStatus; -import tech.pegasys.teku.spec.executionengine.TransitionConfiguration; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel; +import tech.pegasys.teku.spec.executionlayer.ForkChoiceState; +import tech.pegasys.teku.spec.executionlayer.PayloadAttributes; +import tech.pegasys.teku.spec.executionlayer.PayloadStatus; +import tech.pegasys.teku.spec.executionlayer.TransitionConfiguration; import tech.pegasys.teku.spec.schemas.SchemaDefinitionsBellatrix; -public class ExecutionEngineChannelImpl implements ExecutionEngineChannel { +public class ExecutionLayerChannelImpl implements ExecutionLayerChannel { private static final Logger LOG = LogManager.getLogger(); private final ExecutionEngineClient executionEngineClient; + + @SuppressWarnings("UnusedVariable") // will be removed in upcoming PR + private final Optional executionBuilderClient; + private final Spec spec; - public static ExecutionEngineChannelImpl create( - final Web3JClient web3JClient, final Version version, final Spec spec) { + public static ExecutionLayerChannelImpl create( + final Web3JClient engineWeb3JClient, + final Optional builderWeb3JClient, + final Version version, + final Spec spec, + final MetricsSystem metricsSystem) { checkNotNull(version); - return new ExecutionEngineChannelImpl(createEngineClient(version, web3JClient), spec); + return new ExecutionLayerChannelImpl( + createEngineClient(version, engineWeb3JClient, metricsSystem), + createBuilderClient(builderWeb3JClient, metricsSystem), + spec); } private static ExecutionEngineClient createEngineClient( - final Version version, final Web3JClient web3JClient) { + final Version version, final Web3JClient web3JClient, final MetricsSystem metricsSystem) { LOG.info("Execution Engine version: {}", version); if (version != Version.KILNV2) { throw new InvalidConfigurationException("Unsupported execution engine version: " + version); } - return new Web3JExecutionEngineClient(web3JClient); + return new ThrottlingExecutionEngineClient( + new Web3JExecutionEngineClient(web3JClient), MAXIMUM_CONCURRENT_EE_REQUESTS, metricsSystem); } - private ExecutionEngineChannelImpl(ExecutionEngineClient executionEngineClient, Spec spec) { - this.spec = spec; + private static Optional createBuilderClient( + final Optional web3JClient, final MetricsSystem metricsSystem) { + return web3JClient.flatMap( + client -> + Optional.of( + new ThrottlingExecutionBuilderClient( + new Web3JExecutionBuilderClient(client), + MAXIMUM_CONCURRENT_EB_REQUESTS, + metricsSystem))); + } + + private ExecutionLayerChannelImpl( + final ExecutionEngineClient executionEngineClient, + final Optional executionBuilderClient, + final Spec spec) { this.executionEngineClient = executionEngineClient; + this.executionBuilderClient = executionBuilderClient; + this.spec = spec; } private static K unwrapResponseOrThrow(Response response) { @@ -82,7 +117,7 @@ private static K unwrapResponseOrThrow(Response response) { } @Override - public SafeFuture> getPowBlock(final Bytes32 blockHash) { + public SafeFuture> eth1GetPowBlock(final Bytes32 blockHash) { LOG.trace("calling getPowBlock(blockHash={})", blockHash); return executionEngineClient @@ -91,7 +126,7 @@ public SafeFuture> getPowBlock(final Bytes32 blockHash) { } @Override - public SafeFuture getPowChainHead() { + public SafeFuture eth1GetPowChainHead() { LOG.trace("calling getPowChainHead()"); return executionEngineClient @@ -100,8 +135,8 @@ public SafeFuture getPowChainHead() { } @Override - public SafeFuture - forkChoiceUpdated( + public SafeFuture + engineForkChoiceUpdated( final ForkChoiceState forkChoiceState, final Optional payloadAttributes) { @@ -114,7 +149,7 @@ public SafeFuture getPowChainHead() { .forkChoiceUpdated( ForkChoiceStateV1.fromInternalForkChoiceState(forkChoiceState), PayloadAttributesV1.fromInternalForkChoiceState(payloadAttributes)) - .thenApply(ExecutionEngineChannelImpl::unwrapResponseOrThrow) + .thenApply(ExecutionLayerChannelImpl::unwrapResponseOrThrow) .thenApply(ForkChoiceUpdatedResult::asInternalExecutionPayload) .thenPeek( forkChoiceUpdatedResult -> @@ -126,12 +161,12 @@ public SafeFuture getPowChainHead() { } @Override - public SafeFuture getPayload(final Bytes8 payloadId, final UInt64 slot) { + public SafeFuture engineGetPayload(final Bytes8 payloadId, final UInt64 slot) { LOG.trace("calling getPayload(payloadId={}, slot={})", payloadId, slot); return executionEngineClient .getPayload(payloadId) - .thenApply(ExecutionEngineChannelImpl::unwrapResponseOrThrow) + .thenApply(ExecutionLayerChannelImpl::unwrapResponseOrThrow) .thenCombine( SafeFuture.of( () -> @@ -145,12 +180,12 @@ public SafeFuture getPayload(final Bytes8 payloadId, final UIn } @Override - public SafeFuture newPayload(final ExecutionPayload executionPayload) { + public SafeFuture engineNewPayload(final ExecutionPayload executionPayload) { LOG.trace("calling newPayload(executionPayload={})", executionPayload); return executionEngineClient .newPayload(ExecutionPayloadV1.fromInternalExecutionPayload(executionPayload)) - .thenApply(ExecutionEngineChannelImpl::unwrapResponseOrThrow) + .thenApply(ExecutionLayerChannelImpl::unwrapResponseOrThrow) .thenApply(PayloadStatusV1::asInternalExecutionPayload) .thenPeek( payloadStatus -> @@ -159,7 +194,7 @@ public SafeFuture newPayload(final ExecutionPayload executionPayl } @Override - public SafeFuture exchangeTransitionConfiguration( + public SafeFuture engineExchangeTransitionConfiguration( TransitionConfiguration transitionConfiguration) { LOG.trace( "calling exchangeTransitionConfiguration(transitionConfiguration={})", @@ -168,7 +203,7 @@ public SafeFuture exchangeTransitionConfiguration( return executionEngineClient .exchangeTransitionConfiguration( TransitionConfigurationV1.fromInternalTransitionConfiguration(transitionConfiguration)) - .thenApply(ExecutionEngineChannelImpl::unwrapResponseOrThrow) + .thenApply(ExecutionLayerChannelImpl::unwrapResponseOrThrow) .thenApply(TransitionConfigurationV1::asInternalTransitionConfiguration) .thenPeek( remoteTransitionConfiguration -> @@ -178,6 +213,22 @@ public SafeFuture exchangeTransitionConfiguration( remoteTransitionConfiguration)); } + @Override + public SafeFuture builderStatus() { + if (executionBuilderClient.isEmpty()) { + LOG.trace("Skipping calling builderStatus() because execution builder is not enabled."); + return SafeFuture.completedFuture(null); + } + LOG.trace("calling builderStatus()"); + return executionBuilderClient + .get() + .status() + .thenApply(ExecutionLayerChannelImpl::unwrapResponseOrThrow) + .thenApply(___ -> BuilderStatus.withOkStatus()) + .exceptionally(BuilderStatus::withFailedStatus) + .thenPeek(builderStatus -> LOG.trace("builderStatus() -> {}", builderStatus)); + } + @Override public SafeFuture getPayloadHeader( final Bytes8 payloadId, final UInt64 slot) { @@ -185,7 +236,7 @@ public SafeFuture getPayloadHeader( return executionEngineClient .getPayloadHeader(payloadId) - .thenApply(ExecutionEngineChannelImpl::unwrapResponseOrThrow) + .thenApply(ExecutionLayerChannelImpl::unwrapResponseOrThrow) .thenCombine( SafeFuture.of( () -> @@ -212,7 +263,7 @@ public SafeFuture proposeBlindedBlock( return executionEngineClient .proposeBlindedBlock(signedBlindedBeaconBlock) - .thenApply(ExecutionEngineChannelImpl::unwrapResponseOrThrow) + .thenApply(ExecutionLayerChannelImpl::unwrapResponseOrThrow) .thenCombine( SafeFuture.of( () -> diff --git a/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/client/ThrottlingExecutionBuilderClient.java b/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/client/ThrottlingExecutionBuilderClient.java new file mode 100644 index 00000000000..91dc8695e9d --- /dev/null +++ b/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/client/ThrottlingExecutionBuilderClient.java @@ -0,0 +1,70 @@ +/* + * Copyright 2022 ConsenSys AG. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package tech.pegasys.teku.ethereum.executionlayer.client; + +import org.apache.tuweni.bytes.Bytes32; +import org.apache.tuweni.bytes.Bytes48; +import org.hyperledger.besu.plugin.services.MetricsSystem; +import tech.pegasys.teku.ethereum.executionengine.schema.Response; +import tech.pegasys.teku.ethereum.executionlayer.client.schema.BlindedBeaconBlockV1; +import tech.pegasys.teku.ethereum.executionlayer.client.schema.BuilderBidV1; +import tech.pegasys.teku.ethereum.executionlayer.client.schema.ExecutionPayloadV1; +import tech.pegasys.teku.ethereum.executionlayer.client.schema.GenericBuilderStatus; +import tech.pegasys.teku.ethereum.executionlayer.client.schema.SignedMessage; +import tech.pegasys.teku.ethereum.executionlayer.client.schema.ValidatorRegistrationV1; +import tech.pegasys.teku.infrastructure.async.SafeFuture; +import tech.pegasys.teku.infrastructure.async.ThrottlingTaskQueue; +import tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory; +import tech.pegasys.teku.infrastructure.unsigned.UInt64; + +public class ThrottlingExecutionBuilderClient implements ExecutionBuilderClient { + private final ExecutionBuilderClient delegate; + private final ThrottlingTaskQueue taskQueue; + + public ThrottlingExecutionBuilderClient( + final ExecutionBuilderClient delegate, + final int maximumConcurrentRequests, + final MetricsSystem metricsSystem) { + this.delegate = delegate; + taskQueue = + new ThrottlingTaskQueue( + maximumConcurrentRequests, + metricsSystem, + TekuMetricCategory.BEACON, + "eb_request_queue_size"); + } + + @Override + public SafeFuture> status() { + return taskQueue.queueTask(delegate::status); + } + + @Override + public SafeFuture> registerValidator( + final SignedMessage signedValidatorRegistrationV1) { + return taskQueue.queueTask(() -> delegate.registerValidator(signedValidatorRegistrationV1)); + } + + @Override + public SafeFuture>> getHeader( + final UInt64 slot, final Bytes48 pubKey, final Bytes32 parentHash) { + return taskQueue.queueTask(() -> delegate.getHeader(slot, pubKey, parentHash)); + } + + @Override + public SafeFuture> getPayload( + final SignedMessage signedBlindedBeaconBlock) { + return taskQueue.queueTask(() -> delegate.getPayload(signedBlindedBeaconBlock)); + } +} diff --git a/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/ThrottlingExecutionEngineChannel.java b/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/client/ThrottlingExecutionEngineClient.java similarity index 54% rename from ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/ThrottlingExecutionEngineChannel.java rename to ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/client/ThrottlingExecutionEngineClient.java index 5c3f14f94cc..981f60c4f05 100644 --- a/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/ThrottlingExecutionEngineChannel.java +++ b/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/client/ThrottlingExecutionEngineClient.java @@ -11,33 +11,32 @@ * specific language governing permissions and limitations under the License. */ -package tech.pegasys.teku.ethereum.executionlayer; +package tech.pegasys.teku.ethereum.executionlayer.client; import java.util.Optional; import org.apache.tuweni.bytes.Bytes32; import org.hyperledger.besu.plugin.services.MetricsSystem; +import tech.pegasys.teku.ethereum.executionengine.schema.Response; +import tech.pegasys.teku.ethereum.executionlayer.client.schema.ExecutionPayloadHeaderV1; +import tech.pegasys.teku.ethereum.executionlayer.client.schema.ExecutionPayloadV1; +import tech.pegasys.teku.ethereum.executionlayer.client.schema.ForkChoiceStateV1; +import tech.pegasys.teku.ethereum.executionlayer.client.schema.ForkChoiceUpdatedResult; +import tech.pegasys.teku.ethereum.executionlayer.client.schema.PayloadAttributesV1; +import tech.pegasys.teku.ethereum.executionlayer.client.schema.PayloadStatusV1; +import tech.pegasys.teku.ethereum.executionlayer.client.schema.TransitionConfigurationV1; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.async.ThrottlingTaskQueue; import tech.pegasys.teku.infrastructure.bytes.Bytes8; import tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory; -import tech.pegasys.teku.infrastructure.unsigned.UInt64; import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock; -import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload; -import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeader; import tech.pegasys.teku.spec.datastructures.execution.PowBlock; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel; -import tech.pegasys.teku.spec.executionengine.ForkChoiceState; -import tech.pegasys.teku.spec.executionengine.ForkChoiceUpdatedResult; -import tech.pegasys.teku.spec.executionengine.PayloadAttributes; -import tech.pegasys.teku.spec.executionengine.PayloadStatus; -import tech.pegasys.teku.spec.executionengine.TransitionConfiguration; -public class ThrottlingExecutionEngineChannel implements ExecutionEngineChannel { - private final ExecutionEngineChannel delegate; +public class ThrottlingExecutionEngineClient implements ExecutionEngineClient { + private final ExecutionEngineClient delegate; private final ThrottlingTaskQueue taskQueue; - public ThrottlingExecutionEngineChannel( - final ExecutionEngineChannel delegate, + public ThrottlingExecutionEngineClient( + final ExecutionEngineClient delegate, final int maximumConcurrentRequests, final MetricsSystem metricsSystem) { this.delegate = delegate; @@ -50,47 +49,49 @@ public ThrottlingExecutionEngineChannel( } @Override - public SafeFuture> getPowBlock(Bytes32 blockHash) { + public SafeFuture> getPowBlock(final Bytes32 blockHash) { return taskQueue.queueTask(() -> delegate.getPowBlock(blockHash)); } @Override public SafeFuture getPowChainHead() { - return taskQueue.queueTask(delegate::getPowChainHead); + return taskQueue.queueTask(() -> delegate.getPowChainHead()); } @Override - public SafeFuture forkChoiceUpdated( - ForkChoiceState forkChoiceState, Optional payloadAttributes) { - return taskQueue.queueTask( - () -> delegate.forkChoiceUpdated(forkChoiceState, payloadAttributes)); + public SafeFuture> getPayload(final Bytes8 payloadId) { + return taskQueue.queueTask(() -> delegate.getPayload(payloadId)); } @Override - public SafeFuture getPayload(Bytes8 payloadId, UInt64 slot) { - return taskQueue.queueTask(() -> delegate.getPayload(payloadId, slot)); + public SafeFuture> newPayload( + final ExecutionPayloadV1 executionPayload) { + return taskQueue.queueTask(() -> delegate.newPayload(executionPayload)); } @Override - public SafeFuture newPayload(ExecutionPayload executionPayload) { - return taskQueue.queueTask(() -> delegate.newPayload(executionPayload)); + public SafeFuture> forkChoiceUpdated( + final ForkChoiceStateV1 forkChoiceState, + final Optional payloadAttributes) { + return taskQueue.queueTask( + () -> delegate.forkChoiceUpdated(forkChoiceState, payloadAttributes)); } @Override - public SafeFuture exchangeTransitionConfiguration( - TransitionConfiguration transitionConfiguration) { + public SafeFuture> exchangeTransitionConfiguration( + final TransitionConfigurationV1 transitionConfiguration) { return taskQueue.queueTask( () -> delegate.exchangeTransitionConfiguration(transitionConfiguration)); } @Override - public SafeFuture getPayloadHeader(Bytes8 payloadId, UInt64 slot) { - return taskQueue.queueTask(() -> delegate.getPayloadHeader(payloadId, slot)); + public SafeFuture> getPayloadHeader(final Bytes8 payloadId) { + return taskQueue.queueTask(() -> delegate.getPayloadHeader(payloadId)); } @Override - public SafeFuture proposeBlindedBlock( - SignedBeaconBlock signedBlindedBeaconBlock) { + public SafeFuture> proposeBlindedBlock( + final SignedBeaconBlock signedBlindedBeaconBlock) { return taskQueue.queueTask(() -> delegate.proposeBlindedBlock(signedBlindedBeaconBlock)); } } diff --git a/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/client/schema/ForkChoiceStateV1.java b/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/client/schema/ForkChoiceStateV1.java index 82dcf3b4183..9b888ca6f06 100644 --- a/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/client/schema/ForkChoiceStateV1.java +++ b/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/client/schema/ForkChoiceStateV1.java @@ -23,7 +23,7 @@ import org.apache.tuweni.bytes.Bytes32; import tech.pegasys.teku.ethereum.executionlayer.client.serialization.Bytes32Deserializer; import tech.pegasys.teku.ethereum.executionlayer.client.serialization.BytesSerializer; -import tech.pegasys.teku.spec.executionengine.ForkChoiceState; +import tech.pegasys.teku.spec.executionlayer.ForkChoiceState; public class ForkChoiceStateV1 { @JsonSerialize(using = BytesSerializer.class) diff --git a/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/client/schema/ForkChoiceUpdatedResult.java b/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/client/schema/ForkChoiceUpdatedResult.java index 4332385f4de..1a7fd0f1109 100644 --- a/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/client/schema/ForkChoiceUpdatedResult.java +++ b/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/client/schema/ForkChoiceUpdatedResult.java @@ -37,9 +37,9 @@ public ForkChoiceUpdatedResult( this.payloadId = payloadId; } - public tech.pegasys.teku.spec.executionengine.ForkChoiceUpdatedResult + public tech.pegasys.teku.spec.executionlayer.ForkChoiceUpdatedResult asInternalExecutionPayload() { - return new tech.pegasys.teku.spec.executionengine.ForkChoiceUpdatedResult( + return new tech.pegasys.teku.spec.executionlayer.ForkChoiceUpdatedResult( payloadStatus.asInternalExecutionPayload(), Optional.ofNullable(payloadId)); } diff --git a/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/client/schema/PayloadAttributesV1.java b/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/client/schema/PayloadAttributesV1.java index b547d603479..43c468a37b4 100644 --- a/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/client/schema/PayloadAttributesV1.java +++ b/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/client/schema/PayloadAttributesV1.java @@ -30,7 +30,7 @@ import tech.pegasys.teku.ethereum.executionlayer.client.serialization.UInt64AsHexSerializer; import tech.pegasys.teku.infrastructure.bytes.Bytes20; import tech.pegasys.teku.infrastructure.unsigned.UInt64; -import tech.pegasys.teku.spec.executionengine.PayloadAttributes; +import tech.pegasys.teku.spec.executionlayer.PayloadAttributes; public class PayloadAttributesV1 { @JsonSerialize(using = UInt64AsHexSerializer.class) diff --git a/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/client/schema/PayloadStatusV1.java b/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/client/schema/PayloadStatusV1.java index 18876dad096..7ee45a13375 100644 --- a/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/client/schema/PayloadStatusV1.java +++ b/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/client/schema/PayloadStatusV1.java @@ -22,8 +22,8 @@ import java.util.Optional; import org.apache.tuweni.bytes.Bytes32; import tech.pegasys.teku.ethereum.executionlayer.client.serialization.Bytes32Deserializer; -import tech.pegasys.teku.spec.executionengine.ExecutionPayloadStatus; -import tech.pegasys.teku.spec.executionengine.PayloadStatus; +import tech.pegasys.teku.spec.executionlayer.ExecutionPayloadStatus; +import tech.pegasys.teku.spec.executionlayer.PayloadStatus; public class PayloadStatusV1 { private final ExecutionPayloadStatus status; diff --git a/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/client/schema/TransitionConfigurationV1.java b/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/client/schema/TransitionConfigurationV1.java index 4ed36ab9a79..0109353f829 100644 --- a/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/client/schema/TransitionConfigurationV1.java +++ b/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/client/schema/TransitionConfigurationV1.java @@ -30,7 +30,7 @@ import tech.pegasys.teku.ethereum.executionlayer.client.serialization.UInt64AsHexDeserializer; import tech.pegasys.teku.ethereum.executionlayer.client.serialization.UInt64AsHexSerializer; import tech.pegasys.teku.infrastructure.unsigned.UInt64; -import tech.pegasys.teku.spec.executionengine.TransitionConfiguration; +import tech.pegasys.teku.spec.executionlayer.TransitionConfiguration; public class TransitionConfigurationV1 { @JsonSerialize(using = UInt256AsHexSerializer.class) diff --git a/ethereum/executionlayer/src/test/java/tech/pegasys/teku/ethereum/executionlayer/client/Web3JExecutionEngineClientTest.java b/ethereum/executionlayer/src/test/java/tech/pegasys/teku/ethereum/executionlayer/client/Web3JExecutionEngineClientTest.java index 2c52b7cafd0..21204ee9e0f 100644 --- a/ethereum/executionlayer/src/test/java/tech/pegasys/teku/ethereum/executionlayer/client/Web3JExecutionEngineClientTest.java +++ b/ethereum/executionlayer/src/test/java/tech/pegasys/teku/ethereum/executionlayer/client/Web3JExecutionEngineClientTest.java @@ -58,9 +58,9 @@ import tech.pegasys.teku.spec.TestSpecInvocationContextProvider.SpecContext; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeader; -import tech.pegasys.teku.spec.executionengine.ExecutionPayloadStatus; -import tech.pegasys.teku.spec.executionengine.PayloadStatus; -import tech.pegasys.teku.spec.executionengine.TransitionConfiguration; +import tech.pegasys.teku.spec.executionlayer.ExecutionPayloadStatus; +import tech.pegasys.teku.spec.executionlayer.PayloadStatus; +import tech.pegasys.teku.spec.executionlayer.TransitionConfiguration; import tech.pegasys.teku.spec.util.DataStructureUtil; @TestSpecContext(milestone = SpecMilestone.BELLATRIX) @@ -310,7 +310,7 @@ void shouldThrowDeserializingInvalidPayloadStatusV1() { void shouldDeserializeForkChoiceUpdatedResultWithNulls() throws IOException { ForkChoiceUpdatedResult forkChoiceUpdatedResultExpected = createExternalForkChoiceUpdatedResult(ExecutionPayloadStatus.SYNCING, null, null); - tech.pegasys.teku.spec.executionengine.ForkChoiceUpdatedResult + tech.pegasys.teku.spec.executionlayer.ForkChoiceUpdatedResult internalForkChoiceUpdatedResultExpected = createInternalForkChoiceUpdatedResult( ExecutionPayloadStatus.SYNCING, Optional.empty(), Optional.empty()); @@ -318,7 +318,7 @@ void shouldDeserializeForkChoiceUpdatedResultWithNulls() throws IOException { ForkChoiceUpdatedResult executeForkChoiceUpdatedResultDeserialized = objectMapper.readValue(json, ForkChoiceUpdatedResult.class); - tech.pegasys.teku.spec.executionengine.ForkChoiceUpdatedResult internalForkChoiceUpdatedResult = + tech.pegasys.teku.spec.executionlayer.ForkChoiceUpdatedResult internalForkChoiceUpdatedResult = executeForkChoiceUpdatedResultDeserialized.asInternalExecutionPayload(); assertThat(executeForkChoiceUpdatedResultDeserialized) @@ -333,7 +333,7 @@ void shouldDeserializeForkChoiceUpdatedResult() throws IOException { ForkChoiceUpdatedResult forkChoiceUpdatedResultExpected = createExternalForkChoiceUpdatedResult( ExecutionPayloadStatus.VALID, latestValidHash, payloadId); - tech.pegasys.teku.spec.executionengine.ForkChoiceUpdatedResult + tech.pegasys.teku.spec.executionlayer.ForkChoiceUpdatedResult internalForkChoiceUpdatedResultExpected = createInternalForkChoiceUpdatedResult( ExecutionPayloadStatus.VALID, Optional.of(latestValidHash), Optional.of(payloadId)); @@ -346,7 +346,7 @@ void shouldDeserializeForkChoiceUpdatedResult() throws IOException { ForkChoiceUpdatedResult executeForkChoiceUpdatedResultDeserialized = objectMapper.readValue(json, ForkChoiceUpdatedResult.class); - tech.pegasys.teku.spec.executionengine.ForkChoiceUpdatedResult internalForkChoiceUpdatedResult = + tech.pegasys.teku.spec.executionlayer.ForkChoiceUpdatedResult internalForkChoiceUpdatedResult = executeForkChoiceUpdatedResultDeserialized.asInternalExecutionPayload(); assertThat(executeForkChoiceUpdatedResultDeserialized) @@ -501,12 +501,12 @@ private ForkChoiceUpdatedResult createExternalForkChoiceUpdatedResult( new PayloadStatusV1(status, latestValidHash, null), payloadId); } - private tech.pegasys.teku.spec.executionengine.ForkChoiceUpdatedResult + private tech.pegasys.teku.spec.executionlayer.ForkChoiceUpdatedResult createInternalForkChoiceUpdatedResult( ExecutionPayloadStatus status, Optional latestValidHash, Optional payloadId) { - return new tech.pegasys.teku.spec.executionengine.ForkChoiceUpdatedResult( + return new tech.pegasys.teku.spec.executionlayer.ForkChoiceUpdatedResult( PayloadStatus.create(status, latestValidHash, Optional.empty()), payloadId); } } diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/Constants.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/Constants.java index 19c3d16d753..be7233a3588 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/Constants.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/Constants.java @@ -49,6 +49,7 @@ public class Constants { Duration.ofSeconds(60); // syncing or wrong chainid public static final int MAXIMUM_CONCURRENT_ETH1_REQUESTS = 5; public static final int MAXIMUM_CONCURRENT_EE_REQUESTS = 5; + public static final int MAXIMUM_CONCURRENT_EB_REQUESTS = 5; public static final int REPUTATION_MANAGER_CAPACITY = 1024; public static final Duration STORAGE_REQUEST_TIMEOUT = Duration.ofSeconds(60); public static final int STORAGE_QUERY_CHANNEL_PARALLELISM = 10; // # threads diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/BuilderStatus.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/BuilderStatus.java new file mode 100644 index 00000000000..ae20356f8c6 --- /dev/null +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/BuilderStatus.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 ConsenSys AG. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package tech.pegasys.teku.spec.datastructures.execution; + +import com.google.common.base.MoreObjects; + +public class BuilderStatus { + + private final Status status; + private final String errorMessage; + + private BuilderStatus(final Status status, final String errorMessage) { + this.status = status; + this.errorMessage = errorMessage; + } + + public static BuilderStatus withOkStatus() { + return new BuilderStatus(Status.OK, null); + } + + public static BuilderStatus withFailedStatus(final Throwable cause) { + return new BuilderStatus(null, cause.getMessage()); + } + + public Status getStatus() { + return status; + } + + public String getErrorMessage() { + return errorMessage; + } + + public boolean hasFailed() { + return status == null; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("errorMessage", errorMessage) + .toString(); + } + + public enum Status { + OK + } +} diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionengine/ExecutionEngineChannel.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/ExecutionLayerChannel.java similarity index 67% rename from ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionengine/ExecutionEngineChannel.java rename to ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/ExecutionLayerChannel.java index 29eaf0c0877..710c44018a0 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionengine/ExecutionEngineChannel.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/ExecutionLayerChannel.java @@ -11,7 +11,7 @@ * specific language governing permissions and limitations under the License. */ -package tech.pegasys.teku.spec.executionengine; +package tech.pegasys.teku.spec.executionlayer; import java.util.Optional; import org.apache.tuweni.bytes.Bytes32; @@ -20,26 +20,27 @@ import tech.pegasys.teku.infrastructure.events.ChannelInterface; import tech.pegasys.teku.infrastructure.unsigned.UInt64; import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock; +import tech.pegasys.teku.spec.datastructures.execution.BuilderStatus; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeader; import tech.pegasys.teku.spec.datastructures.execution.PowBlock; -public interface ExecutionEngineChannel extends ChannelInterface { +public interface ExecutionLayerChannel extends ChannelInterface { String STUB_ENDPOINT_IDENTIFIER = "stub"; - ExecutionEngineChannel NOOP = - new ExecutionEngineChannel() { + ExecutionLayerChannel NOOP = + new ExecutionLayerChannel() { @Override - public SafeFuture> getPowBlock(final Bytes32 blockHash) { + public SafeFuture> eth1GetPowBlock(final Bytes32 blockHash) { return SafeFuture.completedFuture(Optional.empty()); } @Override - public SafeFuture getPowChainHead() { + public SafeFuture eth1GetPowChainHead() { throw new UnsupportedOperationException(); } @Override - public SafeFuture forkChoiceUpdated( + public SafeFuture engineForkChoiceUpdated( final ForkChoiceState forkChoiceState, final Optional payloadAttributes) { return SafeFuture.completedFuture( @@ -47,21 +48,27 @@ public SafeFuture forkChoiceUpdated( } @Override - public SafeFuture getPayload(final Bytes8 payloadId, final UInt64 slot) { + public SafeFuture engineGetPayload( + final Bytes8 payloadId, final UInt64 slot) { return SafeFuture.completedFuture(null); } @Override - public SafeFuture newPayload(final ExecutionPayload executionPayload) { + public SafeFuture engineNewPayload(final ExecutionPayload executionPayload) { return SafeFuture.completedFuture(PayloadStatus.SYNCING); } @Override - public SafeFuture exchangeTransitionConfiguration( + public SafeFuture engineExchangeTransitionConfiguration( TransitionConfiguration transitionConfiguration) { return SafeFuture.completedFuture(transitionConfiguration); } + @Override + public SafeFuture builderStatus() { + return SafeFuture.completedFuture(BuilderStatus.withOkStatus()); + } + @Override public SafeFuture getPayloadHeader( final Bytes8 payloadId, final UInt64 slot) { @@ -76,22 +83,24 @@ public SafeFuture proposeBlindedBlock( }; // eth namespace - SafeFuture> getPowBlock(final Bytes32 blockHash); + SafeFuture> eth1GetPowBlock(final Bytes32 blockHash); - SafeFuture getPowChainHead(); + SafeFuture eth1GetPowChainHead(); // engine namespace - SafeFuture forkChoiceUpdated( + SafeFuture engineForkChoiceUpdated( final ForkChoiceState forkChoiceState, final Optional payloadAttributes); - SafeFuture getPayload(final Bytes8 payloadId, final UInt64 slot); + SafeFuture engineGetPayload(final Bytes8 payloadId, final UInt64 slot); - SafeFuture newPayload(final ExecutionPayload executionPayload); + SafeFuture engineNewPayload(final ExecutionPayload executionPayload); - SafeFuture exchangeTransitionConfiguration( + SafeFuture engineExchangeTransitionConfiguration( final TransitionConfiguration transitionConfiguration); // builder namespace + SafeFuture builderStatus(); + SafeFuture getPayloadHeader(final Bytes8 payloadId, final UInt64 slot); SafeFuture proposeBlindedBlock( diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionengine/ExecutionEngineChannelStub.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/ExecutionLayerChannelStub.java similarity index 93% rename from ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionengine/ExecutionEngineChannelStub.java rename to ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/ExecutionLayerChannelStub.java index 09b246f295a..56f0a46d181 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionengine/ExecutionEngineChannelStub.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/ExecutionLayerChannelStub.java @@ -11,7 +11,7 @@ * specific language governing permissions and limitations under the License. */ -package tech.pegasys.teku.spec.executionengine; +package tech.pegasys.teku.spec.executionlayer; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; @@ -39,12 +39,13 @@ import tech.pegasys.teku.spec.SpecVersion; import tech.pegasys.teku.spec.config.SpecConfigBellatrix; import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock; +import tech.pegasys.teku.spec.datastructures.execution.BuilderStatus; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeader; import tech.pegasys.teku.spec.datastructures.execution.PowBlock; import tech.pegasys.teku.spec.schemas.SchemaDefinitionsBellatrix; -public class ExecutionEngineChannelStub implements ExecutionEngineChannel { +public class ExecutionLayerChannelStub implements ExecutionLayerChannel { private static final Logger LOG = LogManager.getLogger(); private final TimeProvider timeProvider; private final Map knownBlocks = new ConcurrentHashMap<>(); @@ -70,7 +71,7 @@ public class ExecutionEngineChannelStub implements ExecutionEngineChannel { private Optional lastMevBoostPayloadToBeUnblinded = Optional.empty(); private Optional lastValidBlock = Optional.empty(); - public ExecutionEngineChannelStub( + public ExecutionLayerChannelStub( final Spec spec, final TimeProvider timeProvider, final boolean enableTransitionEmulation) { this.payloadIdToHeadAndAttrsCache = LRUCache.create(10); this.spec = spec; @@ -78,7 +79,7 @@ public ExecutionEngineChannelStub( this.transitionEmulationEnabled = enableTransitionEmulation; } - public ExecutionEngineChannelStub(final Spec spec, final boolean enableTransitionEmulation) { + public ExecutionLayerChannelStub(final Spec spec, final boolean enableTransitionEmulation) { this(spec, new SystemTimeProvider(), enableTransitionEmulation); } @@ -87,7 +88,7 @@ public void addPowBlock(final PowBlock block) { } @Override - public SafeFuture> getPowBlock(final Bytes32 blockHash) { + public SafeFuture> eth1GetPowBlock(final Bytes32 blockHash) { if (!transitionEmulationEnabled) { requestedPowBlocks.add(blockHash); return SafeFuture.completedFuture(Optional.ofNullable(knownBlocks.get(blockHash))); @@ -112,7 +113,7 @@ public SafeFuture> getPowBlock(final Bytes32 blockHash) { } @Override - public SafeFuture getPowChainHead() { + public SafeFuture eth1GetPowChainHead() { if (!transitionEmulationEnabled) { return SafeFuture.failedFuture( new UnsupportedOperationException("getPowChainHead not supported")); @@ -133,7 +134,7 @@ public SafeFuture getPowChainHead() { } @Override - public SafeFuture forkChoiceUpdated( + public SafeFuture engineForkChoiceUpdated( final ForkChoiceState forkChoiceState, final Optional payloadAttributes) { if (!bellatrixActivationDetected) { LOG.info( @@ -159,7 +160,7 @@ public SafeFuture forkChoiceUpdated( } @Override - public SafeFuture getPayload(final Bytes8 payloadId, final UInt64 slot) { + public SafeFuture engineGetPayload(final Bytes8 payloadId, final UInt64 slot) { if (!bellatrixActivationDetected) { LOG.info( "getPayload received before terminalBlock has been sent. Assuming transition already happened"); @@ -225,7 +226,7 @@ public SafeFuture getPayload(final Bytes8 payloadId, final UIn } @Override - public SafeFuture newPayload(final ExecutionPayload executionPayload) { + public SafeFuture engineNewPayload(final ExecutionPayload executionPayload) { LOG.info( "newPayload: executionPayload blockHash: {} -> {}", executionPayload.getBlockHash(), @@ -234,7 +235,7 @@ public SafeFuture newPayload(final ExecutionPayload executionPayl } @Override - public SafeFuture exchangeTransitionConfiguration( + public SafeFuture engineExchangeTransitionConfiguration( TransitionConfiguration transitionConfiguration) { final TransitionConfiguration transitionConfigurationResponse; @@ -256,6 +257,11 @@ public SafeFuture exchangeTransitionConfiguration( return SafeFuture.completedFuture(transitionConfigurationResponse); } + @Override + public SafeFuture builderStatus() { + return SafeFuture.completedFuture(BuilderStatus.withOkStatus()); + } + @Override public SafeFuture getPayloadHeader( final Bytes8 payloadId, final UInt64 slot) { @@ -264,7 +270,7 @@ public SafeFuture getPayloadHeader( payloadId, slot); - return getPayload(payloadId, slot) + return engineGetPayload(payloadId, slot) .thenApply( executionPayload -> { LOG.info( diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionengine/ExecutionPayloadStatus.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/ExecutionPayloadStatus.java similarity index 96% rename from ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionengine/ExecutionPayloadStatus.java rename to ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/ExecutionPayloadStatus.java index f13200a3dca..5ddb9174e8b 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionengine/ExecutionPayloadStatus.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/ExecutionPayloadStatus.java @@ -11,7 +11,7 @@ * specific language governing permissions and limitations under the License. */ -package tech.pegasys.teku.spec.executionengine; +package tech.pegasys.teku.spec.executionlayer; public enum ExecutionPayloadStatus { VALID(Validity.VALID), diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionengine/ForkChoiceState.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/ForkChoiceState.java similarity index 98% rename from ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionengine/ForkChoiceState.java rename to ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/ForkChoiceState.java index dcfd4815f72..8ff7d7ecdc6 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionengine/ForkChoiceState.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/ForkChoiceState.java @@ -11,7 +11,7 @@ * specific language governing permissions and limitations under the License. */ -package tech.pegasys.teku.spec.executionengine; +package tech.pegasys.teku.spec.executionlayer; import com.google.common.base.MoreObjects; import java.util.Objects; diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionengine/ForkChoiceUpdatedResult.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/ForkChoiceUpdatedResult.java similarity index 97% rename from ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionengine/ForkChoiceUpdatedResult.java rename to ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/ForkChoiceUpdatedResult.java index 2a584c62065..f8c517b05f3 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionengine/ForkChoiceUpdatedResult.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/ForkChoiceUpdatedResult.java @@ -11,7 +11,7 @@ * specific language governing permissions and limitations under the License. */ -package tech.pegasys.teku.spec.executionengine; +package tech.pegasys.teku.spec.executionlayer; import com.google.common.base.MoreObjects; import java.util.Objects; diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionengine/PayloadAttributes.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/PayloadAttributes.java similarity index 97% rename from ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionengine/PayloadAttributes.java rename to ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/PayloadAttributes.java index 50bc2969447..48b4ccfcd17 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionengine/PayloadAttributes.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/PayloadAttributes.java @@ -11,7 +11,7 @@ * specific language governing permissions and limitations under the License. */ -package tech.pegasys.teku.spec.executionengine; +package tech.pegasys.teku.spec.executionlayer; import com.google.common.base.MoreObjects; import java.util.Objects; diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionengine/PayloadStatus.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/PayloadStatus.java similarity index 98% rename from ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionengine/PayloadStatus.java rename to ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/PayloadStatus.java index a512fc9fd07..c3953de043d 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionengine/PayloadStatus.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/PayloadStatus.java @@ -11,7 +11,7 @@ * specific language governing permissions and limitations under the License. */ -package tech.pegasys.teku.spec.executionengine; +package tech.pegasys.teku.spec.executionlayer; import com.google.common.base.MoreObjects; import java.util.Objects; diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionengine/TransitionConfiguration.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/TransitionConfiguration.java similarity index 98% rename from ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionengine/TransitionConfiguration.java rename to ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/TransitionConfiguration.java index 91d607bbe31..18f546f2bac 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionengine/TransitionConfiguration.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/TransitionConfiguration.java @@ -11,7 +11,7 @@ * specific language governing permissions and limitations under the License. */ -package tech.pegasys.teku.spec.executionengine; +package tech.pegasys.teku.spec.executionlayer; import com.google.common.base.MoreObjects; import java.util.Objects; diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/bellatrix/helpers/BellatrixTransitionHelpers.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/bellatrix/helpers/BellatrixTransitionHelpers.java index 67df56ce7d3..14355dc8bd3 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/bellatrix/helpers/BellatrixTransitionHelpers.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/bellatrix/helpers/BellatrixTransitionHelpers.java @@ -22,8 +22,8 @@ import tech.pegasys.teku.spec.config.SpecConfigBellatrix; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload; import tech.pegasys.teku.spec.datastructures.execution.PowBlock; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel; -import tech.pegasys.teku.spec.executionengine.PayloadStatus; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel; +import tech.pegasys.teku.spec.executionlayer.PayloadStatus; public class BellatrixTransitionHelpers { @@ -46,21 +46,21 @@ public BellatrixTransitionHelpers( *

That is, the PoW chain stops as soon as one block has exceeded TTD and from that point on * merges into the beacon chain. * - * @param executionEngine the execution engine to use for verification + * @param executionLayer the execution layer to use for verification * @param executionPayload the first non-empty payload on the beacon chain * @param blockSlot the slot of the block the executionPayload is from * @return a future containing the validation result for the execution payload */ public SafeFuture validateMergeBlock( - final ExecutionEngineChannel executionEngine, + final ExecutionLayerChannel executionLayer, final ExecutionPayload executionPayload, final UInt64 blockSlot) { if (!specConfig.getTerminalBlockHash().isZero()) { return validateWithTerminalBlockHash(executionPayload, blockSlot); } - return executionEngine - .getPowBlock(executionPayload.getParentHash()) - .thenCompose(maybePowBlock -> validatePowBlock(executionEngine, maybePowBlock)); + return executionLayer + .eth1GetPowBlock(executionPayload.getParentHash()) + .thenCompose(maybePowBlock -> validatePowBlock(executionLayer, maybePowBlock)); } private SafeFuture validateWithTerminalBlockHash( @@ -77,7 +77,7 @@ private SafeFuture validateWithTerminalBlockHash( } private SafeFuture validatePowBlock( - final ExecutionEngineChannel executionEngine, final Optional maybePowBlock) { + final ExecutionLayerChannel executionLayer, final Optional maybePowBlock) { if (maybePowBlock.isEmpty()) { return completedFuture(PayloadStatus.SYNCING); } @@ -85,7 +85,7 @@ private SafeFuture validatePowBlock( if (isBelowTotalDifficulty(powBlock)) { return invalid("PowBlock has not reached terminal total difficulty"); } - return validateParentPowBlock(executionEngine, powBlock.getParentHash()); + return validateParentPowBlock(executionLayer, powBlock.getParentHash()); } private static SafeFuture invalid(final String message) { @@ -93,9 +93,9 @@ private static SafeFuture invalid(final String message) { } private SafeFuture validateParentPowBlock( - final ExecutionEngineChannel executionEngine, final Bytes32 parentBlockHash) { - return executionEngine - .getPowBlock(parentBlockHash) + final ExecutionLayerChannel executionLayer, final Bytes32 parentBlockHash) { + return executionLayer + .eth1GetPowBlock(parentBlockHash) .thenCompose( maybeParentPowBlock -> { if (maybeParentPowBlock.isEmpty()) { diff --git a/ethereum/spec/src/test/java/tech/pegasys/teku/spec/logic/versions/bellatrix/helpers/BellatrixTransitionHelpersTest.java b/ethereum/spec/src/test/java/tech/pegasys/teku/spec/logic/versions/bellatrix/helpers/BellatrixTransitionHelpersTest.java index 8d1d279459a..c5aacda7e7c 100644 --- a/ethereum/spec/src/test/java/tech/pegasys/teku/spec/logic/versions/bellatrix/helpers/BellatrixTransitionHelpersTest.java +++ b/ethereum/spec/src/test/java/tech/pegasys/teku/spec/logic/versions/bellatrix/helpers/BellatrixTransitionHelpersTest.java @@ -30,16 +30,16 @@ import tech.pegasys.teku.spec.TestSpecFactory; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload; import tech.pegasys.teku.spec.datastructures.execution.PowBlock; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel; -import tech.pegasys.teku.spec.executionengine.ExecutionPayloadStatus; -import tech.pegasys.teku.spec.executionengine.PayloadStatus; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel; +import tech.pegasys.teku.spec.executionlayer.ExecutionPayloadStatus; +import tech.pegasys.teku.spec.executionlayer.PayloadStatus; import tech.pegasys.teku.spec.util.DataStructureUtil; class BellatrixTransitionHelpersTest { private final Spec spec = TestSpecFactory.createMinimalBellatrix(); private final DataStructureUtil dataStructureUtil = new DataStructureUtil(spec); - private final ExecutionEngineChannel executionEngine = mock(ExecutionEngineChannel.class); + private final ExecutionLayerChannel executionLayer = mock(ExecutionLayerChannel.class); private final UInt256 terminalDifficulty = spec.getGenesisSpecConfig().toVersionBellatrix().orElseThrow().getTerminalTotalDifficulty(); @@ -49,7 +49,7 @@ class BellatrixTransitionHelpersTest { @BeforeEach void setUp() { - when(executionEngine.getPowBlock(any())).thenReturn(completedFuture(Optional.empty())); + when(executionLayer.eth1GetPowBlock(any())).thenReturn(completedFuture(Optional.empty())); } @Test @@ -96,7 +96,7 @@ void shouldBeValidWhenTerminalBlockHashMatchesInActivationEpoch() { spec.getGenesisSpec() .getBellatrixTransitionHelpers() .orElseThrow() - .validateMergeBlock(executionEngine, payload, blockSlot); + .validateMergeBlock(executionLayer, payload, blockSlot); assertPayloadResultStatus(result, ExecutionPayloadStatus.VALID); } @@ -109,7 +109,7 @@ void shouldBeValidWhenTerminalBlockHashMatchesAfterActivationEpoch() { spec.getGenesisSpec() .getBellatrixTransitionHelpers() .orElseThrow() - .validateMergeBlock(executionEngine, payload, blockSlot); + .validateMergeBlock(executionLayer, payload, blockSlot); assertPayloadResultStatus(result, ExecutionPayloadStatus.VALID); } @@ -122,7 +122,7 @@ void shouldBeInvalidWhenTerminalBlockHashDoesNotMatch() { spec.getGenesisSpec() .getBellatrixTransitionHelpers() .orElseThrow() - .validateMergeBlock(executionEngine, payload, blockSlot); + .validateMergeBlock(executionLayer, payload, blockSlot); assertPayloadResultStatus(result, ExecutionPayloadStatus.INVALID); } @@ -135,7 +135,7 @@ void shouldBeInvalidWhenBeforeActivationEpoch() { spec.getGenesisSpec() .getBellatrixTransitionHelpers() .orElseThrow() - .validateMergeBlock(executionEngine, payload, blockSlot); + .validateMergeBlock(executionLayer, payload, blockSlot); assertPayloadResultStatus(result, ExecutionPayloadStatus.INVALID); } @@ -152,7 +152,7 @@ private Spec createSpec( private PowBlock withPowBlock(final Bytes32 hash, final UInt256 totalDifficulty) { final PowBlock powBlock = new PowBlock(hash, dataStructureUtil.randomBytes32(), totalDifficulty, UInt64.ZERO); - when(executionEngine.getPowBlock(powBlock.getBlockHash())) + when(executionLayer.eth1GetPowBlock(powBlock.getBlockHash())) .thenReturn(completedFuture(Optional.of(powBlock))); return powBlock; } @@ -165,7 +165,7 @@ private SafeFuture validateMergeBlock() { return spec.getGenesisSpec() .getBellatrixTransitionHelpers() .orElseThrow() - .validateMergeBlock(executionEngine, payload, slot); + .validateMergeBlock(executionLayer, payload, slot); } private void assertPayloadResultStatus( diff --git a/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/util/DataStructureUtil.java b/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/util/DataStructureUtil.java index 1b5b456f5c8..f19e14cd99a 100644 --- a/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/util/DataStructureUtil.java +++ b/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/util/DataStructureUtil.java @@ -118,7 +118,7 @@ import tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.phase0.BeaconStateSchemaPhase0; import tech.pegasys.teku.spec.datastructures.type.SszPublicKey; import tech.pegasys.teku.spec.datastructures.util.DepositGenerator; -import tech.pegasys.teku.spec.executionengine.ForkChoiceState; +import tech.pegasys.teku.spec.executionlayer.ForkChoiceState; import tech.pegasys.teku.spec.schemas.SchemaDefinitions; import tech.pegasys.teku.spec.schemas.SchemaDefinitionsAltair; import tech.pegasys.teku.spec.schemas.SchemaDefinitionsBellatrix; diff --git a/ethereum/statetransition/src/integration-test/java/tech/pegasys/teku/statetransition/attestation/AttestationManagerIntegrationTest.java b/ethereum/statetransition/src/integration-test/java/tech/pegasys/teku/statetransition/attestation/AttestationManagerIntegrationTest.java index 3f37d8ba686..4c0eaf4074b 100644 --- a/ethereum/statetransition/src/integration-test/java/tech/pegasys/teku/statetransition/attestation/AttestationManagerIntegrationTest.java +++ b/ethereum/statetransition/src/integration-test/java/tech/pegasys/teku/statetransition/attestation/AttestationManagerIntegrationTest.java @@ -38,7 +38,7 @@ import tech.pegasys.teku.spec.datastructures.operations.AttestationData; import tech.pegasys.teku.spec.datastructures.state.Fork; import tech.pegasys.teku.spec.datastructures.state.ForkInfo; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel; import tech.pegasys.teku.statetransition.forkchoice.ForkChoice; import tech.pegasys.teku.statetransition.forkchoice.MergeTransitionBlockValidator; import tech.pegasys.teku.statetransition.forkchoice.StubForkChoiceNotifier; @@ -69,7 +69,7 @@ class AttestationManagerIntegrationTest { new AggregatingAttestationPool( spec, new NoOpMetricsSystem(), DEFAULT_MAXIMUM_ATTESTATION_COUNT); private final MergeTransitionBlockValidator transitionBlockValidator = - new MergeTransitionBlockValidator(spec, recentChainData, ExecutionEngineChannel.NOOP); + new MergeTransitionBlockValidator(spec, recentChainData, ExecutionLayerChannel.NOOP); private final ForkChoice forkChoice = new ForkChoice( spec, diff --git a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/block/BlockImporter.java b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/block/BlockImporter.java index c87db5c1b76..759bb657dad 100644 --- a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/block/BlockImporter.java +++ b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/block/BlockImporter.java @@ -34,7 +34,7 @@ import tech.pegasys.teku.spec.datastructures.operations.ProposerSlashing; import tech.pegasys.teku.spec.datastructures.operations.SignedVoluntaryExit; import tech.pegasys.teku.spec.datastructures.state.CheckpointState; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel; import tech.pegasys.teku.spec.logic.common.statetransition.results.BlockImportResult; import tech.pegasys.teku.statetransition.forkchoice.ForkChoice; import tech.pegasys.teku.storage.client.RecentChainData; @@ -47,7 +47,7 @@ public class BlockImporter { private final RecentChainData recentChainData; private final ForkChoice forkChoice; private final WeakSubjectivityValidator weakSubjectivityValidator; - private final ExecutionEngineChannel executionEngine; + private final ExecutionLayerChannel executionLayer; private final Subscribers attestationSubscribers = Subscribers.create(true); @@ -67,13 +67,13 @@ public BlockImporter( final RecentChainData recentChainData, final ForkChoice forkChoice, final WeakSubjectivityValidator weakSubjectivityValidator, - final ExecutionEngineChannel executionEngine) { + final ExecutionLayerChannel executionLayer) { this.spec = spec; this.blockImportNotifications = blockImportNotifications; this.recentChainData = recentChainData; this.forkChoice = forkChoice; this.weakSubjectivityValidator = weakSubjectivityValidator; - this.executionEngine = executionEngine; + this.executionLayer = executionLayer; } @CheckReturnValue @@ -99,7 +99,7 @@ public SafeFuture importBlock( } return validateWeakSubjectivityPeriod() - .thenCompose(__ -> forkChoice.onBlock(block, blockImportPerformance, executionEngine)) + .thenCompose(__ -> forkChoice.onBlock(block, blockImportPerformance, executionLayer)) .thenApply( result -> { if (!result.isSuccessful()) { diff --git a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoice.java b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoice.java index 1d2d7b1471e..88b67630245 100644 --- a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoice.java +++ b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoice.java @@ -46,9 +46,9 @@ import tech.pegasys.teku.spec.datastructures.state.Checkpoint; import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState; import tech.pegasys.teku.spec.datastructures.util.AttestationProcessingResult; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel; -import tech.pegasys.teku.spec.executionengine.ForkChoiceState; -import tech.pegasys.teku.spec.executionengine.PayloadStatus; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel; +import tech.pegasys.teku.spec.executionlayer.ForkChoiceState; +import tech.pegasys.teku.spec.executionlayer.PayloadStatus; import tech.pegasys.teku.spec.logic.common.statetransition.exceptions.StateTransitionException; import tech.pegasys.teku.spec.logic.common.statetransition.results.BlockImportResult; import tech.pegasys.teku.spec.logic.common.statetransition.results.BlockImportResult.FailureReason; @@ -197,13 +197,13 @@ private SafeFuture processHead(Optional nodeSlot) { public SafeFuture onBlock( final SignedBeaconBlock block, final Optional blockImportPerformance, - final ExecutionEngineChannel executionEngine) { + final ExecutionLayerChannel executionLayer) { return recentChainData .retrieveStateAtSlot(new SlotAndBlockRoot(block.getSlot(), block.getParentRoot())) .thenPeek(__ -> blockImportPerformance.ifPresent(BlockImportPerformance::preStateRetrieved)) .thenCompose( blockSlotState -> - onBlock(block, blockSlotState, blockImportPerformance, executionEngine)); + onBlock(block, blockSlotState, blockImportPerformance, executionLayer)); } /** @@ -214,7 +214,7 @@ private SafeFuture onBlock( final SignedBeaconBlock block, final Optional blockSlotState, final Optional blockImportPerformance, - final ExecutionEngineChannel executionEngine) { + final ExecutionLayerChannel executionLayer) { if (blockSlotState.isEmpty()) { return SafeFuture.completedFuture(BlockImportResult.FAILED_UNKNOWN_PARENT); } @@ -225,7 +225,7 @@ private SafeFuture onBlock( blockSlotState.get().getSlot()); final ForkChoicePayloadExecutor payloadExecutor = - ForkChoicePayloadExecutor.create(spec, recentChainData, block, executionEngine); + ForkChoicePayloadExecutor.create(spec, recentChainData, block, executionLayer); final ForkChoiceUtil forkChoiceUtil = spec.atSlot(block.getSlot()).getForkChoiceUtil(); final BlockImportResult preconditionCheckResult = forkChoiceUtil.checkOnBlockConditions( diff --git a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceNotifier.java b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceNotifier.java index c8f6a99bab4..e5fafb1b200 100644 --- a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceNotifier.java +++ b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceNotifier.java @@ -20,7 +20,7 @@ import tech.pegasys.teku.infrastructure.bytes.Bytes8; import tech.pegasys.teku.infrastructure.unsigned.UInt64; import tech.pegasys.teku.spec.datastructures.operations.versions.bellatrix.BeaconPreparableProposer; -import tech.pegasys.teku.spec.executionengine.ForkChoiceState; +import tech.pegasys.teku.spec.executionlayer.ForkChoiceState; public interface ForkChoiceNotifier { void onUpdatePreparableProposers(Collection proposers); diff --git a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceNotifierImpl.java b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceNotifierImpl.java index 65b1c583dd8..b7c3e7e7424 100644 --- a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceNotifierImpl.java +++ b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceNotifierImpl.java @@ -29,9 +29,9 @@ import tech.pegasys.teku.spec.Spec; import tech.pegasys.teku.spec.config.SpecConfig; import tech.pegasys.teku.spec.datastructures.operations.versions.bellatrix.BeaconPreparableProposer; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel; -import tech.pegasys.teku.spec.executionengine.ForkChoiceState; -import tech.pegasys.teku.spec.executionengine.ForkChoiceUpdatedResult; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel; +import tech.pegasys.teku.spec.executionlayer.ForkChoiceState; +import tech.pegasys.teku.spec.executionlayer.ForkChoiceUpdatedResult; import tech.pegasys.teku.statetransition.forkchoice.ForkChoiceUpdatedResultSubscriber.ForkChoiceUpdatedResultNotification; import tech.pegasys.teku.storage.client.RecentChainData; @@ -39,7 +39,7 @@ public class ForkChoiceNotifierImpl implements ForkChoiceNotifier { private static final Logger LOG = LogManager.getLogger(); private final EventThread eventThread; - private final ExecutionEngineChannel executionEngineChannel; + private final ExecutionLayerChannel executionLayerChannel; private final RecentChainData recentChainData; private final PayloadAttributesCalculator payloadAttributesCalculator; private final Spec spec; @@ -54,12 +54,12 @@ public class ForkChoiceNotifierImpl implements ForkChoiceNotifier { ForkChoiceNotifierImpl( final EventThread eventThread, final Spec spec, - final ExecutionEngineChannel executionEngineChannel, + final ExecutionLayerChannel executionLayerChannel, final RecentChainData recentChainData, final PayloadAttributesCalculator payloadAttributesCalculator) { this.eventThread = eventThread; this.spec = spec; - this.executionEngineChannel = executionEngineChannel; + this.executionLayerChannel = executionLayerChannel; this.recentChainData = recentChainData; this.payloadAttributesCalculator = payloadAttributesCalculator; } @@ -67,7 +67,7 @@ public class ForkChoiceNotifierImpl implements ForkChoiceNotifier { public static ForkChoiceNotifier create( final AsyncRunnerFactory asyncRunnerFactory, final Spec spec, - final ExecutionEngineChannel executionEngineChannel, + final ExecutionLayerChannel executionLayerChannel, final RecentChainData recentChainData, final Optional proposerDefaultFeeRecipient) { final AsyncRunnerEventThread eventThread = @@ -76,7 +76,7 @@ public static ForkChoiceNotifier create( return new ForkChoiceNotifierImpl( eventThread, spec, - executionEngineChannel, + executionLayerChannel, recentChainData, new PayloadAttributesCalculator( spec, eventThread, recentChainData, proposerDefaultFeeRecipient)); @@ -242,7 +242,7 @@ private void internalAttestationsDue(final UInt64 slot) { private void sendForkChoiceUpdated() { final SafeFuture> forkChoiceUpdatedResult = - forkChoiceUpdateData.send(executionEngineChannel); + forkChoiceUpdateData.send(executionLayerChannel); subscribers.deliver( ForkChoiceUpdatedResultSubscriber::onForkChoiceUpdatedResult, diff --git a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoicePayloadExecutor.java b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoicePayloadExecutor.java index c39e5dc0756..ee66019665b 100644 --- a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoicePayloadExecutor.java +++ b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoicePayloadExecutor.java @@ -21,37 +21,37 @@ import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeader; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel; -import tech.pegasys.teku.spec.executionengine.PayloadStatus; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel; +import tech.pegasys.teku.spec.executionlayer.PayloadStatus; import tech.pegasys.teku.spec.logic.versions.bellatrix.block.OptimisticExecutionPayloadExecutor; import tech.pegasys.teku.storage.client.RecentChainData; class ForkChoicePayloadExecutor implements OptimisticExecutionPayloadExecutor { private static final Logger LOG = LogManager.getLogger(); - private final ExecutionEngineChannel executionEngine; + private final ExecutionLayerChannel executionLayer; private final SignedBeaconBlock block; private final MergeTransitionBlockValidator transitionBlockValidator; private Optional> result = Optional.empty(); ForkChoicePayloadExecutor( final SignedBeaconBlock block, - final ExecutionEngineChannel executionEngine, + final ExecutionLayerChannel executionLayer, final MergeTransitionBlockValidator transitionBlockValidator) { this.block = block; this.transitionBlockValidator = transitionBlockValidator; - this.executionEngine = executionEngine; + this.executionLayer = executionLayer; } public static ForkChoicePayloadExecutor create( final Spec spec, final RecentChainData recentChainData, final SignedBeaconBlock block, - final ExecutionEngineChannel executionEngine) { + final ExecutionLayerChannel executionLayer) { return new ForkChoicePayloadExecutor( block, - executionEngine, - new MergeTransitionBlockValidator(spec, recentChainData, executionEngine)); + executionLayer, + new MergeTransitionBlockValidator(spec, recentChainData, executionLayer)); } public SafeFuture getExecutionResult() { @@ -72,8 +72,8 @@ public boolean optimisticallyExecute( result = Optional.of( - executionEngine - .newPayload(executionPayload) + executionLayer + .engineNewPayload(executionPayload) .thenCompose( result -> { if (result.hasValidStatus()) { diff --git a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceUpdateData.java b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceUpdateData.java index f836529c6a2..4ec6652d1d1 100644 --- a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceUpdateData.java +++ b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceUpdateData.java @@ -23,10 +23,10 @@ import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.bytes.Bytes8; import tech.pegasys.teku.infrastructure.unsigned.UInt64; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel; -import tech.pegasys.teku.spec.executionengine.ForkChoiceState; -import tech.pegasys.teku.spec.executionengine.ForkChoiceUpdatedResult; -import tech.pegasys.teku.spec.executionengine.PayloadAttributes; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel; +import tech.pegasys.teku.spec.executionlayer.ForkChoiceState; +import tech.pegasys.teku.spec.executionlayer.ForkChoiceUpdatedResult; +import tech.pegasys.teku.spec.executionlayer.PayloadAttributes; public class ForkChoiceUpdateData { private static final Logger LOG = LogManager.getLogger(); @@ -151,7 +151,7 @@ public SafeFuture> getPayloadId() { } public SafeFuture> send( - final ExecutionEngineChannel executionEngine) { + final ExecutionLayerChannel executionLayer) { if (sent) { LOG.debug("send - already sent"); return SafeFuture.completedFuture(Optional.empty()); @@ -166,7 +166,7 @@ public SafeFuture> send( LOG.debug("send - calling forkChoiceUpdated({}, {})", forkChoiceState, payloadAttributes); final SafeFuture forkChoiceUpdatedResult = - executionEngine.forkChoiceUpdated(forkChoiceState, payloadAttributes); + executionLayer.engineForkChoiceUpdated(forkChoiceState, payloadAttributes); forkChoiceUpdatedResult .thenApply(ForkChoiceUpdatedResult::getPayloadId) diff --git a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceUpdatedResultSubscriber.java b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceUpdatedResultSubscriber.java index dc229db9d53..2218f7f1a3f 100644 --- a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceUpdatedResultSubscriber.java +++ b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceUpdatedResultSubscriber.java @@ -15,8 +15,8 @@ import java.util.Optional; import tech.pegasys.teku.infrastructure.async.SafeFuture; -import tech.pegasys.teku.spec.executionengine.ForkChoiceState; -import tech.pegasys.teku.spec.executionengine.ForkChoiceUpdatedResult; +import tech.pegasys.teku.spec.executionlayer.ForkChoiceState; +import tech.pegasys.teku.spec.executionlayer.ForkChoiceUpdatedResult; public interface ForkChoiceUpdatedResultSubscriber { void onForkChoiceUpdatedResult( diff --git a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/MergeTransitionBlockValidator.java b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/MergeTransitionBlockValidator.java index 0d9344703ac..e8efdb11a38 100644 --- a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/MergeTransitionBlockValidator.java +++ b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/MergeTransitionBlockValidator.java @@ -27,8 +27,8 @@ import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeader; import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel; -import tech.pegasys.teku.spec.executionengine.PayloadStatus; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel; +import tech.pegasys.teku.spec.executionlayer.PayloadStatus; import tech.pegasys.teku.spec.logic.versions.bellatrix.helpers.BellatrixTransitionHelpers; import tech.pegasys.teku.storage.client.RecentChainData; import tech.pegasys.teku.storage.store.UpdatableStore.StoreTransaction; @@ -39,15 +39,15 @@ public class MergeTransitionBlockValidator { private final Spec spec; private final RecentChainData recentChainData; - private final ExecutionEngineChannel executionEngine; + private final ExecutionLayerChannel executionLayer; public MergeTransitionBlockValidator( final Spec spec, final RecentChainData recentChainData, - final ExecutionEngineChannel executionEngine) { + final ExecutionLayerChannel executionLayer) { this.spec = spec; this.recentChainData = recentChainData; - this.executionEngine = executionEngine; + this.executionLayer = executionLayer; } public SafeFuture verifyTransitionBlock( @@ -143,7 +143,7 @@ private SafeFuture verifyTransitionPayload( new IllegalStateException( "Attempting to validate a bellatrix block when spec does not have bellatrix transition helpers")); return bellatrixTransitionHelpers - .validateMergeBlock(executionEngine, executionPayload, slot) + .validateMergeBlock(executionLayer, executionPayload, slot) .exceptionally( error -> { LOG.error("Error while validating merge block", error); diff --git a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/MergeTransitionConfigCheck.java b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/MergeTransitionConfigCheck.java index 309a88fff6e..9c13d6ea5c3 100644 --- a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/MergeTransitionConfigCheck.java +++ b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/MergeTransitionConfigCheck.java @@ -27,8 +27,8 @@ import tech.pegasys.teku.spec.SpecMilestone; import tech.pegasys.teku.spec.SpecVersion; import tech.pegasys.teku.spec.config.SpecConfigBellatrix; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel; -import tech.pegasys.teku.spec.executionengine.TransitionConfiguration; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel; +import tech.pegasys.teku.spec.executionlayer.TransitionConfiguration; public class MergeTransitionConfigCheck extends Service { @@ -47,7 +47,7 @@ public class MergeTransitionConfigCheck extends Service { private final EventLogger eventLogger; private final Spec spec; - private final ExecutionEngineChannel executionEngine; + private final ExecutionLayerChannel executionLayer; private final AsyncRunner asyncRunner; private Optional timer = Optional.empty(); @@ -56,11 +56,11 @@ public class MergeTransitionConfigCheck extends Service { public MergeTransitionConfigCheck( final EventLogger eventLogger, final Spec spec, - final ExecutionEngineChannel executionEngine, + final ExecutionLayerChannel executionLayer, final AsyncRunner asyncRunner) { this.eventLogger = eventLogger; this.spec = spec; - this.executionEngine = executionEngine; + this.executionLayer = executionLayer; this.asyncRunner = asyncRunner; } @@ -97,8 +97,8 @@ protected synchronized SafeFuture doStop() { } private synchronized void verifyTransitionConfiguration() { - executionEngine - .exchangeTransitionConfiguration(localTransitionConfiguration) + executionLayer + .engineExchangeTransitionConfiguration(localTransitionConfiguration) .thenAccept( remoteTransitionConfiguration -> { if (!localTransitionConfiguration diff --git a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/PayloadAttributesCalculator.java b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/PayloadAttributesCalculator.java index f41425bcd51..efbe22ac5e8 100644 --- a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/PayloadAttributesCalculator.java +++ b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/PayloadAttributesCalculator.java @@ -31,7 +31,7 @@ import tech.pegasys.teku.spec.datastructures.blocks.SlotAndBlockRoot; import tech.pegasys.teku.spec.datastructures.operations.versions.bellatrix.BeaconPreparableProposer; import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState; -import tech.pegasys.teku.spec.executionengine.PayloadAttributes; +import tech.pegasys.teku.spec.executionlayer.PayloadAttributes; import tech.pegasys.teku.storage.client.ChainHead; import tech.pegasys.teku.storage.client.RecentChainData; diff --git a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/PayloadValidationResult.java b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/PayloadValidationResult.java index f3a2e20696b..9514cf20fa1 100644 --- a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/PayloadValidationResult.java +++ b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/PayloadValidationResult.java @@ -17,7 +17,7 @@ import java.util.Objects; import java.util.Optional; import org.apache.tuweni.bytes.Bytes32; -import tech.pegasys.teku.spec.executionengine.PayloadStatus; +import tech.pegasys.teku.spec.executionlayer.PayloadStatus; public class PayloadValidationResult { diff --git a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/TerminalPowBlockMonitor.java b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/TerminalPowBlockMonitor.java index c4f315b2565..e8163827195 100644 --- a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/TerminalPowBlockMonitor.java +++ b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/TerminalPowBlockMonitor.java @@ -31,7 +31,7 @@ import tech.pegasys.teku.spec.SpecVersion; import tech.pegasys.teku.spec.config.SpecConfigBellatrix; import tech.pegasys.teku.spec.datastructures.execution.PowBlock; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel; import tech.pegasys.teku.storage.client.ChainHead; import tech.pegasys.teku.storage.client.RecentChainData; @@ -46,7 +46,7 @@ public class TerminalPowBlockMonitor { private final EventLogger eventLogger; private final TimeProvider timeProvider; - private final ExecutionEngineChannel executionEngine; + private final ExecutionLayerChannel executionLayer; private final AsyncRunner asyncRunner; private Optional timer = Optional.empty(); private final Spec spec; @@ -65,14 +65,14 @@ public class TerminalPowBlockMonitor { private final ArrayDeque lastTotalDifficulty = new ArrayDeque<>(); public TerminalPowBlockMonitor( - final ExecutionEngineChannel executionEngine, + final ExecutionLayerChannel executionLayer, final Spec spec, final RecentChainData recentChainData, final ForkChoiceNotifier forkChoiceNotifier, final AsyncRunner asyncRunner, final EventLogger eventLogger, final TimeProvider timeProvider) { - this.executionEngine = executionEngine; + this.executionLayer = executionLayer; this.asyncRunner = asyncRunner; this.spec = spec; this.recentChainData = recentChainData; @@ -206,8 +206,8 @@ private void checkTerminalBlockByBlockHash(final Bytes32 blockHashTracking) { .isGreaterThanOrEqualTo(specConfigBellatrix.getTerminalBlockHashActivationEpoch()); if (isActivationEpochReached) { - executionEngine - .getPowBlock(blockHashTracking) + executionLayer + .eth1GetPowBlock(blockHashTracking) .thenAccept( maybePowBlock -> maybePowBlock @@ -231,8 +231,8 @@ private void checkTerminalBlockByBlockHash(final Bytes32 blockHashTracking) { } private void checkTerminalBlockByTTD() { - executionEngine - .getPowChainHead() + executionLayer + .eth1GetPowChainHead() .thenCompose( powBlock -> { final UInt256 totalDifficulty = powBlock.getTotalDifficulty(); @@ -269,8 +269,8 @@ private void checkTerminalBlockByTTD() { } private SafeFuture validateTerminalBlockParentByTTD(final PowBlock terminalBlock) { - return executionEngine - .getPowBlock(terminalBlock.getParentHash()) + return executionLayer + .eth1GetPowBlock(terminalBlock.getParentHash()) .thenApply( powBlock -> { UInt256 totalDifficulty = diff --git a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/block/BlockImporterTest.java b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/block/BlockImporterTest.java index a89209fd5dc..8467087648e 100644 --- a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/block/BlockImporterTest.java +++ b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/block/BlockImporterTest.java @@ -50,7 +50,7 @@ import tech.pegasys.teku.spec.datastructures.operations.Attestation.AttestationSchema; import tech.pegasys.teku.spec.datastructures.state.Checkpoint; import tech.pegasys.teku.spec.datastructures.state.CheckpointState; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel; import tech.pegasys.teku.spec.logic.common.block.AbstractBlockProcessor; import tech.pegasys.teku.spec.logic.common.statetransition.results.BlockImportResult; import tech.pegasys.teku.spec.logic.common.statetransition.results.BlockImportResult.FailureReason; @@ -81,7 +81,7 @@ public class BlockImporterTest { mock(WeakSubjectivityValidator.class); private final ForkChoiceNotifier forkChoiceNotifier = new StubForkChoiceNotifier(); private final MergeTransitionBlockValidator transitionBlockValidator = - new MergeTransitionBlockValidator(spec, recentChainData, ExecutionEngineChannel.NOOP); + new MergeTransitionBlockValidator(spec, recentChainData, ExecutionLayerChannel.NOOP); private final ForkChoice forkChoice = new ForkChoice( spec, @@ -103,7 +103,7 @@ public class BlockImporterTest { recentChainData, forkChoice, weakSubjectivityValidator, - ExecutionEngineChannel.NOOP); + ExecutionLayerChannel.NOOP); @BeforeAll public static void init() { @@ -382,7 +382,7 @@ public void importBlock_weakSubjectivityFailure_wrongAncestor() throws Exception recentChainData, forkChoice, weakSubjectivityValidator, - ExecutionEngineChannel.NOOP); + ExecutionLayerChannel.NOOP); final BlockImportResult result = blockImporter.importBlock(otherBlock).get(); assertImportFailed(result, FailureReason.FAILED_WEAK_SUBJECTIVITY_CHECKS); @@ -412,7 +412,7 @@ public void importBlock_weakSubjectivityChecksPass() throws Exception { recentChainData, forkChoice, weakSubjectivityValidator, - ExecutionEngineChannel.NOOP); + ExecutionLayerChannel.NOOP); // Import wsBlock final BlockImportResult result = blockImporter.importBlock(wsBlock).get(); @@ -440,7 +440,7 @@ public void importBlock_runWSPChecks() throws Exception { storageSystem.recentChainData(), forkChoice, weakSubjectivityValidator, - ExecutionEngineChannel.NOOP); + ExecutionLayerChannel.NOOP); // The current slot is far ahead of the block being imported final UInt64 wsPeriod = UInt64.valueOf(10); @@ -483,7 +483,7 @@ public void importBlock_nonFinalizingChain_runWSPChecks() throws Exception { storageSystem.recentChainData(), forkChoice, weakSubjectivityValidator, - ExecutionEngineChannel.NOOP); + ExecutionLayerChannel.NOOP); // Set current time to be several WSP's ahead of finalized checkpoint final UInt64 wsPeriod = UInt64.valueOf(10); @@ -534,7 +534,7 @@ public void importBlock_nonFinalizingChain_skipWSPChecks() throws Exception { storageSystem.recentChainData(), forkChoice, weakSubjectivityValidator, - ExecutionEngineChannel.NOOP); + ExecutionLayerChannel.NOOP); // Set current time to be several WSP's ahead of finalized checkpoint final UInt64 wsPeriod = UInt64.valueOf(10); @@ -577,7 +577,7 @@ public void getLatestCheckpointState_initialCall() { storageSystem.recentChainData(), forkChoice, weakSubjectivityValidator, - ExecutionEngineChannel.NOOP); + ExecutionLayerChannel.NOOP); final SignedBlockAndState genesis = storageSystem.chainUpdater().initializeGenesis(); @@ -608,7 +608,7 @@ public void getLatestCheckpointState_shouldPullUpdatedFinalizedCheckpoint() { storageSystem.recentChainData(), forkChoice, weakSubjectivityValidator, - ExecutionEngineChannel.NOOP); + ExecutionLayerChannel.NOOP); final SignedBlockAndState genesis = storageSystem.chainUpdater().initializeGenesis(); diff --git a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/block/BlockManagerTest.java b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/block/BlockManagerTest.java index 9aec40f92cb..973aece1b46 100644 --- a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/block/BlockManagerTest.java +++ b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/block/BlockManagerTest.java @@ -54,9 +54,9 @@ import tech.pegasys.teku.spec.TestSpecFactory; import tech.pegasys.teku.spec.datastructures.blocks.ImportedBlockListener; import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannelStub; -import tech.pegasys.teku.spec.executionengine.PayloadStatus; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannelStub; +import tech.pegasys.teku.spec.executionlayer.PayloadStatus; import tech.pegasys.teku.spec.logic.common.block.AbstractBlockProcessor; import tech.pegasys.teku.spec.logic.common.statetransition.results.BlockImportResult; import tech.pegasys.teku.spec.logic.common.statetransition.results.BlockImportResult.FailureReason; @@ -98,7 +98,7 @@ public class BlockManagerTest { private final ForkChoiceNotifier forkChoiceNotifier = new StubForkChoiceNotifier(); private final MergeTransitionBlockValidator transitionBlockValidator = - new MergeTransitionBlockValidator(spec, localRecentChainData, ExecutionEngineChannel.NOOP); + new MergeTransitionBlockValidator(spec, localRecentChainData, ExecutionLayerChannel.NOOP); private final ForkChoice forkChoice = new ForkChoice( spec, @@ -107,8 +107,8 @@ public class BlockManagerTest { forkChoiceNotifier, transitionBlockValidator); - private final ExecutionEngineChannelStub executionEngine = - new ExecutionEngineChannelStub(spec, false); + private final ExecutionLayerChannelStub executionLayer = + new ExecutionLayerChannelStub(spec, false); private final BlockValidator blockValidator = mock(BlockValidator.class); private final BlockImporter blockImporter = @@ -118,7 +118,7 @@ public class BlockManagerTest { localRecentChainData, forkChoice, WeakSubjectivityFactory.lenientValidator(), - executionEngine); + executionLayer); private final BlockManager blockManager = new BlockManager( localRecentChainData, @@ -208,7 +208,7 @@ public void shouldNotifySubscribersOnKnownBlock() { @Test public void shouldNotifySubscribersOnKnownOptimisticBlock() { final ImportedBlockListener subscriber = mock(ImportedBlockListener.class); - executionEngine.setPayloadStatus(PayloadStatus.SYNCING); + executionLayer.setPayloadStatus(PayloadStatus.SYNCING); blockManager.subscribeToReceivedBlocks(subscriber); final UInt64 nextSlot = GENESIS_SLOT.plus(UInt64.ONE); final SignedBeaconBlock nextBlock = @@ -498,11 +498,11 @@ public void onBlockImported_withPendingDescendantsOfFailedExecutionPayloadExecut } // gossip the first block with execution payload failure - executionEngine.setPayloadStatus(PayloadStatus.failedExecution(new Error("error"))); + executionLayer.setPayloadStatus(PayloadStatus.failedExecution(new Error("error"))); assertImportBlockWithResult(blocks.get(0), FailureReason.FAILED_EXECUTION_PAYLOAD_EXECUTION); // EL is now alive - executionEngine.setPayloadStatus(PayloadStatus.VALID); + executionLayer.setPayloadStatus(PayloadStatus.VALID); // Gossip all remaining blocks blocks.subList(1, blockCount).stream() diff --git a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceNotifierTest.java b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceNotifierTest.java index d57bff7e792..3b91675bef7 100644 --- a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceNotifierTest.java +++ b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceNotifierTest.java @@ -47,12 +47,12 @@ import tech.pegasys.teku.spec.datastructures.forkchoice.ReadOnlyForkChoiceStrategy; import tech.pegasys.teku.spec.datastructures.operations.versions.bellatrix.BeaconPreparableProposer; import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel; -import tech.pegasys.teku.spec.executionengine.ExecutionPayloadStatus; -import tech.pegasys.teku.spec.executionengine.ForkChoiceState; -import tech.pegasys.teku.spec.executionengine.ForkChoiceUpdatedResult; -import tech.pegasys.teku.spec.executionengine.PayloadAttributes; -import tech.pegasys.teku.spec.executionengine.PayloadStatus; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel; +import tech.pegasys.teku.spec.executionlayer.ExecutionPayloadStatus; +import tech.pegasys.teku.spec.executionlayer.ForkChoiceState; +import tech.pegasys.teku.spec.executionlayer.ForkChoiceUpdatedResult; +import tech.pegasys.teku.spec.executionlayer.PayloadAttributes; +import tech.pegasys.teku.spec.executionlayer.PayloadStatus; import tech.pegasys.teku.spec.logic.common.block.AbstractBlockProcessor; import tech.pegasys.teku.spec.util.DataStructureUtil; import tech.pegasys.teku.statetransition.forkchoice.ForkChoiceUpdatedResultSubscriber.ForkChoiceUpdatedResultNotification; @@ -73,7 +73,7 @@ class ForkChoiceNotifierTest { private Optional defaultFeeRecipient = Optional.of(Bytes20.fromHexString("0x2Df386eFF130f991321bfC4F8372Ba838b9AB14B")); - private final ExecutionEngineChannel executionEngineChannel = mock(ExecutionEngineChannel.class); + private final ExecutionLayerChannel executionLayerChannel = mock(ExecutionLayerChannel.class); private ForkChoiceNotifierImpl notifier; private ForkChoiceUpdatedResultNotification forkChoiceUpdatedResultNotification; @@ -106,11 +106,7 @@ void setUp(final boolean doNotInitializeWithDefaultFeeRecipient) { doNotInitializeWithDefaultFeeRecipient ? Optional.empty() : defaultFeeRecipient)); notifier = new ForkChoiceNotifierImpl( - eventThread, - spec, - executionEngineChannel, - recentChainData, - payloadAttributesCalculator); + eventThread, spec, executionLayerChannel, recentChainData, payloadAttributesCalculator); notifier.onSyncingStatusChanged(true); // Start in sync to make testing easier // store fcu notification notifier.subscribeToForkChoiceUpdatedResult( @@ -119,9 +115,9 @@ void setUp(final boolean doNotInitializeWithDefaultFeeRecipient) { storageSystem.chainUpdater().updateBestBlock(storageSystem.chainUpdater().advanceChain()); forkChoiceStrategy = recentChainData.getForkChoiceStrategy().orElseThrow(); - when(executionEngineChannel.newPayload(any())) + when(executionLayerChannel.engineNewPayload(any())) .thenReturn(SafeFuture.completedFuture(PayloadStatus.VALID)); - when(executionEngineChannel.forkChoiceUpdated(any(), any())) + when(executionLayerChannel.engineForkChoiceUpdated(any(), any())) .thenReturn( SafeFuture.completedFuture( createForkChoiceUpdatedResult(ExecutionPayloadStatus.VALID, Optional.empty()))); @@ -136,11 +132,7 @@ void reInitializePreMerge() { spec, eventThread, recentChainData, defaultFeeRecipient)); notifier = new ForkChoiceNotifierImpl( - eventThread, - spec, - executionEngineChannel, - recentChainData, - payloadAttributesCalculator); + eventThread, spec, executionLayerChannel, recentChainData, payloadAttributesCalculator); notifier.onSyncingStatusChanged(true); // store fcu notification notifier.subscribeToForkChoiceUpdatedResult( @@ -167,7 +159,7 @@ private void doMerge(Bytes32 terminalBlockHash) { void onForkChoiceUpdated_shouldSendNotificationToExecutionEngine() { final ForkChoiceState forkChoiceState = getCurrentForkChoiceState(); notifyForkChoiceUpdated(forkChoiceState); - verify(executionEngineChannel).forkChoiceUpdated(forkChoiceState, Optional.empty()); + verify(executionLayerChannel).engineForkChoiceUpdated(forkChoiceState, Optional.empty()); } @Test @@ -178,8 +170,8 @@ void onForkChoiceUpdated_shouldSendNotificationWithPayloadAttributesForNextPropo final PayloadAttributes payloadAttributes = withProposerForSlot(headState, blockSlot); notifyForkChoiceUpdated(forkChoiceState); - verify(executionEngineChannel) - .forkChoiceUpdated(forkChoiceState, Optional.of(payloadAttributes)); + verify(executionLayerChannel) + .engineForkChoiceUpdated(forkChoiceState, Optional.of(payloadAttributes)); } @Test @@ -195,7 +187,7 @@ void onForkChoiceUpdated_shouldSendNotificationWithoutPayloadAttributesWhenNotPr UInt64.valueOf(notTheNextProposer), dataStructureUtil.randomBytes20()))); notifyForkChoiceUpdated(forkChoiceState); - verify(executionEngineChannel).forkChoiceUpdated(forkChoiceState, Optional.empty()); + verify(executionLayerChannel).engineForkChoiceUpdated(forkChoiceState, Optional.empty()); } @Test @@ -205,7 +197,7 @@ void onForkChoiceUpdated_shouldNotSendNotificationWhenHeadBlockHashIsZero() { new ForkChoiceState( Bytes32.ZERO, UInt64.ZERO, Bytes32.ZERO, Bytes32.ZERO, Bytes32.ZERO, false)); - verifyNoInteractions(executionEngineChannel); + verifyNoInteractions(executionLayerChannel); } @Test @@ -237,7 +229,7 @@ void onForkChoiceUpdated_shouldNotSendNotificationOfOutOfOrderPayloadAttributes( notifyForkChoiceUpdated(forkChoiceState); // calculate attributes for slot 2 // it is called once with no attributes. the one with attributes is pending - verify(executionEngineChannel).forkChoiceUpdated(forkChoiceState, Optional.empty()); + verify(executionLayerChannel).engineForkChoiceUpdated(forkChoiceState, Optional.empty()); // forward to real method call doAnswer(InvocationOnMock::callRealMethod) @@ -251,14 +243,14 @@ void onForkChoiceUpdated_shouldNotSendNotificationOfOutOfOrderPayloadAttributes( notifyForkChoiceUpdated(forkChoiceState); // calculate attributes for slot 3 // expect a call with second attributes - verify(executionEngineChannel) - .forkChoiceUpdated(forkChoiceState, Optional.of(payloadAttributes.get(1))); + verify(executionLayerChannel) + .engineForkChoiceUpdated(forkChoiceState, Optional.of(payloadAttributes.get(1))); // let the payload attributes for slot 2 return actualResponseA.get().propagateTo(deferredResponseA); // it should get ignored - verifyNoMoreInteractions(executionEngineChannel); + verifyNoMoreInteractions(executionLayerChannel); } @Test @@ -276,8 +268,8 @@ void onForkChoiceUpdated_shouldSendNotificationOfOrderedPayloadAttributes() { notifyForkChoiceUpdated(forkChoiceState); // calculate attributes for slot 2 // expect attributes for slot 2 - verify(executionEngineChannel) - .forkChoiceUpdated(forkChoiceState, Optional.of(payloadAttributes.get(0))); + verify(executionLayerChannel) + .engineForkChoiceUpdated(forkChoiceState, Optional.of(payloadAttributes.get(0))); storageSystem .chainUpdater() @@ -286,10 +278,10 @@ void onForkChoiceUpdated_shouldSendNotificationOfOrderedPayloadAttributes() { notifyForkChoiceUpdated(forkChoiceState); // calculate attributes for slot 3 // expect attributes for slot 3 - verify(executionEngineChannel) - .forkChoiceUpdated(forkChoiceState, Optional.of(payloadAttributes.get(1))); + verify(executionLayerChannel) + .engineForkChoiceUpdated(forkChoiceState, Optional.of(payloadAttributes.get(1))); - verifyNoMoreInteractions(executionEngineChannel); + verifyNoMoreInteractions(executionLayerChannel); } @Test @@ -310,8 +302,8 @@ void onForkChoiceUpdated_shouldNotSendNotificationWithOldPayloadAttributes() { notifyForkChoiceUpdated(forkChoiceState); // calculate attributes for slot 2 // expect attributes for slot 2 - verify(executionEngineChannel) - .forkChoiceUpdated(forkChoiceState, Optional.of(payloadAttributes)); + verify(executionLayerChannel) + .engineForkChoiceUpdated(forkChoiceState, Optional.of(payloadAttributes)); // advance chain (generate block at slot 2), we get a new forkChoiceState storageSystem.chainUpdater().addNewBestBlock(); @@ -344,16 +336,16 @@ void onForkChoiceUpdated_shouldNotSendNotificationWithOldPayloadAttributes() { notifyForkChoiceUpdated(forkChoiceStateSlot3); // calculate attributes for slot 2 // it is called once with no attributes. the one with attributes is pending - verify(executionEngineChannel).forkChoiceUpdated(forkChoiceStateSlot3, Optional.empty()); + verify(executionLayerChannel).engineForkChoiceUpdated(forkChoiceStateSlot3, Optional.empty()); // let the payload attributes for slot 3 return actualResponseA.get().propagateTo(deferredResponseA); // expect attributes for slot 3 - verify(executionEngineChannel) - .forkChoiceUpdated(forkChoiceStateSlot3, Optional.of(payloadAttributesSlot3)); + verify(executionLayerChannel) + .engineForkChoiceUpdated(forkChoiceStateSlot3, Optional.of(payloadAttributesSlot3)); - verifyNoMoreInteractions(executionEngineChannel); + verifyNoMoreInteractions(executionLayerChannel); } @Test @@ -361,13 +353,13 @@ void onAttestationsDue_shouldNotSendUpdateIfNotChanged() { final BeaconState headState = getHeadState(); final ForkChoiceState forkChoiceState = getCurrentForkChoiceState(); notifyForkChoiceUpdated(forkChoiceState); - verify(executionEngineChannel).forkChoiceUpdated(forkChoiceState, Optional.empty()); + verify(executionLayerChannel).engineForkChoiceUpdated(forkChoiceState, Optional.empty()); notifier.onAttestationsDue(headState.getSlot()); - verifyNoMoreInteractions(executionEngineChannel); + verifyNoMoreInteractions(executionLayerChannel); notifier.onAttestationsDue(headState.getSlot().plus(1)); - verifyNoMoreInteractions(executionEngineChannel); + verifyNoMoreInteractions(executionLayerChannel); } @Test @@ -386,12 +378,12 @@ void onAttestationsDue_shouldSendUpdateEvenWithAMissedBlockIfWeAreDueToProposeNe final ForkChoiceState forkChoiceState = getCurrentForkChoiceState(); notifyForkChoiceUpdated(forkChoiceState); // We are proposing block on slot 2 - verify(executionEngineChannel) - .forkChoiceUpdated(forkChoiceState, Optional.of(payloadAttributes.get(0))); + verify(executionLayerChannel) + .engineForkChoiceUpdated(forkChoiceState, Optional.of(payloadAttributes.get(0))); // onAttestationsDue for slot 1 (attributes for slot2) notifier.onAttestationsDue(headState.getSlot()); - verifyNoMoreInteractions(executionEngineChannel); + verifyNoMoreInteractions(executionLayerChannel); // simulating we missed trying to produce a block: we are now in slot 2 storageSystem @@ -400,11 +392,11 @@ void onAttestationsDue_shouldSendUpdateEvenWithAMissedBlockIfWeAreDueToProposeNe // Slot 2 is now assumed empty so prepare to propose in slot 3 notifier.onAttestationsDue(recentChainData.getCurrentSlot().orElseThrow()); - verify(executionEngineChannel) - .forkChoiceUpdated(forkChoiceState, Optional.of(payloadAttributes.get(1))); + verify(executionLayerChannel) + .engineForkChoiceUpdated(forkChoiceState, Optional.of(payloadAttributes.get(1))); // Shouldn't resend with added payload attributes - verifyNoMoreInteractions(executionEngineChannel); + verifyNoMoreInteractions(executionLayerChannel); } @Test @@ -423,8 +415,8 @@ void shouldUseStateFromCorrectEpochToCalculateBlockProposer() { notifyForkChoiceUpdated(getCurrentForkChoiceState()); - verify(executionEngineChannel) - .forkChoiceUpdated(getCurrentForkChoiceState(), Optional.of(payloadAttributes)); + verify(executionLayerChannel) + .engineForkChoiceUpdated(getCurrentForkChoiceState(), Optional.of(payloadAttributes)); } @Test @@ -436,20 +428,20 @@ void onForkChoiceUpdated_shouldNotIncludePayloadAttributesWhileSyncing() { notifyForkChoiceUpdated(forkChoiceState); // We're syncing so don't include payload attributes - verify(executionEngineChannel).forkChoiceUpdated(forkChoiceState, Optional.empty()); + verify(executionLayerChannel).engineForkChoiceUpdated(forkChoiceState, Optional.empty()); } @Test void onUpdatePreparableProposers_shouldNotIncludePayloadAttributesWhileSyncing() { final ForkChoiceState forkChoiceState = getCurrentForkChoiceState(); notifyForkChoiceUpdated(forkChoiceState); - verify(executionEngineChannel).forkChoiceUpdated(forkChoiceState, Optional.empty()); + verify(executionLayerChannel).engineForkChoiceUpdated(forkChoiceState, Optional.empty()); notifier.onSyncingStatusChanged(false); withProposerForSlot(recentChainData.getHeadSlot().plus(1)); // Shouldn't resend with added payload attributes - verifyNoMoreInteractions(executionEngineChannel); + verifyNoMoreInteractions(executionLayerChannel); } @Test @@ -459,11 +451,11 @@ void onUpdatePreparableProposers_shouldSendNewNotificationWhenProposerAdded() { final UInt64 blockSlot = headState.getSlot().plus(1); notifyForkChoiceUpdated(forkChoiceState); - verify(executionEngineChannel).forkChoiceUpdated(forkChoiceState, Optional.empty()); + verify(executionLayerChannel).engineForkChoiceUpdated(forkChoiceState, Optional.empty()); final PayloadAttributes payloadAttributes = withProposerForSlot(headState, blockSlot); - verify(executionEngineChannel) - .forkChoiceUpdated(forkChoiceState, Optional.of(payloadAttributes)); + verify(executionLayerChannel) + .engineForkChoiceUpdated(forkChoiceState, Optional.of(payloadAttributes)); } @Test @@ -476,7 +468,8 @@ void getPayloadId_shouldReturnLatestPayloadId() { final PayloadAttributes payloadAttributes = withProposerForSlot(headState, blockSlot); final SafeFuture responseFuture = new SafeFuture<>(); - when(executionEngineChannel.forkChoiceUpdated(forkChoiceState, Optional.of(payloadAttributes))) + when(executionLayerChannel.engineForkChoiceUpdated( + forkChoiceState, Optional.of(payloadAttributes))) .thenReturn(responseFuture); notifyForkChoiceUpdated(forkChoiceState); @@ -503,7 +496,8 @@ void getPayloadId_shouldReturnExceptionallyLatestPayloadIdOnWrongRoot() { final PayloadAttributes payloadAttributes = withProposerForSlot(headState, blockSlot); final SafeFuture responseFuture = new SafeFuture<>(); - when(executionEngineChannel.forkChoiceUpdated(forkChoiceState, Optional.of(payloadAttributes))) + when(executionLayerChannel.engineForkChoiceUpdated( + forkChoiceState, Optional.of(payloadAttributes))) .thenReturn(responseFuture); notifyForkChoiceUpdated(forkChoiceState); @@ -568,7 +562,8 @@ void getPayloadId_shouldObtainAPayloadIdOnPostMergeBlockNonFinalized() { assertThat(nonFinalizedForkChoiceState.getFinalizedExecutionBlockHash()) .isEqualTo(Bytes32.ZERO); notifyForkChoiceUpdated(nonFinalizedForkChoiceState); - verify(executionEngineChannel).forkChoiceUpdated(nonFinalizedForkChoiceState, Optional.empty()); + verify(executionLayerChannel) + .engineForkChoiceUpdated(nonFinalizedForkChoiceState, Optional.empty()); final Bytes8 payloadId = dataStructureUtil.randomBytes8(); @@ -587,7 +582,8 @@ void getPayloadId_shouldObtainAPayloadIdOnPostMergeBlockFinalized() { assertThat(finalizedForkChoiceState.getFinalizedExecutionBlockHash()) .isNotEqualTo(Bytes32.ZERO); notifyForkChoiceUpdated(finalizedForkChoiceState); - verify(executionEngineChannel).forkChoiceUpdated(finalizedForkChoiceState, Optional.empty()); + verify(executionLayerChannel) + .engineForkChoiceUpdated(finalizedForkChoiceState, Optional.empty()); final BeaconState headState = getHeadState(); final UInt64 blockSlot = headState.getSlot().plus(2); // proposing slot 3 @@ -609,7 +605,8 @@ void getPayloadId_shouldObtainAPayloadIdOnPostMergeBlockFinalizedEvenIfProposerN assertThat(finalizedForkChoiceState.getFinalizedExecutionBlockHash()) .isNotEqualTo(Bytes32.ZERO); notifyForkChoiceUpdated(finalizedForkChoiceState); - verify(executionEngineChannel).forkChoiceUpdated(finalizedForkChoiceState, Optional.empty()); + verify(executionLayerChannel) + .engineForkChoiceUpdated(finalizedForkChoiceState, Optional.empty()); final BeaconState headState = getHeadState(); final UInt64 blockSlot = headState.getSlot().plus(2); // proposing slot 3 @@ -633,7 +630,8 @@ void getPayloadId_shouldFailIfDefaultFeeRecipientIsNotConfigured() { assertThat(finalizedForkChoiceState.getFinalizedExecutionBlockHash()) .isNotEqualTo(Bytes32.ZERO); notifyForkChoiceUpdated(finalizedForkChoiceState); - verify(executionEngineChannel).forkChoiceUpdated(finalizedForkChoiceState, Optional.empty()); + verify(executionLayerChannel) + .engineForkChoiceUpdated(finalizedForkChoiceState, Optional.empty()); final BeaconState headState = getHeadState(); final UInt64 blockSlot = headState.getSlot().plus(2); // proposing slot 3 @@ -654,7 +652,8 @@ void getPayloadId_shouldReturnExceptionallyBeforeTheFirstForkChoiceState() { final ForkChoiceState forkChoiceState = getCurrentForkChoiceState(); final PayloadAttributes payloadAttributes = withProposerForSlot(headState, blockSlot); - when(executionEngineChannel.forkChoiceUpdated(forkChoiceState, Optional.of(payloadAttributes))) + when(executionLayerChannel.engineForkChoiceUpdated( + forkChoiceState, Optional.of(payloadAttributes))) .thenReturn(responseFuture); storageSystem.chainUpdater().setCurrentSlot(blockSlot); @@ -674,7 +673,8 @@ void getPayloadId_preMergeShouldReturnEmptyBeforeTheFirstForkChoiceState() { final ForkChoiceState forkChoiceState = getCurrentForkChoiceState(); final PayloadAttributes payloadAttributes = withProposerForSlot(headState, blockSlot); - when(executionEngineChannel.forkChoiceUpdated(forkChoiceState, Optional.of(payloadAttributes))) + when(executionLayerChannel.engineForkChoiceUpdated( + forkChoiceState, Optional.of(payloadAttributes))) .thenReturn(responseFuture); storageSystem.chainUpdater().setCurrentSlot(blockSlot); @@ -702,7 +702,8 @@ private void validateGetPayloadIdOnTheFlyRetrieval( storageSystem.chainUpdater().setCurrentSlot(blockSlot); - when(executionEngineChannel.forkChoiceUpdated(forkChoiceState, Optional.of(payloadAttributes))) + when(executionLayerChannel.engineForkChoiceUpdated( + forkChoiceState, Optional.of(payloadAttributes))) .thenReturn(responseFuture); // Initially has no payload ID. diff --git a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoicePayloadExecutorTest.java b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoicePayloadExecutorTest.java index 5432d84e6f5..205220abc51 100644 --- a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoicePayloadExecutorTest.java +++ b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoicePayloadExecutorTest.java @@ -19,7 +19,7 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import static tech.pegasys.teku.spec.executionengine.PayloadStatus.VALID; +import static tech.pegasys.teku.spec.executionlayer.PayloadStatus.VALID; import java.util.Optional; import org.junit.jupiter.api.AfterAll; @@ -32,8 +32,8 @@ import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeader; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel; -import tech.pegasys.teku.spec.executionengine.PayloadStatus; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel; +import tech.pegasys.teku.spec.executionlayer.PayloadStatus; import tech.pegasys.teku.spec.logic.common.block.AbstractBlockProcessor; import tech.pegasys.teku.spec.schemas.SchemaDefinitionsBellatrix; import tech.pegasys.teku.spec.util.DataStructureUtil; @@ -49,7 +49,7 @@ class ForkChoicePayloadExecutorTest { schemaDefinitionsBellatrix.getExecutionPayloadHeaderSchema().getDefault(); private final DataStructureUtil dataStructureUtil = new DataStructureUtil(spec); private final SafeFuture executionResult = new SafeFuture<>(); - private final ExecutionEngineChannel executionEngine = mock(ExecutionEngineChannel.class); + private final ExecutionLayerChannel executionLayer = mock(ExecutionLayerChannel.class); private final MergeTransitionBlockValidator transitionValidator = mock(MergeTransitionBlockValidator.class); private final ExecutionPayloadHeader payloadHeader = @@ -69,14 +69,14 @@ public static void resetSession() { @BeforeEach void setUp() { - when(executionEngine.newPayload(any())).thenReturn(executionResult); + when(executionLayer.engineNewPayload(any())).thenReturn(executionResult); } @Test void optimisticallyExecute_shouldSendToExecutionEngineAndReturnTrue() { final ForkChoicePayloadExecutor payloadExecutor = createPayloadExecutor(); final boolean result = payloadExecutor.optimisticallyExecute(payloadHeader, payload); - verify(executionEngine).newPayload(payload); + verify(executionLayer).engineNewPayload(payload); assertThat(result).isTrue(); } @@ -84,7 +84,7 @@ void optimisticallyExecute_shouldSendToExecutionEngineAndReturnTrue() { void optimisticallyExecute_shouldNotExecuteDefaultPayload() { final ForkChoicePayloadExecutor payloadExecutor = createPayloadExecutor(); final boolean result = payloadExecutor.optimisticallyExecute(payloadHeader, defaultPayload); - verify(executionEngine, never()).newPayload(any()); + verify(executionLayer, never()).engineNewPayload(any()); assertThat(result).isTrue(); assertThat(payloadExecutor.getExecutionResult()) .isCompletedWithValue(new PayloadValidationResult(PayloadStatus.VALID)); @@ -92,26 +92,26 @@ void optimisticallyExecute_shouldNotExecuteDefaultPayload() { @Test void optimisticallyExecute_shouldValidateMergeBlockWhenThisIsTheMergeBlock() { - when(executionEngine.newPayload(payload)).thenReturn(SafeFuture.completedFuture(VALID)); - when(executionEngine.getPowBlock(payload.getParentHash())).thenReturn(new SafeFuture<>()); + when(executionLayer.engineNewPayload(payload)).thenReturn(SafeFuture.completedFuture(VALID)); + when(executionLayer.eth1GetPowBlock(payload.getParentHash())).thenReturn(new SafeFuture<>()); final ForkChoicePayloadExecutor payloadExecutor = createPayloadExecutor(); final boolean result = payloadExecutor.optimisticallyExecute(defaultPayloadHeader, payload); // Should execute first and then begin validation of the transition block conditions. - verify(executionEngine).newPayload(payload); + verify(executionLayer).engineNewPayload(payload); verify(transitionValidator).verifyTransitionBlock(defaultPayloadHeader, block); assertThat(result).isTrue(); } @Test void optimisticallyExecute_shouldReturnFailedExecutionOnMergeBlockWhenELOfflineAtExecution() { - when(executionEngine.newPayload(payload)).thenReturn(SafeFuture.failedFuture(new Error())); + when(executionLayer.engineNewPayload(payload)).thenReturn(SafeFuture.failedFuture(new Error())); final ForkChoicePayloadExecutor payloadExecutor = createPayloadExecutor(); final boolean execution = payloadExecutor.optimisticallyExecute(defaultPayloadHeader, payload); // Should not attempt to validate transition conditions because execute payload failed verify(transitionValidator, never()).verifyTransitionBlock(defaultPayloadHeader, block); - verify(executionEngine).newPayload(payload); + verify(executionLayer).engineNewPayload(payload); assertThat(execution).isTrue(); assertThat(payloadExecutor.getExecutionResult()) .isCompletedWithValueMatching(result -> result.getStatus().hasFailedExecution()); @@ -120,14 +120,14 @@ void optimisticallyExecute_shouldReturnFailedExecutionOnMergeBlockWhenELOfflineA @Test void optimisticallyExecute_shouldReturnFailedExecutionOnMergeBlockWhenELGoesOfflineAfterExecution() { - when(executionEngine.newPayload(payload)).thenReturn(SafeFuture.completedFuture(VALID)); + when(executionLayer.engineNewPayload(payload)).thenReturn(SafeFuture.completedFuture(VALID)); when(transitionValidator.verifyTransitionBlock(defaultPayloadHeader, block)) .thenReturn(SafeFuture.failedFuture(new Error())); final ForkChoicePayloadExecutor payloadExecutor = createPayloadExecutor(); final boolean execution = payloadExecutor.optimisticallyExecute(defaultPayloadHeader, payload); verify(transitionValidator).verifyTransitionBlock(defaultPayloadHeader, block); - verify(executionEngine).newPayload(payload); + verify(executionLayer).engineNewPayload(payload); assertThat(execution).isTrue(); assertThat(payloadExecutor.getExecutionResult()) .isCompletedWithValueMatching(result -> result.getStatus().hasFailedExecution()); @@ -137,12 +137,12 @@ void optimisticallyExecute_shouldReturnFailedExecutionOnMergeBlockWhenELOfflineA void optimisticallyExecute_shouldNotVerifyTransitionIfExecutePayloadIsInvalid() { final PayloadStatus expectedResult = PayloadStatus.invalid(Optional.empty(), Optional.of("Nope")); - when(executionEngine.newPayload(payload)) + when(executionLayer.engineNewPayload(payload)) .thenReturn(SafeFuture.completedFuture(expectedResult)); final ForkChoicePayloadExecutor payloadExecutor = createPayloadExecutor(); final boolean execution = payloadExecutor.optimisticallyExecute(defaultPayloadHeader, payload); - verify(executionEngine).newPayload(payload); + verify(executionLayer).engineNewPayload(payload); verify(transitionValidator, never()).verifyTransitionBlock(defaultPayloadHeader, block); assertThat(execution).isTrue(); assertThat(payloadExecutor.getExecutionResult()) @@ -173,6 +173,6 @@ void shouldReturnExecutionResultWhenExecuted() { } private ForkChoicePayloadExecutor createPayloadExecutor() { - return new ForkChoicePayloadExecutor(block, executionEngine, transitionValidator); + return new ForkChoicePayloadExecutor(block, executionLayer, transitionValidator); } } diff --git a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceTest.java b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceTest.java index 399f64abbdc..fedd883af89 100644 --- a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceTest.java +++ b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceTest.java @@ -67,11 +67,11 @@ import tech.pegasys.teku.spec.datastructures.operations.IndexedAttestation.IndexedAttestationSchema; import tech.pegasys.teku.spec.datastructures.state.Checkpoint; import tech.pegasys.teku.spec.datastructures.util.AttestationProcessingResult; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannelStub; -import tech.pegasys.teku.spec.executionengine.ExecutionPayloadStatus; -import tech.pegasys.teku.spec.executionengine.ForkChoiceState; -import tech.pegasys.teku.spec.executionengine.ForkChoiceUpdatedResult; -import tech.pegasys.teku.spec.executionengine.PayloadStatus; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannelStub; +import tech.pegasys.teku.spec.executionlayer.ExecutionPayloadStatus; +import tech.pegasys.teku.spec.executionlayer.ForkChoiceState; +import tech.pegasys.teku.spec.executionlayer.ForkChoiceUpdatedResult; +import tech.pegasys.teku.spec.executionlayer.PayloadStatus; import tech.pegasys.teku.spec.logic.common.statetransition.results.BlockImportResult; import tech.pegasys.teku.spec.logic.common.statetransition.results.BlockImportResult.FailureReason; import tech.pegasys.teku.spec.util.DataStructureUtil; @@ -105,8 +105,8 @@ class ForkChoiceTest { private final ForkChoiceNotifier forkChoiceNotifier = mock(ForkChoiceNotifier.class); private final OptimisticHeadSubscriber optimisticSyncStateTracker = mock(OptimisticHeadSubscriber.class); - private final ExecutionEngineChannelStub executionEngine = - new ExecutionEngineChannelStub(spec, false); + private final ExecutionLayerChannelStub executionLayer = + new ExecutionLayerChannelStub(spec, false); private final MergeTransitionBlockValidator transitionBlockValidator = mock(MergeTransitionBlockValidator.class); private ForkChoice forkChoice = @@ -159,7 +159,7 @@ void shouldNotTriggerReorgWhenEmptyHeadSlotFilled() { void onBlock_shouldImmediatelyMakeChildOfCurrentHeadTheNewHead() { final SignedBlockAndState blockAndState = chainBuilder.generateBlockAtSlot(ONE); final SafeFuture importResult = - forkChoice.onBlock(blockAndState.getBlock(), Optional.empty(), executionEngine); + forkChoice.onBlock(blockAndState.getBlock(), Optional.empty(), executionLayer); assertBlockImportedSuccessfully(importResult, false); assertThat(recentChainData.getHeadBlock().map(MinimalBeaconBlockSummary::getRoot)) @@ -175,7 +175,7 @@ void onBlock_shouldNotTriggerReorgWhenSelectingChildOfChainHeadWhenForkChoiceSlo final SignedBlockAndState blockAndState = chainBuilder.generateBlockAtSlot(ONE); final SafeFuture importResult = - forkChoice.onBlock(blockAndState.getBlock(), Optional.empty(), executionEngine); + forkChoice.onBlock(blockAndState.getBlock(), Optional.empty(), executionLayer); assertBlockImportedSuccessfully(importResult, false); assertThat(recentChainData.getHeadBlock().map(MinimalBeaconBlockSummary::getRoot)) @@ -410,7 +410,7 @@ void onBlock_shouldHandleNonCanonicalBlockThatUpdatesJustifiedCheckpoint() { void onBlock_shouldSendForkChoiceUpdatedNotification() { final SignedBlockAndState blockAndState = chainBuilder.generateBlockAtSlot(ONE); final SafeFuture importResult = - forkChoice.onBlock(blockAndState.getBlock(), Optional.empty(), executionEngine); + forkChoice.onBlock(blockAndState.getBlock(), Optional.empty(), executionLayer); assertBlockImportedSuccessfully(importResult, false); assertForkChoiceUpdateNotification(blockAndState, false); @@ -420,7 +420,7 @@ void onBlock_shouldSendForkChoiceUpdatedNotification() { void onBlock_shouldNotOptimisticallyImportRecentMergeBlock() { final SignedBlockAndState epoch4Block = generateMergeBlock(); // make EL returning SYNCING - executionEngine.setPayloadStatus(PayloadStatus.SYNCING); + executionLayer.setPayloadStatus(PayloadStatus.SYNCING); importBlockWithError(epoch4Block, FailureReason.FAILED_EXECUTION_PAYLOAD_EXECUTION_SYNCING); } @@ -431,7 +431,7 @@ void onBlock_shouldNotOptimisticallyImportOnELFailure() { UInt64 slotToImport = recentChainData.getHeadSlot().plus(1); // make EL returning low level error - executionEngine.setPayloadStatus( + executionLayer.setPayloadStatus( PayloadStatus.failedExecution(new RuntimeException("net error"))); // generate block which finalize epoch 2 @@ -448,7 +448,7 @@ void onBlock_shouldNotOptimisticallyImportInvalidExecutionPayload() { importBlock(epoch4Block); // make EL returning INVALID - executionEngine.setPayloadStatus(PayloadStatus.invalid(Optional.empty(), Optional.empty())); + executionLayer.setPayloadStatus(PayloadStatus.invalid(Optional.empty(), Optional.empty())); storageSystem.chainUpdater().setCurrentSlot(slotToImport.increment()); importBlockWithError(chainBuilder.generateNextBlock(), FailureReason.FAILED_STATE_TRANSITION); @@ -469,7 +469,7 @@ void onBlock_shouldNotifyOptimisticSyncChangeOnlyWhenImportingOnCanonicalHead() slotToImport = prepFinalizeEpoch(4); // make EL returning SYNCING - executionEngine.setPayloadStatus(PayloadStatus.SYNCING); + executionLayer.setPayloadStatus(PayloadStatus.SYNCING); // generate block which finalize epoch 4 final SignedBlockAndState epoch6Block = chainBuilder.generateBlockAtSlot(slotToImport); @@ -484,7 +484,7 @@ void onBlock_shouldNotifyOptimisticSyncChangeOnlyWhenImportingOnCanonicalHead() ChainBuilder alternativeChain = chainBuilder.fork(); // make EL returning SYNCING - executionEngine.setPayloadStatus(PayloadStatus.VALID); + executionLayer.setPayloadStatus(PayloadStatus.VALID); importBlock(chainBuilder.generateBlockAtSlot(forkSlot)); @@ -495,7 +495,7 @@ void onBlock_shouldNotifyOptimisticSyncChangeOnlyWhenImportingOnCanonicalHead() importBlock(chainBuilder.generateBlockAtSlot(forkSlot.plus(1))); // make EL returning SYNCING - executionEngine.setPayloadStatus(PayloadStatus.SYNCING); + executionLayer.setPayloadStatus(PayloadStatus.SYNCING); // import a fork which won't be canonical importBlockOptimistically(alternativeChain.generateBlockAtSlot(forkSlot)); @@ -524,7 +524,7 @@ void applyHead_shouldSendForkChoiceUpdatedNotificationWhenOptimistic() { final SignedBlockAndState blockAndState = storageSystem.chainBuilder().generateBlockAtSlot(nextBlockSlot); - executionEngine.setPayloadStatus(PayloadStatus.SYNCING); + executionLayer.setPayloadStatus(PayloadStatus.SYNCING); setForkChoiceNotifierForkChoiceUpdatedResult(PayloadStatus.SYNCING); importBlockOptimistically(blockAndState); assertForkChoiceUpdateNotification(blockAndState, true); @@ -551,7 +551,7 @@ void processHead_shouldValidateAncestorTransitionBlockWhenHeadNowValid() { @Test void processHead_shouldMarkHeadInvalidAndRunForkChoiceWhenTransitionBlockFoundToBeInvalid() { setForkChoiceNotifierForkChoiceUpdatedResult(PayloadStatus.SYNCING); - executionEngine.setPayloadStatus(PayloadStatus.SYNCING); + executionLayer.setPayloadStatus(PayloadStatus.SYNCING); Bytes32 initialHeadRoot = recentChainData.getChainHead().orElseThrow().getRoot(); @@ -610,10 +610,10 @@ void onBlock_shouldUseLatestValidHashFromForkChoiceUpdated() { final SignedBlockAndState blockAndState = storageSystem.chainBuilder().generateBlockAtSlot(nextBlockSlot); - executionEngine.setPayloadStatus(PayloadStatus.SYNCING); + executionLayer.setPayloadStatus(PayloadStatus.SYNCING); setForkChoiceNotifierForkChoiceUpdatedResult(PayloadStatus.SYNCING); final SafeFuture result = - forkChoice.onBlock(blockAndState.getBlock(), Optional.empty(), executionEngine); + forkChoice.onBlock(blockAndState.getBlock(), Optional.empty(), executionLayer); assertBlockImportedSuccessfully(result, true); assertForkChoiceUpdateNotification(blockAndState, true); @@ -624,7 +624,7 @@ void onBlock_shouldUseLatestValidHashFromForkChoiceUpdated() { // INVALID will give us a lastValidHash corresponding to the previous block payload (imported // optimistically) - executionEngine.setPayloadStatus(PayloadStatus.ACCEPTED); + executionLayer.setPayloadStatus(PayloadStatus.ACCEPTED); PayloadStatus invalidWithLastValidBlockHash = PayloadStatus.create( @@ -803,8 +803,8 @@ private SignedBlockAndState generateMergeBlock() { dataStructureUtil.randomBytes32(), terminalTotalDifficulty.subtract(1), ZERO); - executionEngine.addPowBlock(terminalBlock); - executionEngine.addPowBlock(terminalParentBlock); + executionLayer.addPowBlock(terminalBlock); + executionLayer.addPowBlock(terminalParentBlock); final SignedBlockAndState epoch4Block = chainBuilder.generateBlockAtSlot( storageSystem.chainUpdater().getHeadSlot().plus(1), @@ -881,13 +881,13 @@ private void assertBlockImportedSuccessfully( private void importBlock(final SignedBlockAndState block) { final SafeFuture result = - forkChoice.onBlock(block.getBlock(), Optional.empty(), executionEngine); + forkChoice.onBlock(block.getBlock(), Optional.empty(), executionLayer); assertBlockImportedSuccessfully(result, false); } private void importBlockOptimistically(final SignedBlockAndState block) { final SafeFuture result = - forkChoice.onBlock(block.getBlock(), Optional.empty(), executionEngine); + forkChoice.onBlock(block.getBlock(), Optional.empty(), executionLayer); assertBlockImportedSuccessfully(result, true); } @@ -900,7 +900,7 @@ private void assertBlockImportFailure( private void importBlockWithError(final SignedBlockAndState block, FailureReason failureReason) { final SafeFuture result = - forkChoice.onBlock(block.getBlock(), Optional.empty(), executionEngine); + forkChoice.onBlock(block.getBlock(), Optional.empty(), executionLayer); assertBlockImportFailure(result, failureReason); } diff --git a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/MergeTransitionBlockValidatorTest.java b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/MergeTransitionBlockValidatorTest.java index caf6175676f..0fb14696c47 100644 --- a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/MergeTransitionBlockValidatorTest.java +++ b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/MergeTransitionBlockValidatorTest.java @@ -32,9 +32,9 @@ import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload; import tech.pegasys.teku.spec.datastructures.execution.PowBlock; import tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.bellatrix.BeaconStateBellatrix; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannelStub; -import tech.pegasys.teku.spec.executionengine.PayloadStatus; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannelStub; +import tech.pegasys.teku.spec.executionlayer.PayloadStatus; import tech.pegasys.teku.spec.logic.common.block.AbstractBlockProcessor; import tech.pegasys.teku.spec.logic.versions.bellatrix.helpers.BellatrixTransitionHelpers; import tech.pegasys.teku.spec.util.DataStructureUtil; @@ -45,8 +45,8 @@ class MergeTransitionBlockValidatorTest { private final Spec spec = TestSpecFactory.createMinimalBellatrix(); private final DataStructureUtil dataStructureUtil = new DataStructureUtil(spec); - private final ExecutionEngineChannelStub executionEngine = - new ExecutionEngineChannelStub(spec, false); + private final ExecutionLayerChannelStub executionLayer = + new ExecutionLayerChannelStub(spec, false); private final StorageSystem storageSystem = InMemoryStorageSystemBuilder.buildDefault(spec); @BeforeAll @@ -62,7 +62,8 @@ public static void resetSession() { /** * The details of how we validate the merge block are all handled by {@link * BellatrixTransitionHelpers} so we don't want to retest all that here. Instead, we check that - * those extra checks started (the call to {@link ExecutionEngineChannel#getPowBlock(Bytes32)}). + * those extra checks started (the call to {@link + * ExecutionLayerChannel#eth1GetPowBlock(Bytes32)}). * *

Since the future we return from getPowBlock is never completed we never complete the * validations which saves us a bunch of mocking. @@ -98,7 +99,7 @@ void shouldReturnValidImmediatelyWhenThereIsTransitionBlockFullyVerified() { blockToVerify.getBlock()); // No need to request blocks and check TTD - assertThat(executionEngine.getRequestedPowBlocks()).isEmpty(); + assertThat(executionLayer.getRequestedPowBlocks()).isEmpty(); assertThat(result).isCompletedWithValue(new PayloadValidationResult(PayloadStatus.VALID)); } @@ -128,7 +129,7 @@ void shouldVerifyNonFinalizedAncestorTransitionBlock() { .getLatestExecutionPayloadHeader(), blockToVerify.getBlock()); - assertThat(executionEngine.getRequestedPowBlocks()) + assertThat(executionLayer.getRequestedPowBlocks()) .contains(getExecutionPayload(transitionBlock).getParentHash()); assertThat(result) .isCompletedWithValue( @@ -161,7 +162,7 @@ void shouldReportRootForInvalidNonFinalizedAncestorTransitionBlock() { .getLatestExecutionPayloadHeader(), blockToVerify.getBlock()); - assertThat(executionEngine.getRequestedPowBlocks()) + assertThat(executionLayer.getRequestedPowBlocks()) .contains(getExecutionPayload(transitionBlock).getParentHash()); assertThat(result).isCompleted(); final PayloadValidationResult validationResult = result.join(); @@ -193,7 +194,7 @@ void shouldVerifyFinalizedAncestorTransitionBlock() { transitionVerifier.verifyTransitionBlock( chainHeadState.getLatestExecutionPayloadHeader(), blockToVerify.getBlock()); - assertThat(executionEngine.getRequestedPowBlocks()) + assertThat(executionLayer.getRequestedPowBlocks()) .contains(getExecutionPayload(transitionBlock).getParentHash()); assertThat(result).isCompletedWithValue(new PayloadValidationResult(PayloadStatus.VALID)); } @@ -250,13 +251,13 @@ private void withPowBlockDifficulties( final UInt256 terminalBlockDifficulty, final UInt256 ttdBlockParentDifficulty) { final Bytes32 terminalBlockParentHash = dataStructureUtil.randomBytes32(); - executionEngine.addPowBlock( + executionLayer.addPowBlock( new PowBlock( getExecutionPayload(transitionBlock).getParentHash(), terminalBlockParentHash, terminalBlockDifficulty, UInt64.ZERO)); - executionEngine.addPowBlock( + executionLayer.addPowBlock( new PowBlock( terminalBlockParentHash, dataStructureUtil.randomBytes32(), @@ -303,7 +304,6 @@ private ExecutionPayload getExecutionPayload(final SignedBlockAndState blockToVe } private MergeTransitionBlockValidator createTransitionValidator() { - return new MergeTransitionBlockValidator( - spec, storageSystem.recentChainData(), executionEngine); + return new MergeTransitionBlockValidator(spec, storageSystem.recentChainData(), executionLayer); } } diff --git a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/MergeTransitionConfigCheckTest.java b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/MergeTransitionConfigCheckTest.java index 5705523af95..dfb55258c64 100644 --- a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/MergeTransitionConfigCheckTest.java +++ b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/MergeTransitionConfigCheckTest.java @@ -32,8 +32,8 @@ import tech.pegasys.teku.spec.Spec; import tech.pegasys.teku.spec.TestSpecFactory; import tech.pegasys.teku.spec.config.SpecConfigLoader; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel; -import tech.pegasys.teku.spec.executionengine.TransitionConfiguration; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel; +import tech.pegasys.teku.spec.executionlayer.TransitionConfiguration; import tech.pegasys.teku.spec.util.DataStructureUtil; class MergeTransitionConfigCheckTest { @@ -42,7 +42,7 @@ class MergeTransitionConfigCheckTest { private static final Bytes32 TERMINAL_BLOCK_HASH = Bytes32.random(); private static final UInt64 TERMINAL_BLOCK_EPOCH = UInt64.valueOf(2); - private final ExecutionEngineChannel executionEngine = mock(ExecutionEngineChannel.class); + private final ExecutionLayerChannel executionLayer = mock(ExecutionLayerChannel.class); private final StubTimeProvider timeProvider = StubTimeProvider.withTimeInSeconds(10_000); private final StubAsyncRunner asyncRunner = new StubAsyncRunner(timeProvider); private final EventLogger eventLogger = Mockito.mock(EventLogger.class); @@ -79,9 +79,9 @@ void setUp() { UInt64.ZERO); final MergeTransitionConfigCheck mergeTransitionConfigCheck = - new MergeTransitionConfigCheck(eventLogger, spec, executionEngine, asyncRunner); + new MergeTransitionConfigCheck(eventLogger, spec, executionLayer, asyncRunner); - when(executionEngine.exchangeTransitionConfiguration(localTransitionConfiguration)) + when(executionLayer.engineExchangeTransitionConfiguration(localTransitionConfiguration)) .thenReturn( SafeFuture.completedFuture( new TransitionConfiguration( @@ -97,7 +97,7 @@ void shouldReportWrongTotalTerminalDifficulty() { final TransitionConfiguration wrongRemoteConfig = new TransitionConfiguration( wrongRemoteTTD, localTransitionConfiguration.getTerminalBlockHash(), UInt64.ZERO); - when(executionEngine.exchangeTransitionConfiguration(localTransitionConfiguration)) + when(executionLayer.engineExchangeTransitionConfiguration(localTransitionConfiguration)) .thenReturn(SafeFuture.completedFuture(wrongRemoteConfig)); asyncRunner.executeQueuedActions(); @@ -112,7 +112,7 @@ void shouldDetectWrongTerminalBlockHash() { final TransitionConfiguration wrongRemoteConfig = new TransitionConfiguration( localTransitionConfiguration.getTerminalTotalDifficulty(), wrongRemoteTBH, UInt64.ZERO); - when(executionEngine.exchangeTransitionConfiguration(localTransitionConfiguration)) + when(executionLayer.engineExchangeTransitionConfiguration(localTransitionConfiguration)) .thenReturn(SafeFuture.completedFuture(wrongRemoteConfig)); asyncRunner.executeQueuedActions(); @@ -129,7 +129,7 @@ void shouldReportInconsistencyReportedByRemote() { localTransitionConfiguration.getTerminalTotalDifficulty(), localTransitionConfiguration.getTerminalBlockHash(), UInt64.ZERO); - when(executionEngine.exchangeTransitionConfiguration(localTransitionConfiguration)) + when(executionLayer.engineExchangeTransitionConfiguration(localTransitionConfiguration)) .thenReturn(SafeFuture.completedFuture(wrongRemoteConfig)); asyncRunner.executeQueuedActions(); diff --git a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/TerminalPowBlockMonitorTest.java b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/TerminalPowBlockMonitorTest.java index a0e5069d880..f18b18b37ba 100644 --- a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/TerminalPowBlockMonitorTest.java +++ b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/TerminalPowBlockMonitorTest.java @@ -44,8 +44,8 @@ import tech.pegasys.teku.spec.config.SpecConfigLoader; import tech.pegasys.teku.spec.datastructures.blocks.SignedBlockAndState; import tech.pegasys.teku.spec.datastructures.execution.PowBlock; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel; -import tech.pegasys.teku.spec.executionengine.TransitionConfiguration; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel; +import tech.pegasys.teku.spec.executionlayer.TransitionConfiguration; import tech.pegasys.teku.spec.logic.common.block.AbstractBlockProcessor; import tech.pegasys.teku.spec.util.DataStructureUtil; import tech.pegasys.teku.storage.client.RecentChainData; @@ -59,7 +59,7 @@ public class TerminalPowBlockMonitorTest { private static final UInt64 TERMINAL_BLOCK_EPOCH = UInt64.valueOf(2); private static final UInt64 TIME_IN_PAST = UInt64.valueOf(123); - private final ExecutionEngineChannel executionEngine = mock(ExecutionEngineChannel.class); + private final ExecutionLayerChannel executionLayer = mock(ExecutionLayerChannel.class); private final StubTimeProvider timeProvider = StubTimeProvider.withTimeInSeconds(10_000); private final StubAsyncRunner asyncRunner = new StubAsyncRunner(timeProvider); private final ForkChoiceNotifier forkChoiceNotifier = mock(ForkChoiceNotifier.class); @@ -90,7 +90,7 @@ private void setUpTerminalBlockHashConfig() { .terminalBlockHash(TERMINAL_BLOCK_HASH) .terminalBlockHashActivationEpoch(TERMINAL_BLOCK_EPOCH)); - when(executionEngine.exchangeTransitionConfiguration(localTransitionConfiguration)) + when(executionLayer.engineExchangeTransitionConfiguration(localTransitionConfiguration)) .thenReturn( SafeFuture.completedFuture( new TransitionConfiguration( @@ -104,7 +104,7 @@ private void setUpTTDConfig() { bellatrixBuilder -> bellatrixBuilder.bellatrixForkEpoch(BELLATRIX_FORK_EPOCH).terminalTotalDifficulty(TTD)); - when(executionEngine.exchangeTransitionConfiguration(localTransitionConfiguration)) + when(executionLayer.engineExchangeTransitionConfiguration(localTransitionConfiguration)) .thenReturn(SafeFuture.completedFuture(localTransitionConfiguration)); } @@ -133,7 +133,7 @@ private void setUpCommon(Consumer bellatrixBuilder) { terminalPowBlockMonitor = new TerminalPowBlockMonitor( - executionEngine, + executionLayer, spec, recentChainData, forkChoiceNotifier, @@ -174,10 +174,10 @@ void shouldNotFailWhenCurrentSlotInBellatrixMilestoneButHeadStateIsFromEarlierMi // Terminal block has been reached final Bytes32 headBlockHash = dataStructureUtil.randomBytes32(); final Bytes32 headBlockParentHash = dataStructureUtil.randomBytes32(); - when(executionEngine.getPowChainHead()) + when(executionLayer.eth1GetPowChainHead()) .thenReturn( completedFuture(new PowBlock(headBlockHash, headBlockParentHash, TTD, TIME_IN_PAST))); - when(executionEngine.getPowBlock(headBlockParentHash)) + when(executionLayer.eth1GetPowBlock(headBlockParentHash)) .thenReturn( completedFuture( Optional.of( @@ -210,7 +210,7 @@ public void shouldPerformTerminalBlockDetectionByTTD() { asyncRunner.executeQueuedActions(); - verify(executionEngine, times(0)).getPowChainHead(); + verify(executionLayer, times(0)).eth1GetPowChainHead(); verify(forkChoiceNotifier, times(0)).onTerminalBlockReached(any()); // AT BELLATRIX FORK, TTD not reached - should not send @@ -218,7 +218,7 @@ public void shouldPerformTerminalBlockDetectionByTTD() { goToSlot(BELLATRIX_FORK_EPOCH.times(spec.getGenesisSpecConfig().getSlotsPerEpoch())); - when(executionEngine.getPowChainHead()) + when(executionLayer.eth1GetPowChainHead()) .thenReturn( completedFuture( new PowBlock( @@ -229,16 +229,16 @@ public void shouldPerformTerminalBlockDetectionByTTD() { asyncRunner.executeQueuedActions(); - verify(executionEngine, times(1)).getPowChainHead(); + verify(executionLayer, times(1)).eth1GetPowChainHead(); verify(forkChoiceNotifier, times(0)).onTerminalBlockReached(any()); // AT BELLATRIX FORK, TTD reached - should notify headBlockHash = dataStructureUtil.randomBytes32(); headBlockParentHash = dataStructureUtil.randomBytes32(); - when(executionEngine.getPowChainHead()) + when(executionLayer.eth1GetPowChainHead()) .thenReturn( completedFuture(new PowBlock(headBlockHash, headBlockParentHash, TTD, TIME_IN_PAST))); - when(executionEngine.getPowBlock(headBlockParentHash)) + when(executionLayer.eth1GetPowBlock(headBlockParentHash)) .thenReturn( completedFuture( Optional.of( @@ -251,24 +251,24 @@ public void shouldPerformTerminalBlockDetectionByTTD() { asyncRunner.executeQueuedActions(); verify(eventLogger).terminalPowBlockDetected(headBlockHash); - verify(executionEngine, times(1)).getPowBlock(headBlockParentHash); - verify(executionEngine, times(2)).getPowChainHead(); + verify(executionLayer, times(1)).eth1GetPowBlock(headBlockParentHash); + verify(executionLayer, times(2)).eth1GetPowChainHead(); verify(forkChoiceNotifier, times(1)).onTerminalBlockReached(headBlockHash); // Terminal Block - should not notify asyncRunner.executeQueuedActions(); - verify(executionEngine, times(3)).getPowChainHead(); - verifyNoMoreInteractions(executionEngine); + verify(executionLayer, times(3)).eth1GetPowChainHead(); + verifyNoMoreInteractions(executionLayer); // new different Terminal Block with wrong parent TTD - should not notify headBlockHash = dataStructureUtil.randomBytes32(); headBlockParentHash = dataStructureUtil.randomBytes32(); - when(executionEngine.getPowChainHead()) + when(executionLayer.eth1GetPowChainHead()) .thenReturn( completedFuture( new PowBlock(headBlockHash, headBlockParentHash, TTD.add(10), TIME_IN_PAST))); - when(executionEngine.getPowBlock(headBlockParentHash)) + when(executionLayer.eth1GetPowBlock(headBlockParentHash)) .thenReturn( completedFuture( Optional.of( @@ -280,18 +280,18 @@ public void shouldPerformTerminalBlockDetectionByTTD() { asyncRunner.executeQueuedActions(); - verify(executionEngine, times(1)).getPowBlock(headBlockParentHash); - verify(executionEngine, times(4)).getPowChainHead(); + verify(executionLayer, times(1)).eth1GetPowBlock(headBlockParentHash); + verify(executionLayer, times(4)).eth1GetPowChainHead(); verify(forkChoiceNotifier, times(0)).onTerminalBlockReached(headBlockHash); // new different Terminal Block with correct parent TTD - should notify headBlockHash = dataStructureUtil.randomBytes32(); headBlockParentHash = dataStructureUtil.randomBytes32(); - when(executionEngine.getPowChainHead()) + when(executionLayer.eth1GetPowChainHead()) .thenReturn( completedFuture( new PowBlock(headBlockHash, headBlockParentHash, TTD.add(10), TIME_IN_PAST))); - when(executionEngine.getPowBlock(headBlockParentHash)) + when(executionLayer.eth1GetPowBlock(headBlockParentHash)) .thenReturn( completedFuture( Optional.of( @@ -304,8 +304,8 @@ public void shouldPerformTerminalBlockDetectionByTTD() { asyncRunner.executeQueuedActions(); verify(eventLogger).terminalPowBlockDetected(headBlockHash); - verify(executionEngine, times(1)).getPowBlock(headBlockParentHash); - verify(executionEngine, times(5)).getPowChainHead(); + verify(executionLayer, times(1)).eth1GetPowBlock(headBlockParentHash); + verify(executionLayer, times(5)).eth1GetPowChainHead(); verify(forkChoiceNotifier, times(1)).onTerminalBlockReached(headBlockHash); // MERGE Completed - should stop @@ -316,7 +316,7 @@ public void shouldPerformTerminalBlockDetectionByTTD() { assertThat(terminalPowBlockMonitor.isRunning()).isFalse(); // final check - verifyNoMoreInteractions(executionEngine); + verifyNoMoreInteractions(executionLayer); verifyNoMoreInteractions(eventLogger); } @@ -334,10 +334,10 @@ public void shouldNotSelectTTDBlockWithTimestampInFuture() { headBlockHash = dataStructureUtil.randomBytes32(); headBlockParentHash = dataStructureUtil.randomBytes32(); final UInt64 timeInFuture = timeProvider.getTimeInSeconds().plus(1); - when(executionEngine.getPowChainHead()) + when(executionLayer.eth1GetPowChainHead()) .thenReturn( completedFuture(new PowBlock(headBlockHash, headBlockParentHash, TTD, timeInFuture))); - when(executionEngine.getPowBlock(headBlockParentHash)) + when(executionLayer.eth1GetPowBlock(headBlockParentHash)) .thenReturn( completedFuture( Optional.of( @@ -367,7 +367,7 @@ void shouldPerformTerminalBlockDetectionByTerminalBlockHash() { asyncRunner.executeQueuedActions(); - verify(executionEngine, times(0)).getPowBlock(any()); + verify(executionLayer, times(0)).eth1GetPowBlock(any()); verify(forkChoiceNotifier, times(0)).onTerminalBlockReached(any()); // AT BELLATRIX FORK, Terminal Bloch Epoch not reached - should not notify @@ -375,21 +375,21 @@ void shouldPerformTerminalBlockDetectionByTerminalBlockHash() { asyncRunner.executeQueuedActions(); - verify(executionEngine, times(0)).getPowBlock(any()); + verify(executionLayer, times(0)).eth1GetPowBlock(any()); verify(forkChoiceNotifier, times(0)).onTerminalBlockReached(any()); // AT Terminal Bloch Epoch, Terminal Block Hash not found - should not notify goToSlot(TERMINAL_BLOCK_EPOCH.times(spec.getGenesisSpecConfig().getSlotsPerEpoch())); - when(executionEngine.getPowBlock(TERMINAL_BLOCK_HASH)) + when(executionLayer.eth1GetPowBlock(TERMINAL_BLOCK_HASH)) .thenReturn(completedFuture(Optional.empty())); asyncRunner.executeQueuedActions(); - verify(executionEngine, times(1)).getPowBlock(TERMINAL_BLOCK_HASH); + verify(executionLayer, times(1)).eth1GetPowBlock(TERMINAL_BLOCK_HASH); verify(forkChoiceNotifier, times(0)).onTerminalBlockReached(any()); // AT Terminal Bloch Epoch, Terminal Block Hash found - should notify - when(executionEngine.getPowBlock(TERMINAL_BLOCK_HASH)) + when(executionLayer.eth1GetPowBlock(TERMINAL_BLOCK_HASH)) .thenReturn( completedFuture( Optional.of( @@ -402,7 +402,7 @@ void shouldPerformTerminalBlockDetectionByTerminalBlockHash() { asyncRunner.executeQueuedActions(); verify(eventLogger).terminalPowBlockDetected(TERMINAL_BLOCK_HASH); - verify(executionEngine, times(2)).getPowBlock(TERMINAL_BLOCK_HASH); + verify(executionLayer, times(2)).eth1GetPowBlock(TERMINAL_BLOCK_HASH); verify(forkChoiceNotifier, times(1)).onTerminalBlockReached(TERMINAL_BLOCK_HASH); // MERGE Completed - should stop @@ -411,7 +411,7 @@ void shouldPerformTerminalBlockDetectionByTerminalBlockHash() { assertThat(terminalPowBlockMonitor.isRunning()).isFalse(); // final check - verifyNoMoreInteractions(executionEngine); + verifyNoMoreInteractions(executionLayer); verifyNoMoreInteractions(eventLogger); } @@ -440,7 +440,7 @@ void shouldNotPerformCheckIfSyncing() { asyncRunner.executeQueuedActions(); - verifyNoMoreInteractions(executionEngine); + verifyNoMoreInteractions(executionLayer); } @Test @@ -468,7 +468,7 @@ void shouldCalculateTtdEta() { } private void pollTtd(final UInt256 ttd) { - when(executionEngine.getPowChainHead()) + when(executionLayer.eth1GetPowChainHead()) .thenReturn( completedFuture( new PowBlock( diff --git a/ethereum/statetransition/src/testFixtures/java/tech/pegasys/teku/statetransition/BeaconChainUtil.java b/ethereum/statetransition/src/testFixtures/java/tech/pegasys/teku/statetransition/BeaconChainUtil.java index a525588844d..1a19529ad9b 100644 --- a/ethereum/statetransition/src/testFixtures/java/tech/pegasys/teku/statetransition/BeaconChainUtil.java +++ b/ethereum/statetransition/src/testFixtures/java/tech/pegasys/teku/statetransition/BeaconChainUtil.java @@ -43,8 +43,8 @@ import tech.pegasys.teku.spec.datastructures.operations.Deposit; import tech.pegasys.teku.spec.datastructures.operations.SignedVoluntaryExit; import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannelStub; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannelStub; import tech.pegasys.teku.spec.logic.common.statetransition.results.BlockImportResult; import tech.pegasys.teku.statetransition.forkchoice.ForkChoice; import tech.pegasys.teku.statetransition.forkchoice.MergeTransitionBlockValidator; @@ -117,7 +117,7 @@ public static BeaconChainUtil create( new InlineEventThread(), storageClient, new StubForkChoiceNotifier(), - new MergeTransitionBlockValidator(spec, storageClient, ExecutionEngineChannel.NOOP)), + new MergeTransitionBlockValidator(spec, storageClient, ExecutionLayerChannel.NOOP)), true); } @@ -143,7 +143,7 @@ public static BeaconChainUtil create( new InlineEventThread(), storageClient, new StubForkChoiceNotifier(), - new MergeTransitionBlockValidator(spec, storageClient, ExecutionEngineChannel.NOOP)), + new MergeTransitionBlockValidator(spec, storageClient, ExecutionLayerChannel.NOOP)), signDeposits); } @@ -251,7 +251,7 @@ public SignedBeaconBlock createAndImportBlockAtSlot( setSlot(slot); final BlockImportResult importResult = forkChoice - .onBlock(block, Optional.empty(), new ExecutionEngineChannelStub(spec, false)) + .onBlock(block, Optional.empty(), new ExecutionLayerChannelStub(spec, false)) .join(); if (!importResult.isSuccessful()) { throw new IllegalStateException( @@ -391,7 +391,7 @@ public BeaconChainUtil build() { recentChainData, new StubForkChoiceNotifier(), new MergeTransitionBlockValidator( - spec, recentChainData, ExecutionEngineChannel.NOOP)); + spec, recentChainData, ExecutionLayerChannel.NOOP)); } if (validatorKeys == null) { new MockStartValidatorKeyPairFactory().generateKeyPairs(0, validatorCount); diff --git a/ethereum/statetransition/src/testFixtures/java/tech/pegasys/teku/statetransition/forkchoice/StubForkChoiceNotifier.java b/ethereum/statetransition/src/testFixtures/java/tech/pegasys/teku/statetransition/forkchoice/StubForkChoiceNotifier.java index 1c8de12ae7e..f5136d12320 100644 --- a/ethereum/statetransition/src/testFixtures/java/tech/pegasys/teku/statetransition/forkchoice/StubForkChoiceNotifier.java +++ b/ethereum/statetransition/src/testFixtures/java/tech/pegasys/teku/statetransition/forkchoice/StubForkChoiceNotifier.java @@ -21,8 +21,8 @@ import tech.pegasys.teku.infrastructure.subscribers.Subscribers; import tech.pegasys.teku.infrastructure.unsigned.UInt64; import tech.pegasys.teku.spec.datastructures.operations.versions.bellatrix.BeaconPreparableProposer; -import tech.pegasys.teku.spec.executionengine.ForkChoiceState; -import tech.pegasys.teku.spec.executionengine.ForkChoiceUpdatedResult; +import tech.pegasys.teku.spec.executionlayer.ForkChoiceState; +import tech.pegasys.teku.spec.executionlayer.ForkChoiceUpdatedResult; import tech.pegasys.teku.statetransition.forkchoice.ForkChoiceUpdatedResultSubscriber.ForkChoiceUpdatedResultNotification; public class StubForkChoiceNotifier implements ForkChoiceNotifier { diff --git a/fork-choice-tests/src/integration-test/java/tech/pegasys/teku/forkChoiceTests/ForkChoiceIntegrationTest.java b/fork-choice-tests/src/integration-test/java/tech/pegasys/teku/forkChoiceTests/ForkChoiceIntegrationTest.java index 86701a1077c..07a8de40432 100644 --- a/fork-choice-tests/src/integration-test/java/tech/pegasys/teku/forkChoiceTests/ForkChoiceIntegrationTest.java +++ b/fork-choice-tests/src/integration-test/java/tech/pegasys/teku/forkChoiceTests/ForkChoiceIntegrationTest.java @@ -47,8 +47,8 @@ import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState; import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconStateSchema; import tech.pegasys.teku.spec.datastructures.util.AttestationProcessingResult; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannelStub; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannelStub; import tech.pegasys.teku.spec.logic.common.statetransition.results.BlockImportResult; import tech.pegasys.teku.spec.schemas.SchemaDefinitions; import tech.pegasys.teku.statetransition.forkchoice.ForkChoice; @@ -177,7 +177,7 @@ void runForkChoiceTests( final InlineEventThread forkChoiceExecutor = new InlineEventThread(); final MergeTransitionBlockValidator transitionBlockValidator = - new MergeTransitionBlockValidator(SPEC, storageClient, ExecutionEngineChannel.NOOP); + new MergeTransitionBlockValidator(SPEC, storageClient, ExecutionLayerChannel.NOOP); ForkChoice forkChoice = new ForkChoice( SPEC, @@ -280,7 +280,7 @@ private boolean processAttestation(ForkChoice fc, Attestation step) { private boolean processBlock(ForkChoice fc, SignedBeaconBlock block) { BlockImportResult blockImportResult = - fc.onBlock(block, Optional.empty(), new ExecutionEngineChannelStub(SPEC, false)).join(); + fc.onBlock(block, Optional.empty(), new ExecutionLayerChannelStub(SPEC, false)).join(); return blockImportResult.isSuccessful(); } diff --git a/infrastructure/logging/src/main/java/tech/pegasys/teku/infrastructure/logging/EventLogger.java b/infrastructure/logging/src/main/java/tech/pegasys/teku/infrastructure/logging/EventLogger.java index 88c08285bea..3128368295f 100644 --- a/infrastructure/logging/src/main/java/tech/pegasys/teku/infrastructure/logging/EventLogger.java +++ b/infrastructure/logging/src/main/java/tech/pegasys/teku/infrastructure/logging/EventLogger.java @@ -237,9 +237,9 @@ public void lateBlockImport( warn(reorgEventLog, Color.YELLOW); } - public void executionEngineStubEnabled() { + public void executionLayerStubEnabled() { info( - "Execution Engine Stub has been enabled. Please make sure this is intentional.", + "Execution Layer Stub has been enabled. Please make sure this is intentional.", Color.YELLOW); } diff --git a/services/beaconchain/src/main/java/tech/pegasys/teku/services/beaconchain/BeaconChainController.java b/services/beaconchain/src/main/java/tech/pegasys/teku/services/beaconchain/BeaconChainController.java index 3f082473f68..c6f3c5a6a0c 100644 --- a/services/beaconchain/src/main/java/tech/pegasys/teku/services/beaconchain/BeaconChainController.java +++ b/services/beaconchain/src/main/java/tech/pegasys/teku/services/beaconchain/BeaconChainController.java @@ -78,7 +78,7 @@ import tech.pegasys.teku.spec.datastructures.operations.SignedVoluntaryExit; import tech.pegasys.teku.spec.datastructures.state.AnchorPoint; import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel; import tech.pegasys.teku.statetransition.EpochCachePrimer; import tech.pegasys.teku.statetransition.LocalOperationAcceptedFilter; import tech.pegasys.teku.statetransition.OperationPool; @@ -200,7 +200,7 @@ public class BeaconChainController extends Service implements BeaconChainControl protected volatile ActiveValidatorTracker activeValidatorTracker; protected volatile AttestationTopicSubscriber attestationTopicSubscriber; protected volatile ForkChoiceNotifier forkChoiceNotifier; - protected volatile ExecutionEngineChannel executionEngine; + protected volatile ExecutionLayerChannel executionLayer; protected volatile Optional terminalPowBlockMonitor = Optional.empty(); protected volatile Optional mergeTransitionConfigCheck = Optional.empty(); @@ -379,7 +379,7 @@ public void initAll() { } protected void initExecutionEngine() { - executionEngine = eventChannels.getPublisher(ExecutionEngineChannel.class, beaconAsyncRunner); + executionLayer = eventChannels.getPublisher(ExecutionLayerChannel.class, beaconAsyncRunner); } protected void initMergeMonitors() { @@ -387,7 +387,7 @@ protected void initMergeMonitors() { terminalPowBlockMonitor = Optional.of( new TerminalPowBlockMonitor( - executionEngine, + executionLayer, spec, recentChainData, forkChoiceNotifier, @@ -397,7 +397,7 @@ protected void initMergeMonitors() { mergeTransitionConfigCheck = Optional.of( - new MergeTransitionConfigCheck(EVENT_LOG, spec, executionEngine, beaconAsyncRunner)); + new MergeTransitionConfigCheck(EVENT_LOG, spec, executionLayer, beaconAsyncRunner)); } } @@ -493,7 +493,7 @@ protected void initForkChoice() { forkChoiceExecutor, recentChainData, forkChoiceNotifier, - new MergeTransitionBlockValidator(spec, recentChainData, executionEngine), + new MergeTransitionBlockValidator(spec, recentChainData, executionLayer), proposerBoostEnabled); forkChoiceTrigger = new ForkChoiceTrigger(forkChoice); } @@ -560,7 +560,7 @@ public void initValidatorApiHandler() { eth1DataCache, VersionProvider.getDefaultGraffiti(), forkChoiceNotifier, - executionEngine, + executionLayer, beaconConfig.validatorConfig().isProposerMevBoostEnabled())); SyncCommitteeSubscriptionManager syncCommitteeSubscriptionManager = beaconConfig.p2pConfig().isSubscribeAllSubnetsEnabled() @@ -837,7 +837,7 @@ public void initBlockImporter() { recentChainData, forkChoice, weakSubjectivityValidator, - executionEngine); + executionLayer); } public void initBlockManager() { @@ -940,7 +940,7 @@ protected void initForkChoiceNotifier() { ForkChoiceNotifierImpl.create( asyncRunnerFactory, spec, - executionEngine, + executionLayer, recentChainData, getProposerDefaultFeeRecipient()); } diff --git a/services/executionengine/src/main/java/tech/pegasys/teku/services/executionengine/ExecutionEngineConfiguration.java b/services/executionengine/src/main/java/tech/pegasys/teku/services/executionengine/ExecutionEngineConfiguration.java deleted file mode 100644 index b051878a28c..00000000000 --- a/services/executionengine/src/main/java/tech/pegasys/teku/services/executionengine/ExecutionEngineConfiguration.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright 2021 ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.services.executionengine; - -import java.net.URL; -import java.util.List; -import java.util.Optional; -import org.apache.commons.lang3.StringUtils; -import tech.pegasys.teku.infrastructure.exceptions.InvalidConfigurationException; -import tech.pegasys.teku.spec.Spec; -import tech.pegasys.teku.spec.SpecMilestone; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel.Version; - -public class ExecutionEngineConfiguration { - - private final Spec spec; - private final Optional endpoint; - private final Version version; - private final Optional jwtSecretFile; - private final List mevBoostUrls; - - private ExecutionEngineConfiguration( - final Spec spec, - final Optional endpoint, - final Version version, - final Optional jwtSecretFile, - final List mevBoostUrls) { - this.spec = spec; - this.endpoint = endpoint; - this.version = version; - this.jwtSecretFile = jwtSecretFile; - this.mevBoostUrls = mevBoostUrls; - } - - public static Builder builder() { - return new Builder(); - } - - public boolean isEnabled() { - return spec.isMilestoneSupported(SpecMilestone.BELLATRIX); - } - - public Spec getSpec() { - return spec; - } - - public String getEndpoint() { - return endpoint.orElseThrow( - () -> - new InvalidConfigurationException( - "Invalid configuration. --ee-endpoint parameter is mandatory when Bellatrix milestone is enabled")); - } - - public Optional getJwtSecretFile() { - return jwtSecretFile; - } - - public Version getVersion() { - return version; - } - - public List getMevBoostUrls() { - return mevBoostUrls; - } - - public static class Builder { - private Spec spec; - private Optional endpoint = Optional.empty(); - private Version version = Version.DEFAULT_VERSION; - private Optional jwtSecretFile = Optional.empty(); - private List mevBoostUrls = List.of(); - - private Builder() {} - - public ExecutionEngineConfiguration build() { - - return new ExecutionEngineConfiguration(spec, endpoint, version, jwtSecretFile, mevBoostUrls); - } - - public Builder endpoint(final String endpoint) { - this.endpoint = Optional.ofNullable(endpoint); - return this; - } - - public Builder version(final Version version) { - this.version = version; - return this; - } - - public Builder specProvider(final Spec spec) { - this.spec = spec; - return this; - } - - public Builder jwtSecretFile(final String jwtSecretFile) { - this.jwtSecretFile = Optional.ofNullable(jwtSecretFile).filter(StringUtils::isNotBlank); - return this; - } - - public Builder mevBoostUrls(final List mevBoostUrls) { - this.mevBoostUrls = mevBoostUrls; - return this; - } - } -} diff --git a/services/executionengine/src/main/java/tech/pegasys/teku/services/executionengine/ExecutionEngineService.java b/services/executionengine/src/main/java/tech/pegasys/teku/services/executionengine/ExecutionEngineService.java deleted file mode 100644 index 15c697b2fec..00000000000 --- a/services/executionengine/src/main/java/tech/pegasys/teku/services/executionengine/ExecutionEngineService.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2021 ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.services.executionengine; - -import static tech.pegasys.teku.infrastructure.logging.EventLogger.EVENT_LOG; -import static tech.pegasys.teku.spec.config.Constants.EXECUTION_TIMEOUT; -import static tech.pegasys.teku.spec.config.Constants.MAXIMUM_CONCURRENT_EE_REQUESTS; - -import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.hyperledger.besu.plugin.services.MetricsSystem; -import tech.pegasys.teku.ethereum.executionengine.ExecutionClientProvider; -import tech.pegasys.teku.ethereum.executionlayer.ExecutionEngineChannelImpl; -import tech.pegasys.teku.ethereum.executionlayer.ThrottlingExecutionEngineChannel; -import tech.pegasys.teku.infrastructure.async.SafeFuture; -import tech.pegasys.teku.infrastructure.events.EventChannels; -import tech.pegasys.teku.infrastructure.time.TimeProvider; -import tech.pegasys.teku.service.serviceutils.Service; -import tech.pegasys.teku.service.serviceutils.ServiceConfig; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannelStub; - -public class ExecutionEngineService extends Service { - - private static final Logger LOG = LogManager.getLogger(); - - private final EventChannels eventChannels; - private final ExecutionEngineConfiguration config; - private final MetricsSystem metricsSystem; - private final ExecutionClientProvider web3jClientProvider; - private final TimeProvider timeProvider; - - public ExecutionEngineService( - final ServiceConfig serviceConfig, final ExecutionEngineConfiguration config) { - this.eventChannels = serviceConfig.getEventChannels(); - this.metricsSystem = serviceConfig.getMetricsSystem(); - this.config = config; - this.web3jClientProvider = - ExecutionClientProvider.create( - config.getEndpoint(), - serviceConfig.getTimeProvider(), - EXECUTION_TIMEOUT, - config.getJwtSecretFile(), - serviceConfig.getDataDirLayout().getBeaconDataDirectory()); - this.timeProvider = serviceConfig.getTimeProvider(); - } - - @Override - protected SafeFuture doStart() { - final String endpoint = web3jClientProvider.getEndpoint(); - LOG.info("Using execution engine at {}", endpoint); - final ExecutionEngineChannel executionEngineChannel; - if (web3jClientProvider.isStub()) { - EVENT_LOG.executionEngineStubEnabled(); - executionEngineChannel = new ExecutionEngineChannelStub(config.getSpec(), timeProvider, true); - } else { - executionEngineChannel = - ExecutionEngineChannelImpl.create( - web3jClientProvider.getWeb3JClient(), config.getVersion(), config.getSpec()); - } - final ExecutionEngineChannel executionEngine = - new ThrottlingExecutionEngineChannel( - executionEngineChannel, MAXIMUM_CONCURRENT_EE_REQUESTS, metricsSystem); - eventChannels.subscribe(ExecutionEngineChannel.class, executionEngine); - return SafeFuture.COMPLETE; - } - - @Override - protected SafeFuture doStop() { - return SafeFuture.COMPLETE; - } - - public Optional getWeb3jClientProvider() { - return web3jClientProvider.isStub() ? Optional.empty() : Optional.of(web3jClientProvider); - } -} diff --git a/services/executionengine/src/main/java/tech/pegasys/teku/services/executionlayer/ExecutionLayerConfiguration.java b/services/executionengine/src/main/java/tech/pegasys/teku/services/executionlayer/ExecutionLayerConfiguration.java new file mode 100644 index 00000000000..0374b4a43c8 --- /dev/null +++ b/services/executionengine/src/main/java/tech/pegasys/teku/services/executionlayer/ExecutionLayerConfiguration.java @@ -0,0 +1,115 @@ +/* + * Copyright 2021 ConsenSys AG. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package tech.pegasys.teku.services.executionlayer; + +import java.util.Optional; +import org.apache.commons.lang3.StringUtils; +import tech.pegasys.teku.infrastructure.exceptions.InvalidConfigurationException; +import tech.pegasys.teku.spec.Spec; +import tech.pegasys.teku.spec.SpecMilestone; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel.Version; + +public class ExecutionLayerConfiguration { + + private final Spec spec; + private final Optional engineEndpoint; + private final Version engineVersion; + private final Optional engineJwtSecretFile; + private final Optional builderEndpoint; + + private ExecutionLayerConfiguration( + final Spec spec, + final Optional engineEndpoint, + final Version engineVersion, + final Optional engineJwtSecretFile, + final Optional builderEndpoint) { + this.spec = spec; + this.engineEndpoint = engineEndpoint; + this.engineVersion = engineVersion; + this.engineJwtSecretFile = engineJwtSecretFile; + this.builderEndpoint = builderEndpoint; + } + + public static Builder builder() { + return new Builder(); + } + + public boolean isEnabled() { + return spec.isMilestoneSupported(SpecMilestone.BELLATRIX); + } + + public Spec getSpec() { + return spec; + } + + public String getEngineEndpoint() { + return engineEndpoint.orElseThrow( + () -> + new InvalidConfigurationException( + "Invalid configuration. --ee-endpoint parameter is mandatory when Bellatrix milestone is enabled")); + } + + public Optional getEngineJwtSecretFile() { + return engineJwtSecretFile; + } + + public Version getEngineVersion() { + return engineVersion; + } + + public Optional getBuilderEndpoint() { + return builderEndpoint; + } + + public static class Builder { + private Spec spec; + private Optional engineEndpoint = Optional.empty(); + private Version engineVersion = Version.DEFAULT_VERSION; + private Optional engineJwtSecretFile = Optional.empty(); + private Optional builderEndpoint = Optional.empty(); + + private Builder() {} + + public ExecutionLayerConfiguration build() { + + return new ExecutionLayerConfiguration( + spec, engineEndpoint, engineVersion, engineJwtSecretFile, builderEndpoint); + } + + public Builder engineEndpoint(final String engineEndpoint) { + this.engineEndpoint = Optional.ofNullable(engineEndpoint); + return this; + } + + public Builder engineVersion(final Version version) { + this.engineVersion = version; + return this; + } + + public Builder specProvider(final Spec spec) { + this.spec = spec; + return this; + } + + public Builder engineJwtSecretFile(final String jwtSecretFile) { + this.engineJwtSecretFile = Optional.ofNullable(jwtSecretFile).filter(StringUtils::isNotBlank); + return this; + } + + public Builder builderEndpoint(final String builderEndpoint) { + this.builderEndpoint = Optional.ofNullable(builderEndpoint); + return this; + } + } +} diff --git a/services/executionengine/src/main/java/tech/pegasys/teku/services/executionlayer/ExecutionLayerService.java b/services/executionengine/src/main/java/tech/pegasys/teku/services/executionlayer/ExecutionLayerService.java new file mode 100644 index 00000000000..05c2fd307d8 --- /dev/null +++ b/services/executionengine/src/main/java/tech/pegasys/teku/services/executionlayer/ExecutionLayerService.java @@ -0,0 +1,139 @@ +/* + * Copyright 2021 ConsenSys AG. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package tech.pegasys.teku.services.executionlayer; + +import static com.google.common.base.Preconditions.checkState; +import static tech.pegasys.teku.infrastructure.logging.EventLogger.EVENT_LOG; +import static tech.pegasys.teku.spec.config.Constants.EXECUTION_TIMEOUT; + +import java.util.Optional; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.hyperledger.besu.plugin.services.MetricsSystem; +import tech.pegasys.teku.ethereum.executionengine.ExecutionClientProvider; +import tech.pegasys.teku.ethereum.executionlayer.ExecutionLayerChannelImpl; +import tech.pegasys.teku.infrastructure.async.AsyncRunner; +import tech.pegasys.teku.infrastructure.async.SafeFuture; +import tech.pegasys.teku.infrastructure.async.timed.RepeatingTaskScheduler; +import tech.pegasys.teku.infrastructure.events.EventChannels; +import tech.pegasys.teku.infrastructure.time.TimeProvider; +import tech.pegasys.teku.infrastructure.unsigned.UInt64; +import tech.pegasys.teku.service.serviceutils.Service; +import tech.pegasys.teku.service.serviceutils.ServiceConfig; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannelStub; + +public class ExecutionLayerService extends Service { + + private static final Logger LOG = LogManager.getLogger(); + + private final EventChannels eventChannels; + private final ExecutionClientProvider engineWeb3jClientProvider; + private final Optional builderWeb3jClientProvider; + private final TimeProvider timeProvider; + private final ExecutionLayerChannel executionLayerChannel; + private final AsyncRunner asyncRunner; + + public ExecutionLayerService( + final ServiceConfig serviceConfig, final ExecutionLayerConfiguration config) { + this.eventChannels = serviceConfig.getEventChannels(); + this.engineWeb3jClientProvider = + ExecutionClientProvider.create( + config.getEngineEndpoint(), + serviceConfig.getTimeProvider(), + EXECUTION_TIMEOUT, + config.getEngineJwtSecretFile(), + serviceConfig.getDataDirLayout().getBeaconDataDirectory()); + + this.builderWeb3jClientProvider = + config + .getBuilderEndpoint() + .map( + builderEndpoint -> + ExecutionClientProvider.create( + builderEndpoint, + serviceConfig.getTimeProvider(), + EXECUTION_TIMEOUT, + Optional.empty(), + serviceConfig.getDataDirLayout().getBeaconDataDirectory())); + + final boolean builderIsStub = + builderWeb3jClientProvider.map(ExecutionClientProvider::isStub).orElse(false); + + checkState( + engineWeb3jClientProvider.isStub() == builderIsStub, + "mixed configuration with stubbed and non-stubbed execution layer endpoints is not supported"); + + this.timeProvider = serviceConfig.getTimeProvider(); + this.asyncRunner = serviceConfig.createAsyncRunner("execution-layer"); + + final String endpoint = engineWeb3jClientProvider.getEndpoint(); + LOG.info("Using execution engine at {}", endpoint); + if (engineWeb3jClientProvider.isStub()) { + EVENT_LOG.executionLayerStubEnabled(); + this.executionLayerChannel = + new ExecutionLayerChannelStub(config.getSpec(), timeProvider, true); + } else { + final MetricsSystem metricsSystem = serviceConfig.getMetricsSystem(); + this.executionLayerChannel = + ExecutionLayerChannelImpl.create( + engineWeb3jClientProvider.getWeb3JClient(), + builderWeb3jClientProvider.map(ExecutionClientProvider::getWeb3JClient), + config.getEngineVersion(), + config.getSpec(), + metricsSystem); + } + } + + @Override + protected SafeFuture doStart() { + eventChannels.subscribe(ExecutionLayerChannel.class, executionLayerChannel); + final RepeatingTaskScheduler taskScheduler = + new RepeatingTaskScheduler(asyncRunner, timeProvider); + taskScheduler.scheduleRepeatingEvent( + timeProvider.getTimeInSeconds(), + UInt64.valueOf(30), + (scheduledTime, actualTime) -> performBuilderHealthCheck()); + return SafeFuture.COMPLETE; + } + + @Override + protected SafeFuture doStop() { + asyncRunner.shutdown(); + return SafeFuture.COMPLETE; + } + + public Optional getEngineWeb3jClientProvider() { + return engineWeb3jClientProvider.isStub() + ? Optional.empty() + : Optional.of(engineWeb3jClientProvider); + } + + private void performBuilderHealthCheck() { + if (builderWeb3jClientProvider.isEmpty()) { + return; + } + executionLayerChannel + .builderStatus() + .finish( + status -> { + if (status.hasFailed()) { + LOG.error( + "The execution builder has failed health check: {}", status.getErrorMessage()); + } + }, + throwable -> + LOG.error("Error while performing the execution builder health check", throwable)); + } +} diff --git a/services/executionengine/src/test/java/tech/pegasys/teku/services/executionengine/ExecutionEngineConfigurationTest.java b/services/executionengine/src/test/java/tech/pegasys/teku/services/executionlayer/ExecutionLayerConfigurationTest.java similarity index 68% rename from services/executionengine/src/test/java/tech/pegasys/teku/services/executionengine/ExecutionEngineConfigurationTest.java rename to services/executionengine/src/test/java/tech/pegasys/teku/services/executionlayer/ExecutionLayerConfigurationTest.java index 456c0252b2d..6244b4815ec 100644 --- a/services/executionengine/src/test/java/tech/pegasys/teku/services/executionengine/ExecutionEngineConfigurationTest.java +++ b/services/executionengine/src/test/java/tech/pegasys/teku/services/executionlayer/ExecutionLayerConfigurationTest.java @@ -11,7 +11,7 @@ * specific language governing permissions and limitations under the License. */ -package tech.pegasys.teku.services.executionengine; +package tech.pegasys.teku.services.executionlayer; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; @@ -19,26 +19,26 @@ import tech.pegasys.teku.spec.Spec; import tech.pegasys.teku.spec.TestSpecFactory; -public class ExecutionEngineConfigurationTest { - private final ExecutionEngineConfiguration.Builder configBuilder = - ExecutionEngineConfiguration.builder(); +public class ExecutionLayerConfigurationTest { + private final ExecutionLayerConfiguration.Builder configBuilder = + ExecutionLayerConfiguration.builder(); private final Spec bellatrixSpec = TestSpecFactory.createMinimalBellatrix(); @Test public void shouldThrowExceptionIfNoEeEndpointSpecified() { - final ExecutionEngineConfiguration config = configBuilder.specProvider(bellatrixSpec).build(); + final ExecutionLayerConfiguration config = configBuilder.specProvider(bellatrixSpec).build(); Assertions.assertThatExceptionOfType(InvalidConfigurationException.class) - .isThrownBy(config::getEndpoint) + .isThrownBy(config::getEngineEndpoint) .withMessageContaining( "Invalid configuration. --ee-endpoint parameter is mandatory when Bellatrix milestone is enabled"); } @Test public void noExceptionThrownIfEeEndpointSpecified() { - final ExecutionEngineConfiguration config = - configBuilder.specProvider(bellatrixSpec).endpoint("someEndpoint").build(); + final ExecutionLayerConfiguration config = + configBuilder.specProvider(bellatrixSpec).engineEndpoint("someEndpoint").build(); - Assertions.assertThatCode(config::getEndpoint).doesNotThrowAnyException(); + Assertions.assertThatCode(config::getEngineEndpoint).doesNotThrowAnyException(); } } diff --git a/storage/src/main/java/tech/pegasys/teku/storage/protoarray/ForkChoiceStrategy.java b/storage/src/main/java/tech/pegasys/teku/storage/protoarray/ForkChoiceStrategy.java index bacb93b9008..631a671efee 100644 --- a/storage/src/main/java/tech/pegasys/teku/storage/protoarray/ForkChoiceStrategy.java +++ b/storage/src/main/java/tech/pegasys/teku/storage/protoarray/ForkChoiceStrategy.java @@ -39,9 +39,9 @@ import tech.pegasys.teku.spec.datastructures.forkchoice.VoteUpdater; import tech.pegasys.teku.spec.datastructures.operations.IndexedAttestation; import tech.pegasys.teku.spec.datastructures.state.Checkpoint; -import tech.pegasys.teku.spec.executionengine.ExecutionPayloadStatus; -import tech.pegasys.teku.spec.executionengine.ForkChoiceState; -import tech.pegasys.teku.spec.executionengine.PayloadStatus; +import tech.pegasys.teku.spec.executionlayer.ExecutionPayloadStatus; +import tech.pegasys.teku.spec.executionlayer.ForkChoiceState; +import tech.pegasys.teku.spec.executionlayer.PayloadStatus; public class ForkChoiceStrategy implements BlockMetadataStore, ReadOnlyForkChoiceStrategy { private static final Logger LOG = LogManager.getLogger(); diff --git a/storage/src/test/java/tech/pegasys/teku/storage/protoarray/ForkChoiceStrategyTest.java b/storage/src/test/java/tech/pegasys/teku/storage/protoarray/ForkChoiceStrategyTest.java index e002014ecb2..173910f0f64 100644 --- a/storage/src/test/java/tech/pegasys/teku/storage/protoarray/ForkChoiceStrategyTest.java +++ b/storage/src/test/java/tech/pegasys/teku/storage/protoarray/ForkChoiceStrategyTest.java @@ -46,7 +46,7 @@ import tech.pegasys.teku.spec.datastructures.state.AnchorPoint; import tech.pegasys.teku.spec.datastructures.state.Checkpoint; import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState; -import tech.pegasys.teku.spec.executionengine.PayloadStatus; +import tech.pegasys.teku.spec.executionlayer.PayloadStatus; import tech.pegasys.teku.spec.util.DataStructureUtil; import tech.pegasys.teku.storage.storageSystem.InMemoryStorageSystemBuilder; import tech.pegasys.teku.storage.storageSystem.StorageSystem; diff --git a/storage/src/test/java/tech/pegasys/teku/storage/server/AbstractDatabaseTest.java b/storage/src/test/java/tech/pegasys/teku/storage/server/AbstractDatabaseTest.java index 32d1bb3144d..6795728d248 100644 --- a/storage/src/test/java/tech/pegasys/teku/storage/server/AbstractDatabaseTest.java +++ b/storage/src/test/java/tech/pegasys/teku/storage/server/AbstractDatabaseTest.java @@ -58,7 +58,7 @@ import tech.pegasys.teku.spec.datastructures.state.AnchorPoint; import tech.pegasys.teku.spec.datastructures.state.Checkpoint; import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState; -import tech.pegasys.teku.spec.executionengine.PayloadStatus; +import tech.pegasys.teku.spec.executionlayer.PayloadStatus; import tech.pegasys.teku.spec.util.DataStructureUtil; import tech.pegasys.teku.storage.api.WeakSubjectivityUpdate; import tech.pegasys.teku.storage.client.RecentChainData; diff --git a/storage/src/testFixtures/java/tech/pegasys/teku/storage/client/ChainUpdater.java b/storage/src/testFixtures/java/tech/pegasys/teku/storage/client/ChainUpdater.java index 241bcb71c11..d2e0e0e215f 100644 --- a/storage/src/testFixtures/java/tech/pegasys/teku/storage/client/ChainUpdater.java +++ b/storage/src/testFixtures/java/tech/pegasys/teku/storage/client/ChainUpdater.java @@ -29,7 +29,7 @@ import tech.pegasys.teku.spec.datastructures.blocks.SignedBlockAndState; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeader; import tech.pegasys.teku.spec.datastructures.state.Checkpoint; -import tech.pegasys.teku.spec.executionengine.PayloadStatus; +import tech.pegasys.teku.spec.executionlayer.PayloadStatus; import tech.pegasys.teku.spec.schemas.SchemaDefinitionsBellatrix; import tech.pegasys.teku.storage.store.UpdatableStore.StoreTransaction; diff --git a/teku/src/main/java/tech/pegasys/teku/cli/BeaconNodeCommand.java b/teku/src/main/java/tech/pegasys/teku/cli/BeaconNodeCommand.java index 3c074c522ec..f4ef589c090 100644 --- a/teku/src/main/java/tech/pegasys/teku/cli/BeaconNodeCommand.java +++ b/teku/src/main/java/tech/pegasys/teku/cli/BeaconNodeCommand.java @@ -38,7 +38,7 @@ import tech.pegasys.teku.cli.options.DataStorageOptions; import tech.pegasys.teku.cli.options.DepositOptions; import tech.pegasys.teku.cli.options.Eth2NetworkOptions; -import tech.pegasys.teku.cli.options.ExecutionEngineOptions; +import tech.pegasys.teku.cli.options.ExecutionLayerOptions; import tech.pegasys.teku.cli.options.InteropOptions; import tech.pegasys.teku.cli.options.LoggingOptions; import tech.pegasys.teku.cli.options.MetricsOptions; @@ -149,8 +149,8 @@ private static class ConfigFileCommand { @Mixin(name = "Deposit") private DepositOptions depositOptions; - @Mixin(name = "Execution Engine") - private ExecutionEngineOptions executionEngineOptions; + @Mixin(name = "Execution Layer") + private ExecutionLayerOptions executionLayerOptions; @Mixin(name = "Logging") private final LoggingOptions loggingOptions = new LoggingOptions(); @@ -354,7 +354,7 @@ protected TekuConfiguration tekuConfiguration() { // Eth2NetworkOptions configures network defaults across builders, so configure this first eth2NetworkOptions.configure(builder); depositOptions.configure(builder); - executionEngineOptions.configure(builder); + executionLayerOptions.configure(builder); weakSubjectivityOptions.configure(builder); validatorOptions.configure(builder); dataOptions.configure(builder); diff --git a/teku/src/main/java/tech/pegasys/teku/cli/options/ExecutionEngineOptions.java b/teku/src/main/java/tech/pegasys/teku/cli/options/ExecutionLayerOptions.java similarity index 54% rename from teku/src/main/java/tech/pegasys/teku/cli/options/ExecutionEngineOptions.java rename to teku/src/main/java/tech/pegasys/teku/cli/options/ExecutionLayerOptions.java index 6149f01c64c..30e27076956 100644 --- a/teku/src/main/java/tech/pegasys/teku/cli/options/ExecutionEngineOptions.java +++ b/teku/src/main/java/tech/pegasys/teku/cli/options/ExecutionLayerOptions.java @@ -15,15 +15,10 @@ import static tech.pegasys.teku.config.TekuConfiguration.Builder; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; import picocli.CommandLine.Option; -import tech.pegasys.teku.infrastructure.exceptions.InvalidConfigurationException; -import tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel.Version; +import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel.Version; -public class ExecutionEngineOptions { +public class ExecutionLayerOptions { @Option( names = {"--ee-endpoint"}, @@ -40,46 +35,28 @@ public class ExecutionEngineOptions { hidden = true) private Version executionEngineVersion = Version.DEFAULT_VERSION; - @Option( - names = {"--Xee-payload-builders"}, - paramLabel = "", - description = "List of MEV boost api compatible endpoints to get execution payloads", - arity = "1..*", - split = ",", - hidden = true) - private List mevUrls = new ArrayList<>(); - @Option( names = {"--ee-jwt-secret-file"}, paramLabel = "", description = "Location of the file specifying the hex-encoded 256 bit secret key to be used for verifying/generating jwt tokens", arity = "1") - private String jwtSecretFile = null; + private String engineJwtSecretFile = null; + + @Option( + names = {"--Xeb-endpoint"}, + paramLabel = "", + description = "URL for Execution Builder node.", + arity = "1", + hidden = true) + private String executionBuilderEndpoint = null; public void configure(final Builder builder) { - builder.executionEngine( + builder.executionLayer( b -> - b.endpoint(executionEngineEndpoint) - .version(executionEngineVersion) - .jwtSecretFile(jwtSecretFile) - .mevBoostUrls(parseMevBoostUrls())); - } - - private List parseMevBoostUrls() { - if (mevUrls.isEmpty()) { - return List.of(); - } - - try { - final List result = new ArrayList<>(); - for (String mevUrl : mevUrls) { - result.add(new URL(mevUrl)); - } - return result; - } catch (MalformedURLException e) { - throw new InvalidConfigurationException( - "Invalid configuration. MEV boost URL did not appear to be a valid URL.", e); - } + b.engineEndpoint(executionEngineEndpoint) + .engineVersion(executionEngineVersion) + .engineJwtSecretFile(engineJwtSecretFile) + .builderEndpoint(executionBuilderEndpoint)); } } diff --git a/teku/src/main/java/tech/pegasys/teku/config/TekuConfiguration.java b/teku/src/main/java/tech/pegasys/teku/config/TekuConfiguration.java index 57de6539732..90a8537e85a 100644 --- a/teku/src/main/java/tech/pegasys/teku/config/TekuConfiguration.java +++ b/teku/src/main/java/tech/pegasys/teku/config/TekuConfiguration.java @@ -30,7 +30,7 @@ import tech.pegasys.teku.services.beaconchain.BeaconChainConfiguration; import tech.pegasys.teku.services.beaconchain.BeaconChainControllerFactory; import tech.pegasys.teku.services.chainstorage.StorageConfiguration; -import tech.pegasys.teku.services.executionengine.ExecutionEngineConfiguration; +import tech.pegasys.teku.services.executionlayer.ExecutionLayerConfiguration; import tech.pegasys.teku.services.powchain.PowchainConfiguration; import tech.pegasys.teku.spec.Spec; import tech.pegasys.teku.spec.datastructures.eth1.Eth1Address; @@ -51,7 +51,7 @@ public class TekuConfiguration { private final BeaconChainConfiguration beaconChainConfig; private final ValidatorClientConfiguration validatorClientConfig; private final PowchainConfiguration powchainConfiguration; - private final ExecutionEngineConfiguration executionEngineConfiguration; + private final ExecutionLayerConfiguration executionLayerConfiguration; private final NatConfiguration natConfiguration; private final ValidatorRestApiConfig validatorRestApiConfig; @@ -62,7 +62,7 @@ private TekuConfiguration( final WeakSubjectivityConfig weakSubjectivityConfig, final ValidatorConfig validatorConfig, final PowchainConfiguration powchainConfiguration, - final ExecutionEngineConfiguration executionEngineConfiguration, + final ExecutionLayerConfiguration executionLayerConfiguration, final InteropConfig interopConfig, final DataConfig dataConfig, final P2PConfig p2PConfig, @@ -77,7 +77,7 @@ private TekuConfiguration( this.storageConfiguration = storageConfiguration; this.weakSubjectivityConfig = weakSubjectivityConfig; this.powchainConfiguration = powchainConfiguration; - this.executionEngineConfiguration = executionEngineConfiguration; + this.executionLayerConfiguration = executionLayerConfiguration; this.dataConfig = dataConfig; this.metricsConfig = metricsConfig; this.beaconChainConfig = @@ -145,8 +145,8 @@ public PowchainConfiguration powchain() { return powchainConfiguration; } - public ExecutionEngineConfiguration executionEngine() { - return executionEngineConfiguration; + public ExecutionLayerConfiguration executionLayer() { + return executionLayerConfiguration; } public DataConfig dataConfig() { @@ -175,8 +175,8 @@ public static class Builder { private final ValidatorConfig.Builder validatorConfigBuilder = ValidatorConfig.builder(); private final PowchainConfiguration.Builder powchainConfigBuilder = PowchainConfiguration.builder(); - private final ExecutionEngineConfiguration.Builder executionEngineConfigBuilder = - ExecutionEngineConfiguration.builder(); + private final ExecutionLayerConfiguration.Builder executionLayerConfigBuilder = + ExecutionLayerConfiguration.builder(); private final InteropConfig.InteropConfigBuilder interopConfigBuilder = InteropConfig.builder(); private final DataConfig.Builder dataConfigBuilder = DataConfig.builder(); private final P2PConfig.Builder p2pConfigBuilder = P2PConfig.builder(); @@ -206,7 +206,7 @@ public TekuConfiguration build() { weakSubjectivityBuilder.specProvider(spec); p2pConfigBuilder.specProvider(spec); powchainConfigBuilder.specProvider(spec); - executionEngineConfigBuilder.specProvider(spec); + executionLayerConfigBuilder.specProvider(spec); Eth1Address depositContractAddress = eth2NetworkConfiguration.getEth1DepositContractAddress(); Optional depositContractDeployBlock = @@ -231,7 +231,7 @@ public TekuConfiguration build() { weakSubjectivityBuilder.build(), validatorConfig, powchainConfigBuilder.build(), - executionEngineConfigBuilder.build(), + executionLayerConfigBuilder.build(), interopConfigBuilder.build(), dataConfig, p2PConfig, @@ -275,8 +275,8 @@ public Builder powchain(final Consumer consumer) return this; } - public Builder executionEngine(final Consumer consumer) { - consumer.accept(executionEngineConfigBuilder); + public Builder executionLayer(final Consumer consumer) { + consumer.accept(executionLayerConfigBuilder); return this; } diff --git a/teku/src/main/java/tech/pegasys/teku/services/BeaconNodeServiceController.java b/teku/src/main/java/tech/pegasys/teku/services/BeaconNodeServiceController.java index d1c90d0efcb..8ce3905c8e3 100644 --- a/teku/src/main/java/tech/pegasys/teku/services/BeaconNodeServiceController.java +++ b/teku/src/main/java/tech/pegasys/teku/services/BeaconNodeServiceController.java @@ -20,7 +20,7 @@ import tech.pegasys.teku.service.serviceutils.ServiceConfig; import tech.pegasys.teku.services.beaconchain.BeaconChainService; import tech.pegasys.teku.services.chainstorage.StorageService; -import tech.pegasys.teku.services.executionengine.ExecutionEngineService; +import tech.pegasys.teku.services.executionlayer.ExecutionLayerService; import tech.pegasys.teku.services.powchain.PowchainService; import tech.pegasys.teku.validator.client.ValidatorClientService; @@ -31,12 +31,12 @@ public BeaconNodeServiceController( // Note services will be started in the order they are added here. services.add(new StorageService(serviceConfig, tekuConfig.storageConfiguration())); Optional maybeExecutionClientProvider = Optional.empty(); - if (tekuConfig.executionEngine().isEnabled()) { + if (tekuConfig.executionLayer().isEnabled()) { // Need to make sure the execution engine is listening before starting the beacon chain - ExecutionEngineService executionEngineService = - new ExecutionEngineService(serviceConfig, tekuConfig.executionEngine()); - services.add(executionEngineService); - maybeExecutionClientProvider = executionEngineService.getWeb3jClientProvider(); + ExecutionLayerService executionLayerService = + new ExecutionLayerService(serviceConfig, tekuConfig.executionLayer()); + services.add(executionLayerService); + maybeExecutionClientProvider = executionLayerService.getEngineWeb3jClientProvider(); } services.add(new BeaconChainService(serviceConfig, tekuConfig.beaconChain())); services.add( diff --git a/teku/src/test/java/tech/pegasys/teku/cli/BeaconNodeCommandTest.java b/teku/src/test/java/tech/pegasys/teku/cli/BeaconNodeCommandTest.java index 4d5554fb1fd..fca89cb3ab3 100644 --- a/teku/src/test/java/tech/pegasys/teku/cli/BeaconNodeCommandTest.java +++ b/teku/src/test/java/tech/pegasys/teku/cli/BeaconNodeCommandTest.java @@ -379,7 +379,7 @@ private TekuConfiguration.Builder expectedDefaultConfigurationBuilder() { return expectedConfigurationBuilder() .eth2NetworkConfig(b -> b.applyNetworkDefaults("mainnet")) - .executionEngine(b -> b.endpoint(null)) + .executionLayer(b -> b.engineEndpoint(null)) .powchain( b -> { b.depositContract(networkConfig.getEth1DepositContractAddress()); @@ -416,7 +416,7 @@ private TekuConfiguration.Builder expectedCompleteConfigInFileBuilder() { private TekuConfiguration.Builder expectedConfigurationBuilder() { return TekuConfiguration.builder() .eth2NetworkConfig(b -> b.applyMinimalNetworkDefaults().eth1DepositContractAddress(address)) - .executionEngine(b -> b.endpoint("http://localhost:8550")) + .executionLayer(b -> b.engineEndpoint("http://localhost:8550")) .powchain( b -> b.eth1Endpoints(List.of("http://localhost:8545")) diff --git a/teku/src/test/java/tech/pegasys/teku/cli/options/Eth2NetworkOptionsTest.java b/teku/src/test/java/tech/pegasys/teku/cli/options/Eth2NetworkOptionsTest.java index 83be2a72f00..4f694a1b992 100644 --- a/teku/src/test/java/tech/pegasys/teku/cli/options/Eth2NetworkOptionsTest.java +++ b/teku/src/test/java/tech/pegasys/teku/cli/options/Eth2NetworkOptionsTest.java @@ -65,7 +65,7 @@ void shouldUseBellatrixForkEpochIfSpecified() { .isEqualTo(SpecMilestone.BELLATRIX); assertThat( createConfigBuilder() - .executionEngine(b -> b.endpoint("someEndpoint")) + .executionLayer(b -> b.engineEndpoint("someEndpoint")) .eth2NetworkConfig(b -> b.bellatrixForkEpoch(UInt64.valueOf(120000))) .build()) .usingRecursiveComparison() diff --git a/teku/src/test/java/tech/pegasys/teku/cli/options/ExecutionEngineOptionsTest.java b/teku/src/test/java/tech/pegasys/teku/cli/options/ExecutionLayerOptionsTest.java similarity index 60% rename from teku/src/test/java/tech/pegasys/teku/cli/options/ExecutionEngineOptionsTest.java rename to teku/src/test/java/tech/pegasys/teku/cli/options/ExecutionLayerOptionsTest.java index 24d6f3433ba..a59c81c07dd 100644 --- a/teku/src/test/java/tech/pegasys/teku/cli/options/ExecutionEngineOptionsTest.java +++ b/teku/src/test/java/tech/pegasys/teku/cli/options/ExecutionLayerOptionsTest.java @@ -16,24 +16,23 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import java.net.MalformedURLException; -import java.net.URL; import org.junit.jupiter.api.Test; import tech.pegasys.teku.cli.AbstractBeaconNodeCommandTest; import tech.pegasys.teku.config.TekuConfiguration; import tech.pegasys.teku.infrastructure.exceptions.InvalidConfigurationException; import tech.pegasys.teku.infrastructure.unsigned.UInt64; -public class ExecutionEngineOptionsTest extends AbstractBeaconNodeCommandTest { +public class ExecutionLayerOptionsTest extends AbstractBeaconNodeCommandTest { @Test - public void shouldReadExecutionEngineOptionsFromConfigurationFile() { + public void shouldReadExecutionLayerOptionsFromConfigurationFile() { final TekuConfiguration config = - getTekuConfigurationFromFile("executionEngineOptions_config.yaml"); + getTekuConfigurationFromFile("executionLayerOptions_config.yaml"); // Spec doesn't include the merge so execution engine is disabled - assertThat(config.executionEngine().isEnabled()).isFalse(); - assertThat(config.executionEngine().getEndpoint()).isEqualTo("http://example.com:1234/path/"); + assertThat(config.executionLayer().isEnabled()).isFalse(); + assertThat(config.executionLayer().getEngineEndpoint()) + .isEqualTo("http://example.com:1234/path/"); } @Test @@ -47,13 +46,41 @@ public void shouldReportEEEnabledIfSpecEnablesBellatrix() { "http://example.com:1234/path/" }; final TekuConfiguration config = getTekuConfigurationFromArguments(args); - assertThat(config.executionEngine().isEnabled()).isTrue(); + assertThat(config.executionLayer().isEnabled()).isTrue(); assertThat( createConfigBuilder() .eth2NetworkConfig( b -> b.altairForkEpoch(UInt64.ZERO).bellatrixForkEpoch(UInt64.ONE)) - .executionEngine(b -> b.endpoint("http://example.com:1234/path/")) + .executionLayer(b -> b.engineEndpoint("http://example.com:1234/path/")) + .build()) + .usingRecursiveComparison() + .isEqualTo(config); + } + + @Test + public void shouldAcceptEngineAndBuilderEndpointIfSpecEnablesBellatrix() { + final String[] args = { + "--Xnetwork-altair-fork-epoch", + "0", + "--Xnetwork-bellatrix-fork-epoch", + "1", + "--ee-endpoint", + "http://example.com:1234/path/", + "--Xeb-endpoint", + "http://example2.com:1234/path2/" + }; + final TekuConfiguration config = getTekuConfigurationFromArguments(args); + assertThat(config.executionLayer().isEnabled()).isTrue(); + + assertThat( + createConfigBuilder() + .eth2NetworkConfig( + b -> b.altairForkEpoch(UInt64.ZERO).bellatrixForkEpoch(UInt64.ONE)) + .executionLayer( + b -> + b.engineEndpoint("http://example.com:1234/path/") + .builderEndpoint("http://example2.com:1234/path2/")) .build()) .usingRecursiveComparison() .isEqualTo(config); @@ -62,7 +89,7 @@ public void shouldReportEEEnabledIfSpecEnablesBellatrix() { @Test public void shouldReportEEDisabledIfEndpointNotSpecified() { final TekuConfiguration config = getTekuConfigurationFromArguments(); - assertThat(config.executionEngine().isEnabled()).isFalse(); + assertThat(config.executionLayer().isEnabled()).isFalse(); } @Test @@ -71,15 +98,7 @@ void shouldThrowInvalidConfigurationExceptionIfEndpointRequiredButNotSpecified() "--Xnetwork-altair-fork-epoch", "0", "--Xnetwork-bellatrix-fork-epoch", "1" }; final TekuConfiguration config = getTekuConfigurationFromArguments(args); - assertThatThrownBy(config.executionEngine()::getEndpoint) + assertThatThrownBy(config.executionLayer()::getEngineEndpoint) .isInstanceOf(InvalidConfigurationException.class); } - - @Test - void shouldAllowMultipleMevBoostUrls() throws MalformedURLException { - final String[] args = {"--Xee-payload-builders", "http://a.com,http://b.com"}; - final TekuConfiguration config = getTekuConfigurationFromArguments(args); - assertThat(config.executionEngine().getMevBoostUrls()) - .containsOnly(new URL("http://a.com"), new URL("http://b.com")); - } } diff --git a/teku/src/test/resources/executionEngineOptions_config.yaml b/teku/src/test/resources/executionLayerOptions_config.yaml similarity index 100% rename from teku/src/test/resources/executionEngineOptions_config.yaml rename to teku/src/test/resources/executionLayerOptions_config.yaml