mirror of
https://github.com/vacp2p/status-linea-besu.git
synced 2026-01-08 21:38:15 -05:00
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:
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
@@ -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.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user