Search in sources :

Example 1 with BlockHeadersMessage

use of org.hyperledger.besu.ethereum.eth.messages.BlockHeadersMessage in project besu by hyperledger.

the class Istanbul99ProtocolManagerTest method respondToEth65GetHeadersUsingIstanbul99.

@Test
public void respondToEth65GetHeadersUsingIstanbul99() throws ExecutionException, InterruptedException, TimeoutException {
    final CompletableFuture<Void> done = new CompletableFuture<>();
    final EthScheduler ethScheduler = new DeterministicEthScheduler(() -> false);
    EthPeers peers = new EthPeers(Istanbul99Protocol.NAME, TestClock.fixed(), new NoOpMetricsSystem(), 25);
    EthMessages messages = new EthMessages();
    final BigInteger networkId = BigInteger.ONE;
    try (final EthProtocolManager ethManager = new Istanbul99ProtocolManager(blockchain, networkId, protocolContext.getWorldStateArchive(), transactionPool, EthProtocolConfiguration.defaultConfig(), peers, messages, new EthContext(peers, messages, ethScheduler), Collections.emptyList(), false, ethScheduler)) {
        final long startBlock = blockchain.getChainHeadBlockNumber() + 1;
        final int blockCount = 5;
        final MessageData messageData = GetBlockHeadersMessage.create(startBlock, blockCount, 0, false);
        final PeerSendHandler onSend = (cap, message, conn) -> {
            if (message.getCode() == EthPV62.STATUS) {
                // Ignore status message
                return;
            }
            assertThat(message.getCode()).isEqualTo(EthPV62.BLOCK_HEADERS);
            final BlockHeadersMessage headersMsg = BlockHeadersMessage.readFrom(message);
            final List<BlockHeader> headers = Lists.newArrayList(headersMsg.getHeaders(protocolSchedule));
            assertThat(headers.size()).isEqualTo(0);
            done.complete(null);
        };
        final PeerConnection peer = setupPeer(ethManager, onSend);
        ethManager.processMessage(Istanbul99Protocol.ISTANBUL99, new DefaultMessage(peer, messageData));
        done.get(10, TimeUnit.SECONDS);
    }
}
Also used : MockPeerConnection(org.hyperledger.besu.ethereum.eth.manager.MockPeerConnection) StatusMessage(org.hyperledger.besu.ethereum.eth.messages.StatusMessage) EthPV62(org.hyperledger.besu.ethereum.eth.messages.EthPV62) PeerSendHandler(org.hyperledger.besu.ethereum.eth.manager.MockPeerConnection.PeerSendHandler) BeforeClass(org.junit.BeforeClass) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) TimeoutException(java.util.concurrent.TimeoutException) CompletableFuture(java.util.concurrent.CompletableFuture) NoOpMetricsSystem(org.hyperledger.besu.metrics.noop.NoOpMetricsSystem) DefaultMessage(org.hyperledger.besu.ethereum.p2p.rlpx.wire.DefaultMessage) EthProtocol(org.hyperledger.besu.ethereum.eth.EthProtocol) ProtocolSchedule(org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule) HashSet(java.util.HashSet) GetBlockHeadersMessage(org.hyperledger.besu.ethereum.eth.messages.GetBlockHeadersMessage) BlockchainSetupUtil(org.hyperledger.besu.ethereum.core.BlockchainSetupUtil) DataStorageFormat(org.hyperledger.besu.ethereum.worldstate.DataStorageFormat) Lists(com.google.common.collect.Lists) EthScheduler(org.hyperledger.besu.ethereum.eth.manager.EthScheduler) PeerConnection(org.hyperledger.besu.ethereum.p2p.rlpx.connections.PeerConnection) BigInteger(java.math.BigInteger) TransactionPool(org.hyperledger.besu.ethereum.eth.transactions.TransactionPool) BlockHeader(org.hyperledger.besu.ethereum.core.BlockHeader) EthProtocolConfiguration(org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration) Blockchain(org.hyperledger.besu.ethereum.chain.Blockchain) EthContext(org.hyperledger.besu.ethereum.eth.manager.EthContext) Set(java.util.Set) Test(org.junit.Test) BlockHeadersMessage(org.hyperledger.besu.ethereum.eth.messages.BlockHeadersMessage) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) EthProtocolManager(org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager) List(java.util.List) MessageData(org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData) EthPeers(org.hyperledger.besu.ethereum.eth.manager.EthPeers) ProtocolContext(org.hyperledger.besu.ethereum.ProtocolContext) DeterministicEthScheduler(org.hyperledger.besu.ethereum.eth.manager.DeterministicEthScheduler) EthMessages(org.hyperledger.besu.ethereum.eth.manager.EthMessages) Capability(org.hyperledger.besu.ethereum.p2p.rlpx.wire.Capability) Collections(java.util.Collections) TestClock(org.hyperledger.besu.testutil.TestClock) DefaultMessage(org.hyperledger.besu.ethereum.p2p.rlpx.wire.DefaultMessage) EthContext(org.hyperledger.besu.ethereum.eth.manager.EthContext) EthMessages(org.hyperledger.besu.ethereum.eth.manager.EthMessages) MockPeerConnection(org.hyperledger.besu.ethereum.eth.manager.MockPeerConnection) PeerConnection(org.hyperledger.besu.ethereum.p2p.rlpx.connections.PeerConnection) MessageData(org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData) DeterministicEthScheduler(org.hyperledger.besu.ethereum.eth.manager.DeterministicEthScheduler) EthPeers(org.hyperledger.besu.ethereum.eth.manager.EthPeers) EthProtocolManager(org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager) CompletableFuture(java.util.concurrent.CompletableFuture) EthScheduler(org.hyperledger.besu.ethereum.eth.manager.EthScheduler) DeterministicEthScheduler(org.hyperledger.besu.ethereum.eth.manager.DeterministicEthScheduler) NoOpMetricsSystem(org.hyperledger.besu.metrics.noop.NoOpMetricsSystem) BigInteger(java.math.BigInteger) List(java.util.List) GetBlockHeadersMessage(org.hyperledger.besu.ethereum.eth.messages.GetBlockHeadersMessage) BlockHeadersMessage(org.hyperledger.besu.ethereum.eth.messages.BlockHeadersMessage) PeerSendHandler(org.hyperledger.besu.ethereum.eth.manager.MockPeerConnection.PeerSendHandler) Test(org.junit.Test)

