Merge branch 'main' into zkbesu

# Conflicts:
#	acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java
This commit is contained in:
Fabio Di Fabio
2024-08-21 10:19:57 +02:00
17 changed files with 141 additions and 52 deletions

View File

@@ -10,6 +10,7 @@
### Additions and Improvements
- Add 'inbound' field to admin_peers JSON-RPC Call [#7461](https://github.com/hyperledger/besu/pull/7461)
- Add pending block header to `TransactionEvaluationContext` plugin API [#7483](https://github.com/hyperledger/besu/pull/7483)
- Add bootnode to holesky config [#7500](https://github.com/hyperledger/besu/pull/7500)
### Bug fixes
- Fix tracing in precompiled contracts when halting for out of gas [#7318](https://github.com/hyperledger/besu/issues/7318)

View File

@@ -57,6 +57,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.junit.After;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -183,4 +184,11 @@ public class AcceptanceTestBase {
assertThat(node.execute(ethTransactions.blockNumber()))
.isGreaterThanOrEqualTo(BigInteger.valueOf(blockchainHeight)));
}
@Test
public void dryRunDetector() {
assertThat(true)
.withFailMessage("This test is here so gradle --dry-run executes this class")
.isTrue();
}
}

View File

@@ -58,6 +58,7 @@ import java.util.concurrent.Executors;
import org.apache.logging.log4j.ThreadContext;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.extension.ExtendWith;
import org.slf4j.Logger;
@@ -196,4 +197,11 @@ public class AcceptanceTestBaseJunit5 {
assertThat(node.execute(ethTransactions.blockNumber()))
.isGreaterThanOrEqualTo(BigInteger.valueOf(blockchainHeight)));
}
@Test
void dryRunDetector() {
assertThat(true)
.withFailMessage("This test is here so gradle --dry-run executes this class")
.isTrue();
}
}

View File

@@ -24,8 +24,6 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration;
import org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration;
import org.hyperledger.besu.ethereum.p2p.rlpx.connections.netty.TLSConfiguration;
import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration;
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
import org.hyperledger.besu.ethereum.worldstate.ImmutableDataStorageConfiguration;
import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration;
import org.hyperledger.besu.plugin.services.metrics.MetricCategory;
import org.hyperledger.besu.tests.acceptance.dsl.StaticNodesUtils;
@@ -113,11 +111,7 @@ public class ProcessBesuNodeRunner implements BesuNodeRunner {
.getCLIOptions());
params.addAll(
DataStorageOptions.fromConfig(
ImmutableDataStorageConfiguration.builder()
.from(DataStorageConfiguration.DEFAULT_FOREST_CONFIG)
.build())
.getCLIOptions());
DataStorageOptions.fromConfig(node.getDataStorageConfiguration()).getCLIOptions());
if (node.getMiningParameters().isMiningEnabled()) {
params.add("--miner-enabled");

View File

@@ -40,7 +40,6 @@ import org.hyperledger.besu.ethereum.p2p.peers.EnodeURLImpl;
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProvider;
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProviderBuilder;
import org.hyperledger.besu.ethereum.transaction.TransactionSimulator;
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.MetricsSystemFactory;
import org.hyperledger.besu.metrics.ObservableMetricsSystem;
@@ -250,7 +249,7 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
.nodeKey(new NodeKey(new KeyPairSecurityModule(KeyPairUtil.loadKeyPair(dataDir))))
.metricsSystem(metricsSystem)
.transactionPoolConfiguration(txPoolConfig)
.dataStorageConfiguration(DataStorageConfiguration.DEFAULT_FOREST_CONFIG)
.dataStorageConfiguration(node.getDataStorageConfiguration())
.ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
.clock(Clock.systemUTC())
.isRevertReasonEnabled(node.isRevertReasonEnabled())

View File

@@ -40,6 +40,7 @@ import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
@@ -147,4 +148,11 @@ abstract class AbstractJsonRpcTest {
return Arrays.stream(testCasesList).sorted().map(File::toURI).map(Arguments::of);
}
@Test
void dryRunDetector() {
assertThat(true)
.withFailMessage("This test is here so gradle --dry-run executes this class")
.isTrue();
}
}

