@Test public void setForkInfo_noFutureForkScheduled() { final ForkInfo currentForkInfo = dataStructureUtil.randomForkInfo(); discoveryNetwork.setForkInfo(currentForkInfo, Optional.empty()); final EnrForkId expectedEnrForkId = new EnrForkId( currentForkInfo.getForkDigest(), currentForkInfo.getFork().getCurrent_version(), FAR_FUTURE_EPOCH); verify(discoveryService) .updateCustomENRField("eth2", SimpleOffsetSerializer.serialize(expectedEnrForkId)); }
public void setForkInfo(final ForkInfo currentForkInfo, final Optional<Fork> nextForkInfo) { final Bytes4 nextVersion = nextForkInfo .map(Fork::getCurrent_version) .orElse(currentForkInfo.getFork().getCurrent_version()); final UInt64 nextForkEpoch = nextForkInfo.map(Fork::getEpoch).orElse(FAR_FUTURE_EPOCH); final Bytes4 forkDigest = currentForkInfo.getForkDigest(); final EnrForkId enrForkId = new EnrForkId(forkDigest, nextVersion, nextForkEpoch); final Bytes encodedEnrForkId = SimpleOffsetSerializer.serialize(enrForkId); discoveryService.updateCustomENRField(ETH2_ENR_FIELD, encodedEnrForkId); this.enrForkId = Optional.of(enrForkId); }
DiscoveryNetwork extends DelegatingP2PNetwork<P> { public void setForkInfo(final ForkInfo currentForkInfo, final Optional<Fork> nextForkInfo) { final Bytes4 nextVersion = nextForkInfo .map(Fork::getCurrent_version) .orElse(currentForkInfo.getFork().getCurrent_version()); final UInt64 nextForkEpoch = nextForkInfo.map(Fork::getEpoch).orElse(FAR_FUTURE_EPOCH); final Bytes4 forkDigest = currentForkInfo.getForkDigest(); final EnrForkId enrForkId = new EnrForkId(forkDigest, nextVersion, nextForkEpoch); final Bytes encodedEnrForkId = SimpleOffsetSerializer.serialize(enrForkId); discoveryService.updateCustomENRField(ETH2_ENR_FIELD, encodedEnrForkId); this.enrForkId = Optional.of(enrForkId); } }
DiscoveryNetwork extends DelegatingP2PNetwork<P> { public void setForkInfo(final ForkInfo currentForkInfo, final Optional<Fork> nextForkInfo) { final Bytes4 nextVersion = nextForkInfo .map(Fork::getCurrent_version) .orElse(currentForkInfo.getFork().getCurrent_version()); final UInt64 nextForkEpoch = nextForkInfo.map(Fork::getEpoch).orElse(FAR_FUTURE_EPOCH); final Bytes4 forkDigest = currentForkInfo.getForkDigest(); final EnrForkId enrForkId = new EnrForkId(forkDigest, nextVersion, nextForkEpoch); final Bytes encodedEnrForkId = SimpleOffsetSerializer.serialize(enrForkId); discoveryService.updateCustomENRField(ETH2_ENR_FIELD, encodedEnrForkId); this.enrForkId = Optional.of(enrForkId); } DiscoveryNetwork(
      final P2PNetwork<P> p2pNetwork,
      final DiscoveryService discoveryService,
      final ConnectionManager connectionManager); }
DiscoveryNetwork extends DelegatingP2PNetwork<P> { public void setForkInfo(final ForkInfo currentForkInfo, final Optional<Fork> nextForkInfo) { final Bytes4 nextVersion = nextForkInfo .map(Fork::getCurrent_version) .orElse(currentForkInfo.getFork().getCurrent_version()); final UInt64 nextForkEpoch = nextForkInfo.map(Fork::getEpoch).orElse(FAR_FUTURE_EPOCH); final Bytes4 forkDigest = currentForkInfo.getForkDigest(); final EnrForkId enrForkId = new EnrForkId(forkDigest, nextVersion, nextForkEpoch); final Bytes encodedEnrForkId = SimpleOffsetSerializer.serialize(enrForkId); discoveryService.updateCustomENRField(ETH2_ENR_FIELD, encodedEnrForkId); this.enrForkId = Optional.of(enrForkId); } DiscoveryNetwork(
      final P2PNetwork<P> p2pNetwork,
      final DiscoveryService discoveryService,
      final ConnectionManager connectionManager); void initialize(); static DiscoveryNetwork<P> create(
      final MetricsSystem metricsSystem,
      final AsyncRunner asyncRunner,
      final KeyValueStore<String, Bytes> kvStore,
      final P2PNetwork<P> p2pNetwork,
      final PeerSelectionStrategy peerSelectionStrategy,
      final NetworkConfig p2pConfig); @Override SafeFuture<?> start(); @Override SafeFuture<?> stop(); void addStaticPeer(final String peerAddress); @Override Optional<String> getEnr(); @Override Optional<String> getDiscoveryAddress(); void setLongTermAttestationSubnetSubscriptions(Iterable<Integer> subnetIds); void setPreGenesisForkInfo(); void setForkInfo(final ForkInfo currentForkInfo, final Optional<Fork> nextForkInfo); @Override long subscribeConnect(final PeerConnectedSubscriber<P> subscriber); @Override void unsubscribeConnect(final long subscriptionId); @Override Optional<P> getPeer(final NodeId id); @Override Stream<P> streamPeers(); }
DiscoveryNetwork extends DelegatingP2PNetwork<P> { public void setForkInfo(final ForkInfo currentForkInfo, final Optional<Fork> nextForkInfo) { final Bytes4 nextVersion = nextForkInfo .map(Fork::getCurrent_version) .orElse(currentForkInfo.getFork().getCurrent_version()); final UInt64 nextForkEpoch = nextForkInfo.map(Fork::getEpoch).orElse(FAR_FUTURE_EPOCH); final Bytes4 forkDigest = currentForkInfo.getForkDigest(); final EnrForkId enrForkId = new EnrForkId(forkDigest, nextVersion, nextForkEpoch); final Bytes encodedEnrForkId = SimpleOffsetSerializer.serialize(enrForkId); discoveryService.updateCustomENRField(ETH2_ENR_FIELD, encodedEnrForkId); this.enrForkId = Optional.of(enrForkId); } DiscoveryNetwork(
      final P2PNetwork<P> p2pNetwork,
      final DiscoveryService discoveryService,
      final ConnectionManager connectionManager); void initialize(); static DiscoveryNetwork<P> create(
      final MetricsSystem metricsSystem,
      final AsyncRunner asyncRunner,
      final KeyValueStore<String, Bytes> kvStore,
      final P2PNetwork<P> p2pNetwork,
      final PeerSelectionStrategy peerSelectionStrategy,
      final NetworkConfig p2pConfig); @Override SafeFuture<?> start(); @Override SafeFuture<?> stop(); void addStaticPeer(final String peerAddress); @Override Optional<String> getEnr(); @Override Optional<String> getDiscoveryAddress(); void setLongTermAttestationSubnetSubscriptions(Iterable<Integer> subnetIds); void setPreGenesisForkInfo(); void setForkInfo(final ForkInfo currentForkInfo, final Optional<Fork> nextForkInfo); @Override long subscribeConnect(final PeerConnectedSubscriber<P> subscriber); @Override void unsubscribeConnect(final long subscriptionId); @Override Optional<P> getPeer(final NodeId id); @Override Stream<P> streamPeers(); static final String ATTESTATION_SUBNET_ENR_FIELD; static final String ETH2_ENR_FIELD; }