mirror of
https://github.com/vacp2p/linea-besu.git
synced 2026-01-09 21:17:54 -05:00
Add eth protocol manager test builder (#7954)
* 7311: Add EthProtocolManagerTestBuilder Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net> * 7311: Add EthProtocolManagerTestBuilder.builder method Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net> * 7311: Replace EthProtocolManagerTestUtil.create() usages with builder Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net> * 7311: Replace EthProtocolManagerTestUtil.create(TimeoutPolicy) Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net> * 7311: Replace EthProtocolManagerTestUtil.create(Blockchain) Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net> * 7311: Replace EthProtocolManagerTestUtil.create(EthScheduler) Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net> * Replace EthProtocolManagerTestUtil.create(ProtocolSchedule, Blockchain, TimeoutPolicy, WorldStateArchive, TransactionPool, EthProtocolConfiguration) Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net> * Replace EthProtocolManagerTestUtil.create(ProtocolSchedule, Blockchain, EthScheduler) Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net> * Replace EthProtocolManagerTestUtil.create(ProtocolSchedule, Blockchain, EthScheduler) Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net> * Replace EthProtocolManagerTestUtil.create(ProtocolSchedule, Blockchain, WorldStateArchive, TransactionPool, EthProtocolConfiguration) Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net> * Replace EthProtocolManagerTestUtil.create(ProtocolSchedule, Blockchain, EthScheduler, WorldStateArchive, TransactionPool, EthProtocolConfiguration) Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net> * Replace EthProtocolManagerTestUtil.create(ProtocolSchedule, Blockchain, EthScheduler, WorldStateArchive, TransactionPool, EthProtocolConfiguration) Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net> * Remove remaining create methods and apply spotless Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net> --------- Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>
This commit is contained in:
@@ -27,6 +27,7 @@ import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
|
||||
import org.hyperledger.besu.ethereum.core.MutableWorldState;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestBuilder;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer;
|
||||
@@ -94,12 +95,14 @@ public class WorldStateDownloaderBenchmark {
|
||||
|
||||
tempDir = Files.createTempDir().toPath();
|
||||
ethProtocolManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
new EthScheduler(
|
||||
syncConfig.getDownloaderParallelism(),
|
||||
syncConfig.getTransactionsParallelism(),
|
||||
syncConfig.getComputationParallelism(),
|
||||
metricsSystem));
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setEthScheduler(
|
||||
new EthScheduler(
|
||||
syncConfig.getDownloaderParallelism(),
|
||||
syncConfig.getTransactionsParallelism(),
|
||||
syncConfig.getComputationParallelism(),
|
||||
metricsSystem))
|
||||
.build();
|
||||
|
||||
peer = EthProtocolManagerTestUtil.createPeer(ethProtocolManager, blockHeader.getNumber());
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ public class EthPeersTest {
|
||||
@BeforeEach
|
||||
public void setup() throws Exception {
|
||||
when(peerRequest.sendRequest(any())).thenReturn(responseStream);
|
||||
ethProtocolManager = EthProtocolManagerTestUtil.create();
|
||||
ethProtocolManager = EthProtocolManagerTestBuilder.builder().build();
|
||||
ethPeers = ethProtocolManager.ethContext().getEthPeers();
|
||||
final ChainHeadTracker mock = mock(ChainHeadTracker.class);
|
||||
final BlockHeader blockHeader = mock(BlockHeader.class);
|
||||
|
||||
@@ -77,6 +77,7 @@ import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
|
||||
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
||||
import org.hyperledger.besu.plugin.services.MetricsSystem;
|
||||
import org.hyperledger.besu.plugin.services.storage.DataStorageFormat;
|
||||
import org.hyperledger.besu.testutil.DeterministicEthScheduler;
|
||||
import org.hyperledger.besu.testutil.TestClock;
|
||||
|
||||
import java.math.BigInteger;
|
||||
@@ -132,13 +133,14 @@ public final class EthProtocolManagerTest {
|
||||
@Test
|
||||
public void handleMalformedRequestIdMessage() {
|
||||
try (final EthProtocolManager ethManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
blockchain,
|
||||
() -> false,
|
||||
protocolContext.getWorldStateArchive(),
|
||||
transactionPool,
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(blockchain)
|
||||
.setEthScheduler(new DeterministicEthScheduler(() -> false))
|
||||
.setWorldStateArchive(protocolContext.getWorldStateArchive())
|
||||
.setTransactionPool(transactionPool)
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.build()) {
|
||||
// this is a non-request id message, but we'll be processing it with eth66, make sure we
|
||||
// disconnect the peer gracefully
|
||||
final MessageData messageData = GetBlockHeadersMessage.create(1, 1, 0, false);
|
||||
@@ -151,13 +153,14 @@ public final class EthProtocolManagerTest {
|
||||
@Test
|
||||
public void disconnectOnUnsolicitedMessage() {
|
||||
try (final EthProtocolManager ethManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
blockchain,
|
||||
() -> false,
|
||||
protocolContext.getWorldStateArchive(),
|
||||
transactionPool,
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(blockchain)
|
||||
.setEthScheduler(new DeterministicEthScheduler(() -> false))
|
||||
.setWorldStateArchive(protocolContext.getWorldStateArchive())
|
||||
.setTransactionPool(transactionPool)
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.build()) {
|
||||
final MessageData messageData =
|
||||
BlockHeadersMessage.create(Collections.singletonList(blockchain.getBlockHeader(1).get()));
|
||||
final MockPeerConnection peer = setupPeer(ethManager, (cap, msg, conn) -> {});
|
||||
@@ -169,13 +172,14 @@ public final class EthProtocolManagerTest {
|
||||
@Test
|
||||
public void disconnectOnFailureToSendStatusMessage() {
|
||||
try (final EthProtocolManager ethManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
blockchain,
|
||||
() -> false,
|
||||
protocolContext.getWorldStateArchive(),
|
||||
transactionPool,
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(blockchain)
|
||||
.setEthScheduler(new DeterministicEthScheduler(() -> false))
|
||||
.setWorldStateArchive(protocolContext.getWorldStateArchive())
|
||||
.setTransactionPool(transactionPool)
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.build()) {
|
||||
final MessageData messageData =
|
||||
BlockHeadersMessage.create(Collections.singletonList(blockchain.getBlockHeader(1).get()));
|
||||
final MockPeerConnection peer =
|
||||
@@ -188,13 +192,14 @@ public final class EthProtocolManagerTest {
|
||||
@Test
|
||||
public void disconnectOnWrongChainId() {
|
||||
try (final EthProtocolManager ethManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
blockchain,
|
||||
() -> false,
|
||||
protocolContext.getWorldStateArchive(),
|
||||
transactionPool,
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(blockchain)
|
||||
.setEthScheduler(new DeterministicEthScheduler(() -> false))
|
||||
.setWorldStateArchive(protocolContext.getWorldStateArchive())
|
||||
.setTransactionPool(transactionPool)
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.build()) {
|
||||
final MessageData messageData =
|
||||
BlockHeadersMessage.create(Collections.singletonList(blockchain.getBlockHeader(1).get()));
|
||||
final MockPeerConnection peer =
|
||||
@@ -219,13 +224,14 @@ public final class EthProtocolManagerTest {
|
||||
public void disconnectNewPoWPeers() {
|
||||
final MergePeerFilter mergePeerFilter = new MergePeerFilter();
|
||||
try (final EthProtocolManager ethManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
blockchain,
|
||||
protocolContext.getWorldStateArchive(),
|
||||
transactionPool,
|
||||
EthProtocolConfiguration.defaultConfig(),
|
||||
Optional.of(mergePeerFilter))) {
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(blockchain)
|
||||
.setWorldStateArchive(protocolContext.getWorldStateArchive())
|
||||
.setTransactionPool(transactionPool)
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.setMergePeerFilter(Optional.of(mergePeerFilter))
|
||||
.build()) {
|
||||
|
||||
final MockPeerConnection workPeer = setupPeer(ethManager, (cap, msg, conn) -> {});
|
||||
final MockPeerConnection stakePeer = setupPeer(ethManager, (cap, msg, conn) -> {});
|
||||
@@ -267,13 +273,14 @@ public final class EthProtocolManagerTest {
|
||||
@Test
|
||||
public void doNotDisconnectOnLargeMessageWithinLimits() {
|
||||
try (final EthProtocolManager ethManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
blockchain,
|
||||
() -> false,
|
||||
protocolContext.getWorldStateArchive(),
|
||||
transactionPool,
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(blockchain)
|
||||
.setEthScheduler(new DeterministicEthScheduler(() -> false))
|
||||
.setWorldStateArchive(protocolContext.getWorldStateArchive())
|
||||
.setTransactionPool(transactionPool)
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.build()) {
|
||||
final MessageData messageData = mock(MessageData.class);
|
||||
when(messageData.getSize()).thenReturn(EthProtocolConfiguration.DEFAULT_MAX_MESSAGE_SIZE);
|
||||
when(messageData.getCode()).thenReturn(EthPV62.TRANSACTIONS);
|
||||
@@ -287,13 +294,14 @@ public final class EthProtocolManagerTest {
|
||||
@Test
|
||||
public void disconnectOnWrongGenesisHash() {
|
||||
try (final EthProtocolManager ethManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
blockchain,
|
||||
() -> false,
|
||||
protocolContext.getWorldStateArchive(),
|
||||
transactionPool,
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(blockchain)
|
||||
.setEthScheduler(new DeterministicEthScheduler(() -> false))
|
||||
.setWorldStateArchive(protocolContext.getWorldStateArchive())
|
||||
.setTransactionPool(transactionPool)
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.build()) {
|
||||
final MessageData messageData =
|
||||
BlockHeadersMessage.create(Collections.singletonList(blockchain.getBlockHeader(1).get()));
|
||||
final MockPeerConnection peer =
|
||||
@@ -317,13 +325,14 @@ public final class EthProtocolManagerTest {
|
||||
@Test
|
||||
public void doNotDisconnectOnValidMessage() {
|
||||
try (final EthProtocolManager ethManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
blockchain,
|
||||
() -> false,
|
||||
protocolContext.getWorldStateArchive(),
|
||||
transactionPool,
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(blockchain)
|
||||
.setEthScheduler(new DeterministicEthScheduler(() -> false))
|
||||
.setWorldStateArchive(protocolContext.getWorldStateArchive())
|
||||
.setTransactionPool(transactionPool)
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.build()) {
|
||||
final MessageData messageData =
|
||||
GetBlockBodiesMessage.create(Collections.singletonList(gen.hash()));
|
||||
final MockPeerConnection peer = setupPeer(ethManager, (cap, msg, conn) -> {});
|
||||
@@ -339,13 +348,14 @@ public final class EthProtocolManagerTest {
|
||||
public void respondToGetHeaders() throws ExecutionException, InterruptedException {
|
||||
final CompletableFuture<Void> done = new CompletableFuture<>();
|
||||
try (final EthProtocolManager ethManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
blockchain,
|
||||
() -> false,
|
||||
protocolContext.getWorldStateArchive(),
|
||||
transactionPool,
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(blockchain)
|
||||
.setEthScheduler(new DeterministicEthScheduler(() -> false))
|
||||
.setWorldStateArchive(protocolContext.getWorldStateArchive())
|
||||
.setTransactionPool(transactionPool)
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.build()) {
|
||||
final long startBlock = 5L;
|
||||
final int blockCount = 5;
|
||||
final MessageData messageData =
|
||||
@@ -379,13 +389,14 @@ public final class EthProtocolManagerTest {
|
||||
final EthProtocolConfiguration config =
|
||||
EthProtocolConfiguration.builder().maxGetBlockHeaders(limit).build();
|
||||
try (final EthProtocolManager ethManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
blockchain,
|
||||
() -> false,
|
||||
protocolContext.getWorldStateArchive(),
|
||||
transactionPool,
|
||||
config)) {
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(blockchain)
|
||||
.setEthScheduler(new DeterministicEthScheduler(() -> false))
|
||||
.setWorldStateArchive(protocolContext.getWorldStateArchive())
|
||||
.setTransactionPool(transactionPool)
|
||||
.setEthereumWireProtocolConfiguration(config)
|
||||
.build()) {
|
||||
final long startBlock = 5L;
|
||||
final int blockCount = 10;
|
||||
final MessageData messageData =
|
||||
@@ -416,13 +427,14 @@ public final class EthProtocolManagerTest {
|
||||
public void respondToGetHeadersReversed() throws ExecutionException, InterruptedException {
|
||||
final CompletableFuture<Void> done = new CompletableFuture<>();
|
||||
try (final EthProtocolManager ethManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
blockchain,
|
||||
() -> false,
|
||||
protocolContext.getWorldStateArchive(),
|
||||
transactionPool,
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(blockchain)
|
||||
.setEthScheduler(new DeterministicEthScheduler(() -> false))
|
||||
.setWorldStateArchive(protocolContext.getWorldStateArchive())
|
||||
.setTransactionPool(transactionPool)
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.build()) {
|
||||
|
||||
final long endBlock = 10L;
|
||||
final int blockCount = 5;
|
||||
@@ -453,13 +465,14 @@ public final class EthProtocolManagerTest {
|
||||
public void respondToGetHeadersWithSkip() throws ExecutionException, InterruptedException {
|
||||
final CompletableFuture<Void> done = new CompletableFuture<>();
|
||||
try (final EthProtocolManager ethManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
blockchain,
|
||||
() -> false,
|
||||
protocolContext.getWorldStateArchive(),
|
||||
transactionPool,
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(blockchain)
|
||||
.setEthScheduler(new DeterministicEthScheduler(() -> false))
|
||||
.setWorldStateArchive(protocolContext.getWorldStateArchive())
|
||||
.setTransactionPool(transactionPool)
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.build()) {
|
||||
|
||||
final long startBlock = 5L;
|
||||
final int blockCount = 5;
|
||||
@@ -493,13 +506,14 @@ public final class EthProtocolManagerTest {
|
||||
throws ExecutionException, InterruptedException {
|
||||
final CompletableFuture<Void> done = new CompletableFuture<>();
|
||||
try (final EthProtocolManager ethManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
blockchain,
|
||||
() -> false,
|
||||
protocolContext.getWorldStateArchive(),
|
||||
transactionPool,
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(blockchain)
|
||||
.setEthScheduler(new DeterministicEthScheduler(() -> false))
|
||||
.setWorldStateArchive(protocolContext.getWorldStateArchive())
|
||||
.setTransactionPool(transactionPool)
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.build()) {
|
||||
|
||||
final long endBlock = 10L;
|
||||
final int blockCount = 5;
|
||||
@@ -557,13 +571,14 @@ public final class EthProtocolManagerTest {
|
||||
public void respondToGetHeadersPartial() throws ExecutionException, InterruptedException {
|
||||
final CompletableFuture<Void> done = new CompletableFuture<>();
|
||||
try (final EthProtocolManager ethManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
blockchain,
|
||||
() -> false,
|
||||
protocolContext.getWorldStateArchive(),
|
||||
transactionPool,
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(blockchain)
|
||||
.setEthScheduler(new DeterministicEthScheduler(() -> false))
|
||||
.setWorldStateArchive(protocolContext.getWorldStateArchive())
|
||||
.setTransactionPool(transactionPool)
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.build()) {
|
||||
|
||||
final long startBlock = blockchain.getChainHeadBlockNumber() - 1L;
|
||||
final int blockCount = 5;
|
||||
@@ -595,13 +610,14 @@ public final class EthProtocolManagerTest {
|
||||
public void respondToGetHeadersEmpty() throws ExecutionException, InterruptedException {
|
||||
final CompletableFuture<Void> done = new CompletableFuture<>();
|
||||
try (final EthProtocolManager ethManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
blockchain,
|
||||
() -> false,
|
||||
protocolContext.getWorldStateArchive(),
|
||||
transactionPool,
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(blockchain)
|
||||
.setEthScheduler(new DeterministicEthScheduler(() -> false))
|
||||
.setWorldStateArchive(protocolContext.getWorldStateArchive())
|
||||
.setTransactionPool(transactionPool)
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.build()) {
|
||||
|
||||
final long startBlock = blockchain.getChainHeadBlockNumber() + 1;
|
||||
final int blockCount = 5;
|
||||
@@ -630,13 +646,14 @@ public final class EthProtocolManagerTest {
|
||||
public void respondToGetBodies() throws ExecutionException, InterruptedException {
|
||||
final CompletableFuture<Void> done = new CompletableFuture<>();
|
||||
try (final EthProtocolManager ethManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
blockchain,
|
||||
() -> false,
|
||||
protocolContext.getWorldStateArchive(),
|
||||
transactionPool,
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(blockchain)
|
||||
.setEthScheduler(new DeterministicEthScheduler(() -> false))
|
||||
.setWorldStateArchive(protocolContext.getWorldStateArchive())
|
||||
.setTransactionPool(transactionPool)
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.build()) {
|
||||
|
||||
// Setup blocks query
|
||||
final long startBlock = blockchain.getChainHeadBlockNumber() - 5;
|
||||
@@ -683,13 +700,14 @@ public final class EthProtocolManagerTest {
|
||||
final EthProtocolConfiguration config =
|
||||
EthProtocolConfiguration.builder().maxGetBlockBodies(limit).build();
|
||||
try (final EthProtocolManager ethManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
blockchain,
|
||||
() -> false,
|
||||
protocolContext.getWorldStateArchive(),
|
||||
transactionPool,
|
||||
config)) {
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(blockchain)
|
||||
.setEthScheduler(new DeterministicEthScheduler(() -> false))
|
||||
.setWorldStateArchive(protocolContext.getWorldStateArchive())
|
||||
.setTransactionPool(transactionPool)
|
||||
.setEthereumWireProtocolConfiguration(config)
|
||||
.build()) {
|
||||
// Setup blocks query
|
||||
final int blockCount = 10;
|
||||
final long startBlock = blockchain.getChainHeadBlockNumber() - blockCount;
|
||||
@@ -732,13 +750,14 @@ public final class EthProtocolManagerTest {
|
||||
public void respondToGetBodiesPartial() throws ExecutionException, InterruptedException {
|
||||
final CompletableFuture<Void> done = new CompletableFuture<>();
|
||||
try (final EthProtocolManager ethManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
blockchain,
|
||||
() -> false,
|
||||
protocolContext.getWorldStateArchive(),
|
||||
transactionPool,
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(blockchain)
|
||||
.setEthScheduler(new DeterministicEthScheduler(() -> false))
|
||||
.setWorldStateArchive(protocolContext.getWorldStateArchive())
|
||||
.setTransactionPool(transactionPool)
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.build()) {
|
||||
// Setup blocks query
|
||||
final long expectedBlockNumber = blockchain.getChainHeadBlockNumber() - 1;
|
||||
final BlockHeader header = blockchain.getBlockHeader(expectedBlockNumber).get();
|
||||
@@ -775,13 +794,14 @@ public final class EthProtocolManagerTest {
|
||||
public void respondToGetReceipts() throws ExecutionException, InterruptedException {
|
||||
final CompletableFuture<Void> done = new CompletableFuture<>();
|
||||
try (final EthProtocolManager ethManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
blockchain,
|
||||
() -> false,
|
||||
protocolContext.getWorldStateArchive(),
|
||||
transactionPool,
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(blockchain)
|
||||
.setEthScheduler(new DeterministicEthScheduler(() -> false))
|
||||
.setWorldStateArchive(protocolContext.getWorldStateArchive())
|
||||
.setTransactionPool(transactionPool)
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.build()) {
|
||||
// Setup blocks query
|
||||
final long startBlock = blockchain.getChainHeadBlockNumber() - 5;
|
||||
final int blockCount = 2;
|
||||
@@ -826,13 +846,14 @@ public final class EthProtocolManagerTest {
|
||||
final EthProtocolConfiguration config =
|
||||
EthProtocolConfiguration.builder().maxGetReceipts(limit).build();
|
||||
try (final EthProtocolManager ethManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
blockchain,
|
||||
() -> false,
|
||||
protocolContext.getWorldStateArchive(),
|
||||
transactionPool,
|
||||
config)) {
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(blockchain)
|
||||
.setEthScheduler(new DeterministicEthScheduler(() -> false))
|
||||
.setWorldStateArchive(protocolContext.getWorldStateArchive())
|
||||
.setTransactionPool(transactionPool)
|
||||
.setEthereumWireProtocolConfiguration(config)
|
||||
.build()) {
|
||||
// Setup blocks query
|
||||
final int blockCount = 10;
|
||||
final long startBlock = blockchain.getChainHeadBlockNumber() - blockCount;
|
||||
@@ -874,13 +895,14 @@ public final class EthProtocolManagerTest {
|
||||
public void respondToGetReceiptsPartial() throws ExecutionException, InterruptedException {
|
||||
final CompletableFuture<Void> done = new CompletableFuture<>();
|
||||
try (final EthProtocolManager ethManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
blockchain,
|
||||
() -> false,
|
||||
protocolContext.getWorldStateArchive(),
|
||||
transactionPool,
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(blockchain)
|
||||
.setEthScheduler(new DeterministicEthScheduler(() -> false))
|
||||
.setWorldStateArchive(protocolContext.getWorldStateArchive())
|
||||
.setTransactionPool(transactionPool)
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.build()) {
|
||||
// Setup blocks query
|
||||
final long blockNumber = blockchain.getChainHeadBlockNumber() - 5;
|
||||
final BlockHeader header = blockchain.getBlockHeader(blockNumber).get();
|
||||
@@ -919,13 +941,14 @@ public final class EthProtocolManagerTest {
|
||||
final WorldStateArchive worldStateArchive = protocolContext.getWorldStateArchive();
|
||||
|
||||
try (final EthProtocolManager ethManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
blockchain,
|
||||
() -> false,
|
||||
protocolContext.getWorldStateArchive(),
|
||||
transactionPool,
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(blockchain)
|
||||
.setEthScheduler(new DeterministicEthScheduler(() -> false))
|
||||
.setWorldStateArchive(protocolContext.getWorldStateArchive())
|
||||
.setTransactionPool(transactionPool)
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.build()) {
|
||||
// Setup node data query
|
||||
|
||||
final List<Bytes> expectedResults = new ArrayList<>();
|
||||
@@ -967,13 +990,14 @@ public final class EthProtocolManagerTest {
|
||||
@Test
|
||||
public void newBlockMinedSendsNewBlockMessageToAllPeers() {
|
||||
try (final EthProtocolManager ethManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
blockchain,
|
||||
() -> false,
|
||||
protocolContext.getWorldStateArchive(),
|
||||
transactionPool,
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(blockchain)
|
||||
.setEthScheduler(new DeterministicEthScheduler(() -> false))
|
||||
.setWorldStateArchive(protocolContext.getWorldStateArchive())
|
||||
.setTransactionPool(transactionPool)
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.build()) {
|
||||
// Define handler to validate response
|
||||
final PeerSendHandler onSend = mock(PeerSendHandler.class);
|
||||
final List<PeerConnection> peers = Lists.newArrayList();
|
||||
@@ -1038,13 +1062,14 @@ public final class EthProtocolManagerTest {
|
||||
|
||||
final CompletableFuture<Void> done = new CompletableFuture<>();
|
||||
try (final EthProtocolManager ethManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
blockchain,
|
||||
() -> false,
|
||||
protocolContext.getWorldStateArchive(),
|
||||
transactionPool,
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(blockchain)
|
||||
.setEthScheduler(new DeterministicEthScheduler(() -> false))
|
||||
.setWorldStateArchive(protocolContext.getWorldStateArchive())
|
||||
.setTransactionPool(transactionPool)
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.build()) {
|
||||
|
||||
final long startBlock = 1L;
|
||||
final int requestedBlockCount = 13;
|
||||
@@ -1105,13 +1130,14 @@ public final class EthProtocolManagerTest {
|
||||
final TransactionsMessage transactionMessage = TransactionsMessage.readFrom(raw);
|
||||
|
||||
try (final EthProtocolManager ethManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
blockchain,
|
||||
ethScheduler,
|
||||
protocolContext.getWorldStateArchive(),
|
||||
transactionPool,
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(blockchain)
|
||||
.setEthScheduler(ethScheduler)
|
||||
.setWorldStateArchive(protocolContext.getWorldStateArchive())
|
||||
.setTransactionPool(transactionPool)
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.build()) {
|
||||
// Create a transaction pool. This has a side effect of registering a listener for the
|
||||
// transactions message.
|
||||
TransactionPoolFactory.createTransactionPool(
|
||||
@@ -1141,15 +1167,17 @@ public final class EthProtocolManagerTest {
|
||||
public void forkIdForChainHeadLegacyNoForksNotEmpty() {
|
||||
final EthScheduler ethScheduler = mock(EthScheduler.class);
|
||||
try (final EthProtocolManager ethManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
blockchain,
|
||||
ethScheduler,
|
||||
protocolContext.getWorldStateArchive(),
|
||||
transactionPool,
|
||||
EthProtocolConfiguration.defaultConfig(),
|
||||
new ForkIdManager(
|
||||
blockchain, Collections.emptyList(), Collections.emptyList(), true))) {
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(blockchain)
|
||||
.setEthScheduler(ethScheduler)
|
||||
.setWorldStateArchive(protocolContext.getWorldStateArchive())
|
||||
.setTransactionPool(transactionPool)
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.setForkIdManager(
|
||||
new ForkIdManager(
|
||||
blockchain, Collections.emptyList(), Collections.emptyList(), true))
|
||||
.build()) {
|
||||
|
||||
assertThat(ethManager.getForkIdAsBytesList()).isNotEmpty();
|
||||
final CRC32 genesisHashCRC = new CRC32();
|
||||
|
||||
@@ -0,0 +1,245 @@
|
||||
/*
|
||||
* Copyright contributors to Besu.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
package org.hyperledger.besu.ethereum.eth.manager;
|
||||
|
||||
import static org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider.createInMemoryBlockchain;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import org.hyperledger.besu.config.GenesisConfigFile;
|
||||
import org.hyperledger.besu.ethereum.chain.Blockchain;
|
||||
import org.hyperledger.besu.ethereum.chain.GenesisState;
|
||||
import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil;
|
||||
import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture;
|
||||
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
|
||||
import org.hyperledger.besu.ethereum.eth.peervalidation.PeerValidator;
|
||||
import org.hyperledger.besu.ethereum.eth.sync.SyncMode;
|
||||
import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;
|
||||
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
|
||||
import org.hyperledger.besu.ethereum.forkid.ForkIdManager;
|
||||
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
|
||||
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
|
||||
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
||||
import org.hyperledger.besu.plugin.services.storage.DataStorageFormat;
|
||||
import org.hyperledger.besu.testutil.DeterministicEthScheduler;
|
||||
import org.hyperledger.besu.testutil.TestClock;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.apache.tuweni.bytes.Bytes;
|
||||
|
||||
public class EthProtocolManagerTestBuilder {
|
||||
private static final BigInteger DEFAULT_NETWORK_ID = BigInteger.ONE;
|
||||
private static final ProtocolSchedule DEFAULT_PROTOCOL_SCHEDULE = ProtocolScheduleFixture.MAINNET;
|
||||
|
||||
private ProtocolSchedule protocolSchedule;
|
||||
private GenesisConfigFile genesisConfigFile;
|
||||
private GenesisState genesisState;
|
||||
private Blockchain blockchain;
|
||||
private BigInteger networkId;
|
||||
private WorldStateArchive worldStateArchive;
|
||||
private TransactionPool transactionPool;
|
||||
private EthProtocolConfiguration ethereumWireProtocolConfiguration;
|
||||
private ForkIdManager forkIdManager;
|
||||
private EthPeers ethPeers;
|
||||
private EthMessages ethMessages;
|
||||
private EthMessages snapMessages;
|
||||
private EthScheduler ethScheduler;
|
||||
private EthContext ethContext;
|
||||
private List<PeerValidator> peerValidators;
|
||||
private Optional<MergePeerFilter> mergePeerFilter;
|
||||
private SynchronizerConfiguration synchronizerConfiguration;
|
||||
|
||||
public static EthProtocolManagerTestBuilder builder() {
|
||||
return new EthProtocolManagerTestBuilder();
|
||||
}
|
||||
|
||||
public EthProtocolManagerTestBuilder setProtocolSchedule(
|
||||
final ProtocolSchedule protocolSchedule) {
|
||||
this.protocolSchedule = protocolSchedule;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EthProtocolManagerTestBuilder setGenesisConfigFile(
|
||||
final GenesisConfigFile genesisConfigFile) {
|
||||
this.genesisConfigFile = genesisConfigFile;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EthProtocolManagerTestBuilder setGenesisState(final GenesisState genesisState) {
|
||||
this.genesisState = genesisState;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EthProtocolManagerTestBuilder setBlockchain(final Blockchain blockchain) {
|
||||
this.blockchain = blockchain;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EthProtocolManagerTestBuilder setNetworkId(final BigInteger networkId) {
|
||||
this.networkId = networkId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EthProtocolManagerTestBuilder setWorldStateArchive(
|
||||
final WorldStateArchive worldStateArchive) {
|
||||
this.worldStateArchive = worldStateArchive;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EthProtocolManagerTestBuilder setTransactionPool(final TransactionPool transactionPool) {
|
||||
this.transactionPool = transactionPool;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EthProtocolManagerTestBuilder setEthereumWireProtocolConfiguration(
|
||||
final EthProtocolConfiguration ethereumWireProtocolConfiguration) {
|
||||
this.ethereumWireProtocolConfiguration = ethereumWireProtocolConfiguration;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EthProtocolManagerTestBuilder setForkIdManager(final ForkIdManager forkIdManager) {
|
||||
this.forkIdManager = forkIdManager;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EthProtocolManagerTestBuilder setEthPeers(final EthPeers ethPeers) {
|
||||
this.ethPeers = ethPeers;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EthProtocolManagerTestBuilder setEthMessages(final EthMessages ethMessages) {
|
||||
this.ethMessages = ethMessages;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EthProtocolManagerTestBuilder setSnapMessages(final EthMessages snapMessages) {
|
||||
this.snapMessages = snapMessages;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EthProtocolManagerTestBuilder setEthContext(final EthContext ethContext) {
|
||||
this.ethContext = ethContext;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EthProtocolManagerTestBuilder setPeerValidators(final List<PeerValidator> peerValidators) {
|
||||
this.peerValidators = peerValidators;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EthProtocolManagerTestBuilder setMergePeerFilter(
|
||||
final Optional<MergePeerFilter> mergePeerFilter) {
|
||||
this.mergePeerFilter = mergePeerFilter;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EthProtocolManagerTestBuilder setSynchronizerConfiguration(
|
||||
final SynchronizerConfiguration synchronizerConfiguration) {
|
||||
this.synchronizerConfiguration = synchronizerConfiguration;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EthProtocolManagerTestBuilder setEthScheduler(final EthScheduler ethScheduler) {
|
||||
this.ethScheduler = ethScheduler;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EthProtocolManager build() {
|
||||
if (protocolSchedule == null) {
|
||||
protocolSchedule = DEFAULT_PROTOCOL_SCHEDULE;
|
||||
}
|
||||
if (genesisConfigFile == null) {
|
||||
genesisConfigFile = GenesisConfigFile.mainnet();
|
||||
}
|
||||
if (genesisState == null) {
|
||||
genesisState = GenesisState.fromConfig(genesisConfigFile, protocolSchedule);
|
||||
}
|
||||
if (blockchain == null) {
|
||||
blockchain = createInMemoryBlockchain(genesisState.getBlock());
|
||||
}
|
||||
if (networkId == null) {
|
||||
networkId = DEFAULT_NETWORK_ID;
|
||||
}
|
||||
if (worldStateArchive == null) {
|
||||
worldStateArchive =
|
||||
BlockchainSetupUtil.forTesting(DataStorageFormat.FOREST).getWorldArchive();
|
||||
}
|
||||
if (transactionPool == null) {
|
||||
transactionPool = mock(TransactionPool.class);
|
||||
}
|
||||
if (ethereumWireProtocolConfiguration == null) {
|
||||
ethereumWireProtocolConfiguration = EthProtocolConfiguration.defaultConfig();
|
||||
}
|
||||
if (forkIdManager == null) {
|
||||
forkIdManager =
|
||||
new ForkIdManager(blockchain, Collections.emptyList(), Collections.emptyList(), false);
|
||||
}
|
||||
if (ethPeers == null) {
|
||||
ethPeers =
|
||||
new EthPeers(
|
||||
() -> protocolSchedule.getByBlockHeader(blockchain.getChainHeadHeader()),
|
||||
TestClock.fixed(),
|
||||
new NoOpMetricsSystem(),
|
||||
EthProtocolConfiguration.DEFAULT_MAX_MESSAGE_SIZE,
|
||||
Collections.emptyList(),
|
||||
Bytes.random(64),
|
||||
25,
|
||||
25,
|
||||
false,
|
||||
SyncMode.FAST,
|
||||
forkIdManager);
|
||||
}
|
||||
ethPeers.setChainHeadTracker(EthProtocolManagerTestUtil.getChainHeadTrackerMock());
|
||||
if (ethMessages == null) {
|
||||
ethMessages = new EthMessages();
|
||||
}
|
||||
if (snapMessages == null) {
|
||||
snapMessages = new EthMessages();
|
||||
}
|
||||
if (ethScheduler == null) {
|
||||
ethScheduler =
|
||||
new DeterministicEthScheduler(DeterministicEthScheduler.TimeoutPolicy.NEVER_TIMEOUT);
|
||||
}
|
||||
if (ethContext == null) {
|
||||
ethContext = new EthContext(ethPeers, ethMessages, snapMessages, ethScheduler);
|
||||
}
|
||||
if (peerValidators == null) {
|
||||
peerValidators = Collections.emptyList();
|
||||
}
|
||||
if (mergePeerFilter == null) {
|
||||
mergePeerFilter = Optional.of(new MergePeerFilter());
|
||||
}
|
||||
if (synchronizerConfiguration == null) {
|
||||
synchronizerConfiguration = SynchronizerConfiguration.builder().build();
|
||||
}
|
||||
return new EthProtocolManager(
|
||||
blockchain,
|
||||
networkId,
|
||||
worldStateArchive,
|
||||
transactionPool,
|
||||
ethereumWireProtocolConfiguration,
|
||||
ethPeers,
|
||||
ethMessages,
|
||||
ethContext,
|
||||
peerValidators,
|
||||
mergePeerFilter,
|
||||
synchronizerConfiguration,
|
||||
ethScheduler,
|
||||
forkIdManager);
|
||||
}
|
||||
}
|
||||
@@ -15,229 +15,29 @@
|
||||
package org.hyperledger.besu.ethereum.eth.manager;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider.createInMemoryBlockchain;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import org.hyperledger.besu.config.GenesisConfigFile;
|
||||
import org.hyperledger.besu.datatypes.Hash;
|
||||
import org.hyperledger.besu.ethereum.chain.Blockchain;
|
||||
import org.hyperledger.besu.ethereum.chain.ChainHead;
|
||||
import org.hyperledger.besu.ethereum.chain.GenesisState;
|
||||
import org.hyperledger.besu.ethereum.core.BlockHeader;
|
||||
import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil;
|
||||
import org.hyperledger.besu.ethereum.core.Difficulty;
|
||||
import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture;
|
||||
import org.hyperledger.besu.ethereum.eth.EthProtocol;
|
||||
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.snap.SnapProtocolManager;
|
||||
import org.hyperledger.besu.ethereum.eth.peervalidation.PeerValidator;
|
||||
import org.hyperledger.besu.ethereum.eth.sync.ChainHeadTracker;
|
||||
import org.hyperledger.besu.ethereum.eth.sync.SyncMode;
|
||||
import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;
|
||||
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
|
||||
import org.hyperledger.besu.ethereum.forkid.ForkIdManager;
|
||||
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
|
||||
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.DefaultMessage;
|
||||
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData;
|
||||
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
|
||||
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
||||
import org.hyperledger.besu.plugin.services.storage.DataStorageFormat;
|
||||
import org.hyperledger.besu.testutil.DeterministicEthScheduler;
|
||||
import org.hyperledger.besu.testutil.DeterministicEthScheduler.TimeoutPolicy;
|
||||
import org.hyperledger.besu.testutil.TestClock;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalLong;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.apache.tuweni.bytes.Bytes;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
public class EthProtocolManagerTestUtil {
|
||||
|
||||
public static EthProtocolManager create(
|
||||
final ProtocolSchedule protocolSchedule,
|
||||
final Blockchain blockchain,
|
||||
final TimeoutPolicy timeoutPolicy,
|
||||
final WorldStateArchive worldStateArchive,
|
||||
final TransactionPool transactionPool,
|
||||
final EthProtocolConfiguration ethereumWireProtocolConfiguration) {
|
||||
return create(
|
||||
protocolSchedule,
|
||||
blockchain,
|
||||
new DeterministicEthScheduler(timeoutPolicy),
|
||||
worldStateArchive,
|
||||
transactionPool,
|
||||
ethereumWireProtocolConfiguration);
|
||||
}
|
||||
|
||||
public static EthProtocolManager create(
|
||||
final ProtocolSchedule protocolSchedule,
|
||||
final Blockchain blockchain,
|
||||
final WorldStateArchive worldStateArchive,
|
||||
final TransactionPool transactionPool,
|
||||
final EthProtocolConfiguration ethereumWireProtocolConfiguration,
|
||||
final Optional<MergePeerFilter> mergePeerFilter) {
|
||||
|
||||
final EthPeers peers =
|
||||
new EthPeers(
|
||||
() -> protocolSchedule.getByBlockHeader(blockchain.getChainHeadHeader()),
|
||||
TestClock.fixed(),
|
||||
new NoOpMetricsSystem(),
|
||||
EthProtocolConfiguration.DEFAULT_MAX_MESSAGE_SIZE,
|
||||
Collections.emptyList(),
|
||||
Bytes.random(64),
|
||||
25,
|
||||
25,
|
||||
false,
|
||||
SyncMode.FAST,
|
||||
new ForkIdManager(blockchain, Collections.emptyList(), Collections.emptyList(), false));
|
||||
|
||||
final ChainHeadTracker chainHeadTrackerMock = getChainHeadTrackerMock();
|
||||
peers.setChainHeadTracker(chainHeadTrackerMock);
|
||||
|
||||
final EthMessages messages = new EthMessages();
|
||||
final EthScheduler ethScheduler = new DeterministicEthScheduler(TimeoutPolicy.NEVER_TIMEOUT);
|
||||
final EthContext ethContext = new EthContext(peers, messages, ethScheduler);
|
||||
|
||||
return new EthProtocolManager(
|
||||
blockchain,
|
||||
BigInteger.ONE,
|
||||
worldStateArchive,
|
||||
transactionPool,
|
||||
ethereumWireProtocolConfiguration,
|
||||
peers,
|
||||
messages,
|
||||
ethContext,
|
||||
Collections.emptyList(),
|
||||
mergePeerFilter,
|
||||
mock(SynchronizerConfiguration.class),
|
||||
ethScheduler,
|
||||
new ForkIdManager(blockchain, Collections.emptyList(), Collections.emptyList(), false));
|
||||
}
|
||||
|
||||
public static EthProtocolManager create(
|
||||
final Blockchain blockchain,
|
||||
final EthScheduler ethScheduler,
|
||||
final WorldStateArchive worldStateArchive,
|
||||
final TransactionPool transactionPool,
|
||||
final EthProtocolConfiguration ethereumWireProtocolConfiguration,
|
||||
final EthPeers ethPeers,
|
||||
final EthMessages ethMessages,
|
||||
final EthContext ethContext) {
|
||||
return create(
|
||||
blockchain,
|
||||
ethScheduler,
|
||||
worldStateArchive,
|
||||
transactionPool,
|
||||
ethereumWireProtocolConfiguration,
|
||||
ethPeers,
|
||||
ethMessages,
|
||||
ethContext,
|
||||
new ForkIdManager(blockchain, Collections.emptyList(), Collections.emptyList(), false));
|
||||
}
|
||||
|
||||
public static EthProtocolManager create(
|
||||
final Blockchain blockchain,
|
||||
final EthScheduler ethScheduler,
|
||||
final WorldStateArchive worldStateArchive,
|
||||
final TransactionPool transactionPool,
|
||||
final EthProtocolConfiguration ethereumWireProtocolConfiguration,
|
||||
final EthPeers ethPeers,
|
||||
final EthMessages ethMessages,
|
||||
final EthContext ethContext,
|
||||
final ForkIdManager forkIdManager) {
|
||||
|
||||
ethPeers.setChainHeadTracker(getChainHeadTrackerMock());
|
||||
|
||||
final BigInteger networkId = BigInteger.ONE;
|
||||
return new EthProtocolManager(
|
||||
blockchain,
|
||||
networkId,
|
||||
worldStateArchive,
|
||||
transactionPool,
|
||||
ethereumWireProtocolConfiguration,
|
||||
ethPeers,
|
||||
ethMessages,
|
||||
ethContext,
|
||||
Collections.emptyList(),
|
||||
Optional.empty(),
|
||||
mock(SynchronizerConfiguration.class),
|
||||
ethScheduler,
|
||||
forkIdManager);
|
||||
}
|
||||
|
||||
public static EthProtocolManager create(final Blockchain blockchain) {
|
||||
return create(
|
||||
ProtocolScheduleFixture.MAINNET,
|
||||
blockchain,
|
||||
new DeterministicEthScheduler(TimeoutPolicy.NEVER_TIMEOUT));
|
||||
}
|
||||
|
||||
public static EthProtocolManager create(
|
||||
final ProtocolSchedule protocolSchedule,
|
||||
final Blockchain blockchain,
|
||||
final WorldStateArchive worldStateArchive,
|
||||
final TransactionPool transactionPool,
|
||||
final EthProtocolConfiguration ethProtocolConfiguration) {
|
||||
return create(
|
||||
protocolSchedule,
|
||||
blockchain,
|
||||
new DeterministicEthScheduler(TimeoutPolicy.NEVER_TIMEOUT),
|
||||
worldStateArchive,
|
||||
transactionPool,
|
||||
ethProtocolConfiguration);
|
||||
}
|
||||
|
||||
public static EthProtocolManager create(final EthScheduler ethScheduler) {
|
||||
final ProtocolSchedule protocolSchedule = ProtocolScheduleFixture.MAINNET;
|
||||
final GenesisConfigFile config = GenesisConfigFile.mainnet();
|
||||
final GenesisState genesisState = GenesisState.fromConfig(config, protocolSchedule);
|
||||
final Blockchain blockchain = createInMemoryBlockchain(genesisState.getBlock());
|
||||
return create(protocolSchedule, blockchain, ethScheduler);
|
||||
}
|
||||
|
||||
public static EthProtocolManager create(
|
||||
final ProtocolSchedule protocolSchedule,
|
||||
final Blockchain blockchain,
|
||||
final EthScheduler ethScheduler,
|
||||
final WorldStateArchive worldStateArchive,
|
||||
final TransactionPool transactionPool,
|
||||
final EthProtocolConfiguration configuration) {
|
||||
|
||||
final EthPeers peers =
|
||||
new EthPeers(
|
||||
() -> protocolSchedule.getByBlockHeader(blockchain.getChainHeadHeader()),
|
||||
TestClock.fixed(),
|
||||
new NoOpMetricsSystem(),
|
||||
EthProtocolConfiguration.DEFAULT_MAX_MESSAGE_SIZE,
|
||||
Collections.emptyList(),
|
||||
Bytes.random(64),
|
||||
25,
|
||||
25,
|
||||
false,
|
||||
SyncMode.FAST,
|
||||
new ForkIdManager(blockchain, Collections.emptyList(), Collections.emptyList(), false));
|
||||
final EthMessages messages = new EthMessages();
|
||||
|
||||
final ChainHeadTracker chtMock = getChainHeadTrackerMock();
|
||||
|
||||
peers.setChainHeadTracker(chtMock);
|
||||
|
||||
return create(
|
||||
blockchain,
|
||||
ethScheduler,
|
||||
worldStateArchive,
|
||||
transactionPool,
|
||||
configuration,
|
||||
peers,
|
||||
messages,
|
||||
new EthContext(peers, messages, ethScheduler));
|
||||
}
|
||||
|
||||
public static ChainHeadTracker getChainHeadTrackerMock() {
|
||||
final ChainHeadTracker chtMock = mock(ChainHeadTracker.class);
|
||||
final BlockHeader blockHeaderMock = mock(BlockHeader.class);
|
||||
@@ -249,84 +49,6 @@ public class EthProtocolManagerTestUtil {
|
||||
return chtMock;
|
||||
}
|
||||
|
||||
public static EthProtocolManager create(
|
||||
final ProtocolSchedule protocolSchedule,
|
||||
final Blockchain blockchain,
|
||||
final EthScheduler ethScheduler,
|
||||
final WorldStateArchive worldStateArchive,
|
||||
final TransactionPool transactionPool,
|
||||
final EthProtocolConfiguration configuration,
|
||||
final ForkIdManager forkIdManager) {
|
||||
|
||||
final EthPeers peers =
|
||||
new EthPeers(
|
||||
() -> protocolSchedule.getByBlockHeader(blockchain.getChainHeadHeader()),
|
||||
TestClock.fixed(),
|
||||
new NoOpMetricsSystem(),
|
||||
EthProtocolConfiguration.DEFAULT_MAX_MESSAGE_SIZE,
|
||||
Collections.emptyList(),
|
||||
Bytes.random(64),
|
||||
25,
|
||||
25,
|
||||
false,
|
||||
SyncMode.FAST,
|
||||
new ForkIdManager(blockchain, Collections.emptyList(), Collections.emptyList(), false));
|
||||
final EthMessages messages = new EthMessages();
|
||||
|
||||
return create(
|
||||
blockchain,
|
||||
ethScheduler,
|
||||
worldStateArchive,
|
||||
transactionPool,
|
||||
configuration,
|
||||
peers,
|
||||
messages,
|
||||
new EthContext(peers, messages, ethScheduler),
|
||||
forkIdManager);
|
||||
}
|
||||
|
||||
public static EthProtocolManager create(
|
||||
final ProtocolSchedule protocolSchedule,
|
||||
final Blockchain blockchain,
|
||||
final EthScheduler ethScheduler) {
|
||||
final EthPeers ethPeers =
|
||||
new EthPeers(
|
||||
() -> protocolSchedule.getByBlockHeader(blockchain.getChainHeadHeader()),
|
||||
TestClock.fixed(),
|
||||
new NoOpMetricsSystem(),
|
||||
EthProtocolConfiguration.DEFAULT_MAX_MESSAGE_SIZE,
|
||||
Collections.emptyList(),
|
||||
Bytes.random(64),
|
||||
25,
|
||||
25,
|
||||
false,
|
||||
SyncMode.FAST,
|
||||
new ForkIdManager(blockchain, Collections.emptyList(), Collections.emptyList(), false));
|
||||
|
||||
final ChainHeadTracker chainHeadTrackerMock = getChainHeadTrackerMock();
|
||||
ethPeers.setChainHeadTracker(chainHeadTrackerMock);
|
||||
|
||||
final EthMessages messages = new EthMessages();
|
||||
|
||||
return create(
|
||||
blockchain,
|
||||
ethScheduler,
|
||||
BlockchainSetupUtil.forTesting(DataStorageFormat.FOREST).getWorldArchive(),
|
||||
mock(TransactionPool.class),
|
||||
EthProtocolConfiguration.defaultConfig(),
|
||||
ethPeers,
|
||||
messages,
|
||||
new EthContext(ethPeers, messages, ethScheduler));
|
||||
}
|
||||
|
||||
public static EthProtocolManager create() {
|
||||
return create(TimeoutPolicy.NEVER_TIMEOUT);
|
||||
}
|
||||
|
||||
public static EthProtocolManager create(final TimeoutPolicy timeoutPolicy) {
|
||||
return create(new DeterministicEthScheduler(timeoutPolicy));
|
||||
}
|
||||
|
||||
// Utility to prevent scheduler from automatically running submitted tasks
|
||||
public static void disableEthSchedulerAutoRun(final EthProtocolManager ethProtocolManager) {
|
||||
final EthScheduler scheduler = ethProtocolManager.ethContext().getScheduler();
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.hyperledger.besu.ethereum.eth.manager.EthMessages;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthPeer;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthPeers;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestBuilder;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer;
|
||||
@@ -146,15 +147,16 @@ public abstract class AbstractMessageTaskTest<T, R> {
|
||||
transactionPool.setEnabled();
|
||||
|
||||
ethProtocolManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
blockchain,
|
||||
ethScheduler,
|
||||
protocolContext.getWorldStateArchive(),
|
||||
transactionPool,
|
||||
EthProtocolConfiguration.defaultConfig(),
|
||||
ethPeers,
|
||||
ethMessages,
|
||||
ethContext);
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(blockchain)
|
||||
.setEthScheduler(ethScheduler)
|
||||
.setTransactionPool(transactionPool)
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.setEthPeers(ethPeers)
|
||||
.setEthMessages(ethMessages)
|
||||
.setEthContext(ethContext)
|
||||
.build();
|
||||
}
|
||||
|
||||
protected abstract T generateDataToBeRequested();
|
||||
|
||||
@@ -18,6 +18,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestBuilder;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
|
||||
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
||||
import org.hyperledger.besu.plugin.services.MetricsSystem;
|
||||
@@ -36,7 +37,7 @@ public class WaitForPeerTaskTest {
|
||||
|
||||
@BeforeEach
|
||||
public void setupTest() {
|
||||
ethProtocolManager = EthProtocolManagerTestUtil.create();
|
||||
ethProtocolManager = EthProtocolManagerTestBuilder.builder().build();
|
||||
ethContext = ethProtocolManager.ethContext();
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestBuilder;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
|
||||
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
||||
import org.hyperledger.besu.plugin.services.MetricsSystem;
|
||||
@@ -36,7 +37,7 @@ public class WaitForPeersTaskTest {
|
||||
|
||||
@BeforeEach
|
||||
public void setupTest() {
|
||||
ethProtocolManager = EthProtocolManagerTestUtil.create();
|
||||
ethProtocolManager = EthProtocolManagerTestBuilder.builder().build();
|
||||
ethContext = ethProtocolManager.ethContext();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.hyperledger.besu.ethereum.core.BlockDataGenerator;
|
||||
import org.hyperledger.besu.ethereum.core.BlockDataGenerator.BlockOptions;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthPeer;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestBuilder;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer;
|
||||
import org.hyperledger.besu.ethereum.eth.messages.BlockHeadersMessage;
|
||||
@@ -43,7 +44,11 @@ public abstract class AbstractPeerBlockValidatorTest {
|
||||
@Test
|
||||
public void validatePeer_unresponsivePeer() {
|
||||
final EthProtocolManager ethProtocolManager =
|
||||
EthProtocolManagerTestUtil.create(DeterministicEthScheduler.TimeoutPolicy.ALWAYS_TIMEOUT);
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setEthScheduler(
|
||||
new DeterministicEthScheduler(
|
||||
DeterministicEthScheduler.TimeoutPolicy.ALWAYS_TIMEOUT))
|
||||
.build();
|
||||
final long blockNumber = 500;
|
||||
|
||||
final PeerValidator validator = createValidator(blockNumber, 0);
|
||||
@@ -61,7 +66,7 @@ public abstract class AbstractPeerBlockValidatorTest {
|
||||
|
||||
@Test
|
||||
public void validatePeer_requestBlockFromPeerBeingTested() {
|
||||
final EthProtocolManager ethProtocolManager = EthProtocolManagerTestUtil.create();
|
||||
final EthProtocolManager ethProtocolManager = EthProtocolManagerTestBuilder.builder().build();
|
||||
final BlockDataGenerator gen = new BlockDataGenerator(1);
|
||||
final long blockNumber = 500;
|
||||
final Block block = gen.block(BlockOptions.create().setBlockNumber(blockNumber));
|
||||
@@ -97,7 +102,11 @@ public abstract class AbstractPeerBlockValidatorTest {
|
||||
public void canBeValidated() {
|
||||
final BlockDataGenerator gen = new BlockDataGenerator(1);
|
||||
final EthProtocolManager ethProtocolManager =
|
||||
EthProtocolManagerTestUtil.create(DeterministicEthScheduler.TimeoutPolicy.ALWAYS_TIMEOUT);
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setEthScheduler(
|
||||
new DeterministicEthScheduler(
|
||||
DeterministicEthScheduler.TimeoutPolicy.ALWAYS_TIMEOUT))
|
||||
.build();
|
||||
final long blockNumber = 500;
|
||||
final long buffer = 10;
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.hyperledger.besu.ethereum.core.BlockDataGenerator;
|
||||
import org.hyperledger.besu.ethereum.core.BlockDataGenerator.BlockOptions;
|
||||
import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestBuilder;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer;
|
||||
import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderValidator;
|
||||
@@ -42,7 +43,7 @@ public class DaoForkPeerValidatorTest extends AbstractPeerBlockValidatorTest {
|
||||
|
||||
@Test
|
||||
public void validatePeer_responsivePeerOnRightSideOfFork() {
|
||||
final EthProtocolManager ethProtocolManager = EthProtocolManagerTestUtil.create();
|
||||
final EthProtocolManager ethProtocolManager = EthProtocolManagerTestBuilder.builder().build();
|
||||
final BlockDataGenerator gen = new BlockDataGenerator(1);
|
||||
final long daoBlockNumber = 500;
|
||||
final Block daoBlock =
|
||||
@@ -73,7 +74,7 @@ public class DaoForkPeerValidatorTest extends AbstractPeerBlockValidatorTest {
|
||||
|
||||
@Test
|
||||
public void validatePeer_responsivePeerOnWrongSideOfFork() {
|
||||
final EthProtocolManager ethProtocolManager = EthProtocolManagerTestUtil.create();
|
||||
final EthProtocolManager ethProtocolManager = EthProtocolManagerTestBuilder.builder().build();
|
||||
final BlockDataGenerator gen = new BlockDataGenerator(1);
|
||||
final long daoBlockNumber = 500;
|
||||
final Block daoBlock =
|
||||
@@ -101,7 +102,7 @@ public class DaoForkPeerValidatorTest extends AbstractPeerBlockValidatorTest {
|
||||
|
||||
@Test
|
||||
public void validatePeer_responsivePeerDoesNotHaveBlockWhenPastForkHeight() {
|
||||
final EthProtocolManager ethProtocolManager = EthProtocolManagerTestUtil.create();
|
||||
final EthProtocolManager ethProtocolManager = EthProtocolManagerTestBuilder.builder().build();
|
||||
final long daoBlockNumber = 500;
|
||||
|
||||
final PeerValidator validator =
|
||||
|
||||
@@ -25,6 +25,7 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthPeer;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestBuilder;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
|
||||
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.messages.DisconnectMessage.DisconnectReason;
|
||||
|
||||
@@ -39,7 +40,7 @@ public class PeerValidatorRunnerTest {
|
||||
public void checkPeer_schedulesFutureCheckWhenPeerNotReady() {
|
||||
final PeerValidator validator = mock(PeerValidator.class);
|
||||
|
||||
final EthProtocolManager ethProtocolManager = EthProtocolManagerTestUtil.create();
|
||||
final EthProtocolManager ethProtocolManager = EthProtocolManagerTestBuilder.builder().build();
|
||||
EthProtocolManagerTestUtil.disableEthSchedulerAutoRun(ethProtocolManager);
|
||||
final EthPeer peer =
|
||||
EthProtocolManagerTestUtil.peerBuilder()
|
||||
@@ -78,7 +79,7 @@ public class PeerValidatorRunnerTest {
|
||||
public void checkPeer_doesNotScheduleFutureCheckWhenPeerNotReadyAndDisconnected() {
|
||||
final PeerValidator validator = mock(PeerValidator.class);
|
||||
|
||||
final EthProtocolManager ethProtocolManager = EthProtocolManagerTestUtil.create();
|
||||
final EthProtocolManager ethProtocolManager = EthProtocolManagerTestBuilder.builder().build();
|
||||
EthProtocolManagerTestUtil.disableEthSchedulerAutoRun(ethProtocolManager);
|
||||
final EthPeer peer =
|
||||
EthProtocolManagerTestUtil.peerBuilder()
|
||||
@@ -105,7 +106,7 @@ public class PeerValidatorRunnerTest {
|
||||
public void checkPeer_handlesInvalidPeer() {
|
||||
final PeerValidator validator = mock(PeerValidator.class);
|
||||
|
||||
final EthProtocolManager ethProtocolManager = EthProtocolManagerTestUtil.create();
|
||||
final EthProtocolManager ethProtocolManager = EthProtocolManagerTestBuilder.builder().build();
|
||||
EthProtocolManagerTestUtil.disableEthSchedulerAutoRun(ethProtocolManager);
|
||||
final EthPeer peer =
|
||||
EthProtocolManagerTestUtil.peerBuilder()
|
||||
@@ -138,7 +139,7 @@ public class PeerValidatorRunnerTest {
|
||||
public void checkPeer_handlesValidPeer() {
|
||||
final PeerValidator validator = mock(PeerValidator.class);
|
||||
|
||||
final EthProtocolManager ethProtocolManager = EthProtocolManagerTestUtil.create();
|
||||
final EthProtocolManager ethProtocolManager = EthProtocolManagerTestBuilder.builder().build();
|
||||
EthProtocolManagerTestUtil.disableEthSchedulerAutoRun(ethProtocolManager);
|
||||
final EthPeer peer =
|
||||
EthProtocolManagerTestUtil.peerBuilder()
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.hyperledger.besu.ethereum.core.BlockDataGenerator;
|
||||
import org.hyperledger.besu.ethereum.core.BlockDataGenerator.BlockOptions;
|
||||
import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestBuilder;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer;
|
||||
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
||||
@@ -41,7 +42,10 @@ public class RequiredBlocksPeerValidatorTest extends AbstractPeerBlockValidatorT
|
||||
|
||||
@Test
|
||||
public void validatePeer_responsivePeerWithRequiredBlock() {
|
||||
final EthProtocolManager ethProtocolManager = EthProtocolManagerTestUtil.create();
|
||||
final EthProtocolManager ethProtocolManager =
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(ProtocolScheduleFixture.MAINNET)
|
||||
.build();
|
||||
final BlockDataGenerator gen = new BlockDataGenerator(1);
|
||||
final long requiredBlockNumber = 500;
|
||||
final Block requiredBlock =
|
||||
@@ -73,7 +77,7 @@ public class RequiredBlocksPeerValidatorTest extends AbstractPeerBlockValidatorT
|
||||
|
||||
@Test
|
||||
public void validatePeer_responsivePeerWithBadRequiredBlock() {
|
||||
final EthProtocolManager ethProtocolManager = EthProtocolManagerTestUtil.create();
|
||||
final EthProtocolManager ethProtocolManager = EthProtocolManagerTestBuilder.builder().build();
|
||||
final BlockDataGenerator gen = new BlockDataGenerator(1);
|
||||
final long requiredBlockNumber = 500;
|
||||
final Block requiredBlock =
|
||||
@@ -105,7 +109,7 @@ public class RequiredBlocksPeerValidatorTest extends AbstractPeerBlockValidatorT
|
||||
|
||||
@Test
|
||||
public void validatePeer_responsivePeerDoesNotHaveBlockWhenPastForkHeight() {
|
||||
final EthProtocolManager ethProtocolManager = EthProtocolManagerTestUtil.create();
|
||||
final EthProtocolManager ethProtocolManager = EthProtocolManagerTestBuilder.builder().build();
|
||||
|
||||
final PeerValidator validator =
|
||||
new RequiredBlocksPeerValidator(
|
||||
|
||||
@@ -45,6 +45,7 @@ import org.hyperledger.besu.ethereum.eth.manager.EthContext;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthMessages;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthPeers;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestBuilder;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer;
|
||||
@@ -110,12 +111,13 @@ public abstract class AbstractBlockPropagationManagerTest {
|
||||
tempProtocolContext.getConsensusContext(ConsensusContext.class),
|
||||
new BadBlockManager());
|
||||
ethProtocolManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
blockchain,
|
||||
blockchainUtil.getWorldArchive(),
|
||||
blockchainUtil.getTransactionPool(),
|
||||
EthProtocolConfiguration.defaultConfig());
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(blockchain)
|
||||
.setWorldStateArchive(blockchainUtil.getWorldArchive())
|
||||
.setTransactionPool(blockchainUtil.getTransactionPool())
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.build();
|
||||
syncConfig = SynchronizerConfiguration.builder().blockPropagationRange(-3, 5).build();
|
||||
syncState = new SyncState(blockchain, ethProtocolManager.ethContext().getEthPeers());
|
||||
blockBroadcaster = mock(BlockBroadcaster.class);
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.hyperledger.besu.ethereum.core.MiningConfiguration;
|
||||
import org.hyperledger.besu.ethereum.difficulty.fixed.FixedDifficultyProtocolSchedule;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.ChainState;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestBuilder;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer.Responder;
|
||||
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
|
||||
@@ -76,7 +76,7 @@ public class ChainHeadTrackerTest {
|
||||
public void setup(final DataStorageFormat storageFormat) {
|
||||
blockchainSetupUtil = BlockchainSetupUtil.forTesting(storageFormat);
|
||||
blockchain = blockchainSetupUtil.getBlockchain();
|
||||
ethProtocolManager = EthProtocolManagerTestUtil.create(blockchain);
|
||||
ethProtocolManager = EthProtocolManagerTestBuilder.builder().setBlockchain(blockchain).build();
|
||||
respondingPeer =
|
||||
RespondingEthPeer.builder()
|
||||
.ethProtocolManager(ethProtocolManager)
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.hyperledger.besu.ethereum.core.BlockHeader;
|
||||
import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthPeer;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestBuilder;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer;
|
||||
import org.hyperledger.besu.ethereum.eth.sync.range.RangeHeaders;
|
||||
@@ -65,7 +66,7 @@ public class DownloadHeadersStepTest {
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
ethProtocolManager = EthProtocolManagerTestUtil.create(blockchain);
|
||||
ethProtocolManager = EthProtocolManagerTestBuilder.builder().setBlockchain(blockchain).build();
|
||||
downloader =
|
||||
new DownloadHeadersStep(
|
||||
protocolSchedule,
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil;
|
||||
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestBuilder;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer.Responder;
|
||||
@@ -36,6 +37,7 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
|
||||
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
||||
import org.hyperledger.besu.plugin.services.MetricsSystem;
|
||||
import org.hyperledger.besu.plugin.services.storage.DataStorageFormat;
|
||||
import org.hyperledger.besu.testutil.DeterministicEthScheduler;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@@ -73,13 +75,14 @@ public class RangeHeadersFetcherTest {
|
||||
@BeforeEach
|
||||
public void setUpTest() {
|
||||
ethProtocolManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
blockchain,
|
||||
() -> false,
|
||||
protocolContext.getWorldStateArchive(),
|
||||
transactionPool,
|
||||
EthProtocolConfiguration.defaultConfig());
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(blockchain)
|
||||
.setEthScheduler(new DeterministicEthScheduler(() -> false))
|
||||
.setWorldStateArchive(protocolContext.getWorldStateArchive())
|
||||
.setTransactionPool(transactionPool)
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.build();
|
||||
responder =
|
||||
RespondingEthPeer.blockchainResponder(
|
||||
blockchain, protocolContext.getWorldStateArchive(), transactionPool);
|
||||
|
||||
@@ -40,6 +40,7 @@ import org.hyperledger.besu.ethereum.core.MiningConfiguration;
|
||||
import org.hyperledger.besu.ethereum.core.TransactionReceipt;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestBuilder;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer;
|
||||
import org.hyperledger.besu.ethereum.eth.sync.state.SyncState;
|
||||
@@ -144,7 +145,11 @@ public class BackwardSyncContextTest {
|
||||
}
|
||||
}
|
||||
when(protocolContext.getBlockchain()).thenReturn(localBlockchain);
|
||||
EthProtocolManager ethProtocolManager = EthProtocolManagerTestUtil.create();
|
||||
EthProtocolManager ethProtocolManager =
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(localBlockchain)
|
||||
.build();
|
||||
|
||||
peer = EthProtocolManagerTestUtil.createPeer(ethProtocolManager);
|
||||
EthContext ethContext = ethProtocolManager.ethContext();
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.hyperledger.besu.ethereum.core.MiningConfiguration;
|
||||
import org.hyperledger.besu.ethereum.core.TransactionReceipt;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestBuilder;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.exceptions.MaxRetriesReachedException;
|
||||
import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions;
|
||||
@@ -130,7 +130,8 @@ public class BackwardSyncStepTest {
|
||||
when(context.getProtocolSchedule()).thenReturn(protocolSchedule);
|
||||
when(context.getBatchSize()).thenReturn(5);
|
||||
|
||||
EthProtocolManager ethProtocolManager = EthProtocolManagerTestUtil.create(ethScheduler);
|
||||
EthProtocolManager ethProtocolManager =
|
||||
EthProtocolManagerTestBuilder.builder().setEthScheduler(ethScheduler).build();
|
||||
|
||||
peer =
|
||||
RespondingEthPeer.builder()
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.hyperledger.besu.ethereum.core.MiningConfiguration;
|
||||
import org.hyperledger.besu.ethereum.core.TransactionReceipt;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestBuilder;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer;
|
||||
import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions;
|
||||
@@ -127,7 +128,7 @@ public class ForwardSyncStepTest {
|
||||
when(context.getProtocolContext().getBlockchain()).thenReturn(localBlockchain);
|
||||
when(context.getProtocolSchedule()).thenReturn(protocolSchedule);
|
||||
when(context.getBatchSize()).thenReturn(2);
|
||||
EthProtocolManager ethProtocolManager = EthProtocolManagerTestUtil.create();
|
||||
EthProtocolManager ethProtocolManager = EthProtocolManagerTestBuilder.builder().build();
|
||||
|
||||
peer = EthProtocolManagerTestUtil.createPeer(ethProtocolManager);
|
||||
EthContext ethContext = ethProtocolManager.ethContext();
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.hyperledger.besu.ethereum.core.Difficulty;
|
||||
import org.hyperledger.besu.ethereum.core.TransactionReceipt;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestBuilder;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer;
|
||||
@@ -121,10 +122,11 @@ public class CheckPointSyncChainDownloaderTest {
|
||||
protocolSchedule = localBlockchainSetup.getProtocolSchedule();
|
||||
protocolContext = localBlockchainSetup.getProtocolContext();
|
||||
ethProtocolManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
localBlockchain,
|
||||
new EthScheduler(1, 1, 1, 1, new NoOpMetricsSystem()));
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(localBlockchain)
|
||||
.setEthScheduler(new EthScheduler(1, 1, 1, 1, new NoOpMetricsSystem()))
|
||||
.build();
|
||||
ethContext = ethProtocolManager.ethContext();
|
||||
|
||||
final int blockNumber = 10;
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.hyperledger.besu.ethereum.core.Transaction;
|
||||
import org.hyperledger.besu.ethereum.core.TransactionReceipt;
|
||||
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestBuilder;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.peertask.PeerTaskExecutor;
|
||||
@@ -42,6 +43,7 @@ import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
|
||||
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
|
||||
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
||||
import org.hyperledger.besu.plugin.services.storage.DataStorageFormat;
|
||||
import org.hyperledger.besu.testutil.DeterministicEthScheduler;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -78,13 +80,14 @@ public class DownloadReceiptsStepTest {
|
||||
peerTaskExecutor = mock(PeerTaskExecutor.class);
|
||||
TransactionPool transactionPool = mock(TransactionPool.class);
|
||||
ethProtocolManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
ProtocolScheduleFixture.MAINNET,
|
||||
blockchain,
|
||||
() -> false,
|
||||
protocolContext.getWorldStateArchive(),
|
||||
transactionPool,
|
||||
EthProtocolConfiguration.defaultConfig());
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(ProtocolScheduleFixture.MAINNET)
|
||||
.setBlockchain(blockchain)
|
||||
.setEthScheduler(new DeterministicEthScheduler(() -> false))
|
||||
.setWorldStateArchive(protocolContext.getWorldStateArchive())
|
||||
.setTransactionPool(transactionPool)
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.hyperledger.besu.ethereum.eth.manager.EthContext;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthPeer;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthPeers;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestBuilder;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.peertask.PeerTaskExecutor;
|
||||
@@ -45,6 +46,7 @@ import org.hyperledger.besu.ethereum.worldstate.WorldStateStorageCoordinator;
|
||||
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
||||
import org.hyperledger.besu.plugin.services.MetricsSystem;
|
||||
import org.hyperledger.besu.plugin.services.storage.DataStorageFormat;
|
||||
import org.hyperledger.besu.testutil.DeterministicEthScheduler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -93,13 +95,15 @@ public class FastSyncActionsTest {
|
||||
blockchainSetupUtil.importAllBlocks();
|
||||
blockchain = blockchainSetupUtil.getBlockchain();
|
||||
ethProtocolManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
ProtocolScheduleFixture.MAINNET,
|
||||
blockchain,
|
||||
() -> timeoutCount.getAndDecrement() > 0,
|
||||
blockchainSetupUtil.getWorldArchive(),
|
||||
blockchainSetupUtil.getTransactionPool(),
|
||||
EthProtocolConfiguration.defaultConfig());
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(ProtocolScheduleFixture.MAINNET)
|
||||
.setBlockchain(blockchain)
|
||||
.setEthScheduler(
|
||||
new DeterministicEthScheduler(() -> timeoutCount.getAndDecrement() > 0))
|
||||
.setWorldStateArchive(blockchainSetupUtil.getWorldArchive())
|
||||
.setTransactionPool(blockchainSetupUtil.getTransactionPool())
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.build();
|
||||
ethContext = ethProtocolManager.ethContext();
|
||||
ethPeers = ethContext.getEthPeers();
|
||||
syncState = new SyncState(blockchain, ethPeers);
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
|
||||
import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestBuilder;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer;
|
||||
@@ -87,10 +88,11 @@ public class FastSyncChainDownloaderTest {
|
||||
protocolSchedule = localBlockchainSetup.getProtocolSchedule();
|
||||
protocolContext = localBlockchainSetup.getProtocolContext();
|
||||
ethProtocolManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
localBlockchain,
|
||||
new EthScheduler(1, 1, 1, 1, new NoOpMetricsSystem()));
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(localBlockchain)
|
||||
.setEthScheduler(new EthScheduler(1, 1, 1, 1, new NoOpMetricsSystem()))
|
||||
.build();
|
||||
|
||||
ethContext = ethProtocolManager.ethContext();
|
||||
syncState = new SyncState(protocolContext.getBlockchain(), ethContext.getEthPeers());
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
|
||||
import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil;
|
||||
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestBuilder;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer.Responder;
|
||||
@@ -35,6 +36,7 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
|
||||
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
||||
import org.hyperledger.besu.plugin.services.MetricsSystem;
|
||||
import org.hyperledger.besu.plugin.services.storage.DataStorageFormat;
|
||||
import org.hyperledger.besu.testutil.DeterministicEthScheduler;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@@ -79,13 +81,14 @@ public class PivotBlockConfirmerTest {
|
||||
protocolSchedule = blockchainSetupUtil.getProtocolSchedule();
|
||||
protocolContext = blockchainSetupUtil.getProtocolContext();
|
||||
ethProtocolManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
blockchain,
|
||||
timeout::get,
|
||||
blockchainSetupUtil.getWorldArchive(),
|
||||
transactionPool,
|
||||
EthProtocolConfiguration.defaultConfig());
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(blockchain)
|
||||
.setEthScheduler(new DeterministicEthScheduler(timeout::get))
|
||||
.setWorldStateArchive(blockchainSetupUtil.getWorldArchive())
|
||||
.setTransactionPool(transactionPool)
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.build();
|
||||
pivotBlockConfirmer = createPivotBlockConfirmer(3, 2);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil;
|
||||
import org.hyperledger.besu.ethereum.core.Difficulty;
|
||||
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestBuilder;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer.Responder;
|
||||
@@ -37,6 +38,7 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
|
||||
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
||||
import org.hyperledger.besu.plugin.services.MetricsSystem;
|
||||
import org.hyperledger.besu.plugin.services.storage.DataStorageFormat;
|
||||
import org.hyperledger.besu.testutil.DeterministicEthScheduler;
|
||||
import org.hyperledger.besu.util.ExceptionUtils;
|
||||
|
||||
import java.util.Optional;
|
||||
@@ -82,13 +84,14 @@ public class PivotBlockRetrieverTest {
|
||||
protocolContext = blockchainSetupUtil.getProtocolContext();
|
||||
transactionPool = blockchainSetupUtil.getTransactionPool();
|
||||
ethProtocolManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
blockchain,
|
||||
timeout::get,
|
||||
blockchainSetupUtil.getWorldArchive(),
|
||||
transactionPool,
|
||||
EthProtocolConfiguration.defaultConfig());
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(blockchain)
|
||||
.setEthScheduler(new DeterministicEthScheduler(timeout::get))
|
||||
.setWorldStateArchive(blockchainSetupUtil.getWorldArchive())
|
||||
.setTransactionPool(transactionPool)
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.build();
|
||||
|
||||
pivotBlockRetriever = createPivotBlockRetriever(3, 1, 1);
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.hyperledger.besu.ethereum.core.MutableWorldState;
|
||||
import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestBuilder;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer;
|
||||
@@ -114,7 +115,9 @@ class FastWorldStateDownloaderTest {
|
||||
.build());
|
||||
|
||||
final EthProtocolManager ethProtocolManager =
|
||||
EthProtocolManagerTestUtil.create(new EthScheduler(1, 1, 1, 1, new NoOpMetricsSystem()));
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setEthScheduler(new EthScheduler(1, 1, 1, 1, new NoOpMetricsSystem()))
|
||||
.build();
|
||||
|
||||
@AfterEach
|
||||
public void tearDown() throws Exception {
|
||||
@@ -238,7 +241,10 @@ class FastWorldStateDownloaderTest {
|
||||
void canRecoverFromTimeouts() {
|
||||
final DeterministicEthScheduler.TimeoutPolicy timeoutPolicy =
|
||||
DeterministicEthScheduler.TimeoutPolicy.timeoutXTimes(2);
|
||||
final EthProtocolManager ethProtocolManager = EthProtocolManagerTestUtil.create(timeoutPolicy);
|
||||
final EthProtocolManager ethProtocolManager =
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setEthScheduler(new DeterministicEthScheduler(timeoutPolicy))
|
||||
.build();
|
||||
final MockExecutorService serviceExecutor =
|
||||
((DeterministicEthScheduler) ethProtocolManager.ethContext().getScheduler())
|
||||
.mockServiceExecutor();
|
||||
@@ -382,7 +388,7 @@ class FastWorldStateDownloaderTest {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void testCancellation(final boolean shouldCancelFuture) {
|
||||
final EthProtocolManager ethProtocolManager = EthProtocolManagerTestUtil.create();
|
||||
final EthProtocolManager ethProtocolManager = EthProtocolManagerTestBuilder.builder().build();
|
||||
// Prevent the persistence service from running
|
||||
final MockExecutorService serviceExecutor =
|
||||
((DeterministicEthScheduler) ethProtocolManager.ethContext().getScheduler())
|
||||
@@ -661,7 +667,9 @@ class FastWorldStateDownloaderTest {
|
||||
@Timeout(value = 60)
|
||||
void stalledDownloader() {
|
||||
final EthProtocolManager ethProtocolManager =
|
||||
EthProtocolManagerTestUtil.create(new EthScheduler(1, 1, 1, 1, new NoOpMetricsSystem()));
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setEthScheduler(new EthScheduler(1, 1, 1, 1, new NoOpMetricsSystem()))
|
||||
.build();
|
||||
|
||||
// Setup "remote" state
|
||||
final ForestWorldStateKeyValueStorage remoteStorage =
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.hyperledger.besu.ethereum.core.Difficulty;
|
||||
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestBuilder;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer;
|
||||
@@ -66,13 +67,14 @@ public class FullSyncChainDownloaderForkTest {
|
||||
protocolSchedule = localBlockchainSetup.getProtocolSchedule();
|
||||
protocolContext = localBlockchainSetup.getProtocolContext();
|
||||
ethProtocolManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
localBlockchain,
|
||||
new EthScheduler(1, 1, 1, 1, new NoOpMetricsSystem()),
|
||||
localBlockchainSetup.getWorldArchive(),
|
||||
localBlockchainSetup.getTransactionPool(),
|
||||
EthProtocolConfiguration.defaultConfig());
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(localBlockchain)
|
||||
.setEthScheduler(new EthScheduler(1, 1, 1, 1, new NoOpMetricsSystem()))
|
||||
.setWorldStateArchive(localBlockchainSetup.getWorldArchive())
|
||||
.setTransactionPool(localBlockchainSetup.getTransactionPool())
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.build();
|
||||
ethContext = ethProtocolManager.ethContext();
|
||||
syncState = new SyncState(protocolContext.getBlockchain(), ethContext.getEthPeers());
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.hyperledger.besu.ethereum.core.TransactionReceipt;
|
||||
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestBuilder;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer;
|
||||
@@ -96,13 +97,14 @@ public class FullSyncChainDownloaderTest {
|
||||
protocolSchedule = localBlockchainSetup.getProtocolSchedule();
|
||||
protocolContext = localBlockchainSetup.getProtocolContext();
|
||||
ethProtocolManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
localBlockchain,
|
||||
new EthScheduler(1, 1, 1, 1, new NoOpMetricsSystem()),
|
||||
localBlockchainSetup.getWorldArchive(),
|
||||
localBlockchainSetup.getTransactionPool(),
|
||||
EthProtocolConfiguration.defaultConfig());
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(localBlockchain)
|
||||
.setEthScheduler(new EthScheduler(1, 1, 1, 1, new NoOpMetricsSystem()))
|
||||
.setWorldStateArchive(localBlockchainSetup.getWorldArchive())
|
||||
.setTransactionPool(localBlockchainSetup.getTransactionPool())
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.build();
|
||||
ethContext = ethProtocolManager.ethContext();
|
||||
syncState = new SyncState(protocolContext.getBlockchain(), ethContext.getEthPeers());
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.hyperledger.besu.ethereum.core.Difficulty;
|
||||
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestBuilder;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer;
|
||||
@@ -80,13 +81,14 @@ public class FullSyncChainDownloaderTotalTerminalDifficultyTest {
|
||||
protocolSchedule = localBlockchainSetup.getProtocolSchedule();
|
||||
protocolContext = localBlockchainSetup.getProtocolContext();
|
||||
ethProtocolManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
localBlockchain,
|
||||
new EthScheduler(1, 1, 1, 1, new NoOpMetricsSystem()),
|
||||
localBlockchainSetup.getWorldArchive(),
|
||||
localBlockchainSetup.getTransactionPool(),
|
||||
EthProtocolConfiguration.defaultConfig());
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(localBlockchain)
|
||||
.setEthScheduler(new EthScheduler(1, 1, 1, 1, new NoOpMetricsSystem()))
|
||||
.setWorldStateArchive(localBlockchainSetup.getWorldArchive())
|
||||
.setTransactionPool(localBlockchainSetup.getTransactionPool())
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.build();
|
||||
ethContext = ethProtocolManager.ethContext();
|
||||
syncState = new SyncState(protocolContext.getBlockchain(), ethContext.getEthPeers());
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil;
|
||||
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestBuilder;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer;
|
||||
@@ -71,13 +72,14 @@ public class FullSyncDownloaderTest {
|
||||
protocolSchedule = localBlockchainSetup.getProtocolSchedule();
|
||||
protocolContext = localBlockchainSetup.getProtocolContext();
|
||||
ethProtocolManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
localBlockchain,
|
||||
new EthScheduler(1, 1, 1, 1, new NoOpMetricsSystem()),
|
||||
localBlockchainSetup.getWorldArchive(),
|
||||
localBlockchainSetup.getTransactionPool(),
|
||||
EthProtocolConfiguration.defaultConfig());
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(localBlockchain)
|
||||
.setEthScheduler(new EthScheduler(1, 1, 1, 1, new NoOpMetricsSystem()))
|
||||
.setWorldStateArchive(localBlockchainSetup.getWorldArchive())
|
||||
.setTransactionPool(localBlockchainSetup.getTransactionPool())
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.build();
|
||||
ethContext = ethProtocolManager.ethContext();
|
||||
syncState = new SyncState(protocolContext.getBlockchain(), ethContext.getEthPeers());
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture;
|
||||
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestBuilder;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer;
|
||||
@@ -81,13 +82,14 @@ public class FullSyncTargetManagerTest {
|
||||
new ProtocolContext(
|
||||
localBlockchain, localWorldState, mock(ConsensusContext.class), new BadBlockManager());
|
||||
ethProtocolManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
localBlockchain,
|
||||
new EthScheduler(1, 1, 1, 1, new NoOpMetricsSystem()),
|
||||
localWorldState,
|
||||
localBlockchainSetup.getTransactionPool(),
|
||||
EthProtocolConfiguration.defaultConfig());
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(localBlockchain)
|
||||
.setEthScheduler(new EthScheduler(1, 1, 1, 1, new NoOpMetricsSystem()))
|
||||
.setWorldStateArchive(localBlockchainSetup.getWorldArchive())
|
||||
.setTransactionPool(localBlockchainSetup.getTransactionPool())
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.build();
|
||||
final EthContext ethContext = ethProtocolManager.ethContext();
|
||||
localBlockchainSetup.importFirstBlocks(5);
|
||||
otherBlockchainSetup.importFirstBlocks(20);
|
||||
|
||||
@@ -42,6 +42,7 @@ import org.hyperledger.besu.ethereum.eth.manager.ChainState;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthPeer;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthPeers;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestBuilder;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer;
|
||||
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.messages.DisconnectMessage.DisconnectReason;
|
||||
@@ -90,7 +91,7 @@ public class SyncStateTest {
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
ethProtocolManager = EthProtocolManagerTestUtil.create(blockchain);
|
||||
ethProtocolManager = EthProtocolManagerTestBuilder.builder().setBlockchain(blockchain).build();
|
||||
ethPeers = spy(ethProtocolManager.ethContext().getEthPeers());
|
||||
syncTargetPeer = createPeer(TARGET_DIFFICULTY, TARGET_CHAIN_HEIGHT);
|
||||
otherPeer = createPeer(Difficulty.ZERO, 0);
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.hyperledger.besu.ethereum.core.TransactionReceipt;
|
||||
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestBuilder;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.task.EthTask;
|
||||
@@ -135,12 +136,13 @@ public class DetermineCommonAncestorTaskParameterizedTest {
|
||||
|
||||
final WorldStateArchive worldStateArchive = createInMemoryWorldStateArchive();
|
||||
final EthProtocolManager ethProtocolManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
localBlockchain,
|
||||
worldStateArchive,
|
||||
mock(TransactionPool.class),
|
||||
EthProtocolConfiguration.defaultConfig());
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(localBlockchain)
|
||||
.setWorldStateArchive(worldStateArchive)
|
||||
.setTransactionPool(mock(TransactionPool.class))
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.build();
|
||||
final RespondingEthPeer.Responder responder =
|
||||
RespondingEthPeer.blockchainResponder(remoteBlockchain);
|
||||
final RespondingEthPeer respondingEthPeer =
|
||||
|
||||
@@ -41,6 +41,7 @@ import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthPeer;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestBuilder;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.exceptions.EthTaskException;
|
||||
@@ -81,12 +82,13 @@ public class DetermineCommonAncestorTaskTest {
|
||||
localBlockchain = createInMemoryBlockchain(localGenesisBlock);
|
||||
final WorldStateArchive worldStateArchive = createInMemoryWorldStateArchive();
|
||||
ethProtocolManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
protocolSchedule,
|
||||
localBlockchain,
|
||||
worldStateArchive,
|
||||
mock(TransactionPool.class),
|
||||
EthProtocolConfiguration.defaultConfig());
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(localBlockchain)
|
||||
.setWorldStateArchive(worldStateArchive)
|
||||
.setTransactionPool(mock(TransactionPool.class))
|
||||
.setEthereumWireProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.build();
|
||||
ethContext = ethProtocolManager.ethContext();
|
||||
protocolContext =
|
||||
new ProtocolContext(
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.hyperledger.besu.ethereum.core.BlockDataGenerator;
|
||||
import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestBuilder;
|
||||
import org.hyperledger.besu.ethereum.eth.sync.tasks.exceptions.InvalidBlockException;
|
||||
import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode;
|
||||
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
|
||||
@@ -70,7 +70,11 @@ public class PersistBlockTaskTest {
|
||||
protocolSchedule = blockchainUtil.getProtocolSchedule();
|
||||
protocolContext = blockchainUtil.getProtocolContext();
|
||||
blockchain = blockchainUtil.getBlockchain();
|
||||
final EthProtocolManager ethProtocolManager = EthProtocolManagerTestUtil.create();
|
||||
final EthProtocolManager ethProtocolManager =
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(blockchain)
|
||||
.build();
|
||||
ethContext = ethProtocolManager.ethContext();
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ import org.hyperledger.besu.ethereum.core.TransactionReceipt;
|
||||
import org.hyperledger.besu.ethereum.core.TransactionTestFixture;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestBuilder;
|
||||
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
|
||||
import org.hyperledger.besu.ethereum.eth.transactions.layered.LayeredTransactionPoolBaseFeeTest;
|
||||
import org.hyperledger.besu.ethereum.eth.transactions.sorter.LegacyTransactionPoolBaseFeeTest;
|
||||
@@ -225,7 +225,11 @@ public abstract class AbstractTransactionPoolTestBase {
|
||||
protocolSchedule = spy(executionContext.getProtocolSchedule());
|
||||
doReturn(protocolSpec).when(protocolSchedule).getByBlockHeader(any());
|
||||
blockGasLimit = blockchain.getChainHeadBlock().getHeader().getGasLimit();
|
||||
ethProtocolManager = EthProtocolManagerTestUtil.create();
|
||||
ethProtocolManager =
|
||||
EthProtocolManagerTestBuilder.builder()
|
||||
.setProtocolSchedule(protocolSchedule)
|
||||
.setBlockchain(blockchain)
|
||||
.build();
|
||||
ethContext = spy(ethProtocolManager.ethContext());
|
||||
|
||||
final EthScheduler ethScheduler = spy(ethContext.getScheduler());
|
||||
|
||||
Reference in New Issue
Block a user