Skip to content

Commit

Permalink
Release 22.4.3 (hyperledger#3978)
Browse files Browse the repository at this point in the history
* reverts disconnect of pow network
* updates gav coords to 22.4.3

Signed-off-by: Justin Florentine <justin+github@florentine.us>
  • Loading branch information
jflo authored Jun 16, 2022
1 parent 5e32b05 commit 963da3d
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 405 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@
import java.util.OptionalLong;
import java.util.function.Supplier;

import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -360,15 +359,11 @@ public BesuController build() {
Optional.of(
ImmutableCheckpoint.builder()
.blockHash(
Hash.fromHexString(
configOptions.getCheckpointOptions().getHash().get())) // NOSONAR
Hash.fromHexString(configOptions.getCheckpointOptions().getHash().get()))
.blockNumber(configOptions.getCheckpointOptions().getNumber().getAsLong())
.totalDifficulty(
Difficulty.fromHexString(
configOptions
.getCheckpointOptions()
.getTotalDifficulty()
.get())) // NOSONAR
configOptions.getCheckpointOptions().getTotalDifficulty().get()))
.build());
}

Expand Down Expand Up @@ -408,14 +403,19 @@ public BesuController build() {
final PivotBlockSelector pivotBlockSelector = createPivotSelector(protocolContext);

final Synchronizer synchronizer =
createSynchronizer(
new DefaultSynchronizer(
syncConfig,
protocolSchedule,
worldStateStorage,
protocolContext,
worldStateStorage,
ethProtocolManager.getBlockBroadcaster(),
maybePruner,
ethContext,
syncState,
ethProtocolManager,
dataDirectory,
clock,
metricsSystem,
getFullSyncTerminationCondition(protocolContext.getBlockchain()),
pivotBlockSelector);

final MiningCoordinator miningCoordinator =
Expand All @@ -432,6 +432,7 @@ public BesuController build() {

final SubProtocolConfiguration subProtocolConfiguration =
createSubProtocolConfiguration(ethProtocolManager, maybeSnapProtocolManager);
;

final JsonRpcMethods additionalJsonRpcMethodFactory =
createAdditionalJsonRpcMethodFactory(protocolContext);
Expand Down Expand Up @@ -460,32 +461,6 @@ public BesuController build() {
additionalPluginServices);
}

@NotNull
protected DefaultSynchronizer createSynchronizer(
final ProtocolSchedule protocolSchedule,
final WorldStateStorage worldStateStorage,
final ProtocolContext protocolContext,
final Optional<Pruner> maybePruner,
final EthContext ethContext,
final SyncState syncState,
final EthProtocolManager ethProtocolManager,
final PivotBlockSelector pivotBlockSelector) {
return new DefaultSynchronizer(
syncConfig,
protocolSchedule,
protocolContext,
worldStateStorage,
ethProtocolManager.getBlockBroadcaster(),
maybePruner,
ethContext,
syncState,
dataDirectory,
clock,
metricsSystem,
getFullSyncTerminationCondition(protocolContext.getBlockchain()),
pivotBlockSelector);
}

private PivotBlockSelector createPivotSelector(final ProtocolContext protocolContext) {

final PivotSelectorFromPeers pivotSelectorFromPeers = new PivotSelectorFromPeers(syncConfig);
Expand Down Expand Up @@ -532,7 +507,7 @@ protected SyncTerminationCondition getFullSyncTerminationCondition(final Blockch
protected void prepForBuild() {}

protected JsonRpcMethods createAdditionalJsonRpcMethodFactory(
final ProtocolContext protocolContext) { // NOSONAR
final ProtocolContext protocolContext) {
return apis -> Collections.emptyMap();
}

Expand All @@ -542,8 +517,9 @@ protected SubProtocolConfiguration createSubProtocolConfiguration(
final SubProtocolConfiguration subProtocolConfiguration =
new SubProtocolConfiguration().withSubProtocol(EthProtocol.get(), ethProtocolManager);
maybeSnapProtocolManager.ifPresent(
snapProtocolManager ->
subProtocolConfiguration.withSubProtocol(SnapProtocol.get(), snapProtocolManager));
snapProtocolManager -> {
subProtocolConfiguration.withSubProtocol(SnapProtocol.get(), snapProtocolManager);
});
return subProtocolConfiguration;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package org.hyperledger.besu.controller;

import org.hyperledger.besu.config.GenesisConfigFile;
import org.hyperledger.besu.consensus.merge.MergeContext;
import org.hyperledger.besu.consensus.merge.PostMergeContext;
import org.hyperledger.besu.consensus.merge.TransitionBackwardSyncContext;
import org.hyperledger.besu.consensus.merge.TransitionContext;
Expand All @@ -32,14 +31,7 @@
import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
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.EthScheduler;
import org.hyperledger.besu.ethereum.eth.peervalidation.PeerValidator;
import org.hyperledger.besu.ethereum.eth.sync.DefaultSynchronizer;
import org.hyperledger.besu.ethereum.eth.sync.PivotBlockSelector;
import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.backwardsync.BackwardSyncContext;
import org.hyperledger.besu.ethereum.eth.sync.state.SyncState;
Expand All @@ -48,10 +40,8 @@
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.storage.StorageProvider;
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
import org.hyperledger.besu.ethereum.worldstate.Pruner;
import org.hyperledger.besu.ethereum.worldstate.PrunerConfiguration;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.ObservableMetricsSystem;
import org.hyperledger.besu.plugin.services.permissioning.NodeMessagePermissioningProvider;
Expand Down Expand Up @@ -155,79 +145,13 @@ protected PluginServiceFactory createAdditionalPluginServices(
return new NoopPluginServiceFactory();
}

@Override
protected DefaultSynchronizer createSynchronizer(
final ProtocolSchedule protocolSchedule,
final WorldStateStorage worldStateStorage,
final ProtocolContext protocolContext,
final Optional<Pruner> maybePruner,
final EthContext ethContext,
final SyncState syncState,
final EthProtocolManager ethProtocolManager,
final PivotBlockSelector pivotBlockSelector) {

DefaultSynchronizer sync =
super.createSynchronizer(
protocolSchedule,
worldStateStorage,
protocolContext,
maybePruner,
ethContext,
syncState,
ethProtocolManager,
pivotBlockSelector);

ConsensusContext cc = protocolContext.getConsensusContext(ConsensusContext.class);
if (cc instanceof MergeContext) {
protocolContext.getConsensusContext(MergeContext.class).addNewForkchoiceMessageListener(sync);
}
return sync;
}

@Override
protected EthProtocolManager createEthProtocolManager(
final ProtocolContext protocolContext,
final boolean fastSyncEnabled,
final TransactionPool transactionPool,
final EthProtocolConfiguration ethereumWireProtocolConfiguration,
final EthPeers ethPeers,
final EthContext ethContext,
final EthMessages ethMessages,
final EthScheduler scheduler,
final List<PeerValidator> peerValidators) {

EthProtocolManager ethProtocolManager =
super.createEthProtocolManager(
protocolContext,
fastSyncEnabled,
transactionPool,
ethereumWireProtocolConfiguration,
ethPeers,
ethContext,
ethMessages,
scheduler,
peerValidators);

ConsensusContext cc = protocolContext.getConsensusContext(ConsensusContext.class);
if (cc instanceof MergeContext) {
protocolContext
.getConsensusContext(MergeContext.class)
.observeNewIsPostMergeState(ethProtocolManager);
protocolContext
.getConsensusContext(MergeContext.class)
.addNewForkchoiceMessageListener(ethProtocolManager);
}

return ethProtocolManager;
}

private void initTransitionWatcher(
final ProtocolContext protocolContext, final TransitionCoordinator composedCoordinator) {

PostMergeContext postMergeContext = protocolContext.getConsensusContext(PostMergeContext.class);
postMergeContext.observeNewIsPostMergeState(
(isPoS, difficultyStoppedAt) -> {
if (isPoS) {
newIsPostMergeState -> {
if (newIsPostMergeState) {
// if we transitioned to post-merge, stop and disable any mining
composedCoordinator.getPreMergeObject().disable();
composedCoordinator.getPreMergeObject().stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
package org.hyperledger.besu.consensus.merge;

import org.hyperledger.besu.consensus.merge.MergeContext.NewForkchoiceMessageListener;
import org.hyperledger.besu.datatypes.Hash;

import java.util.Optional;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,15 @@ void fireNewUnverifiedForkchoiceMessageEvent(
final Hash headBlockHash,
final Optional<Hash> maybeFinalizedBlockHash,
final Hash safeBlockHash);

interface NewMergeStateCallback {
void onNewIsPostMergeState(final boolean newIsPostMergeState);
}

interface NewForkchoiceMessageListener {
void onNewForkchoiceMessage(
final Hash headBlockHash,
final Optional<Hash> maybeFinalizedBlockHash,
final Hash safeBlockHash);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ public PostMergeContext setTerminalTotalDifficulty(final Difficulty newTerminalT
}

@Override
public void setIsPostMerge(final Difficulty difficultyStoppedAt) {
public void setIsPostMerge(final Difficulty totalDifficulty) {
if (isPostMerge.get().orElse(Boolean.FALSE) && lastFinalized.get() != null) {
// if we have finalized, we never switch back to a pre-merge once we have transitioned
// post-TTD.
return;
}
final boolean newState = terminalTotalDifficulty.get().lessOrEqualThan(difficultyStoppedAt);
final boolean newState = terminalTotalDifficulty.get().lessOrEqualThan(totalDifficulty);
final Optional<Boolean> oldState = isPostMerge.getAndSet(Optional.of(newState));

// if we are past TTD, set it:
Expand All @@ -99,9 +99,7 @@ public void setIsPostMerge(final Difficulty difficultyStoppedAt) {

if (oldState.isEmpty() || oldState.get() != newState) {
newMergeStateCallbackSubscribers.forEach(
newMergeStateCallback ->
newMergeStateCallback.onCrossingMergeBoundary(
newState, Optional.of(difficultyStoppedAt)));
newMergeStateCallback -> newMergeStateCallback.onNewIsPostMergeState(newState));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.when;

import org.hyperledger.besu.consensus.merge.MergeContext.NewMergeStateCallback;
import org.hyperledger.besu.consensus.merge.blockcreation.PayloadIdentifier;
import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockHeader;
Expand Down Expand Up @@ -172,9 +173,8 @@ private static class MergeStateChangeCollector implements NewMergeStateCallback
final List<Boolean> stateChanges = new ArrayList<>();

@Override
public void onCrossingMergeBoundary(
final boolean isPoS, final Optional<Difficulty> difficultyStoppedAt) {
stateChanges.add(isPoS);
public void onNewIsPostMergeState(final boolean newIsPostMergeState) {
stateChanges.add(newIsPostMergeState);
}

public void reset() {
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 963da3d

Please sign in to comment.