use of tech.pegasys.teku.networking.p2p.rpc.RpcMethod in project teku by ConsenSys.
the class PingIntegrationTest method testManualPingTimeout.
@Test
public void testManualPingTimeout() throws Exception {
// sending PING manually to check eth2RpcOutstandingPingThreshold works correctly
Duration pingPeriod = Duration.ofDays(1);
network1 = networkFactory.builder().eth2RpcPingInterval(pingPeriod).eth2RpcOutstandingPingThreshold(2).rpcMethodsModifier(m -> Stream.of(m).filter(t -> t.getIds().stream().noneMatch(id -> id.contains("/ping"))).map(n -> ((RpcMethod<?, ?, ?>) n))).startNetwork();
network2 = networkFactory.builder().eth2RpcPingInterval(pingPeriod).eth2RpcOutstandingPingThreshold(2).peer(network1).startNetwork();
peer1 = network2.getPeer(network1.getNodeId()).orElseThrow();
peer2 = network1.getPeer(network2.getNodeId()).orElseThrow();
Eth2PeerManagerAccess.invokeSendPeriodicPing(getPeerManager(network2), peer1);
assertThat(peer1.isConnected()).isTrue();
Eth2PeerManagerAccess.invokeSendPeriodicPing(getPeerManager(network2), peer1);
assertThat(peer1.isConnected()).isTrue();
// the 3rd ping attempt should disconnect the peer since there are 2 unanswered PING requests
Eth2PeerManagerAccess.invokeSendPeriodicPing(getPeerManager(network2), peer1);
waitFor(() -> assertThat(peer1.isConnected()).isFalse());
}
use of tech.pegasys.teku.networking.p2p.rpc.RpcMethod in project teku by ConsenSys.
the class Eth2P2PNetworkBuilder method build.
public Eth2P2PNetwork build() {
validate();
// Setup eth2 handlers
final SubnetSubscriptionService attestationSubnetService = new SubnetSubscriptionService();
final SubnetSubscriptionService syncCommitteeSubnetService = new SubnetSubscriptionService();
final RpcEncoding rpcEncoding = RpcEncoding.createSszSnappyEncoding(spec.isMilestoneSupported(SpecMilestone.BELLATRIX) ? MAX_CHUNK_SIZE_BELLATRIX : MAX_CHUNK_SIZE);
final Eth2PeerManager eth2PeerManager = Eth2PeerManager.create(asyncRunner, recentChainData, historicalChainData, metricsSystem, attestationSubnetService, syncCommitteeSubnetService, rpcEncoding, requiredCheckpoint, eth2RpcPingInterval, eth2RpcOutstandingPingThreshold, eth2StatusUpdateInterval, timeProvider, config.getPeerRateLimit(), config.getPeerRequestLimit(), spec);
final Collection<RpcMethod<?, ?, ?>> eth2RpcMethods = eth2PeerManager.getBeaconChainMethods().all();
rpcMethods.addAll(eth2RpcMethods);
peerHandlers.add(eth2PeerManager);
final GossipEncoding gossipEncoding = config.getGossipEncoding();
// Build core network and inject eth2 handlers
final DiscoveryNetwork<?> network = buildNetwork(gossipEncoding, syncCommitteeSubnetService);
final GossipForkManager gossipForkManager = buildGossipForkManager(gossipEncoding, network);
return new ActiveEth2P2PNetwork(config.getSpec(), asyncRunner, network, eth2PeerManager, gossipForkManager, eventChannels, recentChainData, attestationSubnetService, syncCommitteeSubnetService, gossipEncoding, config.getGossipConfigurator(), processedAttestationSubscriptionProvider);
}
Aggregations