7311: Fix up everything broken after merge

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>
pull/7638/head
Matilda Clerke 2 months ago
parent 64adedc63b
commit 2c1446efa0
  1. 19
      besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java
  2. 6
      besu/src/main/java/org/hyperledger/besu/controller/ConsensusScheduleBesuControllerBuilder.java
  3. 6
      besu/src/main/java/org/hyperledger/besu/controller/MergeBesuControllerBuilder.java
  4. 6
      besu/src/main/java/org/hyperledger/besu/controller/TransitionBesuControllerBuilder.java
  5. 16
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthProtocolManager.java
  6. 12
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/peertask/task/GetReceiptsFromPeerTask.java
  7. 4
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/checkpointsync/CheckpointDownloadBlockStep.java
  8. 6
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/DownloadReceiptsStep.java
  9. 4
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/EthProtocolManagerTest.java
  10. 6
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/EthProtocolManagerTestUtil.java
  11. 4
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/peertask/task/GetReceiptsFromPeerTaskTest.java
  12. 2
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/checkpointsync/CheckPointSyncChainDownloaderTest.java
  13. 4
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/DownloadReceiptsStepTest.java
  14. 2
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncActionsTest.java
  15. 2
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncChainDownloaderTest.java
  16. 4
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TestNode.java
  17. 4
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolFactoryTest.java

