Skip to content

Commit

Permalink
Merge branch 'main' into prague-engine-validation
Browse files Browse the repository at this point in the history
  • Loading branch information
siladu authored Feb 6, 2025
2 parents ad9a2cb + 952deb7 commit 5272d7f
Show file tree
Hide file tree
Showing 44 changed files with 436 additions and 473 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,22 @@

## Unreleased
### Breaking Changes
- `rpc-gas-cap` default value has changed from 0 (unlimited) to 50M. If you require `rpc-gas-cap` greater than 50M, you'll need to set that explicitly. [#8251](https://github.com/hyperledger/besu/issues/8251)
### Upcoming Breaking Changes
- `MetricSystem::createLabelledGauge` is deprecated and will be removed in a future release, replace it with `MetricSystem::createLabelledSuppliedGauge`
- k8s (KUBERNETES) Nat method is now deprecated and will be removed in a future release. Use docker or none instead.
- `--Xsnapsync-synchronizer-flat-db-healing-enabled` is deprecated, use `--Xbonsai-full-flat-db-enabled` instead.
- `--Xbonsai-limit-trie-logs-enabled` is deprecated, use `--bonsai-limit-trie-logs-enabled` instead.
- `--Xbonsai-trie-log-pruning-enabled` is deprecated, use `--bonsai-limit-trie-logs-enabled` instead.
- `--Xbonsai-trie-logs-pruning-window-size` is deprecated, use `--bonsai-trie-logs-pruning-window-size` instead.
- Sunsetting features - for more context on the reasoning behind the deprecation of these features, including alternative options, read [this blog post](https://www.lfdecentralizedtrust.org/blog/sunsetting-tessera-and-simplifying-hyperledger-besu)
- Tessera privacy
- Smart-contract-based (onchain) permissioning
- Proof of Work consensus
- Fast Sync
### Additions and Improvements
- Add a tx selector to skip txs from the same sender after the first not selected [#8216](https://github.com/hyperledger/besu/pull/8216)
- `rpc-gas-cap` default value has changed from 0 (unlimited) to 50M [#8251](https://github.com/hyperledger/besu/issues/8251)

#### Prague
- Add timestamps to enable Prague hardfork on Sepolia and Holesky test networks [#8163](https://github.com/hyperledger/besu/pull/8163)
Expand All @@ -20,7 +33,7 @@

### Breaking Changes
- `--host-whitelist` has been deprecated since 2020 and this option is removed. Use the equivalent `--host-allowlist` instead.
- Changed tracer API to include the mining beneficiary in BlockAwareOperationTracer::traceStartBlock [#8096](https://github.com/hyperledger/besu/pull/8096)
- Change tracer API to include the mining beneficiary in BlockAwareOperationTracer::traceStartBlock [#8096](https://github.com/hyperledger/besu/pull/8096)
- Change the input defaults on debug_trace* calls to not trace memory by default ("disableMemory": true, "disableStack": false, "disableStorage": false)
- Change the output format of debug_trace* and trace_* calls to match Geth behaviour

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public ApiConfigurationOptions() {}
names = {"--rpc-gas-cap"},
description =
"Specifies the gasLimit cap for transaction simulation RPC methods. Must be >=0. 0 specifies no limit (default: ${DEFAULT-VALUE})")
private final Long rpcGasCap = 0L;
private final Long rpcGasCap = ApiConfiguration.DEFAULT_GAS_CAP;

@CommandLine.Option(
names = {"--rpc-max-trace-filter-range"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
public class MergeBesuControllerBuilder extends BesuControllerBuilder {
private final AtomicReference<SyncState> syncState = new AtomicReference<>();
private static final Logger LOG = LoggerFactory.getLogger(MergeBesuControllerBuilder.class);
private final PostMergeContext postMergeContext = new PostMergeContext();

/** Default constructor. */
public MergeBesuControllerBuilder() {}
Expand Down Expand Up @@ -198,7 +199,7 @@ protected MergeContext createConsensusContext(
&& blockchain.getGenesisBlockHeader().getDifficulty().isZero();

final MergeContext mergeContext =
PostMergeContext.get()
postMergeContext
.setSyncState(syncState.get())
.setTerminalTotalDifficulty(
genesisConfigOptions
Expand Down Expand Up @@ -261,7 +262,16 @@ protected List<PeerValidator> createPeerValidators(
@Override
public BesuController build() {
final BesuController controller = super.build();
PostMergeContext.get().setSyncState(controller.getSyncState());
postMergeContext.setSyncState(syncState.get());
return controller;
}

/**
* Gets post merge context.
*
* @return the post merge context
*/
public PostMergeContext getPostMergeContext() {
return postMergeContext;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ protected MiningCoordinator createMiningCoordinator(
transitionMiningConfiguration,
syncState,
transitionBackwardsSyncContext,
ethProtocolManager.ethContext().getScheduler()));
ethProtocolManager.ethContext().getScheduler()),
mergeBesuControllerBuilder.getPostMergeContext());
initTransitionWatcher(protocolContext, composedCoordinator);
return composedCoordinator;
}
Expand Down Expand Up @@ -185,7 +186,7 @@ protected ProtocolSchedule createProtocolSchedule() {
new TransitionProtocolSchedule(
preMergeBesuControllerBuilder.createProtocolSchedule(),
mergeBesuControllerBuilder.createProtocolSchedule(),
PostMergeContext.get());
mergeBesuControllerBuilder.getPostMergeContext());
return transitionProtocolSchedule;
}

Expand Down Expand Up @@ -255,7 +256,7 @@ protected DefaultSynchronizer createSynchronizer(
private void initTransitionWatcher(
final ProtocolContext protocolContext, final TransitionCoordinator composedCoordinator) {

PostMergeContext postMergeContext = protocolContext.getConsensusContext(PostMergeContext.class);
PostMergeContext postMergeContext = mergeBesuControllerBuilder.getPostMergeContext();
postMergeContext.observeNewIsPostMergeState(
(isPoS, priorState, difficultyStoppedAt) -> {
if (isPoS) {
Expand Down Expand Up @@ -290,7 +291,7 @@ public BesuControllerBuilder storageProvider(final StorageProvider storageProvid
@Override
public BesuController build() {
final BesuController controller = super.build();
PostMergeContext.get().setSyncState(controller.getSyncState());
mergeBesuControllerBuilder.getPostMergeContext().setSyncState(controller.getSyncState());
return controller;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@

@ExtendWith(MockitoExtension.class)
public class ForkIdsNetworkConfigTest {
private static final PostMergeContext postMergeContext = new PostMergeContext();

public static Collection<Object[]> parameters() {
return List.of(
Expand All @@ -63,18 +64,18 @@ public static Collection<Object[]> parameters() {
new ForkId(Bytes.ofUnsignedInt(0xfe3366e7L), 1735371L),
new ForkId(Bytes.ofUnsignedInt(0xb96cbd13L), 1677557088L),
new ForkId(Bytes.ofUnsignedInt(0xf7f9bc08L), 1706655072L),
new ForkId(Bytes.ofUnsignedInt(0x88cf81d9L), 1739980128L),
new ForkId(Bytes.ofUnsignedInt(0xbafd09c3L), 0L),
new ForkId(Bytes.ofUnsignedInt(0xbafd09c3L), 0L))
new ForkId(Bytes.ofUnsignedInt(0x88cf81d9L), 1740471648L),
new ForkId(Bytes.ofUnsignedInt(0x8f6dc030L), 0L),
new ForkId(Bytes.ofUnsignedInt(0x8f6dc030L), 0L))
},
new Object[] {
NetworkName.HOLESKY,
List.of(
new ForkId(Bytes.ofUnsignedInt(0xc61a6098L), 1696000704L),
new ForkId(Bytes.ofUnsignedInt(0xfd4f016bL), 1707305664L),
new ForkId(Bytes.ofUnsignedInt(0x9b192ad0L), 1739352768L),
new ForkId(Bytes.ofUnsignedInt(0xf818a0d6L), 0L),
new ForkId(Bytes.ofUnsignedInt(0xf818a0d6L), 0L))
new ForkId(Bytes.ofUnsignedInt(0x9b192ad0L), 1739942592L),
new ForkId(Bytes.ofUnsignedInt(0xebef3829L), 0L),
new ForkId(Bytes.ofUnsignedInt(0xebef3829L), 0L))
},
new Object[] {
NetworkName.MAINNET,
Expand Down Expand Up @@ -203,10 +204,10 @@ public static class MilestoneStreamingTransitionProtocolSchedule
public MilestoneStreamingTransitionProtocolSchedule(
final MilestoneStreamingProtocolSchedule preMergeProtocolSchedule,
final MilestoneStreamingProtocolSchedule postMergeProtocolSchedule) {
super(preMergeProtocolSchedule, postMergeProtocolSchedule, PostMergeContext.get());
super(preMergeProtocolSchedule, postMergeProtocolSchedule, postMergeContext);
transitionUtils =
new TransitionUtils<>(
preMergeProtocolSchedule, postMergeProtocolSchedule, PostMergeContext.get());
preMergeProtocolSchedule, postMergeProtocolSchedule, postMergeContext);
}

public Stream<Long> streamMilestoneBlocks() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static org.mockito.Mockito.verify;

import org.hyperledger.besu.cli.CommandTestAbstract;
import org.hyperledger.besu.ethereum.api.ApiConfiguration;
import org.hyperledger.besu.ethereum.api.ImmutableApiConfiguration;

import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -111,7 +112,7 @@ public void rpcMaxLogsRangeOptionMustBeUsed() {
verify(mockRunnerBuilder).build();

assertThat(apiConfigurationCaptor.getValue())
.isEqualTo(ImmutableApiConfiguration.builder().maxLogsRange((rpcMaxLogsRange)).build());
.isEqualTo(ImmutableApiConfiguration.builder().maxLogsRange(rpcMaxLogsRange).build());

assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
Expand All @@ -126,7 +127,37 @@ public void rpcGasCapOptionMustBeUsed() {
verify(mockRunnerBuilder).build();

assertThat(apiConfigurationCaptor.getValue())
.isEqualTo(ImmutableApiConfiguration.builder().gasCap((rpcGasCap)).build());
.isEqualTo(ImmutableApiConfiguration.builder().gasCap(rpcGasCap).build());

assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}

@Test
public void rpcGasCapDefault() {
parseCommand();

verify(mockRunnerBuilder).apiConfiguration(apiConfigurationCaptor.capture());
verify(mockRunnerBuilder).build();

assertThat(apiConfigurationCaptor.getValue())
.isEqualTo(
ImmutableApiConfiguration.builder().gasCap(ApiConfiguration.DEFAULT_GAS_CAP).build());

assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}

@Test
public void rpcGasCapAcceptsZero() {
final long rpcGasCap = 0L;
parseCommand("--rpc-gas-cap", Long.toString(rpcGasCap));

verify(mockRunnerBuilder).apiConfiguration(apiConfigurationCaptor.capture());
verify(mockRunnerBuilder).build();

assertThat(apiConfigurationCaptor.getValue())
.isEqualTo(ImmutableApiConfiguration.builder().gasCap(rpcGasCap).build());

assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
Expand All @@ -143,7 +174,7 @@ public void rpcMaxTraceFilterOptionMustBeUsed() {
assertThat(apiConfigurationCaptor.getValue())
.isEqualTo(
ImmutableApiConfiguration.builder()
.maxTraceFilterRange((rpcMaxTraceFilterOption))
.maxTraceFilterRange(rpcMaxTraceFilterOption)
.build());

assertThat(commandOutput.toString(UTF_8)).isEmpty();
Expand Down
2 changes: 1 addition & 1 deletion config/src/main/resources/holesky.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"terminalTotalDifficulty": 0,
"shanghaiTime": 1696000704,
"cancunTime": 1707305664,
"pragueTime": 1739352768,
"pragueTime": 1739942592,
"blobSchedule": {
"cancun": {
"target": 3,
Expand Down
2 changes: 1 addition & 1 deletion config/src/main/resources/sepolia.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"terminalTotalDifficulty": 17000000000000000,
"shanghaiTime": 1677557088,
"cancunTime": 1706655072,
"pragueTime": 1739980128,
"pragueTime": 1740471648,
"blobSchedule": {
"cancun": {
"target": 3,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Stream;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.EvictingQueue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -40,7 +39,6 @@ public class PostMergeContext implements MergeContext {
/** The Max blocks in progress. */
static final int MAX_BLOCKS_IN_PROGRESS = 12;

private static final AtomicReference<PostMergeContext> singleton = new AtomicReference<>();
private final AtomicReference<SyncState> syncState;
private final AtomicReference<Difficulty> terminalTotalDifficulty;
// initial postMerge state is indeterminate until it is set:
Expand All @@ -62,8 +60,7 @@ public class PostMergeContext implements MergeContext {
private boolean isPostMergeAtGenesis;

/** Instantiates a new Post merge context. */
@VisibleForTesting
PostMergeContext() {
public PostMergeContext() {
this(Difficulty.ZERO);
}

Expand All @@ -72,24 +69,11 @@ public class PostMergeContext implements MergeContext {
*
* @param difficulty the difficulty
*/
@VisibleForTesting
PostMergeContext(final Difficulty difficulty) {
private PostMergeContext(final Difficulty difficulty) {
this.terminalTotalDifficulty = new AtomicReference<>(difficulty);
this.syncState = new AtomicReference<>();
}

/**
* Get post merge context.
*
* @return the post merge context
*/
public static PostMergeContext get() {
if (singleton.get() == null) {
singleton.compareAndSet(null, new PostMergeContext());
}
return singleton.get();
}

@Override
public <C extends ConsensusContext> C as(final Class<C> klass) {
return klass.cast(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,16 @@
*/
package org.hyperledger.besu.consensus.merge;

import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.datatypes.HardforkId;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Difficulty;
import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PermissionTransactionFilter;
import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader;
import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
import org.hyperledger.besu.ethereum.mainnet.ScheduledProtocolSpec;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.plugin.services.MetricsSystem;

import java.math.BigInteger;
import java.util.Optional;
Expand Down Expand Up @@ -60,41 +55,6 @@ public TransitionProtocolSchedule(
new TransitionUtils<>(preMergeProtocolSchedule, postMergeProtocolSchedule, mergeContext);
}

/**
* Create a Proof-of-Stake protocol schedule from a config object
*
* @param genesisConfigOptions {@link GenesisConfigOptions} containing the config options for the
* milestone starting points
* @param miningConfiguration the mining parameters
* @param badBlockManager the cache to use to keep invalid blocks
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled.
* @return an initialised TransitionProtocolSchedule using post-merge defaults
*/
public static TransitionProtocolSchedule fromConfig(
final GenesisConfigOptions genesisConfigOptions,
final MiningConfiguration miningConfiguration,
final BadBlockManager badBlockManager,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
ProtocolSchedule preMergeProtocolSchedule =
MainnetProtocolSchedule.fromConfig(
genesisConfigOptions,
miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem);
ProtocolSchedule postMergeProtocolSchedule =
MergeProtocolSchedule.create(
genesisConfigOptions,
false,
miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem);
return new TransitionProtocolSchedule(
preMergeProtocolSchedule, postMergeProtocolSchedule, PostMergeContext.get());
}

/**
* Gets pre merge schedule.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,13 @@ public class TransitionCoordinator extends TransitionUtils<MiningCoordinator>
*
* @param miningCoordinator the mining coordinator
* @param mergeCoordinator the merge coordinator
* @param postMergeContext the post merge context
*/
public TransitionCoordinator(
final MiningCoordinator miningCoordinator, final MiningCoordinator mergeCoordinator) {
super(miningCoordinator, mergeCoordinator, PostMergeContext.get());
final MiningCoordinator miningCoordinator,
final MiningCoordinator mergeCoordinator,
final PostMergeContext postMergeContext) {
super(miningCoordinator, mergeCoordinator, postMergeContext);
this.miningCoordinator = miningCoordinator;
this.mergeCoordinator = (MergeMiningCoordinator) mergeCoordinator;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class MergeReorgTest implements MergeGenesisConfigHelper {

private MergeCoordinator coordinator;

private final MergeContext mergeContext = PostMergeContext.get();
private final MergeContext mergeContext = new PostMergeContext();
private final ProtocolSchedule mockProtocolSchedule = getMergeProtocolSchedule();
private final GenesisState genesisState =
GenesisState.fromConfig(getPowGenesisConfig(), mockProtocolSchedule);
Expand Down
Loading

0 comments on commit 5272d7f

Please sign in to comment.