Skip to content

Commit

Permalink
Implement builder_status and scheduled polling
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov committed May 4, 2022
1 parent c2357c2 commit 4e5912a
Show file tree
Hide file tree
Showing 76 changed files with 1,013 additions and 767 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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<SignedBeaconBlock> pendingBlocks =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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(
Expand All @@ -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;
Expand All @@ -85,7 +85,7 @@ public BlockOperationSelectorFactory(
this.eth1DataCache = eth1DataCache;
this.graffiti = graffiti;
this.forkChoiceNotifier = forkChoiceNotifier;
this.executionEngineChannel = executionEngineChannel;
this.executionLayerChannel = executionLayerChannel;
this.isMevBoostEnabled = isMevBoostEnabled;
}

Expand Down Expand Up @@ -156,7 +156,7 @@ public Consumer<BeaconBlockBodyBuilder> createSelector(
.getExecutionPayloadHeaderSchema()
.getHeaderOfDefaultPayload(),
(payloadId) ->
executionEngineChannel
executionLayerChannel
.getPayloadHeader(payloadId, blockSlotState.getSlot())
.join()));
return;
Expand Down Expand Up @@ -185,7 +185,9 @@ public Consumer<BeaconBlockBodyBuilder> createSelector(
.getExecutionPayloadSchema()
.getDefault(),
(payloadId) ->
executionEngineChannel.getPayload(payloadId, blockSlotState.getSlot()).join()));
executionLayerChannel
.engineGetPayload(payloadId, blockSlotState.getSlot())
.join()));
};
}

Expand Down Expand Up @@ -235,7 +237,7 @@ public Consumer<SignedBeaconBlockUnblinder> createUnblinderSelector() {
} else {
bodyUnblinder.setExecutionPayloadSupplier(
() ->
executionEngineChannel.proposeBlindedBlock(
executionLayerChannel.proposeBlindedBlock(
bodyUnblinder.getSignedBlindedBeaconBlock()));
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -72,7 +72,7 @@ class BlockFactoryTest {
final OperationPool<ProposerSlashing> proposerSlashingPool = mock(OperationPool.class);
final OperationPool<SignedVoluntaryExit> 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);
Expand Down Expand Up @@ -310,7 +310,7 @@ private BeaconBlock assertBlockCreated(
eth1DataCache,
graffiti,
forkChoiceNotifier,
executionEngine,
executionLayer,
isMevBoostEnabled));

when(depositProvider.getDeposits(any(), any())).thenReturn(deposits);
Expand All @@ -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();

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -419,7 +419,7 @@ private BlockFactory createBlockFactory(final Spec spec, final boolean isMevBoos
eth1DataCache,
graffiti,
forkChoiceNotifier,
executionEngine,
executionLayer,
isMevBoostEnabled));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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())
Expand All @@ -147,7 +147,7 @@ class BlockOperationSelectorFactoryTest {
eth1DataCache,
defaultGraffiti,
forkChoiceNotifier,
executionEngine,
executionLayer,
false);

private final BlockOperationSelectorFactory factoryWithMevBoost =
Expand All @@ -162,7 +162,7 @@ class BlockOperationSelectorFactoryTest {
eth1DataCache,
defaultGraffiti,
forkChoiceNotifier,
executionEngine,
executionLayer,
true);

@BeforeEach
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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);
Expand All @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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);
}
Expand Down
Loading

0 comments on commit 4e5912a

Please sign in to comment.