Search in sources :

Example 1 with BlockBodiesMessage

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

the class EthProtocolManagerTest method respondToGetBodiesPartial.

@Test
public void respondToGetBodiesPartial() throws ExecutionException, InterruptedException {
    final CompletableFuture<Void> done = new CompletableFuture<>();
    try (final EthProtocolManager ethManager = EthProtocolManagerTestUtil.create(blockchain, () -> false, protocolContext.getWorldStateArchive(), transactionPool, EthProtocolConfiguration.defaultConfig())) {
        // Setup blocks query
        final long expectedBlockNumber = blockchain.getChainHeadBlockNumber() - 1;
        final BlockHeader header = blockchain.getBlockHeader(expectedBlockNumber).get();
        final BlockBody body = blockchain.getBlockBody(header.getHash()).get();
        final Block expectedBlock = new Block(header, body);
        final List<Hash> hashes = Arrays.asList(gen.hash(), expectedBlock.getHash(), gen.hash());
        final MessageData messageData = GetBlockBodiesMessage.create(hashes);
        // Define handler to validate response
        final PeerSendHandler onSend = (cap, message, conn) -> {
            if (message.getCode() == EthPV62.STATUS) {
                // Ignore status message
                return;
            }
            assertThat(message.getCode()).isEqualTo(EthPV62.BLOCK_BODIES);
            final BlockBodiesMessage blocksMessage = BlockBodiesMessage.readFrom(message);
            final List<BlockBody> bodies = Lists.newArrayList(blocksMessage.bodies(protocolSchedule));
            assertThat(bodies).hasSize(1);
            assertThat(expectedBlock.getBody()).isEqualTo(bodies.get(0));
            done.complete(null);
        };
        // Run test
        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) BlockBody(org.hyperledger.besu.ethereum.core.BlockBody) MessageData(org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData) Hash(org.hyperledger.besu.datatypes.Hash) CompletableFuture(java.util.concurrent.CompletableFuture) Block(org.hyperledger.besu.ethereum.core.Block) BlockBodiesMessage(org.hyperledger.besu.ethereum.eth.messages.BlockBodiesMessage) GetBlockBodiesMessage(org.hyperledger.besu.ethereum.eth.messages.GetBlockBodiesMessage) List(java.util.List) ArrayList(java.util.ArrayList) BlockHeader(org.hyperledger.besu.ethereum.core.BlockHeader) PeerSendHandler(org.hyperledger.besu.ethereum.eth.manager.MockPeerConnection.PeerSendHandler) Test(org.junit.Test)

Example 2 with BlockBodiesMessage

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

the class EthProtocolManagerTest method respondToGetBodies.

@Test
public void respondToGetBodies() throws ExecutionException, InterruptedException {
    final CompletableFuture<Void> done = new CompletableFuture<>();
    try (final EthProtocolManager ethManager = EthProtocolManagerTestUtil.create(blockchain, () -> false, protocolContext.getWorldStateArchive(), transactionPool, EthProtocolConfiguration.defaultConfig())) {
        // Setup blocks query
        final long startBlock = blockchain.getChainHeadBlockNumber() - 5;
        final int blockCount = 2;
        final Block[] expectedBlocks = new Block[blockCount];
        for (int i = 0; i < blockCount; i++) {
            final BlockHeader header = blockchain.getBlockHeader(startBlock + i).get();
            final BlockBody body = blockchain.getBlockBody(header.getHash()).get();
            expectedBlocks[i] = new Block(header, body);
        }
        final List<Hash> hashes = Arrays.stream(expectedBlocks).map(Block::getHash).collect(Collectors.toList());
        final MessageData messageData = GetBlockBodiesMessage.create(hashes);
        // Define handler to validate response
        final PeerSendHandler onSend = (cap, message, conn) -> {
            if (message.getCode() == EthPV62.STATUS) {
                // Ignore status message
                return;
            }
            assertThat(message.getCode()).isEqualTo(EthPV62.BLOCK_BODIES);
            final BlockBodiesMessage blocksMessage = BlockBodiesMessage.readFrom(message);
            final List<BlockBody> bodies = Lists.newArrayList(blocksMessage.bodies(protocolSchedule));
            assertThat(bodies).hasSize(blockCount);
            for (int i = 0; i < blockCount; i++) {
                assertThat(expectedBlocks[i].getBody()).isEqualTo(bodies.get(i));
            }
            done.complete(null);
        };
        // Run test
        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) BlockBody(org.hyperledger.besu.ethereum.core.BlockBody) MessageData(org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData) Hash(org.hyperledger.besu.datatypes.Hash) CompletableFuture(java.util.concurrent.CompletableFuture) Block(org.hyperledger.besu.ethereum.core.Block) BlockBodiesMessage(org.hyperledger.besu.ethereum.eth.messages.BlockBodiesMessage) GetBlockBodiesMessage(org.hyperledger.besu.ethereum.eth.messages.GetBlockBodiesMessage) List(java.util.List) ArrayList(java.util.ArrayList) BlockHeader(org.hyperledger.besu.ethereum.core.BlockHeader) PeerSendHandler(org.hyperledger.besu.ethereum.eth.manager.MockPeerConnection.PeerSendHandler) Test(org.junit.Test)

Example 3 with BlockBodiesMessage

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

the class GetBodiesFromPeerTask method processResponse.

@Override
protected Optional<List<Block>> 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("bodies");
        return Optional.of(Collections.emptyList());
    }
    final BlockBodiesMessage bodiesMessage = BlockBodiesMessage.readFrom(message);
    final List<BlockBody> bodies = bodiesMessage.bodies(protocolSchedule);
    if (bodies.size() == 0) {
        // Message contains no data - nothing to do
        LOG.debug("Message contains no data. Peer: {}", peer);
        return Optional.empty();
    } else if (bodies.size() > headers.size()) {
        // Message doesn't match our request - nothing to do
        LOG.debug("Message doesn't match our request. Peer: {}", peer);
        return Optional.empty();
    }
    final List<Block> blocks = new ArrayList<>();
    for (final BlockBody body : bodies) {
        final List<BlockHeader> headers = bodyToHeaders.get(new BodyIdentifier(body));
        if (headers == null) {
            // This message contains unrelated bodies - exit
            LOG.debug("This message contains unrelated bodies. Peer: {}", peer);
            return Optional.empty();
        }
        headers.forEach(h -> blocks.add(new Block(h, body)));
        // Clear processed headers
        headers.clear();
    }
    return Optional.of(blocks);
}
Also used : BlockBody(org.hyperledger.besu.ethereum.core.BlockBody) ArrayList(java.util.ArrayList) Block(org.hyperledger.besu.ethereum.core.Block) BlockBodiesMessage(org.hyperledger.besu.ethereum.eth.messages.BlockBodiesMessage) BlockHeader(org.hyperledger.besu.ethereum.core.BlockHeader)