Example 2 with BlockHeadersMessage

use of org.hyperledger.besu.ethereum.eth.messages.BlockHeadersMessage in project besu by hyperledger.

the class DownloadHeaderSequenceTaskTest method failsWhenPeerReturnsOnlySubsetOfHeaders.

@Test
public void failsWhenPeerReturnsOnlySubsetOfHeaders() {
    final RespondingEthPeer respondingPeer = EthProtocolManagerTestUtil.createPeer(ethProtocolManager);
    // Execute task and wait for response
    final BlockHeader referenceHeader = blockchain.getChainHeadHeader();
    final EthTask<List<BlockHeader>> task = DownloadHeaderSequenceTask.endingAtHeader(protocolSchedule, protocolContext, ethContext, referenceHeader, 10, maxRetries, validationPolicy, metricsSystem);
    final CompletableFuture<List<BlockHeader>> future = task.run();
    // Filter response to include only reference header and previous header
    final RespondingEthPeer.Responder fullResponder = RespondingEthPeer.blockchainResponder(blockchain);
    final RespondingEthPeer.Responder responder = (cap, message) -> {
        final Optional<MessageData> fullResponse = fullResponder.respond(cap, message);
        if (!fullResponse.isPresent() || message.getCode() != EthPV62.GET_BLOCK_HEADERS) {
            return fullResponse;
        }
        final BlockHeadersMessage headersMessage = BlockHeadersMessage.readFrom(fullResponse.get());
        // Filter for a subset of headers
        final List<BlockHeader> headerSubset = headersMessage.getHeaders(protocolSchedule).stream().filter(h -> h.getNumber() >= referenceHeader.getNumber() - 1L).collect(Collectors.toList());
        return Optional.of(BlockHeadersMessage.create(headerSubset));
    };
    respondingPeer.respondTimes(responder, 100);
    assertThat(future.isDone()).isTrue();
    assertThat(future.isCompletedExceptionally()).isTrue();
    assertThatThrownBy(future::get).hasCauseInstanceOf(MaxRetriesReachedException.class);
}
Also used : EthTask(org.hyperledger.besu.ethereum.eth.manager.task.EthTask) EthPV62(org.hyperledger.besu.ethereum.eth.messages.EthPV62) RetryingMessageTaskTest(org.hyperledger.besu.ethereum.eth.manager.ethtaskutils.RetryingMessageTaskTest) BlockHeader(org.hyperledger.besu.ethereum.core.BlockHeader) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) MaxRetriesReachedException(org.hyperledger.besu.ethereum.eth.manager.exceptions.MaxRetriesReachedException) CompletableFuture(java.util.concurrent.CompletableFuture) Test(org.junit.Test) EthProtocolManagerTestUtil(org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil) Collectors(java.util.stream.Collectors) RespondingEthPeer(org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer) ValidationPolicy(org.hyperledger.besu.ethereum.eth.sync.ValidationPolicy) ArrayList(java.util.ArrayList) BlockHeadersMessage(org.hyperledger.besu.ethereum.eth.messages.BlockHeadersMessage) List(java.util.List) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) MessageData(org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData) Optional(java.util.Optional) HeaderValidationMode(org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode) Collections(java.util.Collections) Optional(java.util.Optional) RespondingEthPeer(org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer) ArrayList(java.util.ArrayList) List(java.util.List) BlockHeader(org.hyperledger.besu.ethereum.core.BlockHeader) BlockHeadersMessage(org.hyperledger.besu.ethereum.eth.messages.BlockHeadersMessage) RetryingMessageTaskTest(org.hyperledger.besu.ethereum.eth.manager.ethtaskutils.RetryingMessageTaskTest) Test(org.junit.Test)