View File

@@ -21,7 +21,7 @@
"id" : 67,
"error" : {
"code" : -32602,
"message" : "Invalid params"
"message" : "Invalid withdrawals"
}
},
"statusCode" : 200

View File

@@ -28,8 +28,7 @@
"id": 67,
"error": {
"code": -32602,
"message": "Invalid params",
"data": "Invalid withdrawals"
"message": "Invalid withdrawals"
}
},
"statusCode": 200

View File

@@ -1651,15 +1651,17 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
}
private GenesisConfigFile readGenesisConfigFile() {
return genesisFile != null
? GenesisConfigFile.fromSource(genesisConfigSource(genesisFile))
: GenesisConfigFile.fromResource(
Optional.ofNullable(network).orElse(MAINNET).getGenesisFile());
final GenesisConfigFile effectiveGenesisFile =
genesisFile != null
? GenesisConfigFile.fromSource(genesisConfigSource(genesisFile))
: GenesisConfigFile.fromResource(
Optional.ofNullable(network).orElse(MAINNET).getGenesisFile());
return effectiveGenesisFile.withOverrides(genesisConfigOverrides);
}
private GenesisConfigOptions readGenesisConfigOptions() {
try {
return genesisConfigFileSupplier.get().getConfigOptions(genesisConfigOverrides);
return genesisConfigFileSupplier.get().getConfigOptions();
} catch (final Exception e) {
throw new ParameterException(
this.commandLine, "Unable to load genesis file. " + e.getCause());

View File

@@ -171,6 +171,60 @@ public class BesuCommandTest extends CommandTestAbstract {
MergeConfigOptions.setMergeEnabled(false);
}
@Test
public void testGenesisOverrideOptions() throws Exception {
parseCommand("--override-genesis-config", "shanghaiTime=123");
final ArgumentCaptor<EthNetworkConfig> networkArg =
ArgumentCaptor.forClass(EthNetworkConfig.class);
verify(mockControllerBuilderFactory).fromEthNetworkConfig(networkArg.capture(), any());
verify(mockControllerBuilder).build();
final EthNetworkConfig config = networkArg.getValue();
// mainnet defaults
assertThat(config.networkId()).isEqualTo(BigInteger.valueOf(1));
// assert that shanghaiTime override is applied
final GenesisConfigFile actualGenesisConfigFile = (config.genesisConfigFile());
assertThat(actualGenesisConfigFile).isNotNull();
assertThat(actualGenesisConfigFile.getConfigOptions().getShanghaiTime()).isNotEmpty();
assertThat(actualGenesisConfigFile.getConfigOptions().getShanghaiTime().getAsLong())
.isEqualTo(123);
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}
@Test
public void testGenesisOverrideOptionsWithCustomGenesis() throws Exception {
final Path genesisFile = createFakeGenesisFile(GENESIS_VALID_JSON);
parseCommand(
"--genesis-file", genesisFile.toString(), "--override-genesis-config", "shanghaiTime=123");
final ArgumentCaptor<EthNetworkConfig> networkArg =
ArgumentCaptor.forClass(EthNetworkConfig.class);
verify(mockControllerBuilderFactory).fromEthNetworkConfig(networkArg.capture(), any());
verify(mockControllerBuilder).build();
final EthNetworkConfig config = networkArg.getValue();
assertThat(config.bootNodes()).isEmpty();
assertThat(config.dnsDiscoveryUrl()).isNull();
assertThat(config.networkId()).isEqualTo(BigInteger.valueOf(3141592));
// then assert that the shanghaiTime is applied
final GenesisConfigFile actualGenesisConfigFile = (config.genesisConfigFile());
assertThat(actualGenesisConfigFile).isNotNull();
assertThat(actualGenesisConfigFile.getConfigOptions().getShanghaiTime()).isNotEmpty();
assertThat(actualGenesisConfigFile.getConfigOptions().getShanghaiTime().getAsLong())
.isEqualTo(123);
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}
@Test
public void callingHelpSubCommandMustDisplayUsage() {
parseCommand("--help");

View File

@@ -104,7 +104,6 @@ public abstract class AbstractBftBesuControllerBuilderTest {
lenient().when(genesisConfigFile.getDifficulty()).thenReturn(Bytes.of(0).toHexString());
lenient().when(genesisConfigFile.getMixHash()).thenReturn(Hash.ZERO.toHexString());
lenient().when(genesisConfigFile.getNonce()).thenReturn(Long.toHexString(1));
lenient().when(genesisConfigFile.getConfigOptions(any())).thenReturn(genesisConfigOptions);
lenient().when(genesisConfigFile.getConfigOptions()).thenReturn(genesisConfigOptions);
lenient().when(genesisConfigOptions.getCheckpointOptions()).thenReturn(checkpointConfigOptions);
lenient()

View File

@@ -113,7 +113,6 @@ public class CliqueBesuControllerBuilderTest {
"0x0000000000000000000000000000000000000000000000000000000000000000b9b81ee349c3807e46bc71aa2632203c5b4620340000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
lenient().when(genesisConfigFile.getMixHash()).thenReturn(Hash.ZERO.toHexString());
lenient().when(genesisConfigFile.getNonce()).thenReturn(Long.toHexString(1));
lenient().when(genesisConfigFile.getConfigOptions(any())).thenReturn(genesisConfigOptions);
lenient().when(genesisConfigFile.getConfigOptions()).thenReturn(genesisConfigOptions);
lenient().when(genesisConfigOptions.getCheckpointOptions()).thenReturn(checkpointConfigOptions);
lenient()

View File

@@ -124,7 +124,6 @@ public class MergeBesuControllerBuilderTest {
lenient().when(genesisConfigFile.getExtraData()).thenReturn(Bytes.EMPTY.toHexString());
lenient().when(genesisConfigFile.getMixHash()).thenReturn(Hash.ZERO.toHexString());
lenient().when(genesisConfigFile.getNonce()).thenReturn(Long.toHexString(1));
lenient().when(genesisConfigFile.getConfigOptions(any())).thenReturn(genesisConfigOptions);
lenient().when(genesisConfigFile.getConfigOptions()).thenReturn(genesisConfigOptions);
lenient().when(genesisConfigOptions.getCheckpointOptions()).thenReturn(checkpointConfigOptions);
when(genesisConfigOptions.getTerminalTotalDifficulty())

View File

@@ -18,7 +18,6 @@ import org.hyperledger.besu.datatypes.Wei;
import java.net.URL;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -41,6 +40,7 @@ public class GenesisConfigFile {
private final GenesisReader loader;
private final ObjectNode genesisRoot;
private Map<String, String> overrides;
private GenesisConfigFile(final GenesisReader loader) {
this.loader = loader;
@@ -107,36 +107,42 @@ public class GenesisConfigFile {
}
/**
* Gets config options.
* Gets config options, including any overrides.
*
* @return the config options
*/
public GenesisConfigOptions getConfigOptions() {
return getConfigOptions(Collections.emptyMap());
}
/**
* Gets config options.
*
* @param overrides the overrides
* @return the config options
*/
public GenesisConfigOptions getConfigOptions(final Map<String, String> overrides) {
final ObjectNode config = loader.getConfig();
Map<String, String> overridesRef = overrides;
// are there any overrides to apply?
if (this.overrides == null) {
return JsonGenesisConfigOptions.fromJsonObject(config);
}
// otherwise apply overrides
Map<String, String> overridesRef = this.overrides;
// if baseFeePerGas has been explicitly configured, pass it as an override:
final var optBaseFee = getBaseFeePerGas();
if (optBaseFee.isPresent()) {
// streams and maps cannot handle null values.
overridesRef = new HashMap<>(overrides);
overridesRef = new HashMap<>(this.overrides);
overridesRef.put("baseFeePerGas", optBaseFee.get().toShortHexString());
}
return JsonGenesisConfigOptions.fromJsonObjectWithOverrides(config, overridesRef);
}
/**
* Sets overrides for genesis options.
*
* @param overrides the overrides
* @return the config options
*/
public GenesisConfigFile withOverrides(final Map<String, String> overrides) {
this.overrides = overrides;
return this;
}
/**
* Stream allocations stream.
*

View File

@@ -20,7 +20,8 @@
"dns": "enrtree://AKA3AM6LPBYEUDMVNU3BSVQJ5AD45Y7YPOHJLEF6W26QOE4VTUDPE@all.holesky.ethdisco.net",
"bootnodes": [
"enode://ac906289e4b7f12df423d654c5a962b6ebe5b3a74cc9e06292a85221f9a64a6f1cfdd6b714ed6dacef51578f92b34c60ee91e9ede9c7f8fadc4d347326d95e2b@146.190.13.128:30303",
"enode://a3435a0155a3e837c02f5e7f5662a2f1fbc25b48e4dc232016e1c51b544cb5b4510ef633ea3278c0e970fa8ad8141e2d4d0f9f95456c537ff05fdf9b31c15072@178.128.136.233:30303"
"enode://a3435a0155a3e837c02f5e7f5662a2f1fbc25b48e4dc232016e1c51b544cb5b4510ef633ea3278c0e970fa8ad8141e2d4d0f9f95456c537ff05fdf9b31c15072@178.128.136.233:30303",
"enode://7fa09f1e8bb179ab5e73f45d3a7169a946e7b3de5ef5cea3a0d4546677e4435ee38baea4dd10b3ddfdc1f1c5e869052932af8b8aeb6f9738598ec4590d0b11a6@65.109.94.124:30303"
]
}
},

View File

@@ -187,7 +187,9 @@ class GenesisConfigFileTest {
@Test
void shouldOverrideConfigOptionsBaseFeeWhenSpecified() {
GenesisConfigOptions withOverrides =
EMPTY_CONFIG.getConfigOptions(Map.of("baseFeePerGas", Wei.of(8).toString()));
EMPTY_CONFIG
.withOverrides(Map.of("baseFeePerGas", Wei.of(8).toString()))
.getConfigOptions();
assertThat(withOverrides.getBaseFeePerGas()).contains(Wei.of(8L));
}
@@ -229,7 +231,8 @@ class GenesisConfigFileTest {
void assertTerminalTotalDifficultyOverride() {
GenesisConfigOptions sepoliaOverrideOptions =
GenesisConfigFile.fromResource("/sepolia.json")
.getConfigOptions(Map.of("terminalTotalDifficulty", String.valueOf(Long.MAX_VALUE)));
.withOverrides(Map.of("terminalTotalDifficulty", String.valueOf(Long.MAX_VALUE)))
.getConfigOptions();
assertThat(sepoliaOverrideOptions.getTerminalTotalDifficulty()).isPresent();
assertThat(sepoliaOverrideOptions.getTerminalTotalDifficulty())
@@ -355,10 +358,12 @@ class GenesisConfigFileTest {
override.put("contractSizeLimit", bigBlockString);
assertThat(config.getForkBlockNumbers()).isNotEmpty();
assertThat(config.getConfigOptions(override).getIstanbulBlockNumber()).hasValue(bigBlock);
assertThat(config.getConfigOptions(override).getChainId())
assertThat(config.withOverrides(override).getConfigOptions().getIstanbulBlockNumber())
.hasValue(bigBlock);
assertThat(config.withOverrides(override).getConfigOptions().getChainId())
.hasValue(BigInteger.valueOf(bigBlock));
assertThat(config.getConfigOptions(override).getContractSizeLimit()).hasValue(bigBlock);
assertThat(config.withOverrides(override).getConfigOptions().getContractSizeLimit())
.hasValue(bigBlock);
}
@Test
@@ -370,9 +375,11 @@ class GenesisConfigFileTest {
override.put("contractSizeLimit", null);
assertThat(config.getForkBlockNumbers()).isNotEmpty();
assertThat(config.getConfigOptions(override).getIstanbulBlockNumber()).isNotPresent();
assertThat(config.getConfigOptions(override).getChainId()).isNotPresent();
assertThat(config.getConfigOptions(override).getContractSizeLimit()).isNotPresent();
assertThat(config.withOverrides(override).getConfigOptions().getIstanbulBlockNumber())
.isNotPresent();
assertThat(config.withOverrides(override).getConfigOptions().getChainId()).isNotPresent();
assertThat(config.withOverrides(override).getConfigOptions().getContractSizeLimit())
.isNotPresent();
}
@Test
@@ -388,10 +395,12 @@ class GenesisConfigFileTest {
// all lower case
override.put("contractsizelimit", bigBlockString);
assertThat(config.getConfigOptions(override).getIstanbulBlockNumber()).hasValue(bigBlock);
assertThat(config.getConfigOptions(override).getChainId())
assertThat(config.withOverrides(override).getConfigOptions().getIstanbulBlockNumber())
.hasValue(bigBlock);
assertThat(config.withOverrides(override).getConfigOptions().getChainId())
.hasValue(BigInteger.valueOf(bigBlock));
assertThat(config.getConfigOptions(override).getContractSizeLimit()).hasValue(bigBlock);
assertThat(config.withOverrides(override).getConfigOptions().getContractSizeLimit())
.hasValue(bigBlock);
}
@Test
@@ -402,9 +411,11 @@ class GenesisConfigFileTest {
override.put("chainId", "");
override.put("contractSizeLimit", "");
assertThat(config.getConfigOptions(override).getIstanbulBlockNumber()).isNotPresent();
assertThat(config.getConfigOptions(override).getChainId()).isNotPresent();
assertThat(config.getConfigOptions(override).getContractSizeLimit()).isNotPresent();
assertThat(config.withOverrides(override).getConfigOptions().getIstanbulBlockNumber())
.isNotPresent();
assertThat(config.withOverrides(override).getConfigOptions().getChainId()).isNotPresent();
assertThat(config.withOverrides(override).getConfigOptions().getContractSizeLimit())
.isNotPresent();
}
@Test
@@ -431,7 +442,8 @@ class GenesisConfigFileTest {
override.put("constantinopleFixBlock", "1000");
assertThatExceptionOfType(RuntimeException.class)
.isThrownBy(() -> config.getConfigOptions(override).getPetersburgBlockNumber())
.isThrownBy(
() -> config.withOverrides(override).getConfigOptions().getPetersburgBlockNumber())
.withMessage(
"Genesis files cannot specify both petersburgBlock and constantinopleFixBlock.");
}

View File

@@ -60,7 +60,7 @@ public class DifficultyCalculatorTests {
"/BasicTests/difficultyMainNetwork.json",
MainnetProtocolSchedule.fromConfig(
GenesisConfigFile.mainnet()
.getConfigOptions(postMergeOverrides),
.withOverrides(postMergeOverrides).getConfigOptions(),
EvmConfiguration.DEFAULT, MiningParameters.newDefault(), new BadBlockManager(), false, new NoOpMetricsSystem())),
Arguments.of(
"/DifficultyTests/dfGrayGlacier/difficultyGrayGlacierForkBlock.json",