Example 4 with BlockBodiesMessage

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

the class EthProtocolManagerTest method respondToGetBodiesWithinLimits.

@Test
public void respondToGetBodiesWithinLimits() 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))) {
        // Setup blocks query
        final int blockCount = 10;
        final long startBlock = blockchain.getChainHeadBlockNumber() - blockCount;
        final Block[] expectedBlocks = new Block[blockCount];
        for (int i = 0; i < blockCount; i++) {
            final BlockHeader header = blockchain.getBlockHeader(startBlock + i).get();
            final BlockBody body = blockchain.getBlockBody(header.getHash()).get();
            expectedBlocks[i] = new Block(header, body);
        }
        final List<Hash> hashes = Arrays.stream(expectedBlocks).map(Block::getHash).collect(Collectors.toList());
        final MessageData messageData = GetBlockBodiesMessage.create(hashes);
        // Define handler to validate response
        final PeerSendHandler onSend = (cap, message, conn) -> {
            if (message.getCode() == EthPV62.STATUS) {
                // Ignore status message
                return;
            }
            assertThat(message.getCode()).isEqualTo(EthPV62.BLOCK_BODIES);
            final BlockBodiesMessage blocksMessage = BlockBodiesMessage.readFrom(message);
            final List<BlockBody> bodies = Lists.newArrayList(blocksMessage.bodies(protocolSchedule));
            assertThat(bodies).hasSize(limit);
            for (int i = 0; i < limit; i++) {
                assertThat(expectedBlocks[i].getBody()).isEqualTo(bodies.get(i));
            }
            done.complete(null);
        };
        // Run test
        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) BlockBody(org.hyperledger.besu.ethereum.core.BlockBody) MessageData(org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData) Hash(org.hyperledger.besu.datatypes.Hash) EthProtocolConfiguration(org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration) CompletableFuture(java.util.concurrent.CompletableFuture) Block(org.hyperledger.besu.ethereum.core.Block) BlockBodiesMessage(org.hyperledger.besu.ethereum.eth.messages.BlockBodiesMessage) GetBlockBodiesMessage(org.hyperledger.besu.ethereum.eth.messages.GetBlockBodiesMessage) List(java.util.List) ArrayList(java.util.ArrayList) BlockHeader(org.hyperledger.besu.ethereum.core.BlockHeader) PeerSendHandler(org.hyperledger.besu.ethereum.eth.manager.MockPeerConnection.PeerSendHandler) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)4 Block (org.hyperledger.besu.ethereum.core.Block)4 BlockBody (org.hyperledger.besu.ethereum.core.BlockBody)4 BlockHeader (org.hyperledger.besu.ethereum.core.BlockHeader)4 Lists (com.google.common.collect.Lists)3 BigInteger (java.math.BigInteger)3 Arrays (java.util.Arrays)3 Collections (java.util.Collections)3 HashSet (java.util.HashSet)3 List (java.util.List)3 Optional (java.util.Optional)3 Set (java.util.Set)3 CompletableFuture (java.util.concurrent.CompletableFuture)3 ExecutionException (java.util.concurrent.ExecutionException)3 ExecutorService (java.util.concurrent.ExecutorService)3 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)3 TimeUnit (java.util.concurrent.TimeUnit)3 Collectors (java.util.stream.Collectors)3 Bytes (org.apache.tuweni.bytes.Bytes)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3