@ -55,8 +55,8 @@ import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
import org.hyperledger.besu.ethereum.eth.manager.MergePeerFilter;
import org.hyperledger.besu.ethereum.eth.manager.MonitoredExecutors;
import org.hyperledger.besu.ethereum.eth.manager.peertask.DefaultPeerManager;
import org.hyperledger.besu.ethereum.eth.manager.peertask.PeerManager;
import org.hyperledger.besu.ethereum.eth.manager.peertask.DefaultPeerSelector;
import org.hyperledger.besu.ethereum.eth.manager.peertask.PeerSelector;
import org.hyperledger.besu.ethereum.eth.manager.peertask.PeerTaskExecutor;
import org.hyperledger.besu.ethereum.eth.manager.peertask.PeerTaskRequestSender;
import org.hyperledger.besu.ethereum.eth.manager.snap.SnapProtocolManager;
@ -656,11 +656,10 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
}
final EthContext ethContext = new EthContext(ethPeers, ethMessages, snapMessages, scheduler);
final PeerManager peerManager = new DefaultPeerManager();
ethPeers.streamAllPeers().forEach(peerManager::addPeer);
final PeerSelector peerSelector = new DefaultPeerSelector(currentProtocolSpecSupplier);
ethPeers.streamAllPeers().forEach(peerSelector::addPeer);
final PeerTaskExecutor peerTaskExecutor =
new PeerTaskExecutor(
peerManager, new PeerTaskRequestSender(), currentProtocolSpecSupplier, metricsSystem);
new PeerTaskExecutor(peerSelector, new PeerTaskRequestSender(), metricsSystem);
final boolean fullSyncDisabled = !SyncMode.isFullSync(syncConfig.getSyncMode());
final SyncState syncState = new SyncState(blockchain, ethPeers, fullSyncDisabled, checkpoint);
@ -701,7 +700,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
peerValidators,
Optional.empty(),
forkIdManager,
peerManager);
peerSelector);
final PivotBlockSelector pivotBlockSelector =
createPivotSelector(
@ -1036,7 +1035,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
* @param peerValidators the peer validators
* @param mergePeerFilter the merge peer filter
* @param forkIdManager the fork id manager
* @param peerManager the PeerManager
* @param peerSelector the PeerSelector
* @return the eth protocol manager
*/
protected EthProtocolManager createEthProtocolManager(
@ -1051,7 +1050,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
final List<PeerValidator> peerValidators,
final Optional<MergePeerFilter> mergePeerFilter,
final ForkIdManager forkIdManager,
final PeerManager peerManager) {
final PeerSelector peerSelector) {
return new EthProtocolManager(
protocolContext.getBlockchain(),
networkId,
@ -1066,7 +1065,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
synchronizerConfiguration,
scheduler,
forkIdManager,
peerManager);
peerSelector);
}
/**

@ -42,7 +42,7 @@ import org.hyperledger.besu.ethereum.eth.manager.EthPeers;
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
import org.hyperledger.besu.ethereum.eth.manager.MergePeerFilter;
import org.hyperledger.besu.ethereum.eth.manager.peertask.PeerManager;
import org.hyperledger.besu.ethereum.eth.manager.peertask.PeerSelector;
import org.hyperledger.besu.ethereum.eth.manager.snap.SnapProtocolManager;
import org.hyperledger.besu.ethereum.eth.peervalidation.PeerValidator;
import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;
@ -245,7 +245,7 @@ public class ConsensusScheduleBesuControllerBuilder extends BesuControllerBuilde
final List<PeerValidator> peerValidators,
final Optional<MergePeerFilter> mergePeerFilter,
final ForkIdManager forkIdManager,
final PeerManager peerManager) {
final PeerSelector peerSelector) {
return besuControllerBuilderSchedule
.get(0L)
.createEthProtocolManager(
@ -260,7 +260,7 @@ public class ConsensusScheduleBesuControllerBuilder extends BesuControllerBuilde
peerValidators,
mergePeerFilter,
forkIdManager,
peerManager);
peerSelector);
}
@Override

@ -34,7 +34,7 @@ import org.hyperledger.besu.ethereum.eth.manager.EthPeers;
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
import org.hyperledger.besu.ethereum.eth.manager.MergePeerFilter;
import org.hyperledger.besu.ethereum.eth.manager.peertask.PeerManager;
import org.hyperledger.besu.ethereum.eth.manager.peertask.PeerSelector;
import org.hyperledger.besu.ethereum.eth.peervalidation.PeerValidator;
import org.hyperledger.besu.ethereum.eth.peervalidation.RequiredBlocksPeerValidator;
import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;
@ -101,7 +101,7 @@ public class MergeBesuControllerBuilder extends BesuControllerBuilder {
final List<PeerValidator> peerValidators,
final Optional<MergePeerFilter> mergePeerFilter,
final ForkIdManager forkIdManager,
final PeerManager peerManager) {
final PeerSelector peerSelector) {
var mergeContext = protocolContext.getConsensusContext(MergeContext.class);
@ -132,7 +132,7 @@ public class MergeBesuControllerBuilder extends BesuControllerBuilder {
peerValidators,
filterToUse,
forkIdManager,
peerManager);
peerSelector);
return ethProtocolManager;
}

@ -40,7 +40,7 @@ import org.hyperledger.besu.ethereum.eth.manager.EthPeers;
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
import org.hyperledger.besu.ethereum.eth.manager.MergePeerFilter;
import org.hyperledger.besu.ethereum.eth.manager.peertask.PeerManager;
import org.hyperledger.besu.ethereum.eth.manager.peertask.PeerSelector;
import org.hyperledger.besu.ethereum.eth.manager.peertask.PeerTaskExecutor;
import org.hyperledger.besu.ethereum.eth.peervalidation.PeerValidator;
import org.hyperledger.besu.ethereum.eth.sync.DefaultSynchronizer;
@ -166,7 +166,7 @@ public class TransitionBesuControllerBuilder extends BesuControllerBuilder {
final List<PeerValidator> peerValidators,
final Optional<MergePeerFilter> mergePeerFilter,
final ForkIdManager forkIdManager,
final PeerManager peerManager) {
final PeerSelector peerSelector) {
return mergeBesuControllerBuilder.createEthProtocolManager(
protocolContext,
synchronizerConfiguration,
@ -179,7 +179,7 @@ public class TransitionBesuControllerBuilder extends BesuControllerBuilder {
peerValidators,
mergePeerFilter,
forkIdManager,
peerManager);
peerSelector);
}
@Override

@ -23,7 +23,7 @@ import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.Difficulty;
import org.hyperledger.besu.ethereum.eth.EthProtocol;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.manager.peertask.PeerManager;
import org.hyperledger.besu.ethereum.eth.manager.peertask.PeerSelector;
import org.hyperledger.besu.ethereum.eth.messages.EthPV62;
import org.hyperledger.besu.ethereum.eth.messages.StatusMessage;
import org.hyperledger.besu.ethereum.eth.peervalidation.PeerValidator;
@ -70,7 +70,7 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver {
private final Hash genesisHash;
private final ForkIdManager forkIdManager;
private final PeerManager peerManager;
private final PeerSelector peerSelector;
private final BigInteger networkId;
private final EthPeers ethPeers;
private final EthMessages ethMessages;
@ -95,7 +95,7 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver {
final SynchronizerConfiguration synchronizerConfiguration,
final EthScheduler scheduler,
final ForkIdManager forkIdManager,
final PeerManager peerManager) {
final PeerSelector peerSelector) {
this.networkId = networkId;
this.peerValidators = peerValidators;
this.scheduler = scheduler;
@ -105,7 +105,7 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver {
this.genesisHash = blockchain.getBlockHashByNumber(0L).orElse(Hash.ZERO);
this.forkIdManager = forkIdManager;
this.peerManager = peerManager;
this.peerSelector = peerSelector;
this.ethPeers = ethPeers;
this.ethMessages = ethMessages;
@ -145,7 +145,7 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver {
final Optional<MergePeerFilter> mergePeerFilter,
final SynchronizerConfiguration synchronizerConfiguration,
final EthScheduler scheduler,
final PeerManager peerManager) {
final PeerSelector peerSelector) {
this(
blockchain,
networkId,
@ -164,7 +164,7 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver {
Collections.emptyList(),
Collections.emptyList(),
ethereumWireProtocolConfiguration.isLegacyEth64ForkIdEnabled()),
peerManager);
peerSelector);
}
public EthContext ethContext() {
@ -343,7 +343,7 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver {
public void handleNewConnection(final PeerConnection connection) {
ethPeers.registerNewConnection(connection, peerValidators);
final EthPeer peer = ethPeers.peer(connection);
peerManager.addPeer(peer);
peerSelector.addPeer(peer);
final Capability cap = connection.capability(getSupportedProtocol());
final ForkId latestForkId =
cap.getVersion() >= 64 ? forkIdManager.getForkIdForChainHead() : null;
@ -375,7 +375,7 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver {
final DisconnectReason reason,
final boolean initiatedByPeer) {
final boolean wasActiveConnection = ethPeers.registerDisconnect(connection);
peerManager.removePeer(connection.getPeer());
peerSelector.removePeer(connection.getPeer());
LOG.atDebug()
.setMessage("Disconnect - active Connection? {} - {} - {} - {} {} - {} peers left")
.addArgument(wasActiveConnection)

@ -20,11 +20,12 @@ import org.hyperledger.besu.ethereum.core.TransactionReceipt;
import org.hyperledger.besu.ethereum.eth.EthProtocol;
import org.hyperledger.besu.ethereum.eth.manager.peertask.InvalidPeerTaskResponseException;
import org.hyperledger.besu.ethereum.eth.manager.peertask.PeerTask;
import org.hyperledger.besu.ethereum.eth.manager.peertask.PeerTaskBehavior;
import org.hyperledger.besu.ethereum.eth.manager.peertask.PeerTaskRetryBehavior;
import org.hyperledger.besu.ethereum.eth.messages.GetReceiptsMessage;
import org.hyperledger.besu.ethereum.eth.messages.ReceiptsMessage;
import org.hyperledger.besu.ethereum.mainnet.BodyValidator;
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData;
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.SubProtocol;
import java.util.ArrayList;
import java.util.Collection;
@ -52,8 +53,8 @@ public class GetReceiptsFromPeerTask
}
@Override
public String getSubProtocol() {
return EthProtocol.NAME;
public SubProtocol getSubProtocol() {
return EthProtocol.get();
}
@Override
@ -101,7 +102,8 @@ public class GetReceiptsFromPeerTask
}
@Override
public Collection<PeerTaskBehavior> getPeerTaskBehaviors() {
return List.of(PeerTaskBehavior.RETRY_WITH_OTHER_PEERS, PeerTaskBehavior.RETRY_WITH_SAME_PEER);
public Collection<PeerTaskRetryBehavior> getPeerTaskBehaviors() {
return List.of(
PeerTaskRetryBehavior.RETRY_WITH_OTHER_PEERS, PeerTaskRetryBehavior.RETRY_WITH_SAME_PEER);
}
}

@ -85,10 +85,10 @@ public class CheckpointDownloadBlockStep {
PeerTaskExecutorResult<Map<BlockHeader, List<TransactionReceipt>>> executorResult =
peerTaskExecutor.execute(task);
if (executorResult.getResponseCode() == PeerTaskExecutorResponseCode.SUCCESS) {
if (executorResult.responseCode() == PeerTaskExecutorResponseCode.SUCCESS) {
List<TransactionReceipt> transactionReceipts =
executorResult
.getResult()
.result()
.map((map) -> map.get(block.getHeader()))
.orElseThrow(
() ->

@ -66,10 +66,10 @@ public class DownloadReceiptsStep
new GetReceiptsFromPeerTask(headers, new BodyValidator());
PeerTaskExecutorResult<Map<BlockHeader, List<TransactionReceipt>>> getReceiptsResult =
peerTaskExecutor.execute(getReceiptsFromPeerTask);
if (getReceiptsResult.getResponseCode() == PeerTaskExecutorResponseCode.SUCCESS
&& getReceiptsResult.getResult().isPresent()) {
if (getReceiptsResult.responseCode() == PeerTaskExecutorResponseCode.SUCCESS
&& getReceiptsResult.result().isPresent()) {
Map<BlockHeader, List<TransactionReceipt>> receiptsResult =
getReceiptsResult.getResult().get();
getReceiptsResult.result().get();
receiptsResult
.keySet()
.forEach(

@ -44,7 +44,7 @@ import org.hyperledger.besu.ethereum.eth.EthProtocol;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.EthProtocolVersion;
import org.hyperledger.besu.ethereum.eth.manager.MockPeerConnection.PeerSendHandler;
import org.hyperledger.besu.ethereum.eth.manager.peertask.DefaultPeerManager;
import org.hyperledger.besu.ethereum.eth.manager.peertask.DefaultPeerSelector;
import org.hyperledger.besu.ethereum.eth.messages.BlockBodiesMessage;
import org.hyperledger.besu.ethereum.eth.messages.BlockHeadersMessage;
import org.hyperledger.besu.ethereum.eth.messages.EthPV62;
@ -1245,7 +1245,7 @@ public final class EthProtocolManagerTest {
syncConfig,
mock(EthScheduler.class),
mock(ForkIdManager.class),
new DefaultPeerManager())) {
new DefaultPeerSelector(() -> null))) {
return ethManager;
}

@ -30,7 +30,7 @@ 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.peertask.DefaultPeerManager;
import org.hyperledger.besu.ethereum.eth.manager.peertask.DefaultPeerSelector;
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;
@ -119,7 +119,7 @@ public class EthProtocolManagerTestUtil {
mock(SynchronizerConfiguration.class),
ethScheduler,
new ForkIdManager(blockchain, Collections.emptyList(), Collections.emptyList(), false),
new DefaultPeerManager());
new DefaultPeerSelector(() -> null));
}
public static EthProtocolManager create(
@ -171,7 +171,7 @@ public class EthProtocolManagerTestUtil {
mock(SynchronizerConfiguration.class),
ethScheduler,
forkIdManager,
new DefaultPeerManager());
new DefaultPeerSelector(() -> null));
}
public static EthProtocolManager create(final Blockchain blockchain) {

@ -41,7 +41,7 @@ public class GetReceiptsFromPeerTaskTest {
@Test
public void testGetSubProtocol() {
GetReceiptsFromPeerTask task = new GetReceiptsFromPeerTask(Collections.emptyList(), null);
Assertions.assertEquals(EthProtocol.NAME, task.getSubProtocol());
Assertions.assertEquals(EthProtocol.get(), task.getSubProtocol());
}
@Test
@ -83,7 +83,7 @@ public class GetReceiptsFromPeerTaskTest {
}
@Test
public void testParseResponseForInvalidResponse() throws InvalidPeerTaskResponseException {
public void testParseResponseForInvalidResponse() {
GetReceiptsFromPeerTask task =
new GetReceiptsFromPeerTask(
List.of(mockBlockHeader(1), mockBlockHeader(2), mockBlockHeader(3)), null);

@ -191,7 +191,7 @@ public class CheckPointSyncChainDownloaderTest {
bh, otherBlockchain.getTxReceipts(bh.getHash()).get()));
return new PeerTaskExecutorResult<>(
getReceiptsFromPeerTaskResult, PeerTaskExecutorResponseCode.SUCCESS);
Optional.of(getReceiptsFromPeerTaskResult), PeerTaskExecutorResponseCode.SUCCESS);
}
@AfterEach

@ -44,6 +44,7 @@ import org.hyperledger.besu.plugin.services.storage.DataStorageFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
@ -121,7 +122,8 @@ public class DownloadReceiptsStepTest {
blocks.forEach(
(b) -> receiptsMap.put(b.getHeader(), List.of(Mockito.mock(TransactionReceipt.class))));
PeerTaskExecutorResult<Map<BlockHeader, List<TransactionReceipt>>> peerTaskResult =
new PeerTaskExecutorResult<>(receiptsMap, PeerTaskExecutorResponseCode.SUCCESS);
new PeerTaskExecutorResult<>(
Optional.of(receiptsMap), PeerTaskExecutorResponseCode.SUCCESS);
Mockito.when(peerTaskExecutor.execute(Mockito.any(GetReceiptsFromPeerTask.class)))
.thenReturn(peerTaskResult);

@ -537,7 +537,7 @@ public class FastSyncActionsTest {
protocolSchedule,
protocolContext,
ethContext,
new PeerTaskExecutor(null, null, null, new NoOpMetricsSystem()),
new PeerTaskExecutor(null, null, new NoOpMetricsSystem()),
new SyncState(blockchain, ethContext.getEthPeers(), true, Optional.empty()),
pivotBlockSelector,
new NoOpMetricsSystem());

@ -111,7 +111,7 @@ public class FastSyncChainDownloaderTest {
protocolSchedule,
protocolContext,
ethContext,
new PeerTaskExecutor(null, null, null, new NoOpMetricsSystem()),
new PeerTaskExecutor(null, null, new NoOpMetricsSystem()),
syncState,
new NoOpMetricsSystem(),
new FastSyncState(otherBlockchain.getBlockHeader(pivotBlockNumber).get()),

@ -44,7 +44,7 @@ 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.EthScheduler;
import org.hyperledger.besu.ethereum.eth.manager.peertask.DefaultPeerManager;
import org.hyperledger.besu.ethereum.eth.manager.peertask.DefaultPeerSelector;
import org.hyperledger.besu.ethereum.eth.sync.ChainHeadTracker;
import org.hyperledger.besu.ethereum.eth.sync.SyncMode;
import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;
@ -198,7 +198,7 @@ public class TestNode implements Closeable {
Optional.empty(),
syncConfig,
scheduler,
new DefaultPeerManager());
new DefaultPeerSelector(() -> null));
final NetworkRunner networkRunner =
NetworkRunner.builder()

@ -45,7 +45,7 @@ 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.EthScheduler;
import org.hyperledger.besu.ethereum.eth.manager.peertask.DefaultPeerManager;
import org.hyperledger.besu.ethereum.eth.manager.peertask.DefaultPeerSelector;
import org.hyperledger.besu.ethereum.eth.sync.SyncMode;
import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.state.SyncState;
@ -320,7 +320,7 @@ public class TransactionPoolFactoryTest {
mock(SynchronizerConfiguration.class),
mock(EthScheduler.class),
mock(ForkIdManager.class),
new DefaultPeerManager());
new DefaultPeerSelector(() -> null));
}
@Test

Loading…
Cancel
Save