Skip to content

Commit e69898b

Browse files
committed
Add BalConfiguration and config options
Signed-off-by: Miroslav Kovar <[email protected]>
1 parent ee7a3de commit e69898b

File tree

86 files changed

+529
-318
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+529
-318
lines changed

app/src/main/java/org/hyperledger/besu/RunnerBuilder.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@
7070
import org.hyperledger.besu.ethereum.eth.manager.EthPeers;
7171
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
7272
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
73+
import org.hyperledger.besu.ethereum.mainnet.BalConfiguration;
74+
import org.hyperledger.besu.ethereum.mainnet.ImmutableBalConfiguration;
7375
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
7476
import org.hyperledger.besu.ethereum.p2p.config.DiscoveryConfiguration;
7577
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
@@ -170,6 +172,7 @@ public class RunnerBuilder {
170172
private WebSocketConfiguration webSocketConfiguration;
171173
private InProcessRpcConfiguration inProcessRpcConfiguration;
172174
private ApiConfiguration apiConfiguration;
175+
private BalConfiguration balConfiguration = ImmutableBalConfiguration.builder().build();
173176
private Path dataDir;
174177
private Optional<Path> pidPath = Optional.empty();
175178
private MetricsConfiguration metricsConfiguration;
@@ -393,6 +396,17 @@ public RunnerBuilder apiConfiguration(final ApiConfiguration apiConfiguration) {
393396
return this;
394397
}
395398

399+
/**
400+
* Sets the block access list configuration.
401+
*
402+
* @param balConfiguration the BAL configuration
403+
* @return the runner builder
404+
*/
405+
public RunnerBuilder balConfiguration(final BalConfiguration balConfiguration) {
406+
this.balConfiguration = balConfiguration;
407+
return this;
408+
}
409+
396410
/**
397411
* Add Permissioning configuration.
398412
*
@@ -1260,6 +1274,7 @@ private Map<String, JsonRpcMethod> jsonRpcMethods(
12601274
besuController.getProtocolManager().ethContext().getEthPeers(),
12611275
consensusEngineServer,
12621276
apiConfiguration,
1277+
balConfiguration,
12631278
enodeDnsConfiguration,
12641279
transactionSimulator,
12651280
ethScheduler);

app/src/main/java/org/hyperledger/besu/cli/BesuCommand.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import org.hyperledger.besu.cli.error.BesuExecutionExceptionHandler;
4343
import org.hyperledger.besu.cli.error.BesuParameterExceptionHandler;
4444
import org.hyperledger.besu.cli.options.ApiConfigurationOptions;
45+
import org.hyperledger.besu.cli.options.BalConfigurationOptions;
4546
import org.hyperledger.besu.cli.options.ChainPruningOptions;
4647
import org.hyperledger.besu.cli.options.DebugTracerOptions;
4748
import org.hyperledger.besu.cli.options.DnsOptions;
@@ -122,6 +123,7 @@
122123
import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;
123124
import org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration;
124125
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
126+
import org.hyperledger.besu.ethereum.mainnet.BalConfiguration;
125127
import org.hyperledger.besu.ethereum.p2p.config.DiscoveryConfiguration;
126128
import org.hyperledger.besu.ethereum.p2p.discovery.P2PDiscoveryConfiguration;
127129
import org.hyperledger.besu.ethereum.p2p.peers.EnodeDnsConfiguration;
@@ -601,6 +603,9 @@ void setUserName(final String userName) {
601603
@CommandLine.ArgGroup(validate = false, heading = "@|bold API Configuration Options|@%n")
602604
ApiConfigurationOptions apiConfigurationOptions = new ApiConfigurationOptions();
603605

606+
@CommandLine.ArgGroup(validate = false, heading = "@|bold Block Access List Options|@%n")
607+
BalConfigurationOptions balConfigurationOptions = new BalConfigurationOptions();
608+
604609
@CommandLine.Option(
605610
names = {"--static-nodes-file"},
606611
paramLabel = MANDATORY_FILE_FORMAT_HELP,
@@ -1241,6 +1246,7 @@ private Runner buildRunner() {
12411246
jsonRpcIpcConfiguration,
12421247
inProcessRpcConfiguration,
12431248
apiConfigurationSupplier.get(),
1249+
balConfigurationOptions.toDomainObject(),
12441250
metricsConfiguration,
12451251
permissioningConfiguration,
12461252
staticNodes,
@@ -1811,6 +1817,9 @@ public BesuControllerBuilder setupControllerBuilder() {
18111817
.withMiningParameters(miningParametersSupplier.get())
18121818
.withJsonRpcHttpOptions(jsonRpcHttpOptions);
18131819
final KeyValueStorageProvider storageProvider = keyValueStorageProvider(keyValueStorageName);
1820+
final ApiConfiguration apiConfiguration = apiConfigurationSupplier.get();
1821+
final BalConfiguration balConfiguration = balConfigurationOptions.toDomainObject();
1822+
18141823
BesuControllerBuilder besuControllerBuilder =
18151824
controllerBuilder
18161825
.fromEthNetworkConfig(updateNetworkConfig(network), getDefaultSyncModeIfNotSet())
@@ -1839,16 +1848,15 @@ public BesuControllerBuilder setupControllerBuilder() {
18391848
.cacheLastBlockHeaders(numberOfBlockHeadersToCache)
18401849
.isCacheLastBlockHeadersPreloadEnabled(isCacheLastBlockHeadersPreloadEnabled)
18411850
.genesisStateHashCacheEnabled(genesisStateHashCacheEnabled)
1842-
.apiConfiguration(apiConfigurationSupplier.get())
1851+
.apiConfiguration(apiConfiguration)
1852+
.balConfiguration(balConfiguration)
18431853
.besuComponent(besuComponent);
18441854
if (DataStorageFormat.BONSAI.equals(getDataStorageConfiguration().getDataStorageFormat())) {
18451855
final PathBasedExtraStorageConfiguration subStorageConfiguration =
18461856
getDataStorageConfiguration().getPathBasedExtraStorageConfiguration();
18471857
besuControllerBuilder.isParallelTxProcessingEnabled(
18481858
subStorageConfiguration.getParallelTxProcessingEnabled());
18491859
}
1850-
besuControllerBuilder.isBlockAccessListEnabled(
1851-
apiConfigurationOptions.apiConfiguration().isBlockAccessListEnabled());
18521860
return besuControllerBuilder;
18531861
}
18541862

@@ -2112,6 +2120,7 @@ private Runner synchronize(
21122120
final JsonRpcIpcConfiguration jsonRpcIpcConfiguration,
21132121
final InProcessRpcConfiguration inProcessRpcConfiguration,
21142122
final ApiConfiguration apiConfiguration,
2123+
final BalConfiguration balConfiguration,
21152124
final MetricsConfiguration metricsConfiguration,
21162125
final Optional<PermissioningConfiguration> permissioningConfiguration,
21172126
final Collection<EnodeURL> staticNodes,
@@ -2140,6 +2149,7 @@ private Runner synchronize(
21402149
.jsonRpcIpcConfiguration(jsonRpcIpcConfiguration)
21412150
.inProcessRpcConfiguration(inProcessRpcConfiguration)
21422151
.apiConfiguration(apiConfiguration)
2152+
.balConfiguration(balConfiguration)
21432153
.pidPath(pidPath)
21442154
.dataDir(dataDir())
21452155
.bannedNodeIds(p2PDiscoveryConfig.bannedNodeIds())

app/src/main/java/org/hyperledger/besu/cli/options/ApiConfigurationOptions.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,6 @@ public ApiConfigurationOptions() {}
6060
"Set to enable gas price and minimum priority fee limit in eth_getGasPrice and eth_feeHistory (default: ${DEFAULT-VALUE})")
6161
private final Boolean apiGasAndPriorityFeeLimitingEnabled = false;
6262

63-
@CommandLine.Option(
64-
names = {"--Xapi-block-access-list-enabled"},
65-
hidden = true,
66-
description =
67-
"Set to enable eth_getBlockAccessListByNumber method and Block Access Lists in simulation results")
68-
private final Boolean apiBlockAccessListEnabled = false;
69-
7063
@CommandLine.Option(
7164
names = {"--api-gas-and-priority-fee-lower-bound-coefficient"},
7265
hidden = true,
@@ -144,8 +137,7 @@ public ApiConfiguration apiConfiguration() {
144137
.maxLogsRange(rpcMaxLogsRange)
145138
.gasCap(rpcGasCap)
146139
.isGasAndPriorityFeeLimitingEnabled(apiGasAndPriorityFeeLimitingEnabled)
147-
.maxTraceFilterRange(maxTraceFilterRange)
148-
.isBlockAccessListEnabled(apiBlockAccessListEnabled);
140+
.maxTraceFilterRange(maxTraceFilterRange);
149141
if (apiGasAndPriorityFeeLimitingEnabled) {
150142
builder
151143
.lowerBoundGasAndPriorityFeeCoefficient(apiGasAndPriorityFeeLowerBoundCoefficient)
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright contributors to Hyperledger Besu.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5+
* the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
* specific language governing permissions and limitations under the License.
12+
*
13+
* SPDX-License-Identifier: Apache-2.0
14+
*/
15+
package org.hyperledger.besu.cli.options;
16+
17+
import org.hyperledger.besu.ethereum.mainnet.BalConfiguration;
18+
import org.hyperledger.besu.ethereum.mainnet.ImmutableBalConfiguration;
19+
20+
import java.time.Duration;
21+
22+
import picocli.CommandLine;
23+
24+
/** Command-line options for configuring Block Access List behaviour. */
25+
public class BalConfigurationOptions {
26+
27+
@CommandLine.Option(
28+
names = {"--Xbal-optimization-enabled"},
29+
hidden = true,
30+
description = "Allows disabling BAL-based optimizations.")
31+
boolean balOptimizationEnabled = true;
32+
33+
@CommandLine.Option(
34+
names = {"--Xbal-trust-state-root"},
35+
hidden = true,
36+
description = "Trust the BAL-computed state root without verification.")
37+
boolean balTrustStateRoot = false;
38+
39+
@CommandLine.Option(
40+
names = {"--Xbal-lenient-on-mismatch"},
41+
hidden = true,
42+
description =
43+
"Log an error instead of throwing when the BAL-computed state root does not match the synchronously computed root.")
44+
boolean balLogErrorOnMismatch = false;
45+
46+
@CommandLine.Option(
47+
names = {"--Xbal-api-enabled"},
48+
hidden = true,
49+
description =
50+
"Set to enable eth_getBlockAccessListByNumber method and Block Access Lists in simulation results")
51+
private final Boolean balApiEnabled = false;
52+
53+
@CommandLine.Option(
54+
names = {"--Xbal-state-root-timeout"},
55+
hidden = true,
56+
paramLabel = "<INTEGER>",
57+
description = "Timeout in milliseconds when waiting for the BAL-computed state root.")
58+
private long balStateRootTimeoutMs = Duration.ofSeconds(1).toMillis();
59+
60+
public BalConfiguration toDomainObject() {
61+
return ImmutableBalConfiguration.builder()
62+
.isBalApiEnabled(balApiEnabled)
63+
.isBalOptimisationEnabled(balOptimizationEnabled)
64+
.isBalStateRootTrusted(balTrustStateRoot)
65+
.isBalLenientOnMismatch(balLogErrorOnMismatch)
66+
.balStateRootTimeout(Duration.ofMillis(balStateRootTimeoutMs))
67+
.build();
68+
}
69+
}

app/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@
7878
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
7979
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolFactory;
8080
import org.hyperledger.besu.ethereum.forkid.ForkIdManager;
81+
import org.hyperledger.besu.ethereum.mainnet.BalConfiguration;
82+
import org.hyperledger.besu.ethereum.mainnet.ImmutableBalConfiguration;
8183
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
8284
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
8385
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
@@ -215,8 +217,8 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
215217
/** whether parallel transaction processing is enabled or not */
216218
protected boolean isParallelTxProcessingEnabled;
217219

218-
/** whether block access list functionality was enabled via CLI feature flag */
219-
protected boolean isBlockAccessListEnabled;
220+
/** Configuration flags related to block access lists. */
221+
protected BalConfiguration balConfiguration = ImmutableBalConfiguration.builder().build();
220222

221223
/** The API configuration */
222224
protected ApiConfiguration apiConfiguration;
@@ -567,15 +569,13 @@ public BesuControllerBuilder isParallelTxProcessingEnabled(
567569
}
568570

569571
/**
570-
* Sets whether functionality related to testing block-level access list implementation should be
571-
* enabled. This includes caching of block-level access lists produced during block processing and
572-
* enabling an RPC endpoint serving those cached BALs.
572+
* Sets configuration for functionality related to block-level access lists.
573573
*
574-
* @param isBlockAccessListEnabled true to enable block-level access list testing functionality
574+
* @param balConfiguration configuration related to block access lists
575575
* @return the besu controller
576576
*/
577-
public BesuControllerBuilder isBlockAccessListEnabled(final boolean isBlockAccessListEnabled) {
578-
this.isBlockAccessListEnabled = isBlockAccessListEnabled;
577+
public BesuControllerBuilder balConfiguration(final BalConfiguration balConfiguration) {
578+
this.balConfiguration = balConfiguration;
579579
return this;
580580
}
581581

app/src/main/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ protected ProtocolSchedule createProtocolSchedule() {
136136
miningConfiguration,
137137
badBlockManager,
138138
isParallelTxProcessingEnabled,
139-
isBlockAccessListEnabled,
139+
balConfiguration,
140140
metricsSystem);
141141
}
142142

app/src/main/java/org/hyperledger/besu/controller/ConsensusScheduleBesuControllerBuilder.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
4747
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
4848
import org.hyperledger.besu.ethereum.forkid.ForkIdManager;
49+
import org.hyperledger.besu.ethereum.mainnet.BalConfiguration;
4950
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
5051
import org.hyperledger.besu.ethereum.p2p.config.SubProtocolConfiguration;
5152
import org.hyperledger.besu.ethereum.storage.StorageProvider;
@@ -379,11 +380,9 @@ public BesuControllerBuilder isParallelTxProcessingEnabled(
379380
}
380381

381382
@Override
382-
public BesuControllerBuilder isBlockAccessListEnabled(final boolean isBlockAccessListEnabled) {
383-
besuControllerBuilderSchedule
384-
.values()
385-
.forEach(b -> b.isBlockAccessListEnabled(isBlockAccessListEnabled));
386-
return super.isBlockAccessListEnabled(isBlockAccessListEnabled);
383+
public BesuControllerBuilder balConfiguration(final BalConfiguration balConfiguration) {
384+
besuControllerBuilderSchedule.values().forEach(b -> b.balConfiguration(balConfiguration));
385+
return super.balConfiguration(balConfiguration);
387386
}
388387

389388
@Override

app/src/main/java/org/hyperledger/besu/controller/IbftBesuControllerBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ protected ProtocolSchedule createProtocolSchedule() {
306306
miningConfiguration,
307307
badBlockManager,
308308
isParallelTxProcessingEnabled,
309-
isBlockAccessListEnabled,
309+
balConfiguration,
310310
metricsSystem);
311311
}
312312

app/src/main/java/org/hyperledger/besu/controller/MainnetBesuControllerBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ protected ProtocolSchedule createProtocolSchedule() {
101101
super.miningConfiguration,
102102
badBlockManager,
103103
isParallelTxProcessingEnabled,
104-
isBlockAccessListEnabled,
104+
balConfiguration,
105105
metricsSystem);
106106
}
107107

app/src/main/java/org/hyperledger/besu/controller/MergeBesuControllerBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ protected ProtocolSchedule createProtocolSchedule() {
181181
miningConfiguration,
182182
badBlockManager,
183183
isParallelTxProcessingEnabled,
184-
isBlockAccessListEnabled,
184+
balConfiguration,
185185
metricsSystem,
186186
evmConfiguration);
187187
}

0 commit comments

Comments
 (0)