increase mainnet & Sepolia gas limit to 36M (#8249)

* increase mainnet gas limit to 36M, remove unused gas limit calculator from BesuControllerBuilder

Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>

* gas limit in SystemCallProcessor is independent of the block gas limit

Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>

* update test to reflect gas limit increase from 30M -> 36M

Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>

* remove unused gas limit check from previous commit

Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>

* moved the target gas limit constant for testnets to the same class as the one for mainnet

Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>

* fix tests

Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>

---------

Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
This commit is contained in:
daniellehrner
2025-02-18 15:15:00 +01:00
committed by GitHub
parent 1cbdcdb01d
commit 18e3917f37
26 changed files with 90 additions and 103 deletions

View File

@@ -31,7 +31,6 @@ import org.hyperledger.besu.controller.BesuControllerBuilder;
import org.hyperledger.besu.crypto.KeyPairUtil;
import org.hyperledger.besu.cryptoservices.KeyPairSecurityModule;
import org.hyperledger.besu.cryptoservices.NodeKey;
import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.api.ApiConfiguration;
import org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.InProcessRpcConfiguration;
@@ -480,7 +479,6 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
.ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
.clock(Clock.systemUTC())
.storageProvider(storageProvider)
.gasLimitCalculator(GasLimitCalculator.constant())
.evmConfiguration(EvmConfiguration.DEFAULT)
.maxPeers(25)
.maxRemotelyInitiatedPeers(15)

View File

@@ -18,12 +18,12 @@
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000",
"blockNumber": "0x1",
"gasLimit": "0x1c9c380",
"gasLimit": "0x1ca35ef",
"gasUsed": "0x0",
"timestamp": "0x5",
"extraData": "0x",
"baseFeePerGas": "0x7",
"blockHash": "0x3559e851470f6e7bbed1db474980683e8c315bfce99b2a6ef47c057c04de7858",
"blockHash": "0x48513c8021d27d6555aacf2a3a124952c5514f80ab280de32da330f528ad1a11",
"transactions": []
}
},

View File

@@ -18,12 +18,12 @@
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000",
"blockNumber": "0x1",
"gasLimit": "0x1c9c380",
"gasLimit": "0x1ca35ef",
"gasUsed": "0x0",
"timestamp": "0x5",
"extraData": "0x",
"baseFeePerGas": "0x7",
"blockHash": "0xf4a1d287dd3bb7e877c57476912e6a6052bc4eed8ea70d032b55d77f26ee985f",
"blockHash": "0xcdda91dbfe90c051ab1bdb703c9996fdb8cebaa7b9e7bc9e430e7e743e1b9682",
"transactions": []
}
},

View File

@@ -17,7 +17,7 @@
"stateRoot": "0xa61c2a422a4f7d7d7f456c1a83d5484eaf0d49e2b6b6d5716f875e782c66a9f0",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x1c9c380",
"gasLimit": "0x1ca35ef",
"gasUsed": "0x0",
"timestamp": "0x10",
"extraData": "0x",
@@ -38,7 +38,7 @@
}
],
"blockNumber": "0x2",
"blockHash": "0x612abd8615f544759d4aeb3dbab32f5f198a8b818e9c5436e9f7a674ef3b0f20",
"blockHash": "0xc7f79c3547adc7886a1607bfd1efb9de3d277991037dba01cffdd67e298aa2bf",
"receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"
},
"blockValue": "0x0"

View File

