Merge branch 'main' into zkbesu

# Conflicts:
#	metrics/core/src/main/java/org/hyperledger/besu/metrics/noop/NoOpMetricsSystem.java
#	metrics/core/src/main/java/org/hyperledger/besu/metrics/opentelemetry/OpenTelemetrySystem.java
#	metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/PrometheusHistogram.java
#	metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/PrometheusMetricsSystem.java
#	metrics/core/src/test-support/java/org/hyperledger/besu/metrics/StubMetricsSystem.java
#	plugin-api/build.gradle
#	plugin-api/src/main/java/org/hyperledger/besu/plugin/services/metrics/Histogram.java
This commit is contained in:
Fabio Di Fabio
2024-11-27 16:09:57 +01:00
151 changed files with 2238 additions and 1663 deletions

View File

@@ -4,6 +4,21 @@
### Breaking Changes
- Removed Retesteth rpc service and commands [#7833](https://github.com/hyperledger/besu/pull/7783)
- With the upgrade of the Prometheus Java Metrics library, there are the following changes:
- Gauge names are not allowed to end with `total`, therefore the metric `besu_blockchain_difficulty_total` is losing the `_total` suffix
- The `_created` timestamps are not returned by default, you can set the env var `BESU_OPTS="-Dio.prometheus.exporter.includeCreatedTimestamps=true"` to enable them
- Some JVM metrics have changed name to adhere to the OTEL standard (see the table below), [Besu Full Grafana dashboard](https://grafana.com/grafana/dashboards/16455-besu-full/) is updated to support both names
| Old Name | New Name |
|---------------------------------|---------------------------------|
| jvm_memory_bytes_committed | jvm_memory_committed_bytes |
| jvm_memory_bytes_init | jvm_memory_init_bytes |
| jvm_memory_bytes_max | jvm_memory_max_bytes |
| jvm_memory_bytes_used | jvm_memory_used_bytes |
| jvm_memory_pool_bytes_committed | jvm_memory_pool_committed_bytes |
| jvm_memory_pool_bytes_init | jvm_memory_pool_init_bytes |
| jvm_memory_pool_bytes_max | jvm_memory_pool_max_bytes |
| jvm_memory_pool_bytes_used | jvm_memory_pool_used_bytes |
### Upcoming Breaking Changes
- Plugin API will be deprecating the BesuContext interface to be replaced with the ServiceManager interface.
@@ -22,13 +37,17 @@
- Create and publish Besu BOM (Bill of Materials) [#7615](https://github.com/hyperledger/besu/pull/7615)
- Update Java dependencies [#7786](https://github.com/hyperledger/besu/pull/7786)
- Add a method to get all the transaction in the pool, to the `TransactionPoolService`, to easily access the transaction pool content from plugins [#7813](https://github.com/hyperledger/besu/pull/7813)
- Upgrade RocksDB JNI library from version 8.3.2 to 9.7.3 [#7817](https://github.com/hyperledger/besu/pull/7817)
- Add a method to check if a metric category is enabled to the plugin API [#7832](https://github.com/hyperledger/besu/pull/7832)
- Add a new metric collector for counters which get their value from suppliers [#7894](https://github.com/hyperledger/besu/pull/7894)
- Add account and state overrides to `eth_call` [#7801](https://github.com/hyperledger/besu/pull/7801) and `eth_estimateGas` [#7890](https://github.com/hyperledger/besu/pull/7890)
- Prometheus Java Metrics library upgraded to version 1.3.3 [#7880](https://github.com/hyperledger/besu/pull/7880)
- Add histogram to Prometheus metrics system [#7944](https://github.com/hyperledger/besu/pull/7944)
### Bug fixes
- Fix registering new metric categories from plugins [#7825](https://github.com/hyperledger/besu/pull/7825)
- Fix CVE-2024-47535 [7878](https://github.com/hyperledger/besu/pull/7878)
- Fix QBFT prepared block based proposal validation [#7875](https://github.com/hyperledger/besu/pull/7875)
## 24.10.0

View File

@@ -74,12 +74,14 @@ import org.hyperledger.besu.plugin.services.TransactionPoolValidatorService;
import org.hyperledger.besu.plugin.services.TransactionSelectionService;
import org.hyperledger.besu.plugin.services.TransactionSimulationService;
import org.hyperledger.besu.plugin.services.metrics.MetricCategoryRegistry;
import org.hyperledger.besu.plugin.services.mining.MiningService;
import org.hyperledger.besu.plugin.services.storage.rocksdb.RocksDBPlugin;
import org.hyperledger.besu.plugin.services.transactionpool.TransactionPoolService;
import org.hyperledger.besu.services.BesuConfigurationImpl;
import org.hyperledger.besu.services.BesuEventsImpl;
import org.hyperledger.besu.services.BesuPluginContextImpl;
import org.hyperledger.besu.services.BlockchainServiceImpl;
import org.hyperledger.besu.services.MiningServiceImpl;
import org.hyperledger.besu.services.PermissioningServiceImpl;
import org.hyperledger.besu.services.PicoCLIOptionsImpl;
import org.hyperledger.besu.services.PrivacyPluginServiceImpl;
@@ -220,6 +222,8 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
besuPluginContext.addService(
TransactionPoolService.class,
new TransactionPoolServiceImpl(besuController.getTransactionPool()));
besuPluginContext.addService(
MiningService.class, new MiningServiceImpl(besuController.getMiningCoordinator()));
component.rpcEndpointService().init(runner.getInProcessRpcMethods());

View File

@@ -16,8 +16,8 @@ package org.hyperledger.besu.tests.acceptance.plugins;
import static java.nio.charset.StandardCharsets.UTF_8;
import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin;
import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.services.PicoCLIOptions;
import java.io.File;
@@ -39,7 +39,8 @@ public class BadCLIOptionsPlugin implements BesuPlugin {
private File callbackDir;
@Override
public void register(final ServiceManager context) {
@SuppressWarnings("removal")
public void register(final BesuContext context) {
LOG.info("Registering BadCliOptionsPlugin");
callbackDir = new File(System.getProperty("besu.plugins.dir", "plugins"));
writeStatus("init");

View File

@@ -14,6 +14,7 @@
*/
package org.hyperledger.besu.tests.acceptance.plugins;
import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin;
import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.data.BlockHeader;
@@ -42,7 +43,8 @@ public class TestBesuEventsPlugin implements BesuPlugin {
private File callbackDir;
@Override
public void register(final ServiceManager context) {
@SuppressWarnings("removal")
public void register(final BesuContext context) {
this.context = context;
LOG.info("Registered");
callbackDir = new File(System.getProperty("besu.plugins.dir", "plugins"));

View File

@@ -17,8 +17,8 @@ package org.hyperledger.besu.tests.acceptance.plugins;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin;
import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.data.BlockContext;
import org.hyperledger.besu.plugin.services.BlockchainService;
import org.hyperledger.besu.plugin.services.RpcEndpointService;
@@ -40,7 +40,8 @@ public class TestBlockchainServiceFinalizedPlugin implements BesuPlugin {
private static final String RPC_METHOD_SAFE_BLOCK = "updateSafeBlockV1";
@Override
public void register(final ServiceManager serviceManager) {
@SuppressWarnings("removal")
public void register(final BesuContext serviceManager) {
LOG.trace("Registering plugin ...");
final RpcEndpointService rpcEndpointService =

View File

@@ -15,8 +15,8 @@
package org.hyperledger.besu.tests.acceptance.plugins;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin;
import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.services.PicoCLIOptions;
import org.hyperledger.besu.plugin.services.RpcEndpointService;
import org.hyperledger.besu.plugin.services.rpc.RpcResponseType;
@@ -36,7 +36,8 @@ public class TestInProcessRpcServicePlugin implements BesuPlugin {
long minGasPrice = -1;
@Override
public void register(final ServiceManager context) {
@SuppressWarnings("removal")
public void register(final BesuContext context) {
final PicoCLIOptions cmdlineOptions =
context
.getService(PicoCLIOptions.class)

View File

@@ -14,6 +14,7 @@
*/
package org.hyperledger.besu.tests.acceptance.plugins;
import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin;
import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.services.MetricsSystem;
@@ -33,7 +34,8 @@ public class TestMetricsPlugin implements BesuPlugin {
private ServiceManager serviceManager;
@Override
public void register(final ServiceManager context) {
@SuppressWarnings("removal")
public void register(final BesuContext context) {
LOG.info("Registering TestMetricsPlugin");
serviceManager = context;
context

View File

@@ -14,8 +14,8 @@
*/
package org.hyperledger.besu.tests.acceptance.plugins;
import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin;
import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.services.PermissioningService;
import org.hyperledger.besu.plugin.services.PicoCLIOptions;
@@ -40,7 +40,8 @@ public class TestPermissioningPlugin implements BesuPlugin {
PermissioningService service;
@Override
public void register(final ServiceManager context) {
@SuppressWarnings("removal")
public void register(final BesuContext context) {
context.getService(PicoCLIOptions.class).orElseThrow().addPicoCLIOptions("permissioning", this);
service = context.getService(PermissioningService.class).orElseThrow();
}

View File

@@ -14,8 +14,8 @@
*/
package org.hyperledger.besu.tests.acceptance.plugins;
import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin;
import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.services.PicoCLIOptions;
import java.io.File;
@@ -57,7 +57,8 @@ public class TestPicoCLIPlugin implements BesuPlugin {
private File callbackDir;
@Override
public void register(final ServiceManager context) {
@SuppressWarnings("removal")
public void register(final BesuContext context) {
LOG.info("Registering. Test Option is '{}'", testOption);
state = "registering";

View File

@@ -14,6 +14,7 @@
*/
package org.hyperledger.besu.tests.acceptance.plugins;
import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin;
import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.services.PicoCLIOptions;
@@ -40,7 +41,8 @@ public class TestPrivacyServicePlugin implements BesuPlugin {
new TestSigningPrivateMarkerTransactionFactory();
@Override
public void register(final ServiceManager context) {
@SuppressWarnings("removal")
public void register(final BesuContext context) {
this.context = context;
context

View File

@@ -16,8 +16,8 @@ package org.hyperledger.besu.tests.acceptance.plugins;
import static com.google.common.base.Preconditions.checkArgument;
import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin;
import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.services.RpcEndpointService;
import org.hyperledger.besu.plugin.services.rpc.PluginRpcRequest;
@@ -51,7 +51,8 @@ public class TestRpcEndpointServicePlugin implements BesuPlugin {
}
@Override
public void register(final ServiceManager context) {
@SuppressWarnings("removal")
public void register(final BesuContext context) {
context
.getService(RpcEndpointService.class)
.ifPresent(

View File

@@ -1034,8 +1034,7 @@ public class RunnerBuilder {
subscriptionManager, privacyParameters, context.getBlockchain().getGenesisBlockHeader());
}
final Optional<MetricsService> metricsService =
createMetricsService(vertx, metricsConfiguration);
final Optional<MetricsService> metricsService = createMetricsService(metricsConfiguration);
final Optional<EthStatsService> ethStatsService;
if (isEthStatsEnabled()) {
@@ -1469,9 +1468,8 @@ public class RunnerBuilder {
vertx, configuration, websocketMessageHandler, authenticationService, metricsSystem);
}
private Optional<MetricsService> createMetricsService(
final Vertx vertx, final MetricsConfiguration configuration) {
return MetricsService.create(vertx, configuration, metricsSystem);
private Optional<MetricsService> createMetricsService(final MetricsConfiguration configuration) {
return MetricsService.create(configuration, metricsSystem);
}
/**

View File

@@ -169,6 +169,7 @@ import org.hyperledger.besu.plugin.services.TransactionSelectionService;
import org.hyperledger.besu.plugin.services.TransactionSimulationService;
import org.hyperledger.besu.plugin.services.exception.StorageException;
import org.hyperledger.besu.plugin.services.metrics.MetricCategoryRegistry;
import org.hyperledger.besu.plugin.services.mining.MiningService;
import org.hyperledger.besu.plugin.services.p2p.P2PService;
import org.hyperledger.besu.plugin.services.rlp.RlpConverterService;
import org.hyperledger.besu.plugin.services.securitymodule.SecurityModule;
@@ -181,6 +182,7 @@ import org.hyperledger.besu.services.BesuConfigurationImpl;
import org.hyperledger.besu.services.BesuEventsImpl;
import org.hyperledger.besu.services.BesuPluginContextImpl;
import org.hyperledger.besu.services.BlockchainServiceImpl;
import org.hyperledger.besu.services.MiningServiceImpl;
import org.hyperledger.besu.services.P2PServiceImpl;
import org.hyperledger.besu.services.PermissioningServiceImpl;
import org.hyperledger.besu.services.PicoCLIOptionsImpl;
@@ -1276,6 +1278,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
besuPluginContext.addService(
SynchronizationService.class,
new SynchronizationServiceImpl(
besuController.getSynchronizer(),
besuController.getProtocolContext(),
besuController.getProtocolSchedule(),
besuController.getSyncState(),
@@ -1301,6 +1304,9 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
miningParametersSupplier.get()),
besuController.getProtocolSchedule()));
besuPluginContext.addService(
MiningService.class, new MiningServiceImpl(besuController.getMiningCoordinator()));
besuController.getAdditionalPluginServices().appendPluginServices(besuPluginContext);
besuPluginContext.startPlugins();
}

View File

@@ -56,32 +56,40 @@ public class PermissionsOptions {
"Account permissioning config TOML file (default: a file named \"permissions_config.toml\" in the Besu data folder)")
private String accountPermissionsConfigFile = null;
private static final String DEPRECATION_PREFIX =
"Deprecated. Onchain permissioning is deprecated. See CHANGELOG for alternative options. ";
@CommandLine.Option(
names = {"--permissions-nodes-contract-address"},
description = "Address of the node permissioning smart contract",
description = DEPRECATION_PREFIX + "Address of the node permissioning smart contract",
arity = "1")
private final Address permissionsNodesContractAddress = null;
@CommandLine.Option(
names = {"--permissions-nodes-contract-version"},
description = "Version of the EEA Node Permissioning interface (default: ${DEFAULT-VALUE})")
description =
DEPRECATION_PREFIX
+ "Version of the EEA Node Permissioning interface (default: ${DEFAULT-VALUE})")
private final Integer permissionsNodesContractVersion = 1;
@CommandLine.Option(
names = {"--permissions-nodes-contract-enabled"},
description = "Enable node level permissions via smart contract (default: ${DEFAULT-VALUE})")
description =
DEPRECATION_PREFIX
+ "Enable node level permissions via smart contract (default: ${DEFAULT-VALUE})")
private final Boolean permissionsNodesContractEnabled = false;
@CommandLine.Option(
names = {"--permissions-accounts-contract-address"},
description = "Address of the account permissioning smart contract",
description = DEPRECATION_PREFIX + "Address of the account permissioning smart contract",
arity = "1")
private final Address permissionsAccountsContractAddress = null;
@CommandLine.Option(
names = {"--permissions-accounts-contract-enabled"},
description =
"Enable account level permissions via smart contract (default: ${DEFAULT-VALUE})")
DEPRECATION_PREFIX
+ "Enable account level permissions via smart contract (default: ${DEFAULT-VALUE})")
private final Boolean permissionsAccountsContractEnabled = false;
/** Default constructor. */
@@ -151,6 +159,7 @@ public class PermissionsOptions {
SmartContractPermissioningConfiguration.createDefault();
if (Boolean.TRUE.equals(permissionsNodesContractEnabled)) {
logger.warn("Onchain (contract) node permissioning options are " + DEPRECATION_PREFIX);
if (permissionsNodesContractAddress == null) {
throw new CommandLine.ParameterException(
commandLine,
@@ -170,6 +179,7 @@ public class PermissionsOptions {
}
if (Boolean.TRUE.equals(permissionsAccountsContractEnabled)) {
logger.warn("Onchain (contract) account permissioning options are " + DEPRECATION_PREFIX);
if (permissionsAccountsContractAddress == null) {
throw new CommandLine.ParameterException(
commandLine,

View File

@@ -53,7 +53,6 @@ import java.util.Optional;
import java.util.function.Function;
import java.util.function.Supplier;
import io.vertx.core.Vertx;
import jakarta.validation.constraints.NotBlank;
import org.apache.tuweni.bytes.Bytes;
import org.slf4j.Logger;
@@ -458,8 +457,7 @@ public class BlocksSubCommand implements Runnable {
parentCommand.parentCommand.metricsConfiguration();
Optional<MetricsService> metricsService =
MetricsService.create(
Vertx.vertx(), metricsConfiguration, parentCommand.parentCommand.getMetricsSystem());
MetricsService.create(metricsConfiguration, parentCommand.parentCommand.getMetricsSystem());
metricsService.ifPresent(MetricsService::start);
return metricsService;
}

View File

@@ -34,9 +34,9 @@ import org.hyperledger.besu.ethereum.rlp.RLPInput;
import org.hyperledger.besu.ethereum.trie.Node;
import org.hyperledger.besu.ethereum.trie.PersistVisitor;
import org.hyperledger.besu.ethereum.trie.RestoreVisitor;
import org.hyperledger.besu.ethereum.trie.common.PmtStateTrieAccountValue;
import org.hyperledger.besu.ethereum.trie.forest.ForestWorldStateArchive;
import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.util.io.RollingFileReader;
import java.io.IOException;
@@ -192,8 +192,8 @@ public class RestoreState implements Runnable {
final Bytes accountRlp = accountInput.readBytes();
final Bytes code = accountInput.readBytes();
final StateTrieAccountValue trieAccount =
StateTrieAccountValue.readFrom(new BytesValueRLPInput(accountRlp, false, true));
final PmtStateTrieAccountValue trieAccount =
PmtStateTrieAccountValue.readFrom(new BytesValueRLPInput(accountRlp, false, true));
if (!trieAccount.getCodeHash().equals(Hash.hash(code))) {
throw new RuntimeException("Code hash doesn't match");
}

View File

@@ -625,7 +625,6 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
ethereumWireProtocolConfiguration.isLegacyEth64ForkIdEnabled());
final EthPeers ethPeers =
new EthPeers(
EthProtocol.NAME,
currentProtocolSpecSupplier,
clock,
metricsSystem,

View File

@@ -18,6 +18,7 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import org.hyperledger.besu.ethereum.core.plugins.PluginConfiguration;
import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin;
import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.services.BesuService;
@@ -49,7 +50,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** The Besu plugin context implementation. */
public class BesuPluginContextImpl implements ServiceManager, PluginVersionsProvider {
@SuppressWarnings("removal")
public class BesuPluginContextImpl implements BesuContext, ServiceManager, PluginVersionsProvider {
private static final Logger LOG = LoggerFactory.getLogger(BesuPluginContextImpl.class);

View File

@@ -0,0 +1,49 @@
/*
* Copyright contributors to Besu.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.services;
import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator;
import org.hyperledger.besu.plugin.services.mining.MiningService;
/**
* Implementation of the {@link MiningService} interface. This class provides methods to start and
* stop the mining process using a {@link MiningCoordinator}.
*/
public class MiningServiceImpl implements MiningService {
private final MiningCoordinator miningCoordinator;
/**
* Constructs a new {@code MiningServiceImpl} with the specified {@link MiningCoordinator}.
*
* @param miningCoordinator the mining coordinator to be used for starting and stopping the mining
* process
*/
public MiningServiceImpl(final MiningCoordinator miningCoordinator) {
this.miningCoordinator = miningCoordinator;
}
/** Stops the mining process by delegating to the {@link MiningCoordinator}. */
@Override
public void stop() {
miningCoordinator.stop();
}
/** Starts the mining process by delegating to the {@link MiningCoordinator}. */
@Override
public void start() {
miningCoordinator.start();
}
}

View File

@@ -20,6 +20,7 @@ import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockImporter;
import org.hyperledger.besu.ethereum.core.Synchronizer;
import org.hyperledger.besu.ethereum.eth.sync.state.SyncState;
import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
@@ -45,6 +46,7 @@ public class SynchronizationServiceImpl implements SynchronizationService {
private final ProtocolContext protocolContext;
private final ProtocolSchedule protocolSchedule;
private final Synchronizer synchronizer;
private final SyncState syncState;
private final Optional<DiffBasedWorldStateProvider> worldStateArchive;
@@ -52,16 +54,19 @@ public class SynchronizationServiceImpl implements SynchronizationService {
/**
* Constructor for SynchronizationServiceImpl.
*
* @param synchronizer synchronizer
* @param protocolContext protocol context
* @param protocolSchedule protocol schedule
* @param syncState sync state
* @param worldStateArchive world state archive
*/
public SynchronizationServiceImpl(
final Synchronizer synchronizer,
final ProtocolContext protocolContext,
final ProtocolSchedule protocolSchedule,
final SyncState syncState,
final WorldStateArchive worldStateArchive) {
this.synchronizer = synchronizer;
this.protocolContext = protocolContext;
this.protocolSchedule = protocolSchedule;
this.syncState = syncState;
@@ -157,4 +162,14 @@ public class SynchronizationServiceImpl implements SynchronizationService {
}
});
}
@Override
public void stop() {
synchronizer.stop();
}
@Override
public void start() {
synchronizer.start();
}
}

View File

@@ -40,8 +40,6 @@ dependencies {
implementation project(':ethereum:p2p')
implementation project(':ethereum:rlp')
implementation project(':evm')
implementation project(':pki')
implementation project(':services:kvstore')
implementation 'com.google.guava:guava'
implementation 'io.vertx:vertx-core'

View File

@@ -97,13 +97,37 @@ public class TestContext {
}
public Block createBlockForProposalFromChainHead(final long timestamp) {
return createBlockForProposalFromChainHead(timestamp, finalState.getLocalAddress());
return createBlockForProposalFromChainHead(timestamp, finalState.getLocalAddress(), 0);
}
public Block createBlockForProposalFromChainHead(final long timestamp, final int roundNumber) {
return createBlockForProposalFromChainHead(
timestamp, finalState.getLocalAddress(), roundNumber);
}
public Block createBlockForProposalFromChainHead(final long timestamp, final Address proposer) {
// this implies that EVERY block will have this node as the proposer :/
return createBlockForProposal(blockchain.getChainHeadHeader(), timestamp, proposer, 0);
}
public Block createBlockForProposalFromChainHead(
final long timestamp, final Address proposer, final int roundNumber) {
// this implies that EVERY block will have this node as the proposer :/
return createBlockForProposal(
blockchain.getChainHeadHeader(), timestamp, proposer, roundNumber);
}
public Block createBlockForProposal(
final BlockHeader parent, final long timestamp, final Address proposer) {
final BlockHeader parent,
final long timestamp,
final Address proposer,
final int roundNumber) {
final Block block =
finalState.getBlockCreatorFactory().create(0).createBlock(timestamp, parent).getBlock();
finalState
.getBlockCreatorFactory()
.create(roundNumber)
.createBlock(timestamp, parent)
.getBlock();
final BlockHeaderBuilder headerBuilder = BlockHeaderBuilder.fromHeader(block.getHeader());
headerBuilder
@@ -114,9 +138,9 @@ public class TestContext {
return new Block(newHeader, block.getBody());
}
public Block createBlockForProposalFromChainHead(final long timestamp, final Address proposer) {
// this implies that EVERY block will have this node as the proposer :/
return createBlockForProposal(blockchain.getChainHeadHeader(), timestamp, proposer);
public Block createBlockForProposal(
final BlockHeader parent, final long timestamp, final Address proposer) {
return createBlockForProposal(parent, timestamp, proposer, 0);
}
public RoundSpecificPeers roundSpecificPeers(final ConsensusRoundIdentifier roundId) {

View File

@@ -144,7 +144,8 @@ public class RoundChangeTest {
public void whenSufficientRoundChangeMessagesAreReceivedForNewRoundLocalNodeCreatesProposalMsg() {
// Note: Round-4 is the next round for which the local node is Proposer
final ConsensusRoundIdentifier targetRound = new ConsensusRoundIdentifier(1, 4);
final Block locallyProposedBlock = context.createBlockForProposalFromChainHead(blockTimeStamp);
final Block locallyProposedBlock =
context.createBlockForProposalFromChainHead(blockTimeStamp, 4);
final RoundChange rc1 = peers.getNonProposing(0).injectRoundChange(targetRound, empty());
final RoundChange rc2 = peers.getNonProposing(1).injectRoundChange(targetRound, empty());
@@ -177,14 +178,14 @@ public class RoundChangeTest {
context,
new ConsensusRoundIdentifier(1, 1),
context.createBlockForProposalFromChainHead(
ARBITRARY_BLOCKTIME / 2, peers.getProposer().getNodeAddress()));
ARBITRARY_BLOCKTIME / 2, peers.getProposer().getNodeAddress(), 1));
final PreparedCertificate bestPrepCert =
createValidPreparedCertificate(
context,
new ConsensusRoundIdentifier(1, 2),
context.createBlockForProposalFromChainHead(
ARBITRARY_BLOCKTIME, peers.getProposer().getNodeAddress()));
ARBITRARY_BLOCKTIME, peers.getProposer().getNodeAddress(), 2));
final ConsensusRoundIdentifier targetRound = new ConsensusRoundIdentifier(1, 4);
@@ -206,7 +207,7 @@ public class RoundChangeTest {
// round number.
final Block expectedBlockToPropose =
context.createBlockForProposalFromChainHead(
ARBITRARY_BLOCKTIME, peers.getProposer().getNodeAddress());
ARBITRARY_BLOCKTIME, peers.getProposer().getNodeAddress(), 4);
final Proposal expectedProposal =
localNodeMessageFactory.createProposal(
@@ -234,7 +235,8 @@ public class RoundChangeTest {
final ConsensusRoundIdentifier priorRound = new ConsensusRoundIdentifier(1, 4);
peers.roundChange(priorRound);
final Block locallyProposedBlock = context.createBlockForProposalFromChainHead(blockTimeStamp);
final Block locallyProposedBlock =
context.createBlockForProposalFromChainHead(blockTimeStamp, 9);
final Proposal expectedProposal =
localNodeMessageFactory.createProposal(
@@ -271,7 +273,7 @@ public class RoundChangeTest {
context,
new ConsensusRoundIdentifier(1, 2),
context.createBlockForProposalFromChainHead(
ARBITRARY_BLOCKTIME, peers.getProposer().getNodeAddress()));
ARBITRARY_BLOCKTIME, peers.getProposer().getNodeAddress(), 2));
final List<SignedData<RoundChangePayload>> roundChangeMessages = Lists.newArrayList();
// Create a roundChange containing a PreparedCertificate
@@ -288,7 +290,7 @@ public class RoundChangeTest {
final Block expectedBlockToPropose =
context.createBlockForProposalFromChainHead(
ARBITRARY_BLOCKTIME, peers.getProposer().getNodeAddress());
ARBITRARY_BLOCKTIME, peers.getProposer().getNodeAddress(), 4);
final Proposal expectedProposal =
localNodeMessageFactory.createProposal(

View File

@@ -160,9 +160,18 @@ public class QbftRound {
} else {
LOG.debug(
"Sending proposal from PreparedCertificate. round={}", roundState.getRoundIdentifier());
blockToPublish = bestPreparedCertificate.get().getBlock();
Block preparedBlock = bestPreparedCertificate.get().getBlock();
final BftBlockInterface bftBlockInterface =
protocolContext.getConsensusContext(BftContext.class).getBlockInterface();
blockToPublish =
bftBlockInterface.replaceRoundInBlock(
preparedBlock,
roundState.getRoundIdentifier().getRoundNumber(),
BftBlockHeaderFunctions.forCommittedSeal(bftExtraDataCodec));
}
LOG.debug(" proposal - new/prepared block hash : {}", blockToPublish.getHash());
updateStateWithProposalAndTransmit(
blockToPublish,
roundChangeArtifacts.getRoundChanges(),
@@ -202,8 +211,9 @@ public class QbftRound {
proposal.getSignedPayload().getPayload().getProposedBlock(),
roundChanges,
prepares);
updateStateWithProposedBlock(proposal);
sendPrepare(block);
if (updateStateWithProposedBlock(proposal)) {
sendPrepare(block);
}
}
/**

View File

@@ -99,7 +99,8 @@ public class QbftRoundFactory {
*/
public QbftRound createNewRoundWithState(
final BlockHeader parentHeader, final RoundState roundState) {
final BlockCreator blockCreator = blockCreatorFactory.create(0);
final BlockCreator blockCreator =
blockCreatorFactory.create(roundState.getRoundIdentifier().getRoundNumber());
// TODO(tmm): Why is this created everytime?!
final QbftMessageTransmitter messageTransmitter =

View File

@@ -137,6 +137,13 @@ public class ProposalValidator {
final PreparedRoundMetadata metadata =
roundChangeWithLatestPreparedRound.get().getPayload().getPreparedRoundMetadata().get();
LOG.debug(
"Prepared Metadata blockhash : {}, proposal blockhash: {}, prepared round in message: {}, proposal round in message: {}",
metadata.getPreparedBlockHash(),
proposal.getBlock().getHash(),
metadata.getPreparedRound(),
proposal.getRoundIdentifier().getRoundNumber());
// The Hash in the roundchange/proposals is NOT the same as the value in the
// prepares/roundchanges
// as said payloads reference the block with an OLD round number in it - therefore, need
@@ -155,8 +162,10 @@ public class ProposalValidator {
if (!metadata.getPreparedBlockHash().equals(expectedPriorBlockHash)) {
LOG.info(
"{}: Latest Prepared Metadata blockhash does not align with proposed block",
ERROR_PREFIX);
"{}: Latest Prepared Metadata blockhash does not align with proposed block. Expected: {}, Actual: {}",
ERROR_PREFIX,
expectedPriorBlockHash,
metadata.getPreparedBlockHash());
return false;
}

View File

@@ -50,9 +50,9 @@ public class DebugMetrics implements JsonRpcMethod {
private void addObservation(
final Map<String, Object> observations, final Observation observation) {
final Map<String, Object> categoryObservations =
getNextMapLevel(observations, observation.getCategory().getName());
if (observation.getLabels().isEmpty()) {
categoryObservations.put(observation.getMetricName(), observation.getValue());
getNextMapLevel(observations, observation.category().getName());
if (observation.labels().isEmpty()) {
categoryObservations.put(observation.metricName(), observation.value());
} else {
addLabelledObservation(categoryObservations, observation);
}
@@ -60,12 +60,12 @@ public class DebugMetrics implements JsonRpcMethod {
private void addLabelledObservation(
final Map<String, Object> categoryObservations, final Observation observation) {
final List<String> labels = observation.getLabels();
Map<String, Object> values = getNextMapLevel(categoryObservations, observation.getMetricName());
final List<String> labels = observation.labels();
Map<String, Object> values = getNextMapLevel(categoryObservations, observation.metricName());
for (int i = 0; i < labels.size() - 1; i++) {
values = getNextMapLevel(values, labels.get(i));
}
values.put(labels.get(labels.size() - 1), observation.getValue());
values.put(labels.get(labels.size() - 1), observation.value());
}
@SuppressWarnings("unchecked")

View File

@@ -20,6 +20,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorR
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
@Deprecated(since = "24.11.0")
public class DisabledPrivacyRpcMethod implements JsonRpcMethod {
private final String methodName;

View File

@@ -27,6 +27,7 @@ import io.vertx.ext.auth.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Deprecated(since = "24.11.0")
public class MultiTenancyRpcMethodDecorator implements JsonRpcMethod {
private static final Logger LOG = LoggerFactory.getLogger(MultiTenancyRpcMethodDecorator.class);
private final JsonRpcMethod rpcMethod;

View File

@@ -18,6 +18,7 @@ import java.util.Optional;
import io.vertx.ext.auth.User;
@Deprecated(since = "24.11.0")
public class MultiTenancyUserUtil {
private static final String PRIVACY_USER_ID_CLAIM = "privacyUserId";
private static final String ENCLAVE_PRIVACY_PUBLIC_KEY_CLAIM = "privacyPublicKey";

View File

@@ -31,6 +31,7 @@ import org.hyperledger.besu.ethereum.privacy.PrivacyController;
import java.util.List;
@Deprecated(since = "24.11.0")
public class PrivGetFilterChanges implements JsonRpcMethod {
private final PrivacyController privacyController;

View File

@@ -31,6 +31,7 @@ import org.hyperledger.besu.ethereum.privacy.PrivacyController;
import java.util.List;
@Deprecated(since = "24.11.0")
public class PrivGetFilterLogs implements JsonRpcMethod {
private final PrivacyController privacyController;

View File

@@ -26,6 +26,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.privacy.MultiTenancyPrivacyController;
import org.hyperledger.besu.ethereum.privacy.PrivacyController;
@Deprecated(since = "24.11.0")
public class PrivUninstallFilter implements JsonRpcMethod {
private final FilterManager filterManager;

View File

@@ -23,6 +23,7 @@ import java.util.Optional;
import io.vertx.ext.auth.User;
@FunctionalInterface
@Deprecated(since = "24.11.0")
public interface PrivacyIdProvider {
String getPrivacyUserId(Optional<User> user);

View File

@@ -48,6 +48,7 @@ import org.apache.tuweni.bytes.Bytes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Deprecated(since = "24.11.0")
public abstract class AbstractEeaSendRawTransaction implements JsonRpcMethod {
private static final Logger LOG = LoggerFactory.getLogger(AbstractEeaSendRawTransaction.class);
private final TransactionPool transactionPool;

View File

@@ -16,6 +16,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.eea;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
@Deprecated(since = "24.11.0")
public class JsonRpcErrorResponseException extends RuntimeException {
private final RpcErrorType jsonRpcError;

View File

@@ -33,6 +33,7 @@ import java.util.Optional;
import io.vertx.ext.auth.User;
import org.apache.tuweni.bytes.Bytes;
@Deprecated(since = "24.11.0")
public class PluginEeaSendRawTransaction extends AbstractEeaSendRawTransaction {
private final PrivacyController privacyController;
private final PrivacyIdProvider privacyIdProvider;

View File

@@ -37,6 +37,7 @@ import java.util.Optional;
import io.vertx.ext.auth.User;
import org.apache.tuweni.bytes.Bytes;
@Deprecated(since = "24.11.0")
public class RestrictedFlexibleEeaSendRawTransaction extends AbstractEeaSendRawTransaction {
private final PrivacyController privacyController;

View File

@@ -35,6 +35,7 @@ import java.util.Optional;
import io.vertx.ext.auth.User;
import org.apache.tuweni.bytes.Bytes;
@Deprecated(since = "24.11.0")
public class RestrictedOffchainEeaSendRawTransaction extends AbstractEeaSendRawTransaction {
final PrivacyController privacyController;

View File

@@ -41,6 +41,7 @@ import java.util.Optional;
import java.util.function.Supplier;
import java.util.stream.Stream;
@Deprecated(since = "24.11.0")
public abstract class AbstractPrivateTraceByHash implements JsonRpcMethod {
protected final Supplier<PrivateBlockTracer> blockTracerSupplier;

View File

@@ -33,6 +33,7 @@ import org.hyperledger.besu.ethereum.privacy.PrivacyController;
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
@Deprecated(since = "24.11.0")
public class PrivCall extends AbstractBlockParameterMethod {
private final PrivacyIdProvider privacyIdProvider;

View File

@@ -32,6 +32,7 @@ import org.hyperledger.besu.ethereum.privacy.PrivacyController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Deprecated(since = "24.11.0")
public class PrivCreatePrivacyGroup implements JsonRpcMethod {
private static final Logger LOG = LoggerFactory.getLogger(PrivCreatePrivacyGroup.class);

View File

@@ -39,6 +39,7 @@ import java.util.regex.Pattern;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Deprecated(since = "24.11.0")
public class PrivDebugGetStateRoot extends AbstractBlockParameterMethod {
private static final Logger LOG = LoggerFactory.getLogger(PrivDebugGetStateRoot.class);

View File

@@ -32,6 +32,7 @@ import org.hyperledger.besu.ethereum.privacy.PrivacyController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Deprecated(since = "24.11.0")
public class PrivDeletePrivacyGroup implements JsonRpcMethod {
private static final Logger LOG = LoggerFactory.getLogger(PrivDeletePrivacyGroup.class);

View File

@@ -48,6 +48,7 @@ import org.apache.tuweni.bytes.Bytes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Deprecated(since = "24.11.0")
public class PrivDistributeRawTransaction implements JsonRpcMethod {
private static final Logger LOG = LoggerFactory.getLogger(PrivDistributeRawTransaction.class);

View File

@@ -37,6 +37,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings("MockNotUsedInProduction")
@Deprecated(since = "24.11.0")
public class PrivFindPrivacyGroup implements JsonRpcMethod {
private static final Logger LOG = LoggerFactory.getLogger(PrivFindPrivacyGroup.class);

View File

@@ -28,6 +28,7 @@ import org.hyperledger.besu.ethereum.privacy.PrivacyController;
import org.apache.tuweni.bytes.Bytes;
@Deprecated(since = "24.11.0")
public class PrivGetCode extends AbstractBlockParameterMethod {
private final PrivacyController privacyController;

View File

@@ -42,6 +42,7 @@ import org.apache.tuweni.bytes.Bytes32;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Deprecated(since = "24.11.0")
public class PrivGetEeaTransactionCount implements JsonRpcMethod {
private static final Logger LOG = LoggerFactory.getLogger(PrivGetEeaTransactionCount.class);

View File

@@ -38,6 +38,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Optional;
@Deprecated(since = "24.11.0")
public class PrivGetLogs implements JsonRpcMethod {
private final BlockchainQueries blockchainQueries;

View File

@@ -22,6 +22,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcRespon
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
@Deprecated(since = "24.11.0")
public class PrivGetPrivacyPrecompileAddress implements JsonRpcMethod {
private final Address privacyAddress;

View File

@@ -38,6 +38,7 @@ import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Deprecated(since = "24.11.0")
public class PrivGetPrivateTransaction implements JsonRpcMethod {
private static final Logger LOG = LoggerFactory.getLogger(PrivGetPrivateTransaction.class);

View File

@@ -34,6 +34,7 @@ import org.hyperledger.besu.ethereum.privacy.PrivacyController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Deprecated(since = "24.11.0")
public class PrivGetTransactionCount implements JsonRpcMethod {
private static final Logger LOG = LoggerFactory.getLogger(PrivGetTransactionCount.class);

View File

@@ -43,6 +43,7 @@ import org.apache.tuweni.bytes.Bytes32;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Deprecated(since = "24.11.0")
public class PrivGetTransactionReceipt implements JsonRpcMethod {
private static final Logger LOG = LoggerFactory.getLogger(PrivGetTransactionReceipt.class);

View File

@@ -29,6 +29,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.privacy.MultiTenancyPrivacyController;
import org.hyperledger.besu.ethereum.privacy.PrivacyController;
@Deprecated(since = "24.11.0")
public class PrivNewFilter implements JsonRpcMethod {
private final FilterManager filterManager;

View File

@@ -43,6 +43,7 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Deprecated(since = "24.11.0")
public class PrivTraceTransaction extends AbstractPrivateTraceByHash implements JsonRpcMethod {
private static final Logger LOG = LoggerFactory.getLogger(TraceTransaction.class);

View File

@@ -20,6 +20,7 @@ import org.hyperledger.besu.ethereum.privacy.PrivacyController;
import java.util.Optional;
@Deprecated(since = "24.11.0")
public class PrivUtil {
public static void checkMembershipForAuthenticatedUser(

View File

@@ -36,6 +36,7 @@ import graphql.com.google.common.collect.Lists;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Deprecated(since = "24.11.0")
public class PrivxFindFlexiblePrivacyGroup implements JsonRpcMethod {
private static final Logger LOG = LoggerFactory.getLogger(PrivxFindFlexiblePrivacyGroup.class);

View File

@@ -19,7 +19,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.Privac
import org.hyperledger.besu.ethereum.privacy.PrivacyController;
// Use PrivxFindFlexiblePrivacyGroup instead
@Deprecated
@Deprecated(since = "21.10.3")
public class PrivxFindOnchainPrivacyGroup extends PrivxFindFlexiblePrivacyGroup {
public PrivxFindOnchainPrivacyGroup(

View File

@@ -20,6 +20,7 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
@Deprecated(since = "24.11.0")
public class CreatePrivacyGroupParameter {
private final List<String> addresses;

View File

@@ -14,6 +14,7 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.results;
import org.hyperledger.besu.ethereum.eth.EthProtocol;
import org.hyperledger.besu.ethereum.eth.manager.EthPeer;
import org.hyperledger.besu.ethereum.p2p.rlpx.connections.PeerConnection;
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.Capability;
@@ -52,7 +53,7 @@ public interface PeerResult {
connection.inboundInitiated()))
.port(Quantity.create(peerInfo.getPort()))
.id(peerInfo.getNodeId().toString())
.protocols(Map.of(peer.getProtocolName(), ProtocolsResult.fromEthPeer(peer)))
.protocols(Map.of(EthProtocol.NAME, ProtocolsResult.fromEthPeer(peer)))
.enode(connection.getRemoteEnode().toString())
.build();
}

View File

@@ -18,7 +18,7 @@ import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.Quantity;
import org.hyperledger.besu.ethereum.proof.WorldStateProof;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.ethereum.trie.common.PmtStateTrieAccountValue;
import java.util.ArrayList;
import java.util.List;
@@ -64,7 +64,8 @@ public class GetProofResult {
public static GetProofResult buildGetProofResult(
final Address address, final WorldStateProof worldStateProof) {
final StateTrieAccountValue stateTrieAccountValue = worldStateProof.getStateTrieAccountValue();
final PmtStateTrieAccountValue stateTrieAccountValue =
worldStateProof.getStateTrieAccountValue();
final List<StorageEntryProof> storageEntries = new ArrayList<>();
worldStateProof

View File

@@ -46,6 +46,7 @@ import org.hyperledger.besu.plugin.services.privacy.PrivateMarkerTransactionFact
import java.util.Map;
@Deprecated(since = "24.11.0")
public class PrivJsonRpcMethods extends PrivacyApiGroupJsonRpcMethods {
private final FilterManager filterManager;

View File

@@ -42,6 +42,7 @@ import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
@Deprecated(since = "24.11.0")
public abstract class PrivacyApiGroupJsonRpcMethods extends ApiGroupJsonRpcMethods {
private final BlockchainQueries blockchainQueries;

View File

@@ -29,9 +29,9 @@ import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
import org.hyperledger.besu.ethereum.trie.Node;
import org.hyperledger.besu.ethereum.trie.TrieIterator;
import org.hyperledger.besu.ethereum.trie.TrieIterator.State;
import org.hyperledger.besu.ethereum.trie.common.PmtStateTrieAccountValue;
import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.util.io.RollingFileWriter;
import java.io.IOException;
@@ -241,8 +241,8 @@ public class StateBackupService {
backupStatus.currentAccount = nodeKey;
final Bytes nodeValue = node.getValue().orElse(Hash.EMPTY);
final StateTrieAccountValue account =
StateTrieAccountValue.readFrom(new BytesValueRLPInput(nodeValue, false));
final PmtStateTrieAccountValue account =
PmtStateTrieAccountValue.readFrom(new BytesValueRLPInput(nodeValue, false));
final Bytes code = worldStateKeyValueStorage.getCode(account.getCodeHash()).orElse(Bytes.EMPTY);
backupStatus.codeSize.addAndGet(code.size());

View File

@@ -74,7 +74,6 @@ public class AdminJsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
peerList.add(
new EthPeer(
MockPeerConnection.create(info1, addr60301, addr30302),
"eth",
c -> {},
List.of(),
EthProtocolConfiguration.DEFAULT_MAX_MESSAGE_SIZE,
@@ -84,7 +83,6 @@ public class AdminJsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
peerList.add(
new EthPeer(
MockPeerConnection.create(info2, addr30301, addr60302),
"eth",
c -> {},
List.of(),
EthProtocolConfiguration.DEFAULT_MAX_MESSAGE_SIZE,
@@ -94,7 +92,6 @@ public class AdminJsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
peerList.add(
new EthPeer(
MockPeerConnection.create(info3, addr30301, addr60303),
"eth",
c -> {},
List.of(),
EthProtocolConfiguration.DEFAULT_MAX_MESSAGE_SIZE,

View File

@@ -120,7 +120,6 @@ public class AdminPeersTest {
final EthPeer ethPeer =
new EthPeer(
p,
"eth",
c -> {},
List.of(),
EthProtocolConfiguration.DEFAULT_MAX_MESSAGE_SIZE,

View File

@@ -42,7 +42,7 @@ import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.proof.WorldStateProof;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.ethereum.trie.common.PmtStateTrieAccountValue;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import java.util.Collections;
@@ -202,7 +202,7 @@ class EthGetProofTest {
when(blockchainQueries.getWorldStateArchive()).thenReturn(archive);
final StateTrieAccountValue stateTrieAccountValue = mock(StateTrieAccountValue.class);
final PmtStateTrieAccountValue stateTrieAccountValue = mock(PmtStateTrieAccountValue.class);
when(stateTrieAccountValue.getBalance()).thenReturn(balance);
when(stateTrieAccountValue.getCodeHash()).thenReturn(codeHash);
when(stateTrieAccountValue.getNonce()).thenReturn(nonce);

View File

@@ -183,7 +183,7 @@ public class DefaultBlockchain implements MutableBlockchain {
metricsSystem.createGauge(
BLOCKCHAIN,
"difficulty_total",
"difficulty",
"Total difficulty of the chainhead",
() -> this.getChainHead().getTotalDifficulty().toBigInteger().doubleValue());

View File

@@ -16,7 +16,7 @@ package org.hyperledger.besu.ethereum.proof;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.trie.Proof;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.ethereum.trie.common.PmtStateTrieAccountValue;
import java.util.ArrayList;
import java.util.List;
@@ -29,14 +29,14 @@ import org.apache.tuweni.units.bigints.UInt256;
public class WorldStateProof {
private final StateTrieAccountValue stateTrieAccountValue;
private final PmtStateTrieAccountValue stateTrieAccountValue;
private final Proof<Bytes> accountProof;
private final Map<UInt256, Proof<Bytes>> storageProofs;
public WorldStateProof(
final StateTrieAccountValue stateTrieAccountValue,
final PmtStateTrieAccountValue stateTrieAccountValue,
final Proof<Bytes> accountProof,
final SortedMap<UInt256, Proof<Bytes>> storageProofs) {
this.stateTrieAccountValue = stateTrieAccountValue;
@@ -44,7 +44,7 @@ public class WorldStateProof {
this.storageProofs = storageProofs;
}
public StateTrieAccountValue getStateTrieAccountValue() {
public PmtStateTrieAccountValue getStateTrieAccountValue() {
return stateTrieAccountValue;
}

View File

@@ -22,10 +22,10 @@ import org.hyperledger.besu.ethereum.trie.InnerNodeDiscoveryManager.InnerNode;
import org.hyperledger.besu.ethereum.trie.MerkleTrie;
import org.hyperledger.besu.ethereum.trie.MerkleTrieException;
import org.hyperledger.besu.ethereum.trie.Proof;
import org.hyperledger.besu.ethereum.trie.common.PmtStateTrieAccountValue;
import org.hyperledger.besu.ethereum.trie.patricia.RemoveVisitor;
import org.hyperledger.besu.ethereum.trie.patricia.SimpleMerklePatriciaTrie;
import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorageCoordinator;
import java.util.Comparator;
@@ -73,7 +73,7 @@ public class WorldStateProofProvider {
return accountProof
.getValue()
.map(RLP::input)
.map(StateTrieAccountValue::readFrom)
.map(PmtStateTrieAccountValue::readFrom)
.map(
account -> {
final SortedMap<UInt256, Proof<Bytes>> storageProofs =
@@ -85,7 +85,7 @@ public class WorldStateProofProvider {
private SortedMap<UInt256, Proof<Bytes>> getStorageProofs(
final Hash accountHash,
final StateTrieAccountValue account,
final PmtStateTrieAccountValue account,
final List<UInt256> accountStorageKeys) {
final MerkleTrie<Bytes32, Bytes> storageTrie =
newAccountStorageTrie(accountHash, account.getStorageRoot());

View File

@@ -0,0 +1,81 @@
/*
* Copyright ConsenSys AG.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.trie.common;
import static com.google.common.base.Preconditions.checkNotNull;
import org.hyperledger.besu.datatypes.AccountValue;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.rlp.RLPOutput;
/** Represents the raw values associated with an account in the world state trie. */
public abstract class AbstractStateTrieAccountValue implements AccountValue {
protected final long nonce;
protected final Wei balance;
protected final Hash codeHash;
public AbstractStateTrieAccountValue(final long nonce, final Wei balance, final Hash codeHash) {
checkNotNull(balance, "balance cannot be null");
checkNotNull(codeHash, "codeHash cannot be null");
this.nonce = nonce;
this.balance = balance;
this.codeHash = codeHash;
}
/**
* The account nonce, that is the number of transactions sent from that account.
*
* @return the account nonce.
*/
@Override
public long getNonce() {
return nonce;
}
/**
* The available balance of that account.
*
* @return the balance, in Wei, of the account.
*/
@Override
public Wei getBalance() {
return balance;
}
/**
* The hash of the EVM bytecode associated with this account.
*
* @return the hash of the account code (which may be {@link Hash#EMPTY}).
*/
@Override
public Hash getCodeHash() {
return codeHash;
}
/**
* The hash of the root of the storage trie associated with this account.
*
* @return the hash of the root node of the storage trie.
*/
@Override
public Hash getStorageRoot() {
return Hash.EMPTY_TRIE_HASH;
}
@Override
public abstract void writeTo(final RLPOutput out);
}

View File

@@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.worldstate;
package org.hyperledger.besu.ethereum.trie.common;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -26,43 +26,17 @@ import java.util.Objects;
import org.apache.tuweni.bytes.Bytes32;
/** Represents the raw values associated with an account in the world state trie. */
public class StateTrieAccountValue implements AccountValue {
/** Represents the raw values associated with an account in the world state patricia merkle trie. */
public class PmtStateTrieAccountValue extends AbstractStateTrieAccountValue
implements AccountValue {
protected final long nonce;
protected final Wei balance;
protected final Hash storageRoot;
protected final Hash codeHash;
public StateTrieAccountValue(
public PmtStateTrieAccountValue(
final long nonce, final Wei balance, final Hash storageRoot, final Hash codeHash) {
checkNotNull(balance, "balance cannot be null");
super(nonce, balance, codeHash);
checkNotNull(storageRoot, "storageRoot cannot be null");
checkNotNull(codeHash, "codeHash cannot be null");
this.nonce = nonce;
this.balance = balance;
this.storageRoot = storageRoot;
this.codeHash = codeHash;
}
/**
* The account nonce, that is the number of transactions sent from that account.
*
* @return the account nonce.
*/
@Override
public long getNonce() {
return nonce;
}
/**
* The available balance of that account.
*
* @return the balance, in Wei, of the account.
*/
@Override
public Wei getBalance() {
return balance;
}
/**
@@ -75,25 +49,15 @@ public class StateTrieAccountValue implements AccountValue {
return storageRoot;
}
/**
* The hash of the EVM bytecode associated with this account.
*
* @return the hash of the account code (which may be {@link Hash#EMPTY}).
*/
@Override
public Hash getCodeHash() {
return codeHash;
}
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final StateTrieAccountValue that = (StateTrieAccountValue) o;
PmtStateTrieAccountValue that = (PmtStateTrieAccountValue) o;
return nonce == that.nonce
&& balance.equals(that.balance)
&& storageRoot.equals(that.storageRoot)
&& codeHash.equals(that.codeHash);
&& Objects.equals(balance, that.balance)
&& Objects.equals(storageRoot, that.storageRoot)
&& Objects.equals(codeHash, that.codeHash);
}
@Override
@@ -109,11 +73,10 @@ public class StateTrieAccountValue implements AccountValue {
out.writeUInt256Scalar(balance);
out.writeBytes(storageRoot);
out.writeBytes(codeHash);
out.endList();
}
public static StateTrieAccountValue readFrom(final RLPInput in) {
public static PmtStateTrieAccountValue readFrom(final RLPInput in) {
in.enterList();
final long nonce = in.readLongScalar();
@@ -132,9 +95,9 @@ public class StateTrieAccountValue implements AccountValue {
} else {
codeHash = in.readBytes32();
}
in.leaveList();
return new StateTrieAccountValue(nonce, balance, Hash.wrap(storageRoot), Hash.wrap(codeHash));
return new PmtStateTrieAccountValue(
nonce, balance, Hash.wrap(storageRoot), Hash.wrap(codeHash));
}
}

View File

@@ -18,6 +18,7 @@ import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.trie.common.PmtStateTrieAccountValue;
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.cache.BonsaiCachedMerkleTrieLoader;
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.cache.BonsaiCachedWorldStorageManager;
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
@@ -26,7 +27,6 @@ import org.hyperledger.besu.ethereum.trie.diffbased.common.DiffBasedWorldStatePr
import org.hyperledger.besu.ethereum.trie.diffbased.common.trielog.TrieLogManager;
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.DiffBasedWorldStateConfig;
import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.plugin.ServiceManager;
@@ -120,7 +120,7 @@ public class BonsaiWorldStateProvider extends DiffBasedWorldStateProvider {
accountTrie
.get(accountHash)
.map(RLP::input)
.map(StateTrieAccountValue::readFrom)
.map(PmtStateTrieAccountValue::readFrom)
.ifPresent(
account -> {
final StoredMerklePatriciaTrie<Bytes, Bytes> storageTrie =

View File

@@ -24,13 +24,13 @@ import org.hyperledger.besu.datatypes.StorageSlotKey;
import org.hyperledger.besu.ethereum.storage.StorageProvider;
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier;
import org.hyperledger.besu.ethereum.trie.MerkleTrie;
import org.hyperledger.besu.ethereum.trie.common.PmtStateTrieAccountValue;
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.flat.BonsaiFlatDbStrategy;
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.flat.BonsaiFlatDbStrategyProvider;
import org.hyperledger.besu.ethereum.trie.diffbased.common.storage.DiffBasedWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.diffbased.common.storage.flat.FlatDbStrategy;
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
import org.hyperledger.besu.ethereum.worldstate.FlatDbMode;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.ethereum.worldstate.WorldStateKeyValueStorage;
import org.hyperledger.besu.evm.account.AccountStorageEntry;
import org.hyperledger.besu.plugin.services.MetricsSystem;
@@ -135,7 +135,7 @@ public class BonsaiWorldStateKeyValueStorage extends DiffBasedWorldStateKeyValue
getAccount(accountHash)
.map(
b ->
StateTrieAccountValue.readFrom(
PmtStateTrieAccountValue.readFrom(
org.hyperledger.besu.ethereum.rlp.RLP.input(b))
.getStorageRoot()),
accountHash,

View File

@@ -22,9 +22,9 @@ import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
import org.hyperledger.besu.ethereum.rlp.RLPInput;
import org.hyperledger.besu.ethereum.rlp.RLPOutput;
import org.hyperledger.besu.ethereum.trie.common.PmtStateTrieAccountValue;
import org.hyperledger.besu.ethereum.trie.diffbased.common.DiffBasedValue;
import org.hyperledger.besu.ethereum.trie.diffbased.common.trielog.TrieLogLayer;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.plugin.data.BlockHeader;
import org.hyperledger.besu.plugin.services.trielogs.TrieLog;
import org.hyperledger.besu.plugin.services.trielogs.TrieLogAccumulator;
@@ -160,8 +160,10 @@ public class TrieLogFactoryImpl implements TrieLogFactory {
input.skipNext();
} else {
input.enterList();
final StateTrieAccountValue oldValue = nullOrValue(input, StateTrieAccountValue::readFrom);
final StateTrieAccountValue newValue = nullOrValue(input, StateTrieAccountValue::readFrom);
final PmtStateTrieAccountValue oldValue =
nullOrValue(input, PmtStateTrieAccountValue::readFrom);
final PmtStateTrieAccountValue newValue =
nullOrValue(input, PmtStateTrieAccountValue::readFrom);
final boolean isCleared = getOptionalIsCleared(input);
input.leaveList();
newLayer

View File

@@ -23,9 +23,9 @@ import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.rlp.RLPException;
import org.hyperledger.besu.ethereum.rlp.RLPInput;
import org.hyperledger.besu.ethereum.trie.MerkleTrie;
import org.hyperledger.besu.ethereum.trie.common.PmtStateTrieAccountValue;
import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.ethereum.worldstate.WorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.worldstate.WorldStatePreimageStorage;
import org.hyperledger.besu.evm.account.Account;
@@ -137,7 +137,7 @@ public class ForestMutableWorldState implements MutableWorldState {
private WorldStateAccount deserializeAccount(
final Address address, final Hash addressHash, final Bytes encoded) throws RLPException {
final RLPInput in = RLP.input(encoded);
final StateTrieAccountValue accountValue = StateTrieAccountValue.readFrom(in);
final PmtStateTrieAccountValue accountValue = PmtStateTrieAccountValue.readFrom(in);
return new WorldStateAccount(address, addressHash, accountValue);
}
@@ -224,13 +224,15 @@ public class ForestMutableWorldState implements MutableWorldState {
private final Address address;
private final Hash addressHash;
final StateTrieAccountValue accountValue;
final PmtStateTrieAccountValue accountValue;
// Lazily initialized since we don't always access storage.
private volatile MerkleTrie<Bytes32, Bytes> storageTrie;
private WorldStateAccount(
final Address address, final Hash addressHash, final StateTrieAccountValue accountValue) {
final Address address,
final Hash addressHash,
final PmtStateTrieAccountValue accountValue) {
this.address = address;
this.addressHash = addressHash;
@@ -454,8 +456,8 @@ public class ForestMutableWorldState implements MutableWorldState {
private static Bytes serializeAccount(
final long nonce, final Wei balance, final Hash storageRoot, final Hash codeHash) {
final StateTrieAccountValue accountValue =
new StateTrieAccountValue(nonce, balance, storageRoot, codeHash);
final PmtStateTrieAccountValue accountValue =
new PmtStateTrieAccountValue(nonce, balance, storageRoot, codeHash);
return RLP.encode(accountValue::writeTo);
}
}

View File

@@ -20,9 +20,9 @@ import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.trie.MerkleTrie;
import org.hyperledger.besu.ethereum.trie.common.PmtStateTrieAccountValue;
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.ethereum.worldstate.WorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorageCoordinator;
@@ -74,8 +74,9 @@ public class TrieGenerator {
});
final Bytes code = Bytes32.leftPad(Bytes.of(i + 10));
final Hash codeHash = Hash.hash(code);
final StateTrieAccountValue accountValue =
new StateTrieAccountValue(1L, Wei.of(2L), Hash.wrap(storageTrie.getRootHash()), codeHash);
final PmtStateTrieAccountValue accountValue =
new PmtStateTrieAccountValue(
1L, Wei.of(2L), Hash.wrap(storageTrie.getRootHash()), codeHash);
accountStateTrie.put(accounts.get(i), RLP.encode(accountValue::writeTo));
applyForStrategy(
updater,

View File

@@ -21,9 +21,9 @@ import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.trie.MerkleTrie;
import org.hyperledger.besu.ethereum.trie.common.PmtStateTrieAccountValue;
import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorageCoordinator;
import org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage;
@@ -82,8 +82,9 @@ public class WorldStateProofProviderTest {
// Define account value
final Hash codeHash = Hash.hash(Bytes.fromHexString("0x1122"));
final StateTrieAccountValue accountValue =
new StateTrieAccountValue(1L, Wei.of(2L), Hash.wrap(storageTrie.getRootHash()), codeHash);
final PmtStateTrieAccountValue accountValue =
new PmtStateTrieAccountValue(
1L, Wei.of(2L), Hash.wrap(storageTrie.getRootHash()), codeHash);
// Save to storage
worldStateTrie.put(addressHash, RLP.encode(accountValue::writeTo));
worldStateTrie.commit((location, hash, value) -> updater.putAccountStateTrieNode(hash, value));

View File

@@ -25,11 +25,11 @@ import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.storage.StorageProvider;
import org.hyperledger.besu.ethereum.trie.MerkleTrie;
import org.hyperledger.besu.ethereum.trie.TrieIterator;
import org.hyperledger.besu.ethereum.trie.common.PmtStateTrieAccountValue;
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.cache.BonsaiCachedMerkleTrieLoader;
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie;
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorageCoordinator;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
@@ -96,8 +96,8 @@ class BonsaiCachedMerkleTrieLoaderTest {
@Test
void shouldAddStorageNodesInCacheDuringPreload() {
final Hash hashAccountZero = accounts.get(0).addressHash();
final StateTrieAccountValue stateTrieAccountValue =
StateTrieAccountValue.readFrom(RLP.input(trie.get(hashAccountZero).orElseThrow()));
final PmtStateTrieAccountValue stateTrieAccountValue =
PmtStateTrieAccountValue.readFrom(RLP.input(trie.get(hashAccountZero).orElseThrow()));
final StoredMerklePatriciaTrie<Bytes, Bytes> storageTrie =
new StoredMerklePatriciaTrie<>(
(location, hash) ->
@@ -154,8 +154,8 @@ class BonsaiCachedMerkleTrieLoaderTest {
@Test
void shouldFallbackWhenStorageNodesIsNotInCache() {
final Hash hashAccountZero = accounts.get(0).addressHash();
final StateTrieAccountValue stateTrieAccountValue =
StateTrieAccountValue.readFrom(RLP.input(trie.get(hashAccountZero).orElseThrow()));
final PmtStateTrieAccountValue stateTrieAccountValue =
PmtStateTrieAccountValue.readFrom(RLP.input(trie.get(hashAccountZero).orElseThrow()));
final StoredMerklePatriciaTrie<Bytes, Bytes> storageTrie =
new StoredMerklePatriciaTrie<>(
(location, hash) ->

View File

@@ -36,12 +36,12 @@ import org.hyperledger.besu.ethereum.storage.StorageProvider;
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier;
import org.hyperledger.besu.ethereum.trie.MerkleTrie;
import org.hyperledger.besu.ethereum.trie.StorageEntriesCollector;
import org.hyperledger.besu.ethereum.trie.common.PmtStateTrieAccountValue;
import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie;
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
import org.hyperledger.besu.ethereum.worldstate.FlatDbMode;
import org.hyperledger.besu.ethereum.worldstate.ImmutableDataStorageConfiguration;
import org.hyperledger.besu.ethereum.worldstate.ImmutableDiffBasedSubStorageConfiguration;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorageCoordinator;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import org.hyperledger.besu.plugin.services.storage.DataStorageFormat;
@@ -316,8 +316,8 @@ public class BonsaiWorldStateKeyValueStorageTest {
(TreeMap<Bytes32, Bytes>)
trie.entriesFrom(root -> StorageEntriesCollector.collectEntries(root, Hash.ZERO, 1));
final StateTrieAccountValue stateTrieAccountValue =
StateTrieAccountValue.readFrom(RLP.input(accounts.firstEntry().getValue()));
final PmtStateTrieAccountValue stateTrieAccountValue =
PmtStateTrieAccountValue.readFrom(RLP.input(accounts.firstEntry().getValue()));
final StoredMerklePatriciaTrie<Bytes, Bytes> storageTrie =
new StoredMerklePatriciaTrie<>(

View File

@@ -23,8 +23,8 @@ import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil;
import org.hyperledger.besu.ethereum.trie.common.PmtStateTrieAccountValue;
import org.hyperledger.besu.ethereum.trie.diffbased.common.trielog.TrieLogLayer;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.plugin.services.storage.DataStorageFormat;
import org.hyperledger.besu.plugin.services.trielogs.TrieLog;
import org.hyperledger.besu.plugin.services.trielogs.TrieLogFactory;
@@ -54,7 +54,7 @@ public class TrieLogFactoryTests {
.addAccountChange(
accountFixture,
null,
new StateTrieAccountValue(0, Wei.fromEth(1), Hash.EMPTY, Hash.EMPTY))
new PmtStateTrieAccountValue(0, Wei.fromEth(1), Hash.EMPTY, Hash.EMPTY))
.addCodeChange(
Address.ZERO,
null,

View File

@@ -19,7 +19,7 @@ import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.StorageSlotKey;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.ethereum.trie.common.PmtStateTrieAccountValue;
import java.util.Optional;
@@ -51,15 +51,16 @@ public class TrieLogLayerTests {
@Test
public void testAddAccountChange() {
Address address = Address.fromHexString("0x00");
StateTrieAccountValue oldValue = new StateTrieAccountValue(0, Wei.ZERO, Hash.EMPTY, Hash.EMPTY);
StateTrieAccountValue newValue =
new StateTrieAccountValue(1, Wei.fromEth(1), Hash.EMPTY, Hash.EMPTY);
PmtStateTrieAccountValue oldValue =
new PmtStateTrieAccountValue(0, Wei.ZERO, Hash.EMPTY, Hash.EMPTY);
PmtStateTrieAccountValue newValue =
new PmtStateTrieAccountValue(1, Wei.fromEth(1), Hash.EMPTY, Hash.EMPTY);
Address otherAddress = Address.fromHexString("0x000000");
StateTrieAccountValue otherOldValue =
new StateTrieAccountValue(0, Wei.ZERO, Hash.EMPTY, Hash.EMPTY);
StateTrieAccountValue otherNewValue =
new StateTrieAccountValue(1, Wei.fromEth(1), Hash.EMPTY, Hash.EMPTY);
PmtStateTrieAccountValue otherOldValue =
new PmtStateTrieAccountValue(0, Wei.ZERO, Hash.EMPTY, Hash.EMPTY);
PmtStateTrieAccountValue otherNewValue =
new PmtStateTrieAccountValue(1, Wei.fromEth(1), Hash.EMPTY, Hash.EMPTY);
trieLogLayer.addAccountChange(address, oldValue, newValue);
otherTrieLogLayer.addAccountChange(otherAddress, otherOldValue, otherNewValue);

View File

@@ -20,6 +20,7 @@ import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.rlp.RLPInput;
import org.hyperledger.besu.ethereum.trie.common.PmtStateTrieAccountValue;
import org.apache.tuweni.bytes.Bytes;
import org.junit.jupiter.api.Test;
@@ -41,11 +42,11 @@ public class StateTrieAccountValueTest {
private void roundTripMainNetAccountValue(
final long nonce, final Wei balance, final Hash storageRoot, final Hash codeHash) {
StateTrieAccountValue accountValue =
new StateTrieAccountValue(nonce, balance, storageRoot, codeHash);
PmtStateTrieAccountValue accountValue =
new PmtStateTrieAccountValue(nonce, balance, storageRoot, codeHash);
Bytes encoded = RLP.encode(accountValue::writeTo);
final RLPInput in = RLP.input(encoded);
StateTrieAccountValue roundTripAccountValue = StateTrieAccountValue.readFrom(in);
PmtStateTrieAccountValue roundTripAccountValue = PmtStateTrieAccountValue.readFrom(in);
assertThat(nonce).isEqualTo(roundTripAccountValue.getNonce());
assertThat(balance).isEqualTo(roundTripAccountValue.getBalance());

View File

@@ -85,7 +85,6 @@ public class EthPeer implements Comparable<EthPeer> {
private Optional<BlockHeader> checkpointHeader = Optional.empty();
private final String protocolName;
private final int maxMessageSize;
private final Clock clock;
private final List<NodeMessagePermissioningProvider> permissioningProviders;
@@ -124,7 +123,6 @@ public class EthPeer implements Comparable<EthPeer> {
@VisibleForTesting
public EthPeer(
final PeerConnection connection,
final String protocolName,
final Consumer<EthPeer> onStatusesExchanged,
final List<PeerValidator> peerValidators,
final int maxMessageSize,
@@ -132,7 +130,6 @@ public class EthPeer implements Comparable<EthPeer> {
final List<NodeMessagePermissioningProvider> permissioningProviders,
final Bytes localNodeId) {
this.connection = connection;
this.protocolName = protocolName;
this.maxMessageSize = maxMessageSize;
this.clock = clock;
this.permissioningProviders = permissioningProviders;
@@ -153,21 +150,23 @@ public class EthPeer implements Comparable<EthPeer> {
getAgreedCapabilities().stream().anyMatch(EthProtocol::isEth66Compatible);
// eth protocol
requestManagers.put(
protocolName,
EthProtocol.NAME,
Map.ofEntries(
Map.entry(
EthPV62.GET_BLOCK_HEADERS,
new RequestManager(this, supportsRequestId, protocolName)),
new RequestManager(this, supportsRequestId, EthProtocol.NAME)),
Map.entry(
EthPV62.GET_BLOCK_BODIES,
new RequestManager(this, supportsRequestId, protocolName)),
new RequestManager(this, supportsRequestId, EthProtocol.NAME)),
Map.entry(
EthPV63.GET_RECEIPTS, new RequestManager(this, supportsRequestId, protocolName)),
EthPV63.GET_RECEIPTS,
new RequestManager(this, supportsRequestId, EthProtocol.NAME)),
Map.entry(
EthPV63.GET_NODE_DATA, new RequestManager(this, supportsRequestId, protocolName)),
EthPV63.GET_NODE_DATA,
new RequestManager(this, supportsRequestId, EthProtocol.NAME)),
Map.entry(
EthPV65.GET_POOLED_TRANSACTIONS,
new RequestManager(this, supportsRequestId, protocolName))));
new RequestManager(this, supportsRequestId, EthProtocol.NAME))));
}
private void initSnapRequestManagers() {
@@ -237,7 +236,7 @@ public class EthPeer implements Comparable<EthPeer> {
}
public RequestManager.ResponseStream send(final MessageData messageData) throws PeerNotConnected {
return send(messageData, this.protocolName);
return send(messageData, EthProtocol.NAME);
}
public RequestManager.ResponseStream send(
@@ -317,7 +316,7 @@ public class EthPeer implements Comparable<EthPeer> {
final GetBlockHeadersMessage message =
GetBlockHeadersMessage.create(hash, maxHeaders, skip, reverse);
final RequestManager requestManager =
requestManagers.get(protocolName).get(EthPV62.GET_BLOCK_HEADERS);
requestManagers.get(EthProtocol.NAME).get(EthPV62.GET_BLOCK_HEADERS);
return sendRequest(requestManager, message);
}
@@ -326,32 +325,34 @@ public class EthPeer implements Comparable<EthPeer> {
throws PeerNotConnected {
final GetBlockHeadersMessage message =
GetBlockHeadersMessage.create(blockNumber, maxHeaders, skip, reverse);
return sendRequest(requestManagers.get(protocolName).get(EthPV62.GET_BLOCK_HEADERS), message);
return sendRequest(
requestManagers.get(EthProtocol.NAME).get(EthPV62.GET_BLOCK_HEADERS), message);
}
public RequestManager.ResponseStream getBodies(final List<Hash> blockHashes)
throws PeerNotConnected {
final GetBlockBodiesMessage message = GetBlockBodiesMessage.create(blockHashes);
return sendRequest(requestManagers.get(protocolName).get(EthPV62.GET_BLOCK_BODIES), message);
return sendRequest(
requestManagers.get(EthProtocol.NAME).get(EthPV62.GET_BLOCK_BODIES), message);
}
public RequestManager.ResponseStream getReceipts(final List<Hash> blockHashes)
throws PeerNotConnected {
final GetReceiptsMessage message = GetReceiptsMessage.create(blockHashes);
return sendRequest(requestManagers.get(protocolName).get(EthPV63.GET_RECEIPTS), message);
return sendRequest(requestManagers.get(EthProtocol.NAME).get(EthPV63.GET_RECEIPTS), message);
}
public RequestManager.ResponseStream getNodeData(final Iterable<Hash> nodeHashes)
throws PeerNotConnected {
final GetNodeDataMessage message = GetNodeDataMessage.create(nodeHashes);
return sendRequest(requestManagers.get(protocolName).get(EthPV63.GET_NODE_DATA), message);
return sendRequest(requestManagers.get(EthProtocol.NAME).get(EthPV63.GET_NODE_DATA), message);
}
public RequestManager.ResponseStream getPooledTransactions(final List<Hash> hashes)
throws PeerNotConnected {
final GetPooledTransactionsMessage message = GetPooledTransactionsMessage.create(hashes);
return sendRequest(
requestManagers.get(protocolName).get(EthPV65.GET_POOLED_TRANSACTIONS), message);
requestManagers.get(EthProtocol.NAME).get(EthPV65.GET_POOLED_TRANSACTIONS), message);
}
public RequestManager.ResponseStream getSnapAccountRange(
@@ -461,7 +462,7 @@ public class EthPeer implements Comparable<EthPeer> {
* @param ethMessage the Eth message to dispatch
*/
void dispatch(final EthMessage ethMessage) {
dispatch(ethMessage, protocolName);
dispatch(ethMessage, EthProtocol.NAME);
}
/**
@@ -587,10 +588,6 @@ public class EthPeer implements Comparable<EthPeer> {
return lastProtocolVersion.get();
}
public String getProtocolName() {
return protocolName;
}
/**
* Return A read-only snapshot of this peer's current {@code chainState}
*

View File

@@ -15,6 +15,7 @@
package org.hyperledger.besu.ethereum.eth.manager;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.eth.EthProtocol;
import org.hyperledger.besu.ethereum.eth.SnapProtocol;
import org.hyperledger.besu.ethereum.eth.manager.EthPeer.DisconnectCallback;
import org.hyperledger.besu.ethereum.eth.manager.peertask.PeerSelector;
@@ -92,7 +93,6 @@ public class EthPeers implements PeerSelector {
.concurrencyLevel(1)
.removalListener(this::onCacheRemoval)
.build();
private final String protocolName;
private final Clock clock;
private final List<NodeMessagePermissioningProvider> permissioningProviders;
private final int maxMessageSize;
@@ -122,7 +122,6 @@ public class EthPeers implements PeerSelector {
() -> TrailingPeerRequirements.UNRESTRICTED;
public EthPeers(
final String protocolName,
final Supplier<ProtocolSpec> currentProtocolSpecSupplier,
final Clock clock,
final MetricsSystem metricsSystem,
@@ -134,7 +133,6 @@ public class EthPeers implements PeerSelector {
final Boolean randomPeerPriority,
final SyncMode syncMode,
final ForkIdManager forkIdManager) {
this.protocolName = protocolName;
this.currentProtocolSpecSupplier = currentProtocolSpecSupplier;
this.clock = clock;
this.permissioningProviders = permissioningProviders;
@@ -191,7 +189,6 @@ public class EthPeers implements PeerSelector {
peerInList.orElse(
new EthPeer(
newConnection,
protocolName,
this::ethPeerStatusExchanged,
peerValidators,
maxMessageSize,
@@ -294,7 +291,7 @@ public class EthPeers implements PeerSelector {
}
public void dispatchMessage(final EthPeer peer, final EthMessage ethMessage) {
dispatchMessage(peer, ethMessage, protocolName);
dispatchMessage(peer, ethMessage, EthProtocol.NAME);
}
@VisibleForTesting

View File

@@ -123,9 +123,8 @@ public class GetReceiptsFromPeerTask
@Override
public Predicate<EthPeer> getPeerRequirementFilter() {
return (ethPeer) ->
ethPeer.getProtocolName().equals(getSubProtocol().getName())
&& (protocolSchedule.anyMatch((ps) -> ps.spec().isPoS())
|| ethPeer.chainState().getEstimatedHeight() >= requiredBlockchainHeight);
(protocolSchedule.anyMatch((ps) -> ps.spec().isPoS())
|| ethPeer.chainState().getEstimatedHeight() >= requiredBlockchainHeight);
}
@Override

View File

@@ -20,7 +20,7 @@ import org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
import org.hyperledger.besu.ethereum.rlp.RLPInput;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.ethereum.trie.common.PmtStateTrieAccountValue;
import java.math.BigInteger;
import java.util.List;
@@ -121,7 +121,7 @@ public final class AccountRangeMessage extends AbstractSnapMessageData {
@VisibleForTesting
public static Bytes toFullAccount(final RLPInput rlpInput) {
final StateTrieAccountValue accountValue = StateTrieAccountValue.readFrom(rlpInput);
final PmtStateTrieAccountValue accountValue = PmtStateTrieAccountValue.readFrom(rlpInput);
final BytesValueRLPOutput rlpOutput = new BytesValueRLPOutput();
rlpOutput.startList();
@@ -135,7 +135,7 @@ public final class AccountRangeMessage extends AbstractSnapMessageData {
}
public static Bytes toSlimAccount(final RLPInput rlpInput) {
StateTrieAccountValue accountValue = StateTrieAccountValue.readFrom(rlpInput);
PmtStateTrieAccountValue accountValue = PmtStateTrieAccountValue.readFrom(rlpInput);
var rlpOutput = new BytesValueRLPOutput();
rlpOutput.startList();
rlpOutput.writeLongScalar(accountValue.getNonce());

View File

@@ -99,7 +99,6 @@ public class DownloadHeadersStep
range.getStart().getNumber(),
headerRequestSize,
metricsSystem)
.assignPeer(range.getSyncTarget())
.run()
.thenApply(PeerTaskResult::getResult);
}

View File

@@ -21,7 +21,7 @@ import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.rlp.RLPOutput;
import org.hyperledger.besu.ethereum.trie.CompactEncoding;
import org.hyperledger.besu.ethereum.trie.MerkleTrie;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.ethereum.trie.common.PmtStateTrieAccountValue;
import org.hyperledger.besu.ethereum.worldstate.WorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorageCoordinator;
@@ -73,7 +73,8 @@ class AccountTrieNodeDataRequest extends TrieNodeDataRequest {
final Bytes path,
final Bytes value) {
final Stream.Builder<NodeDataRequest> builder = Stream.builder();
final StateTrieAccountValue accountValue = StateTrieAccountValue.readFrom(RLP.input(value));
final PmtStateTrieAccountValue accountValue =
PmtStateTrieAccountValue.readFrom(RLP.input(value));
final Optional<Hash> accountHash =
Optional.of(

View File

@@ -31,9 +31,9 @@ import org.hyperledger.besu.ethereum.proof.WorldStateProofProvider;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.rlp.RLPInput;
import org.hyperledger.besu.ethereum.trie.NodeUpdater;
import org.hyperledger.besu.ethereum.trie.common.PmtStateTrieAccountValue;
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.worldstate.FlatDbMode;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.ethereum.worldstate.WorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorageCoordinator;
@@ -210,8 +210,8 @@ public class AccountRangeDataRequest extends SnapDataRequest {
// find missing storages and code
for (Map.Entry<Bytes32, Bytes> account : taskElement.keys().entrySet()) {
final StateTrieAccountValue accountValue =
StateTrieAccountValue.readFrom(RLP.input(account.getValue()));
final PmtStateTrieAccountValue accountValue =
PmtStateTrieAccountValue.readFrom(RLP.input(account.getValue()));
if (!accountValue.getStorageRoot().equals(Hash.EMPTY_TRIE_HASH)) {
childRequests.add(
createStorageRangeDataRequest(

View File

@@ -31,9 +31,9 @@ import org.hyperledger.besu.ethereum.trie.MerkleTrie;
import org.hyperledger.besu.ethereum.trie.RangeManager;
import org.hyperledger.besu.ethereum.trie.RangeStorageEntriesCollector;
import org.hyperledger.besu.ethereum.trie.TrieIterator;
import org.hyperledger.besu.ethereum.trie.common.PmtStateTrieAccountValue;
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.ethereum.worldstate.WorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorageCoordinator;
@@ -104,8 +104,8 @@ public class AccountFlatDatabaseHealingRangeRequest extends SnapDataRequest {
if (downloadState
.getAccountsHealingList()
.contains(CompactEncoding.bytesToPath(account.getKey()))) {
final StateTrieAccountValue accountValue =
StateTrieAccountValue.readFrom(RLP.input(account.getValue()));
final PmtStateTrieAccountValue accountValue =
PmtStateTrieAccountValue.readFrom(RLP.input(account.getValue()));
childRequests.add(
createStorageFlatHealingRangeRequest(
getRootHash(),

View File

@@ -25,8 +25,8 @@ import org.hyperledger.besu.ethereum.eth.sync.snapsync.request.SnapDataRequest;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.trie.CompactEncoding;
import org.hyperledger.besu.ethereum.trie.MerkleTrie;
import org.hyperledger.besu.ethereum.trie.common.PmtStateTrieAccountValue;
import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.ethereum.worldstate.WorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorageCoordinator;
@@ -120,7 +120,7 @@ public class AccountTrieNodeHealingRequest extends TrieNodeHealingRequest {
getLocation().size(),
account.size() - getLocation().size()))
.map(RLP::input)
.map(StateTrieAccountValue::readFrom)
.map(PmtStateTrieAccountValue::readFrom)
.filter(
stateTrieAccountValue ->
// We need to ensure that the accounts to be healed do not have empty storage.
@@ -152,7 +152,8 @@ public class AccountTrieNodeHealingRequest extends TrieNodeHealingRequest {
final Bytes path,
final Bytes value) {
final Stream.Builder<SnapDataRequest> builder = Stream.builder();
final StateTrieAccountValue accountValue = StateTrieAccountValue.readFrom(RLP.input(value));
final PmtStateTrieAccountValue accountValue =
PmtStateTrieAccountValue.readFrom(RLP.input(value));
// Retrieve account hash
final Hash accountHash =

View File

@@ -477,7 +477,6 @@ public class EthPeerTest {
final Consumer<EthPeer> onPeerReady = (peer) -> {};
return new EthPeer(
peerConnection,
"foo",
onPeerReady,
Collections.emptyList(),
EthProtocolConfiguration.DEFAULT_MAX_MESSAGE_SIZE,
@@ -513,7 +512,6 @@ public class EthPeerTest {
// that extend the sub-protocol work correctly
return new EthPeer(
peerConnection,
"foo",
onPeerReady,
peerValidators,
EthProtocolConfiguration.DEFAULT_MAX_MESSAGE_SIZE,

View File

@@ -84,7 +84,6 @@ public class EthProtocolManagerTestUtil {
final EthPeers peers =
new EthPeers(
EthProtocol.NAME,
() -> protocolSchedule.getByBlockHeader(blockchain.getChainHeadHeader()),
TestClock.fixed(),
new NoOpMetricsSystem(),
@@ -211,7 +210,6 @@ public class EthProtocolManagerTestUtil {
final EthPeers peers =
new EthPeers(
EthProtocol.NAME,
() -> protocolSchedule.getByBlockHeader(blockchain.getChainHeadHeader()),
TestClock.fixed(),
new NoOpMetricsSystem(),
@@ -262,7 +260,6 @@ public class EthProtocolManagerTestUtil {
final EthPeers peers =
new EthPeers(
EthProtocol.NAME,
() -> protocolSchedule.getByBlockHeader(blockchain.getChainHeadHeader()),
TestClock.fixed(),
new NoOpMetricsSystem(),
@@ -294,7 +291,6 @@ public class EthProtocolManagerTestUtil {
final EthScheduler ethScheduler) {
final EthPeers ethPeers =
new EthPeers(
EthProtocol.NAME,
() -> protocolSchedule.getByBlockHeader(blockchain.getChainHeadHeader()),
TestClock.fixed(),
new NoOpMetricsSystem(),

View File

@@ -303,7 +303,6 @@ public class RequestManagerTest {
final Consumer<EthPeer> onPeerReady = (peer) -> {};
return new EthPeer(
peerConnection,
EthProtocol.NAME,
onPeerReady,
Collections.emptyList(),
EthProtocolConfiguration.DEFAULT_MAX_MESSAGE_SIZE,

View File

@@ -27,7 +27,6 @@ import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil;
import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.eth.EthProtocol;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
import org.hyperledger.besu.ethereum.eth.manager.EthMessages;
@@ -114,7 +113,6 @@ public abstract class AbstractMessageTaskTest<T, R> {
ethPeers =
spy(
new EthPeers(
EthProtocol.NAME,
() -> protocolSchedule.getByBlockHeader(blockchain.getChainHeadHeader()),
TestClock.fixed(),
metricsSystem,

View File

@@ -162,7 +162,6 @@ public abstract class PeerMessageTaskTest<T>
final Consumer<EthPeer> onPeerReady = (peer) -> {};
return new EthPeer(
peerConnection,
EthProtocol.NAME,
onPeerReady,
Collections.emptyList(),
EthProtocolConfiguration.DEFAULT_MAX_MESSAGE_SIZE,

View File

@@ -214,11 +214,9 @@ public class GetReceiptsFromPeerTaskTest {
new GetReceiptsFromPeerTask(
List.of(blockHeader1, blockHeader2, blockHeader3), protocolSchedule);
EthPeer failForIncorrectProtocol = mockPeer("incorrectProtocol", 5);
EthPeer failForShortChainHeight = mockPeer("incorrectProtocol", 1);
EthPeer successfulCandidate = mockPeer(EthProtocol.NAME, 5);
EthPeer failForShortChainHeight = mockPeer(1);
EthPeer successfulCandidate = mockPeer(5);
Assertions.assertFalse(task.getPeerRequirementFilter().test(failForIncorrectProtocol));
Assertions.assertFalse(task.getPeerRequirementFilter().test(failForShortChainHeight));
Assertions.assertTrue(task.getPeerRequirementFilter().test(successfulCandidate));
}
@@ -251,11 +249,10 @@ public class GetReceiptsFromPeerTaskTest {
return blockHeader;
}
private EthPeer mockPeer(final String protocol, final long chainHeight) {
private EthPeer mockPeer(final long chainHeight) {
EthPeer ethPeer = Mockito.mock(EthPeer.class);
ChainState chainState = Mockito.mock(ChainState.class);
Mockito.when(ethPeer.getProtocolName()).thenReturn(protocol);
Mockito.when(ethPeer.chainState()).thenReturn(chainState);
Mockito.when(chainState.getEstimatedHeight()).thenReturn(chainHeight);

View File

@@ -37,13 +37,13 @@ import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.trie.CompactEncoding;
import org.hyperledger.besu.ethereum.trie.MerkleTrie;
import org.hyperledger.besu.ethereum.trie.common.PmtStateTrieAccountValue;
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.flat.BonsaiFlatDbStrategyProvider;
import org.hyperledger.besu.ethereum.trie.patricia.SimpleMerklePatriciaTrie;
import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie;
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
import org.hyperledger.besu.ethereum.worldstate.FlatDbMode;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorageCoordinator;
import org.hyperledger.besu.metrics.ObservableMetricsSystem;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
@@ -71,7 +71,7 @@ public class SnapServerTest {
record SnapTestAccount(
Hash addressHash,
StateTrieAccountValue accountValue,
PmtStateTrieAccountValue accountValue,
MerkleTrie<Bytes32, Bytes> storage,
Bytes code) {
Bytes accountRLP() {
@@ -722,7 +722,7 @@ public class SnapServerTest {
static SnapTestAccount createTestAccount(final String hexAddr) {
return new SnapTestAccount(
Hash.wrap(Bytes32.rightPad(Bytes.fromHexString(hexAddr))),
new StateTrieAccountValue(
new PmtStateTrieAccountValue(
rand.nextInt(0, 1), Wei.of(rand.nextLong(0L, 1L)), Hash.EMPTY_TRIE_HASH, Hash.EMPTY),
new SimpleMerklePatriciaTrie<>(a -> a),
Bytes.EMPTY);
@@ -768,7 +768,7 @@ public class SnapServerTest {
updater.commit();
return new SnapTestAccount(
acctHash,
new StateTrieAccountValue(
new PmtStateTrieAccountValue(
rand.nextInt(0, 1), Wei.of(rand.nextLong(0L, 1L)),
Hash.wrap(trie.getRootHash()), Hash.hash(mockCode)),
trie,

View File

@@ -23,7 +23,7 @@ import org.hyperledger.besu.ethereum.p2p.rlpx.wire.RawMessage;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.rlp.RLPInput;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.ethereum.trie.common.PmtStateTrieAccountValue;
import java.util.ArrayList;
import java.util.HashMap;
@@ -39,8 +39,8 @@ public final class AccountRangeMessageTest {
@Test
public void roundTripTest() {
final Map<Bytes32, Bytes> keys = new HashMap<>();
final StateTrieAccountValue accountValue =
new StateTrieAccountValue(1L, Wei.of(2L), Hash.EMPTY_TRIE_HASH, Hash.EMPTY);
final PmtStateTrieAccountValue accountValue =
new PmtStateTrieAccountValue(1L, Wei.of(2L), Hash.EMPTY_TRIE_HASH, Hash.EMPTY);
keys.put(Hash.wrap(Bytes32.leftPad(Bytes.of(1))), RLP.encode(accountValue::writeTo));
final List<Bytes> proofs = new ArrayList<>();
@@ -65,8 +65,8 @@ public final class AccountRangeMessageTest {
Wei balance = Wei.of(2L);
// Create a StateTrieAccountValue with the given nonce and balance
final StateTrieAccountValue accountValue =
new StateTrieAccountValue(nonce, balance, Hash.EMPTY_TRIE_HASH, Hash.EMPTY);
final PmtStateTrieAccountValue accountValue =
new PmtStateTrieAccountValue(nonce, balance, Hash.EMPTY_TRIE_HASH, Hash.EMPTY);
// Encode the account value to RLP
final BytesValueRLPOutput rlpOut = new BytesValueRLPOutput();
@@ -104,8 +104,8 @@ public final class AccountRangeMessageTest {
Wei balance = Wei.of(2L);
// Create a StateTrieAccountValue with the given nonce and balance
final StateTrieAccountValue accountValue =
new StateTrieAccountValue(nonce, balance, Hash.EMPTY_TRIE_HASH, Hash.EMPTY);
final PmtStateTrieAccountValue accountValue =
new PmtStateTrieAccountValue(nonce, balance, Hash.EMPTY_TRIE_HASH, Hash.EMPTY);
// Encode the account value to RLP
final BytesValueRLPOutput rlpOut = new BytesValueRLPOutput();

Some files were not shown because too many files have changed in this diff Show More