From 18a328642aeb85430cd39e346c26a6b923d26d11 Mon Sep 17 00:00:00 2001 From: Mehdi AOUADI Date: Fri, 17 Jan 2025 18:02:14 +0100 Subject: [PATCH] 8934 inclusion list pool (#9013) * add inclusion list pool skeleton --- ...tractDataBackedRestAPIIntegrationTest.java | 3 ++ .../tech/pegasys/teku/api/DataProvider.java | 8 ++++ .../pegasys/teku/api/NodeDataProvider.java | 9 ++++ .../teku/api/NodeDataProviderTest.java | 4 ++ .../inclusionlist/InclusionListPool.java | 41 +++++++++++++++++++ .../beaconchain/BeaconChainController.java | 17 ++++---- 6 files changed, 75 insertions(+), 7 deletions(-) create mode 100644 ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/inclusionlist/InclusionListPool.java 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 ed9f5d3a216..4b90f173184 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 @@ -80,6 +80,7 @@ import tech.pegasys.teku.statetransition.forkchoice.MergeTransitionBlockValidator; import tech.pegasys.teku.statetransition.forkchoice.NoopForkChoiceNotifier; import tech.pegasys.teku.statetransition.forkchoice.ProposersDataManager; +import tech.pegasys.teku.statetransition.inclusionlist.InclusionListPool; import tech.pegasys.teku.statetransition.synccommittee.SyncCommitteeContributionPool; import tech.pegasys.teku.statetransition.validation.SignedBlsToExecutionChangeValidator; import tech.pegasys.teku.statetransition.validatorcache.ActiveValidatorCache; @@ -126,6 +127,7 @@ public abstract class AbstractDataBackedRestAPIIntegrationTest { protected final EventChannels eventChannels = mock(EventChannels.class); protected final AggregatingAttestationPool attestationPool = mock(AggregatingAttestationPool.class); + protected final InclusionListPool inclusionListPool = mock(InclusionListPool.class); protected final AttestationManager attestationManager = mock(AttestationManager.class); protected final OperationPool attesterSlashingPool = mock(OperationPool.class); protected final OperationPool proposerSlashingPool = mock(OperationPool.class); @@ -233,6 +235,7 @@ private void setupAndStartRestAPI(final BeaconRestApiConfig config) { .attestationManager(attestationManager) .activeValidatorChannel(activeValidatorChannel) .attestationPool(attestationPool) + .inclusionListPool(inclusionListPool) .attesterSlashingPool(attesterSlashingPool) .proposerSlashingPool(proposerSlashingPool) .voluntaryExitPool(voluntaryExitPool) diff --git a/data/provider/src/main/java/tech/pegasys/teku/api/DataProvider.java b/data/provider/src/main/java/tech/pegasys/teku/api/DataProvider.java index 9fa42ea52c3..eb19a903a56 100644 --- a/data/provider/src/main/java/tech/pegasys/teku/api/DataProvider.java +++ b/data/provider/src/main/java/tech/pegasys/teku/api/DataProvider.java @@ -29,6 +29,7 @@ import tech.pegasys.teku.statetransition.blobs.BlockBlobSidecarsTrackersPool; import tech.pegasys.teku.statetransition.forkchoice.ForkChoiceNotifier; import tech.pegasys.teku.statetransition.forkchoice.ProposersDataManager; +import tech.pegasys.teku.statetransition.inclusionlist.InclusionListPool; import tech.pegasys.teku.statetransition.synccommittee.SyncCommitteeContributionPool; import tech.pegasys.teku.statetransition.validatorcache.ActiveValidatorChannel; import tech.pegasys.teku.storage.client.CombinedChainDataClient; @@ -104,6 +105,7 @@ public static class Builder { private SyncService syncService; private ValidatorApiChannel validatorApiChannel; private AggregatingAttestationPool attestationPool; + private InclusionListPool inclusionListPool; private BlockBlobSidecarsTrackersPool blockBlobSidecarsTrackersPool; private AttestationManager attestationManager; private ActiveValidatorChannel activeValidatorChannel; @@ -152,6 +154,11 @@ public Builder attestationPool(final AggregatingAttestationPool attestationPool) return this; } + public Builder inclusionListPool(final InclusionListPool inclusionListPool) { + this.inclusionListPool = inclusionListPool; + return this; + } + public Builder blockBlobSidecarsTrackersPool( final BlockBlobSidecarsTrackersPool blockBlobSidecarsTrackersPool) { this.blockBlobSidecarsTrackersPool = blockBlobSidecarsTrackersPool; @@ -223,6 +230,7 @@ public DataProvider build() { final NodeDataProvider nodeDataProvider = new NodeDataProvider( attestationPool, + inclusionListPool, attesterSlashingPool, proposerSlashingPool, voluntaryExitPool, diff --git a/data/provider/src/main/java/tech/pegasys/teku/api/NodeDataProvider.java b/data/provider/src/main/java/tech/pegasys/teku/api/NodeDataProvider.java index 79ed78e51ca..c171e1b9c64 100644 --- a/data/provider/src/main/java/tech/pegasys/teku/api/NodeDataProvider.java +++ b/data/provider/src/main/java/tech/pegasys/teku/api/NodeDataProvider.java @@ -33,6 +33,7 @@ import tech.pegasys.teku.spec.datastructures.operations.AttesterSlashing; import tech.pegasys.teku.spec.datastructures.operations.ProposerSlashing; import tech.pegasys.teku.spec.datastructures.operations.SignedBlsToExecutionChange; +import tech.pegasys.teku.spec.datastructures.operations.SignedInclusionList; import tech.pegasys.teku.spec.datastructures.operations.SignedVoluntaryExit; import tech.pegasys.teku.spec.datastructures.operations.versions.altair.SignedContributionAndProof; import tech.pegasys.teku.statetransition.OperationAddedSubscriber; @@ -46,6 +47,7 @@ import tech.pegasys.teku.statetransition.forkchoice.PreparedProposerInfo; import tech.pegasys.teku.statetransition.forkchoice.ProposersDataManager; import tech.pegasys.teku.statetransition.forkchoice.RegisteredValidatorInfo; +import tech.pegasys.teku.statetransition.inclusionlist.InclusionListPool; import tech.pegasys.teku.statetransition.synccommittee.SyncCommitteeContributionPool; import tech.pegasys.teku.statetransition.validation.InternalValidationResult; import tech.pegasys.teku.statetransition.validatorcache.ActiveValidatorChannel; @@ -55,6 +57,7 @@ public class NodeDataProvider { private static final Logger LOG = LogManager.getLogger(); private final AggregatingAttestationPool attestationPool; + private final InclusionListPool inclusionListPool; private final OperationPool attesterSlashingPool; private final OperationPool proposerSlashingPool; private final OperationPool voluntaryExitPool; @@ -71,6 +74,7 @@ public class NodeDataProvider { public NodeDataProvider( final AggregatingAttestationPool attestationPool, + final InclusionListPool inclusionListPool, final OperationPool attesterSlashingsPool, final OperationPool proposerSlashingPool, final OperationPool voluntaryExitPool, @@ -85,6 +89,7 @@ public NodeDataProvider( final RecentChainData recentChainData, final Spec spec) { this.attestationPool = attestationPool; + this.inclusionListPool = inclusionListPool; this.attesterSlashingPool = attesterSlashingsPool; this.proposerSlashingPool = proposerSlashingPool; this.voluntaryExitPool = voluntaryExitPool; @@ -105,6 +110,10 @@ public List getAttestations( return attestationPool.getAttestations(maybeSlot, maybeCommitteeIndex); } + public List getInclusionLists(final UInt64 slot) { + return inclusionListPool.getInclusionLists(slot); + } + public ObjectAndMetaData> getAttestationsAndMetaData( final Optional maybeSlot, final Optional maybeCommitteeIndex) { return lookupMetaData( diff --git a/data/provider/src/test/java/tech/pegasys/teku/api/NodeDataProviderTest.java b/data/provider/src/test/java/tech/pegasys/teku/api/NodeDataProviderTest.java index 29bd11b9180..d8dc5cd71f5 100644 --- a/data/provider/src/test/java/tech/pegasys/teku/api/NodeDataProviderTest.java +++ b/data/provider/src/test/java/tech/pegasys/teku/api/NodeDataProviderTest.java @@ -44,6 +44,7 @@ import tech.pegasys.teku.statetransition.blobs.BlockBlobSidecarsTrackersPool; import tech.pegasys.teku.statetransition.forkchoice.ForkChoiceNotifier; import tech.pegasys.teku.statetransition.forkchoice.ProposersDataManager; +import tech.pegasys.teku.statetransition.inclusionlist.InclusionListPool; import tech.pegasys.teku.statetransition.synccommittee.SyncCommitteeContributionPool; import tech.pegasys.teku.statetransition.validation.InternalValidationResult; import tech.pegasys.teku.statetransition.validatorcache.ActiveValidatorChannel; @@ -55,6 +56,7 @@ public class NodeDataProviderTest { private final Spec spec = TestSpecFactory.createMinimalCapella(); private final DataStructureUtil dataStructureUtil = new DataStructureUtil(spec); private final AggregatingAttestationPool attestationPool = mock(AggregatingAttestationPool.class); + private final InclusionListPool inclusionListPool = mock(InclusionListPool.class); private final BlockBlobSidecarsTrackersPool blockBlobSidecarsTrackersPool = mock(BlockBlobSidecarsTrackersPool.class); private final AttestationManager attestationManager = mock(AttestationManager.class); @@ -81,6 +83,7 @@ public void setup() { provider = new NodeDataProvider( attestationPool, + inclusionListPool, attesterSlashingPool, proposerSlashingPool, voluntaryExitPool, @@ -204,6 +207,7 @@ private Spec setUpMockedSpec() { provider = new NodeDataProvider( attestationPool, + inclusionListPool, attesterSlashingPool, proposerSlashingPool, voluntaryExitPool, diff --git a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/inclusionlist/InclusionListPool.java b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/inclusionlist/InclusionListPool.java new file mode 100644 index 00000000000..04c5f667cbb --- /dev/null +++ b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/inclusionlist/InclusionListPool.java @@ -0,0 +1,41 @@ +/* + * Copyright Consensys Software Inc., 2025 + * + * 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.statetransition.inclusionlist; + +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import tech.pegasys.teku.ethereum.events.SlotEventsChannel; +import tech.pegasys.teku.infrastructure.async.SafeFuture; +import tech.pegasys.teku.infrastructure.unsigned.UInt64; +import tech.pegasys.teku.spec.datastructures.operations.SignedInclusionList; +import tech.pegasys.teku.statetransition.validation.InternalValidationResult; + +// TODO EIP7805 implement pool logic +public class InclusionListPool implements SlotEventsChannel { + + @Override + public synchronized void onSlot(final UInt64 slot) {} + + public void add(final SignedInclusionList signedInclusionList) {} + + public SafeFuture addRemote( + final SignedInclusionList signedInclusionList, final Optional arrivalTimestamp) { + return SafeFuture.completedFuture(InternalValidationResult.ACCEPT); + } + + public List getInclusionLists(final UInt64 slot) { + return Collections.emptyList(); + } +} 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 e4abbaeef99..da0ff05eabe 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 @@ -106,7 +106,6 @@ import tech.pegasys.teku.spec.datastructures.operations.AttesterSlashing; import tech.pegasys.teku.spec.datastructures.operations.ProposerSlashing; import tech.pegasys.teku.spec.datastructures.operations.SignedBlsToExecutionChange; -import tech.pegasys.teku.spec.datastructures.operations.SignedInclusionList; 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; @@ -146,6 +145,7 @@ import tech.pegasys.teku.statetransition.forkchoice.TickProcessingPerformance; import tech.pegasys.teku.statetransition.forkchoice.TickProcessor; import tech.pegasys.teku.statetransition.genesis.GenesisHandler; +import tech.pegasys.teku.statetransition.inclusionlist.InclusionListPool; import tech.pegasys.teku.statetransition.synccommittee.SignedContributionAndProofValidator; import tech.pegasys.teku.statetransition.synccommittee.SyncCommitteeContributionPool; import tech.pegasys.teku.statetransition.synccommittee.SyncCommitteeMessagePool; @@ -253,6 +253,7 @@ public class BeaconChainController extends Service implements BeaconChainControl protected volatile Eth2P2PNetwork p2pNetwork; protected volatile Optional beaconRestAPI = Optional.empty(); protected volatile AggregatingAttestationPool attestationPool; + protected volatile InclusionListPool inclusionListPool; protected volatile DepositProvider depositProvider; protected volatile SyncService syncService; protected volatile AttestationManager attestationManager; @@ -264,7 +265,6 @@ public class BeaconChainController extends Service implements BeaconChainControl protected volatile OperationPool proposerSlashingPool; protected volatile OperationPool voluntaryExitPool; protected volatile MappedOperationPool blsToExecutionChangePool; - protected volatile OperationPool inclusionListPool; protected volatile SyncCommitteeContributionPool syncCommitteeContributionPool; protected volatile SyncCommitteeMessagePool syncCommitteeMessagePool; protected volatile WeakSubjectivityValidator weakSubjectivityValidator; @@ -522,6 +522,7 @@ public void initAll() { initCombinedChainDataClient(); initSignatureVerificationService(); initAttestationPool(); + initInclusionListPool(); initAttesterSlashingPool(); initProposerSlashingPool(); initVoluntaryExitPool(); @@ -758,11 +759,6 @@ protected void initSignedBlsToExecutionChangePool() { blsToExecutionChangePool::removeAll); } - protected void initInclusionListPool() { - LOG.debug("BeaconChainController.initInclusionListPool()"); - // TODO EIP7805 - } - protected void initDataProvider() { dataProvider = DataProvider.builder() @@ -775,6 +771,7 @@ protected void initDataProvider() { .validatorApiChannel( eventChannels.getPublisher(ValidatorApiChannel.class, beaconAsyncRunner)) .attestationPool(attestationPool) + .inclusionListPool(inclusionListPool) .blockBlobSidecarsTrackersPool(blockBlobSidecarsTrackersPool) .attestationManager(attestationManager) .isLivenessTrackingEnabled(getLivenessTrackingEnabled(beaconConfig)) @@ -1205,6 +1202,12 @@ public void initAttestationPool() { attestationPool::onAttestationsIncludedInBlock); } + protected void initInclusionListPool() { + LOG.debug("BeaconChainController.initInclusionListPool()"); + inclusionListPool = new InclusionListPool(); + eventChannels.subscribe(SlotEventsChannel.class, inclusionListPool); + } + public void initRestAPI() { LOG.debug("BeaconChainController.initRestAPI()"); if (!beaconConfig.beaconRestApiConfig().isRestApiEnabled()) {