Example 3 with BlockHeadersMessage

use of org.hyperledger.besu.ethereum.eth.messages.BlockHeadersMessage in project besu by hyperledger.

the class AbstractGetHeadersFromPeerTask method processResponse.

@Override
protected Optional<List<BlockHeader>> processResponse(final boolean streamClosed, final MessageData message, final EthPeer peer) {
    if (streamClosed) {
        // All outstanding requests have been responded to and we still haven't found the response
        // we wanted. It must have been empty or contain data that didn't match.
        peer.recordUselessResponse("headers");
        return Optional.of(Collections.emptyList());
    }
    final BlockHeadersMessage headersMessage = BlockHeadersMessage.readFrom(message);
    final List<BlockHeader> headers = headersMessage.getHeaders(protocolSchedule);
    if (headers.isEmpty()) {
        // Message contains no data - nothing to do
        LOG.debug("headers.isEmpty. Peer: {}", peer);
        return Optional.empty();
    }
    if (headers.size() > count) {
        // Too many headers - this isn't our response
        LOG.debug("headers.size()>count. Peer: {}", peer);
        return Optional.empty();
    }
    final BlockHeader firstHeader = headers.get(0);
    if (!matchesFirstHeader(firstHeader)) {
        // This isn't our message - nothing to do
        LOG.debug("!matchesFirstHeader. Peer: {}", peer);
        return Optional.empty();
    }
    final List<BlockHeader> headersList = new ArrayList<>();
    headersList.add(firstHeader);
    BlockHeader prevBlockHeader = firstHeader;
    final int expectedDelta = reverse ? -(skip + 1) : (skip + 1);
    for (int i = 1; i < headers.size(); i++) {
        final BlockHeader header = headers.get(i);
        if (header.getNumber() != prevBlockHeader.getNumber() + expectedDelta) {
            // Skip doesn't match, this isn't our data
            LOG.debug("header not matching the expected number. Peer: {}", peer);
            return Optional.empty();
        }
        // if headers are supposed to be sequential check if a chain is formed
        if (Math.abs(expectedDelta) == 1) {
            final BlockHeader parent = reverse ? header : prevBlockHeader;
            final BlockHeader child = reverse ? prevBlockHeader : header;
            if (!parent.getHash().equals(child.getParentHash())) {
                LOG.debug("Sequential headers must form a chain through hashes, disconnecting peer: {}", peer);
                peer.disconnect(DisconnectMessage.DisconnectReason.BREACH_OF_PROTOCOL);
                return Optional.empty();
            }
        }
        prevBlockHeader = header;
        headersList.add(header);
    }
    LOG.debug("Received {} of {} headers requested from peer {}", headersList.size(), count, peer);
    return Optional.of(headersList);
}
Also used : ArrayList(java.util.ArrayList) BlockHeader(org.hyperledger.besu.ethereum.core.BlockHeader) BlockHeadersMessage(org.hyperledger.besu.ethereum.eth.messages.BlockHeadersMessage)