@@ -101,7 +101,6 @@ import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.enclave.EnclaveFactory;
import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.api.ApiConfiguration;
import org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.InProcessRpcConfiguration;
@@ -120,7 +119,6 @@ import org.hyperledger.besu.ethereum.eth.sync.SyncMode;
import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;
import org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
import org.hyperledger.besu.ethereum.mainnet.FrontierTargetingGasLimitCalculator;
import org.hyperledger.besu.ethereum.p2p.config.DiscoveryConfiguration;
import org.hyperledger.besu.ethereum.p2p.discovery.P2PDiscoveryConfiguration;
import org.hyperledger.besu.ethereum.p2p.peers.EnodeDnsConfiguration;
@@ -278,7 +276,6 @@ import picocli.CommandLine.ParameterException;
"%nMore info and other profiles at https://besu.hyperledger.org%n"
})
public class BesuCommand implements DefaultCommandValues, Runnable {
@SuppressWarnings("PrivateStaticFinalLoggers")
// non-static for testing
private final Logger logger;
@@ -1805,10 +1802,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
.isRevertReasonEnabled(isRevertReasonEnabled)
.storageProvider(storageProvider)
.isEarlyRoundChangeEnabled(unstableQbftOptions.isEarlyRoundChangeEnabled())
.gasLimitCalculator(
miningParametersSupplier.get().getTargetGasLimit().isPresent()
? new FrontierTargetingGasLimitCalculator()
: GasLimitCalculator.constant())
.requiredBlocks(requiredBlocks)
.reorgLoggingThreshold(reorgLoggingThreshold)
.evmConfiguration(unstableEvmOptions.toDomainObject())
@@ -2139,13 +2132,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
getGenesisBlockPeriodSeconds(genesisConfigOptionsSupplier.get())
.ifPresent(miningParameters::setBlockPeriodSeconds);
initMiningParametersMetrics(miningParameters);
// if network = holesky, set targetGasLimit to 36,000,000 unless otherwise specified
if (miningParameters.getTargetGasLimit().isEmpty() && NetworkName.HOLESKY.equals(network)) {
logger.info(
"Setting target gas limit for holesky: {}",
MiningConfiguration.DEFAULT_TARGET_GAS_LIMIT_HOLESKY);
miningParameters.setTargetGasLimit(MiningConfiguration.DEFAULT_TARGET_GAS_LIMIT_HOLESKY);
}
return miningParameters;
}

View File

