Skip to content

Commit

Permalink
8934 inclusion list pool (#9013)
Browse files Browse the repository at this point in the history
* add inclusion list pool skeleton
  • Loading branch information
mehdi-aouadi committed Jan 17, 2025
1 parent ea5366a commit 18a3286
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<AttesterSlashing> attesterSlashingPool = mock(OperationPool.class);
protected final OperationPool<ProposerSlashing> proposerSlashingPool = mock(OperationPool.class);
Expand Down Expand Up @@ -233,6 +235,7 @@ private void setupAndStartRestAPI(final BeaconRestApiConfig config) {
.attestationManager(attestationManager)
.activeValidatorChannel(activeValidatorChannel)
.attestationPool(attestationPool)
.inclusionListPool(inclusionListPool)
.attesterSlashingPool(attesterSlashingPool)
.proposerSlashingPool(proposerSlashingPool)
.voluntaryExitPool(voluntaryExitPool)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -223,6 +230,7 @@ public DataProvider build() {
final NodeDataProvider nodeDataProvider =
new NodeDataProvider(
attestationPool,
inclusionListPool,
attesterSlashingPool,
proposerSlashingPool,
voluntaryExitPool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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<AttesterSlashing> attesterSlashingPool;
private final OperationPool<ProposerSlashing> proposerSlashingPool;
private final OperationPool<SignedVoluntaryExit> voluntaryExitPool;
Expand All @@ -71,6 +74,7 @@ public class NodeDataProvider {

public NodeDataProvider(
final AggregatingAttestationPool attestationPool,
final InclusionListPool inclusionListPool,
final OperationPool<AttesterSlashing> attesterSlashingsPool,
final OperationPool<ProposerSlashing> proposerSlashingPool,
final OperationPool<SignedVoluntaryExit> voluntaryExitPool,
Expand All @@ -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;
Expand All @@ -105,6 +110,10 @@ public List<Attestation> getAttestations(
return attestationPool.getAttestations(maybeSlot, maybeCommitteeIndex);
}

public List<SignedInclusionList> getInclusionLists(final UInt64 slot) {
return inclusionListPool.getInclusionLists(slot);
}

public ObjectAndMetaData<List<Attestation>> getAttestationsAndMetaData(
final Optional<UInt64> maybeSlot, final Optional<UInt64> maybeCommitteeIndex) {
return lookupMetaData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -81,6 +83,7 @@ public void setup() {
provider =
new NodeDataProvider(
attestationPool,
inclusionListPool,
attesterSlashingPool,
proposerSlashingPool,
voluntaryExitPool,
Expand Down Expand Up @@ -204,6 +207,7 @@ private Spec setUpMockedSpec() {
provider =
new NodeDataProvider(
attestationPool,
inclusionListPool,
attesterSlashingPool,
proposerSlashingPool,
voluntaryExitPool,
Expand Down
Original file line number Diff line number Diff line change
@@ -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<InternalValidationResult> addRemote(
final SignedInclusionList signedInclusionList, final Optional<UInt64> arrivalTimestamp) {
return SafeFuture.completedFuture(InternalValidationResult.ACCEPT);
}

public List<SignedInclusionList> getInclusionLists(final UInt64 slot) {
return Collections.emptyList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -253,6 +253,7 @@ public class BeaconChainController extends Service implements BeaconChainControl
protected volatile Eth2P2PNetwork p2pNetwork;
protected volatile Optional<BeaconRestApi> beaconRestAPI = Optional.empty();
protected volatile AggregatingAttestationPool attestationPool;
protected volatile InclusionListPool inclusionListPool;
protected volatile DepositProvider depositProvider;
protected volatile SyncService syncService;
protected volatile AttestationManager attestationManager;
Expand All @@ -264,7 +265,6 @@ public class BeaconChainController extends Service implements BeaconChainControl
protected volatile OperationPool<ProposerSlashing> proposerSlashingPool;
protected volatile OperationPool<SignedVoluntaryExit> voluntaryExitPool;
protected volatile MappedOperationPool<SignedBlsToExecutionChange> blsToExecutionChangePool;
protected volatile OperationPool<SignedInclusionList> inclusionListPool;
protected volatile SyncCommitteeContributionPool syncCommitteeContributionPool;
protected volatile SyncCommitteeMessagePool syncCommitteeMessagePool;
protected volatile WeakSubjectivityValidator weakSubjectivityValidator;
Expand Down Expand Up @@ -522,6 +522,7 @@ public void initAll() {
initCombinedChainDataClient();
initSignatureVerificationService();
initAttestationPool();
initInclusionListPool();
initAttesterSlashingPool();
initProposerSlashingPool();
initVoluntaryExitPool();
Expand Down Expand Up @@ -758,11 +759,6 @@ protected void initSignedBlsToExecutionChangePool() {
blsToExecutionChangePool::removeAll);
}

protected void initInclusionListPool() {
LOG.debug("BeaconChainController.initInclusionListPool()");
// TODO EIP7805
}

protected void initDataProvider() {
dataProvider =
DataProvider.builder()
Expand All @@ -775,6 +771,7 @@ protected void initDataProvider() {
.validatorApiChannel(
eventChannels.getPublisher(ValidatorApiChannel.class, beaconAsyncRunner))
.attestationPool(attestationPool)
.inclusionListPool(inclusionListPool)
.blockBlobSidecarsTrackersPool(blockBlobSidecarsTrackersPool)
.attestationManager(attestationManager)
.isLivenessTrackingEnabled(getLivenessTrackingEnabled(beaconConfig))
Expand Down Expand Up @@ -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()) {
Expand Down

0 comments on commit 18a3286

Please sign in to comment.