Example 4 with BlockHeadersMessage

use of org.hyperledger.besu.ethereum.eth.messages.BlockHeadersMessage in project besu by hyperledger.

the class EthProtocolManagerTest method respondToGetHeaders.

@Test
public void respondToGetHeaders() throws ExecutionException, InterruptedException {
    final CompletableFuture<Void> done = new CompletableFuture<>();
    try (final EthProtocolManager ethManager = EthProtocolManagerTestUtil.create(blockchain, () -> false, protocolContext.getWorldStateArchive(), transactionPool, EthProtocolConfiguration.defaultConfig())) {
        final long startBlock = 5L;
        final int blockCount = 5;
        final MessageData messageData = GetBlockHeadersMessage.create(startBlock, blockCount, 0, false);
        final PeerSendHandler onSend = (cap, message, conn) -> {
            if (message.getCode() == EthPV62.STATUS) {
                // Ignore status message
                return;
            }
            assertThat(message.getCode()).isEqualTo(EthPV62.BLOCK_HEADERS);
            final BlockHeadersMessage headersMsg = BlockHeadersMessage.readFrom(message);
            final List<BlockHeader> headers = Lists.newArrayList(headersMsg.getHeaders(protocolSchedule));
            assertThat(headers).hasSize(blockCount);
            for (int i = 0; i < blockCount; i++) {
                assertThat(headers.get(i).getNumber()).isEqualTo(startBlock + i);
            }
            done.complete(null);
        };
        final PeerConnection peer = setupPeer(ethManager, onSend);
        ethManager.processMessage(EthProtocol.ETH63, new DefaultMessage(peer, messageData));
        done.get();
    }
}
Also used : TransactionsMessage(org.hyperledger.besu.ethereum.eth.messages.TransactionsMessage) Arrays(java.util.Arrays) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) RawMessage(org.hyperledger.besu.ethereum.p2p.rlpx.wire.RawMessage) DefaultMessage(org.hyperledger.besu.ethereum.p2p.rlpx.wire.DefaultMessage) Mockito.verifyNoInteractions(org.mockito.Mockito.verifyNoInteractions) BlockDataGenerator(org.hyperledger.besu.ethereum.core.BlockDataGenerator) ReceiptsMessage(org.hyperledger.besu.ethereum.eth.messages.ReceiptsMessage) BlockchainSetupUtil(org.hyperledger.besu.ethereum.core.BlockchainSetupUtil) DataStorageFormat(org.hyperledger.besu.ethereum.worldstate.DataStorageFormat) TransactionReceipt(org.hyperledger.besu.ethereum.core.TransactionReceipt) BigInteger(java.math.BigInteger) Block(org.hyperledger.besu.ethereum.core.Block) GetNodeDataMessage(org.hyperledger.besu.ethereum.eth.messages.GetNodeDataMessage) ConditionFactory(org.awaitility.core.ConditionFactory) Difficulty(org.hyperledger.besu.ethereum.core.Difficulty) EthProtocolConfiguration(org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration) Blockchain(org.hyperledger.besu.ethereum.chain.Blockchain) Set(java.util.Set) MiningParameters(org.hyperledger.besu.ethereum.core.MiningParameters) Collectors(java.util.stream.Collectors) BlockBodiesMessage(org.hyperledger.besu.ethereum.eth.messages.BlockBodiesMessage) BlockHeadersMessage(org.hyperledger.besu.ethereum.eth.messages.BlockHeadersMessage) ConditionTimeoutException(org.awaitility.core.ConditionTimeoutException) List(java.util.List) TransactionPoolConfiguration(org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration) ProtocolScheduleFixture(org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture) Optional(java.util.Optional) Capability(org.hyperledger.besu.ethereum.p2p.rlpx.wire.Capability) MetricsSystem(org.hyperledger.besu.plugin.services.MetricsSystem) MutableBlockchain(org.hyperledger.besu.ethereum.chain.MutableBlockchain) TransactionPoolFactory(org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolFactory) Awaitility(org.awaitility.Awaitility) Mockito.mock(org.mockito.Mockito.mock) Hash(org.hyperledger.besu.datatypes.Hash) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) StatusMessage(org.hyperledger.besu.ethereum.eth.messages.StatusMessage) EthPV62(org.hyperledger.besu.ethereum.eth.messages.EthPV62) PeerSendHandler(org.hyperledger.besu.ethereum.eth.manager.MockPeerConnection.PeerSendHandler) SyncState(org.hyperledger.besu.ethereum.eth.sync.state.SyncState) BeforeClass(org.junit.BeforeClass) CompletableFuture(java.util.concurrent.CompletableFuture) NoOpMetricsSystem(org.hyperledger.besu.metrics.noop.NoOpMetricsSystem) Bytes(org.apache.tuweni.bytes.Bytes) EthProtocol(org.hyperledger.besu.ethereum.eth.EthProtocol) ArrayList(java.util.ArrayList) NodeDataMessage(org.hyperledger.besu.ethereum.eth.messages.NodeDataMessage) ProtocolSchedule(org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule) HashSet(java.util.HashSet) InMemoryKeyValueStorageProvider.createInMemoryBlockchain(org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider.createInMemoryBlockchain) GetBlockHeadersMessage(org.hyperledger.besu.ethereum.eth.messages.GetBlockHeadersMessage) Lists(com.google.common.collect.Lists) ArgumentCaptor(org.mockito.ArgumentCaptor) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) PeerConnection(org.hyperledger.besu.ethereum.p2p.rlpx.connections.PeerConnection) WorldStateArchive(org.hyperledger.besu.ethereum.worldstate.WorldStateArchive) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Wei(org.hyperledger.besu.datatypes.Wei) DisconnectReason(org.hyperledger.besu.ethereum.p2p.rlpx.wire.messages.DisconnectMessage.DisconnectReason) ExecutorService(java.util.concurrent.ExecutorService) GetReceiptsMessage(org.hyperledger.besu.ethereum.eth.messages.GetReceiptsMessage) TransactionPool(org.hyperledger.besu.ethereum.eth.transactions.TransactionPool) BlockHeader(org.hyperledger.besu.ethereum.core.BlockHeader) NewBlockMessage(org.hyperledger.besu.ethereum.eth.messages.NewBlockMessage) Mockito.times(org.mockito.Mockito.times) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) MessageData(org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData) GetBlockBodiesMessage(org.hyperledger.besu.ethereum.eth.messages.GetBlockBodiesMessage) ProtocolContext(org.hyperledger.besu.ethereum.ProtocolContext) BlockBody(org.hyperledger.besu.ethereum.core.BlockBody) EthPV63(org.hyperledger.besu.ethereum.eth.messages.EthPV63) Mockito.reset(org.mockito.Mockito.reset) Transaction(org.hyperledger.besu.ethereum.core.Transaction) Collections(java.util.Collections) TestClock(org.hyperledger.besu.testutil.TestClock) DefaultMessage(org.hyperledger.besu.ethereum.p2p.rlpx.wire.DefaultMessage) PeerConnection(org.hyperledger.besu.ethereum.p2p.rlpx.connections.PeerConnection) MessageData(org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData) CompletableFuture(java.util.concurrent.CompletableFuture) List(java.util.List) ArrayList(java.util.ArrayList) BlockHeadersMessage(org.hyperledger.besu.ethereum.eth.messages.BlockHeadersMessage) GetBlockHeadersMessage(org.hyperledger.besu.ethereum.eth.messages.GetBlockHeadersMessage) PeerSendHandler(org.hyperledger.besu.ethereum.eth.manager.MockPeerConnection.PeerSendHandler) Test(org.junit.Test)