@@ -26,7 +26,6 @@ import org.hyperledger.besu.consensus.qbft.BFTPivotSelectorFromPeers;
import org.hyperledger.besu.cryptoservices.NodeKey;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.ConsensusContext;
import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.ApiConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.methods.JsonRpcMethods;
@@ -168,9 +167,6 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
/** The Is revert reason enabled. */
protected boolean isRevertReasonEnabled;
/** The Gas limit calculator. */
GasLimitCalculator gasLimitCalculator;
/** The Storage provider. */
protected StorageProvider storageProvider;
@@ -418,17 +414,6 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
return this;
}
/**
* Gas limit calculator besu controller builder.
*
* @param gasLimitCalculator the gas limit calculator
* @return the besu controller builder
*/
public BesuControllerBuilder gasLimitCalculator(final GasLimitCalculator gasLimitCalculator) {
this.gasLimitCalculator = gasLimitCalculator;
return this;
}
/**
* Required blocks besu controller builder.
*
@@ -586,7 +571,6 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
checkNotNull(transactionPoolConfiguration, "Missing transaction pool configuration");
checkNotNull(nodeKey, "Missing node key");
checkNotNull(storageProvider, "Must supply a storage provider");
checkNotNull(gasLimitCalculator, "Missing gas limit calculator");
checkNotNull(evmConfiguration, "Missing evm config");
checkNotNull(networkingConfiguration, "Missing network configuration");
checkNotNull(apiConfiguration, "Missing API configuration");

View File

@@ -26,7 +26,6 @@ import org.hyperledger.besu.consensus.common.MigratingProtocolContext;
import org.hyperledger.besu.cryptoservices.NodeKey;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.ConsensusContext;
import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.methods.JsonRpcMethods;
import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator;
@@ -364,12 +363,6 @@ public class ConsensusScheduleBesuControllerBuilder extends BesuControllerBuilde
return super.isParallelTxProcessingEnabled(isParallelTxProcessingEnabled);
}
@Override
public BesuControllerBuilder gasLimitCalculator(final GasLimitCalculator gasLimitCalculator) {
besuControllerBuilderSchedule.values().forEach(b -> b.gasLimitCalculator(gasLimitCalculator));
return super.gasLimitCalculator(gasLimitCalculator);
}
@Override
public BesuControllerBuilder requiredBlocks(final Map<Long, Hash> requiredBlocks) {
besuControllerBuilderSchedule.values().forEach(b -> b.requiredBlocks(requiredBlocks));

View File

@@ -24,7 +24,6 @@ import org.hyperledger.besu.consensus.merge.blockcreation.TransitionCoordinator;
import org.hyperledger.besu.cryptoservices.NodeKey;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.ConsensusContext;
import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator;
import org.hyperledger.besu.ethereum.chain.Blockchain;
@@ -390,12 +389,6 @@ public class TransitionBesuControllerBuilder extends BesuControllerBuilder {
return propagateConfig(z -> z.isParallelTxProcessingEnabled(isParallelTxProcessingEnabled));
}
@Override
public BesuControllerBuilder gasLimitCalculator(final GasLimitCalculator gasLimitCalculator) {
super.gasLimitCalculator(gasLimitCalculator);
return propagateConfig(z -> z.gasLimitCalculator(gasLimitCalculator));
}
@Override
public BesuControllerBuilder requiredBlocks(final Map<Long, Hash> requiredBlocks) {
super.requiredBlocks(requiredBlocks);

View File

@@ -27,7 +27,6 @@ import org.hyperledger.besu.controller.BesuController;
import org.hyperledger.besu.cryptoservices.NodeKeyUtils;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.enclave.EnclaveFactory;
import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.api.ImmutableApiConfiguration;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
@@ -159,7 +158,6 @@ class FlexGroupPrivacyTest {
.clock(TestClock.fixed())
.privacyParameters(privacyParameters)
.transactionPoolConfiguration(TransactionPoolConfiguration.DEFAULT)
.gasLimitCalculator(GasLimitCalculator.constant())
.evmConfiguration(EvmConfiguration.DEFAULT)
.networkConfiguration(NetworkingConfiguration.create())
.besuComponent(context)

View File

@@ -39,7 +39,6 @@ import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.enclave.Enclave;
import org.hyperledger.besu.enclave.EnclaveFactory;
import org.hyperledger.besu.enclave.types.ReceiveResponse;
import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.ImmutableApiConfiguration;
import org.hyperledger.besu.ethereum.chain.DefaultBlockchain;
@@ -555,7 +554,6 @@ public class PrivacyReorgTest {
.clock(TestClock.fixed())
.privacyParameters(privacyParameters)
.transactionPoolConfiguration(TransactionPoolConfiguration.DEFAULT)
.gasLimitCalculator(GasLimitCalculator.constant())
.evmConfiguration(EvmConfiguration.DEFAULT)
.networkConfiguration(NetworkingConfiguration.create())
.besuComponent(context)

View File

@@ -27,7 +27,6 @@ import org.hyperledger.besu.config.GenesisConfig;
import org.hyperledger.besu.controller.BesuController;
import org.hyperledger.besu.cryptoservices.NodeKeyUtils;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.api.ImmutableApiConfiguration;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
@@ -134,7 +133,6 @@ class PrivacyTest {
.clock(TestClock.fixed())
.privacyParameters(privacyParameters)
.transactionPoolConfiguration(TransactionPoolConfiguration.DEFAULT)
.gasLimitCalculator(GasLimitCalculator.constant())
.evmConfiguration(EvmConfiguration.DEFAULT)
.networkConfiguration(NetworkingConfiguration.create())
.besuComponent(context)

View File

@@ -34,7 +34,6 @@ import org.hyperledger.besu.controller.MainnetBesuControllerBuilder;
import org.hyperledger.besu.crypto.KeyPairUtil;
import org.hyperledger.besu.cryptoservices.NodeKey;
import org.hyperledger.besu.cryptoservices.NodeKeyUtils;
import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.ImmutableApiConfiguration;
import org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration;
@@ -500,7 +499,6 @@ public final class RunnerTest {
.clock(TestClock.fixed())
.transactionPoolConfiguration(TransactionPoolConfiguration.DEFAULT)
.dataStorageConfiguration(DataStorageConfiguration.DEFAULT_FOREST_CONFIG)
.gasLimitCalculator(GasLimitCalculator.constant())
.evmConfiguration(EvmConfiguration.DEFAULT)
.networkConfiguration(NetworkingConfiguration.create())
.randomPeerPriority(Boolean.FALSE)

View File

@@ -24,7 +24,6 @@ import org.hyperledger.besu.cli.config.NetworkName;
import org.hyperledger.besu.components.BesuComponent;
import org.hyperledger.besu.controller.BesuController;
import org.hyperledger.besu.cryptoservices.NodeKeyUtils;
import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.api.ImmutableApiConfiguration;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.Block;
@@ -102,7 +101,6 @@ public final class RlpBlockExporterTest {
.dataDirectory(dataDir)
.clock(TestClock.fixed())
.transactionPoolConfiguration(TransactionPoolConfiguration.DEFAULT)
.gasLimitCalculator(GasLimitCalculator.constant())
.evmConfiguration(EvmConfiguration.DEFAULT)
.networkConfiguration(NetworkingConfiguration.create())
.besuComponent(mock(BesuComponent.class))

View File

@@ -27,7 +27,6 @@ import org.hyperledger.besu.controller.BesuController;
import org.hyperledger.besu.cryptoservices.NodeKeyUtils;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.api.ImmutableApiConfiguration;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.Block;
@@ -472,7 +471,6 @@ public abstract class JsonBlockImporterTest {
.dataDirectory(dataDir)
.clock(TestClock.fixed())
.transactionPoolConfiguration(TransactionPoolConfiguration.DEFAULT)
.gasLimitCalculator(GasLimitCalculator.constant())
.evmConfiguration(EvmConfiguration.DEFAULT)
.networkConfiguration(NetworkingConfiguration.create())
.besuComponent(DaggerJsonBlockImporterTest_JsonBlockImportComponent.builder().build())

View File

@@ -24,7 +24,6 @@ import org.hyperledger.besu.components.BesuComponent;
import org.hyperledger.besu.config.MergeConfiguration;
import org.hyperledger.besu.controller.BesuController;
import org.hyperledger.besu.cryptoservices.NodeKeyUtils;
import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.api.ImmutableApiConfiguration;
import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider;
import org.hyperledger.besu.ethereum.core.MiningConfiguration;
@@ -77,7 +76,6 @@ public final class RlpBlockImporterTest {
.dataDirectory(dataDir)
.clock(TestClock.fixed())
.transactionPoolConfiguration(TransactionPoolConfiguration.DEFAULT)
.gasLimitCalculator(GasLimitCalculator.constant())
.evmConfiguration(EvmConfiguration.DEFAULT)
.networkConfiguration(NetworkingConfiguration.create())
.besuComponent(mock(BesuComponent.class))
@@ -112,7 +110,6 @@ public final class RlpBlockImporterTest {
.dataDirectory(dataDir)
.clock(TestClock.fixed())
.transactionPoolConfiguration(TransactionPoolConfiguration.DEFAULT)
.gasLimitCalculator(GasLimitCalculator.constant())
.evmConfiguration(EvmConfiguration.DEFAULT)
.networkConfiguration(NetworkingConfiguration.create())
.besuComponent(mock(BesuComponent.class))
@@ -144,7 +141,6 @@ public final class RlpBlockImporterTest {
.dataDirectory(dataDir)
.clock(TestClock.fixed())
.transactionPoolConfiguration(TransactionPoolConfiguration.DEFAULT)
.gasLimitCalculator(GasLimitCalculator.constant())
.evmConfiguration(EvmConfiguration.DEFAULT)
.networkConfiguration(NetworkingConfiguration.create())
.besuComponent(mock(BesuComponent.class))

View File

@@ -51,7 +51,6 @@ import org.hyperledger.besu.config.MergeConfiguration;
import org.hyperledger.besu.crypto.SignatureAlgorithmFactory;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.api.ApiConfiguration;
import org.hyperledger.besu.ethereum.api.ImmutableApiConfiguration;
import org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration;
@@ -283,7 +282,6 @@ public class BesuCommandTest extends CommandTestAbstract {
verify(mockControllerBuilder).miningParameters(miningArg.capture());
verify(mockControllerBuilder).nodeKey(isNotNull());
verify(mockControllerBuilder).storageProvider(storageProviderArgumentCaptor.capture());
verify(mockControllerBuilder).gasLimitCalculator(eq(GasLimitCalculator.constant()));
verify(mockControllerBuilder).maxPeers(eq(maxPeers));
verify(mockControllerBuilder).maxRemotelyInitiatedPeers(eq((int) Math.floor(0.6 * maxPeers)));
verify(mockControllerBuilder).build();
@@ -497,17 +495,19 @@ public class BesuCommandTest extends CommandTestAbstract {
public void testGenesisPathMainnetEthConfig() {
final ArgumentCaptor<EthNetworkConfig> networkArg =
ArgumentCaptor.forClass(EthNetworkConfig.class);
final ArgumentCaptor<MiningConfiguration> miningArg =
ArgumentCaptor.forClass(MiningConfiguration.class);
parseCommand("--network", "mainnet");
verify(mockControllerBuilderFactory).fromEthNetworkConfig(networkArg.capture(), any());
verify(mockControllerBuilder).miningParameters(miningArg.capture());
verify(mockControllerBuilder).build();
final EthNetworkConfig config = networkArg.getValue();
assertThat(config.bootNodes()).isEqualTo(MAINNET_BOOTSTRAP_NODES);
assertThat(config.dnsDiscoveryUrl()).isEqualTo(MAINNET_DISCOVERY_URL);
assertThat(config.networkId()).isEqualTo(BigInteger.valueOf(1));
verify(mockLogger, never()).warn(contains("Mainnet is deprecated and will be shutdown"));
}
@@ -1774,14 +1774,18 @@ public class BesuCommandTest extends CommandTestAbstract {
final ArgumentCaptor<EthNetworkConfig> networkArg =
ArgumentCaptor.forClass(EthNetworkConfig.class);
final ArgumentCaptor<MiningConfiguration> miningArg =
ArgumentCaptor.forClass(MiningConfiguration.class);
verify(mockControllerBuilderFactory).fromEthNetworkConfig(networkArg.capture(), any());
verify(mockControllerBuilder).miningParameters(miningArg.capture());
verify(mockControllerBuilder).build();
assertThat(networkArg.getValue()).isEqualTo(EthNetworkConfig.getNetworkConfig(SEPOLIA));
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
assertThat(miningArg.getValue().getTargetGasLimit()).isEmpty();
verify(mockLogger, never()).warn(contains("Sepolia is deprecated and will be shutdown"));
}
@@ -1792,14 +1796,18 @@ public class BesuCommandTest extends CommandTestAbstract {
final ArgumentCaptor<EthNetworkConfig> networkArg =
ArgumentCaptor.forClass(EthNetworkConfig.class);
final ArgumentCaptor<MiningConfiguration> miningArg =
ArgumentCaptor.forClass(MiningConfiguration.class);
verify(mockControllerBuilderFactory).fromEthNetworkConfig(networkArg.capture(), any());
verify(mockControllerBuilder).miningParameters(miningArg.capture());
verify(mockControllerBuilder).build();
assertThat(networkArg.getValue()).isEqualTo(EthNetworkConfig.getNetworkConfig(HOLESKY));
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
assertThat(miningArg.getValue().getTargetGasLimit()).isEmpty();
verify(mockLogger, never()).warn(contains("Holesky is deprecated and will be shutdown"));
}
@@ -1823,8 +1831,7 @@ public class BesuCommandTest extends CommandTestAbstract {
assertThat(miningArg.getValue().getCoinbase()).isEqualTo(Optional.empty());
assertThat(miningArg.getValue().getMinTransactionGasPrice()).isEqualTo(Wei.of(1000));
assertThat(miningArg.getValue().getExtraData()).isEqualTo(Bytes.EMPTY);
assertThat(miningArg.getValue().getTargetGasLimit().getAsLong())
.isEqualTo(MiningConfiguration.DEFAULT_TARGET_GAS_LIMIT_HOLESKY);
assertThat(miningArg.getValue().getTargetGasLimit()).isEmpty();
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();

View File

@@ -282,7 +282,6 @@ public abstract class CommandTestAbstract {
.thenReturn(mockControllerBuilder);
when(mockControllerBuilder.isEarlyRoundChangeEnabled(false)).thenReturn(mockControllerBuilder);
when(mockControllerBuilder.storageProvider(any())).thenReturn(mockControllerBuilder);
when(mockControllerBuilder.gasLimitCalculator(any())).thenReturn(mockControllerBuilder);
when(mockControllerBuilder.requiredBlocks(any())).thenReturn(mockControllerBuilder);
when(mockControllerBuilder.reorgLoggingThreshold(anyLong())).thenReturn(mockControllerBuilder);
when(mockControllerBuilder.dataStorageConfiguration(any())).thenReturn(mockControllerBuilder);

View File

@@ -23,7 +23,6 @@ import static org.mockito.Mockito.verify;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.Unstable;
@@ -38,7 +37,6 @@ import java.util.Optional;
import org.apache.tuweni.bytes.Bytes;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.junit.jupiter.MockitoExtension;
@ExtendWith(MockitoExtension.class)
@@ -273,20 +271,6 @@ public class MiningOptionsTest extends AbstractCLIOptionsTest<MiningConfiguratio
"--target-gas-limit=10000000");
}
@Test
public void targetGasLimitIsDisabledWhenNotSpecified() {
internalTestSuccess(
miningParams -> {
final ArgumentCaptor<GasLimitCalculator> gasLimitCalculatorArgumentCaptor =
ArgumentCaptor.forClass(GasLimitCalculator.class);
verify(mockControllerBuilder)
.gasLimitCalculator(gasLimitCalculatorArgumentCaptor.capture());
assertThat(gasLimitCalculatorArgumentCaptor.getValue())
.isEqualTo(GasLimitCalculator.constant());
});
}
@Test
public void posBlockCreationMaxTimeDefaultValue() {
internalTestSuccess(

View File

@@ -28,7 +28,6 @@ import org.hyperledger.besu.cryptoservices.NodeKeyUtils;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.api.ImmutableApiConfiguration;
import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockBody;
@@ -83,7 +82,6 @@ public abstract class AbstractBftBesuControllerBuilderTest {
@Mock private PrivacyParameters privacyParameters;
@Mock private Clock clock;
@Mock private StorageProvider storageProvider;
@Mock private GasLimitCalculator gasLimitCalculator;
@Mock private WorldStatePreimageStorage worldStatePreimageStorage;
private static final BigInteger networkId = BigInteger.ONE;
private static final NodeKey nodeKey = NodeKeyUtils.generate();
@@ -156,7 +154,6 @@ public abstract class AbstractBftBesuControllerBuilderTest {
.dataStorageConfiguration(DataStorageConfiguration.DEFAULT_FOREST_CONFIG)
.nodeKey(nodeKey)
.storageProvider(storageProvider)
.gasLimitCalculator(gasLimitCalculator)
.evmConfiguration(EvmConfiguration.DEFAULT)
.besuComponent(mock(BesuComponent.class))
.networkConfiguration(NetworkingConfiguration.create())

View File

@@ -32,7 +32,6 @@ import org.hyperledger.besu.cryptoservices.NodeKeyUtils;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.api.ImmutableApiConfiguration;
import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockBody;
@@ -88,7 +87,6 @@ public class CliqueBesuControllerBuilderTest {
@Mock private PrivacyParameters privacyParameters;
@Mock private Clock clock;
@Mock private StorageProvider storageProvider;
@Mock private GasLimitCalculator gasLimitCalculator;
@Mock private WorldStatePreimageStorage worldStatePreimageStorage;
private static final BigInteger networkId = BigInteger.ONE;
private static final NodeKey nodeKey = NodeKeyUtils.generate();
@@ -189,7 +187,6 @@ public class CliqueBesuControllerBuilderTest {
.dataStorageConfiguration(DataStorageConfiguration.DEFAULT_FOREST_CONFIG)
.nodeKey(nodeKey)
.storageProvider(storageProvider)
.gasLimitCalculator(gasLimitCalculator)
.evmConfiguration(EvmConfiguration.DEFAULT)
.besuComponent(mock(BesuComponent.class))
.networkConfiguration(NetworkingConfiguration.create())

View File

@@ -176,7 +176,6 @@ public class MergeBesuControllerBuilderTest {
MergeBesuControllerBuilder visitWithMockConfigs(final MergeBesuControllerBuilder builder) {
return (MergeBesuControllerBuilder)
builder
.gasLimitCalculator(gasLimitCalculator)
.genesisConfig(genesisConfig)
.synchronizerConfiguration(synchronizerConfiguration)
.ethProtocolConfiguration(ethProtocolConfiguration)

View File

@@ -50,6 +50,7 @@ import org.hyperledger.besu.plugin.services.exception.StorageException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.math.BigInteger;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -79,7 +80,16 @@ public class MergeCoordinator implements MergeMiningCoordinator, BadChainListene
*/
private static final double TRY_FILL_BLOCK = 1.0;
private static final long DEFAULT_TARGET_GAS_LIMIT = 30000000L;
private static final long DEFAULT_TARGET_GAS_LIMIT = 36_000_000L;
// testnets might have higher gas limits than mainnet
private static final long DEFAULT_TARGET_GAS_LIMIT_TESTNET = 36_000_000L;
private static final List<BigInteger> TESTNET_CHAIN_IDS =
List.of(
BigInteger.valueOf(11155111), // Sepolia
BigInteger.valueOf(17000), // Holesky
BigInteger.valueOf(39438135) // Ephemery
);
/** The Mining parameters. */
protected final MiningConfiguration miningConfiguration;
@@ -134,7 +144,7 @@ public class MergeCoordinator implements MergeMiningCoordinator, BadChainListene
miningParams.setCoinbase(Address.ZERO);
}
if (miningParams.getTargetGasLimit().isEmpty()) {
miningParams.setTargetGasLimit(DEFAULT_TARGET_GAS_LIMIT);
miningParams.setTargetGasLimit(getDefaultGasLimit(protocolSchedule));
}
miningParams.setMinBlockOccupancyRatio(TRY_FILL_BLOCK);
@@ -180,7 +190,7 @@ public class MergeCoordinator implements MergeMiningCoordinator, BadChainListene
this.mergeContext = protocolContext.getConsensusContext(MergeContext.class);
this.backwardSyncContext = backwardSyncContext;
if (miningParams.getTargetGasLimit().isEmpty()) {
miningParams.setTargetGasLimit(DEFAULT_TARGET_GAS_LIMIT);
miningParams.setTargetGasLimit(getDefaultGasLimit(protocolSchedule));
}
miningParams.setMinBlockOccupancyRatio(TRY_FILL_BLOCK);
this.miningConfiguration = miningParams;
@@ -877,6 +887,15 @@ public class MergeCoordinator implements MergeMiningCoordinator, BadChainListene
return job.cancelled.get();
}
private long getDefaultGasLimit(final ProtocolSchedule protocolSchedule) {
if (protocolSchedule.getChainId().isPresent()
&& TESTNET_CHAIN_IDS.contains(protocolSchedule.getChainId().get())) {
return DEFAULT_TARGET_GAS_LIMIT_TESTNET;
}
return DEFAULT_TARGET_GAS_LIMIT;
}
private static class BlockCreationTask {
/** The Block creator. */
final MergeBlockCreator blockCreator;

View File

@@ -25,6 +25,7 @@ import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doCallRealMethod;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
@@ -80,16 +81,19 @@ import org.hyperledger.besu.metrics.StubMetricsSystem;
import org.hyperledger.besu.testutil.TestClock;
import org.hyperledger.besu.util.number.Fraction;
import java.math.BigInteger;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.OptionalLong;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Stream;
import com.google.common.base.Suppliers;
import org.apache.tuweni.bytes.Bytes;
@@ -97,6 +101,10 @@ import org.apache.tuweni.bytes.Bytes32;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.aggregator.ArgumentsAccessor;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.mockito.Answers;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
@@ -969,6 +977,39 @@ public class MergeCoordinatorTest implements MergeGenesisConfigHelper {
verify(blockchain, never()).rewindToBlock(any());
}
@ParameterizedTest(name = "{index}: {0}")
@MethodSource("getGasLimits")
public void shouldSetCorrectTargetGasLimit(final ArgumentsAccessor argumentsAccessor) {
final long chainId = argumentsAccessor.getLong(1);
final long expectedTargetGasLimit = argumentsAccessor.getLong(2);
final MiningConfiguration mockMiningConfiguration = mock(MiningConfiguration.class);
when(mockMiningConfiguration.getTargetGasLimit()).thenReturn(OptionalLong.empty());
when(protocolSchedule.getChainId()).thenReturn(Optional.of(BigInteger.valueOf(chainId)));
doNothing().when(backwardSyncContext).subscribeBadChainListener(any());
MergeCoordinator testTargetGasLimitCoordinator =
new MergeCoordinator(
protocolContext,
protocolSchedule,
ethScheduler,
transactionPool,
mockMiningConfiguration,
backwardSyncContext,
Optional.empty());
assertThat(testTargetGasLimitCoordinator).isNotNull();
verify(mockMiningConfiguration).setTargetGasLimit(expectedTargetGasLimit);
}
public static Stream<Arguments> getGasLimits() {
return Stream.of(
Arguments.of("mainnet", 1L, 36_000_000L),
Arguments.of("holesky", 17_000L, 36_000_000L),
Arguments.of("sepolia", 11_155_111L, 36_000_000L),
Arguments.of("ephemery", 39_438_135L, 36_000_000L));
}
private void sendNewPayloadAndForkchoiceUpdate(
final Block block, final Optional<BlockHeader> finalizedHeader, final Hash safeHash) {

View File

@@ -38,7 +38,6 @@ import org.immutables.value.Value;
@Value.Immutable
@Value.Enclosing
public abstract class MiningConfiguration {
public static final long DEFAULT_TARGET_GAS_LIMIT_HOLESKY = 36_000_000L;
public static final PositiveNumber DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME =
PositiveNumber.fromInt((int) Duration.ofSeconds(5).toMillis());
public static final PositiveNumber DEFAULT_POA_BLOCK_TXS_SELECTION_MAX_TIME =

View File

@@ -875,7 +875,6 @@ public abstract class MainnetProtocolSpecs {
.requestsValidator(new MainnetRequestsValidator())
// EIP-7002 Withdrawals / EIP-6610 Deposits / EIP-7685 Requests
.requestProcessorCoordinator(pragueRequestsProcessors(requestContractAddresses))
// change to accept EIP-7702 transactions
.transactionValidatorFactoryBuilder(
(evm, gasLimitCalculator, feeMarket) ->

View File

@@ -37,6 +37,13 @@ import org.slf4j.LoggerFactory;
public class SystemCallProcessor {
private static final Logger LOG = LoggerFactory.getLogger(SystemCallProcessor.class);
/**
* The gas limit as defined in <a
* href="https://eips.ethereum.org/EIPS/eip-2935#block-processing">EIP-2935</a> This value is
* independent of the gas limit of the block
*/
private static final long SYSTEM_CALL_GAS_LIMIT = 30_000_000L;
/** The system address */
static final Address SYSTEM_ADDRESS =
Address.fromHexString("0xfffffffffffffffffffffffffffffffffffffffe");
@@ -108,7 +115,7 @@ public class SystemCallProcessor {
return MessageFrame.builder()
.maxStackSize(DEFAULT_MAX_STACK_SIZE)
.worldUpdater(worldUpdater)
.initialGas(30_000_000L)
.initialGas(SYSTEM_CALL_GAS_LIMIT)
.originator(SYSTEM_ADDRESS)
.gasPrice(Wei.ZERO)
.blobGasPrice(Wei.ZERO)