Example 5 with BlockHeadersMessage

use of org.hyperledger.besu.ethereum.eth.messages.BlockHeadersMessage in project besu by hyperledger.

the class EthProtocolManagerTest method respondToGetHeadersWithinLimits.

@Test
public void respondToGetHeadersWithinLimits() throws ExecutionException, InterruptedException {
    final CompletableFuture<Void> done = new CompletableFuture<>();
    final int limit = 5;
    try (final EthProtocolManager ethManager = EthProtocolManagerTestUtil.create(blockchain, () -> false, protocolContext.getWorldStateArchive(), transactionPool, new EthProtocolConfiguration(limit, limit, limit, limit, limit, false))) {
        final long startBlock = 5L;
        final int blockCount = 10;
        final MessageData messageData = GetBlockHeadersMessage.create(startBlock, blockCount, 0, false);
        final PeerSendHandler onSend = (cap, message, conn) -> {
            if (message.getCode() == EthPV62.STATUS) {
                // Ignore status message
                return;
            }
            assertThat(message.getCode()).isEqualTo(EthPV62.BLOCK_HEADERS);
            final BlockHeadersMessage headersMsg = BlockHeadersMessage.readFrom(message);
            final List<BlockHeader> headers = Lists.newArrayList(headersMsg.getHeaders(protocolSchedule));
            assertThat(headers).hasSize(limit);
            for (int i = 0; i < limit; i++) {
                assertThat(headers.get(i).getNumber()).isEqualTo(startBlock + i);
            }
            done.complete(null);
        };
        final PeerConnection peer = setupPeer(ethManager, onSend);
        ethManager.processMessage(EthProtocol.ETH63, new DefaultMessage(peer, messageData));
        done.get();
    }
}
Also used : TransactionsMessage(org.hyperledger.besu.ethereum.eth.messages.TransactionsMessage) Arrays(java.util.Arrays) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) RawMessage(org.hyperledger.besu.ethereum.p2p.rlpx.wire.RawMessage) DefaultMessage(org.hyperledger.besu.ethereum.p2p.rlpx.wire.DefaultMessage) Mockito.verifyNoInteractions(org.mockito.Mockito.verifyNoInteractions) BlockDataGenerator(org.hyperledger.besu.ethereum.core.BlockDataGenerator) ReceiptsMessage(org.hyperledger.besu.ethereum.eth.messages.ReceiptsMessage) BlockchainSetupUtil(org.hyperledger.besu.ethereum.core.BlockchainSetupUtil) DataStorageFormat(org.hyperledger.besu.ethereum.worldstate.DataStorageFormat) TransactionReceipt(org.hyperledger.besu.ethereum.core.TransactionReceipt) BigInteger(java.math.BigInteger) Block(org.hyperledger.besu.ethereum.core.Block) GetNodeDataMessage(org.hyperledger.besu.ethereum.eth.messages.GetNodeDataMessage) ConditionFactory(org.awaitility.core.ConditionFactory) Difficulty(org.hyperledger.besu.ethereum.core.Difficulty) EthProtocolConfiguration(org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration) Blockchain(org.hyperledger.besu.ethereum.chain.Blockchain) Set(java.util.Set) MiningParameters(org.hyperledger.besu.ethereum.core.MiningParameters) Collectors(java.util.stream.Collectors) BlockBodiesMessage(org.hyperledger.besu.ethereum.eth.messages.BlockBodiesMessage) BlockHeadersMessage(org.hyperledger.besu.ethereum.eth.messages.BlockHeadersMessage) ConditionTimeoutException(org.awaitility.core.ConditionTimeoutException) List(java.util.List) TransactionPoolConfiguration(org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration) ProtocolScheduleFixture(org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture) Optional(java.util.Optional) Capability(org.hyperledger.besu.ethereum.p2p.rlpx.wire.Capability) MetricsSystem(org.hyperledger.besu.plugin.services.MetricsSystem) MutableBlockchain(org.hyperledger.besu.ethereum.chain.MutableBlockchain) TransactionPoolFactory(org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolFactory) Awaitility(org.awaitility.Awaitility) Mockito.mock(org.mockito.Mockito.mock) Hash(org.hyperledger.besu.datatypes.Hash) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) StatusMessage(org.hyperledger.besu.ethereum.eth.messages.StatusMessage) EthPV62(org.hyperledger.besu.ethereum.eth.messages.EthPV62) PeerSendHandler(org.hyperledger.besu.ethereum.eth.manager.MockPeerConnection.PeerSendHandler) SyncState(org.hyperledger.besu.ethereum.eth.sync.state.SyncState) BeforeClass(org.junit.BeforeClass) CompletableFuture(java.util.concurrent.CompletableFuture) NoOpMetricsSystem(org.hyperledger.besu.metrics.noop.NoOpMetricsSystem) Bytes(org.apache.tuweni.bytes.Bytes) EthProtocol(org.hyperledger.besu.ethereum.eth.EthProtocol) ArrayList(java.util.ArrayList) NodeDataMessage(org.hyperledger.besu.ethereum.eth.messages.NodeDataMessage) ProtocolSchedule(org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule) HashSet(java.util.HashSet) InMemoryKeyValueStorageProvider.createInMemoryBlockchain(org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider.createInMemoryBlockchain) GetBlockHeadersMessage(org.hyperledger.besu.ethereum.eth.messages.GetBlockHeadersMessage) Lists(com.google.common.collect.Lists) ArgumentCaptor(org.mockito.ArgumentCaptor) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) PeerConnection(org.hyperledger.besu.ethereum.p2p.rlpx.connections.PeerConnection) WorldStateArchive(org.hyperledger.besu.ethereum.worldstate.WorldStateArchive) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Wei(org.hyperledger.besu.datatypes.Wei) DisconnectReason(org.hyperledger.besu.ethereum.p2p.rlpx.wire.messages.DisconnectMessage.DisconnectReason) ExecutorService(java.util.concurrent.ExecutorService) GetReceiptsMessage(org.hyperledger.besu.ethereum.eth.messages.GetReceiptsMessage) TransactionPool(org.hyperledger.besu.ethereum.eth.transactions.TransactionPool) BlockHeader(org.hyperledger.besu.ethereum.core.BlockHeader) NewBlockMessage(org.hyperledger.besu.ethereum.eth.messages.NewBlockMessage) Mockito.times(org.mockito.Mockito.times) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) MessageData(org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData) GetBlockBodiesMessage(org.hyperledger.besu.ethereum.eth.messages.GetBlockBodiesMessage) ProtocolContext(org.hyperledger.besu.ethereum.ProtocolContext) BlockBody(org.hyperledger.besu.ethereum.core.BlockBody) EthPV63(org.hyperledger.besu.ethereum.eth.messages.EthPV63) Mockito.reset(org.mockito.Mockito.reset) Transaction(org.hyperledger.besu.ethereum.core.Transaction) Collections(java.util.Collections) TestClock(org.hyperledger.besu.testutil.TestClock) DefaultMessage(org.hyperledger.besu.ethereum.p2p.rlpx.wire.DefaultMessage) PeerConnection(org.hyperledger.besu.ethereum.p2p.rlpx.connections.PeerConnection) MessageData(org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData) EthProtocolConfiguration(org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration) CompletableFuture(java.util.concurrent.CompletableFuture) List(java.util.List) ArrayList(java.util.ArrayList) BlockHeadersMessage(org.hyperledger.besu.ethereum.eth.messages.BlockHeadersMessage) GetBlockHeadersMessage(org.hyperledger.besu.ethereum.eth.messages.GetBlockHeadersMessage) PeerSendHandler(org.hyperledger.besu.ethereum.eth.manager.MockPeerConnection.PeerSendHandler) Test(org.junit.Test)

Aggregations

BlockHeader (org.hyperledger.besu.ethereum.core.BlockHeader)11 ArrayList (java.util.ArrayList)10 Collections (java.util.Collections)10 List (java.util.List)10 CompletableFuture (java.util.concurrent.CompletableFuture)10 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)10 Lists (com.google.common.collect.Lists)9 BigInteger (java.math.BigInteger)9 HashSet (java.util.HashSet)9 Optional (java.util.Optional)9 Set (java.util.Set)9 ExecutionException (java.util.concurrent.ExecutionException)9 TimeUnit (java.util.concurrent.TimeUnit)9 Collectors (java.util.stream.Collectors)9 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)9 ProtocolContext (org.hyperledger.besu.ethereum.ProtocolContext)9 Blockchain (org.hyperledger.besu.ethereum.chain.Blockchain)9 BlockchainSetupUtil (org.hyperledger.besu.ethereum.core.BlockchainSetupUtil)9 EthProtocol (org.hyperledger.besu.ethereum.eth.EthProtocol)9 EthProtocolConfiguration (org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration)9