mirror of
https://github.com/vacp2p/linea-besu.git
synced 2026-01-08 04:33:56 -05:00
rename diffbased bonsai prefix (#8424)
Signed-off-by: Karim Taam <karim.t2am@gmail.com>
This commit is contained in:
@@ -50,7 +50,7 @@ import org.hyperledger.besu.ethereum.p2p.peers.EnodeURLImpl;
|
|||||||
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProvider;
|
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProvider;
|
||||||
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProviderBuilder;
|
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProviderBuilder;
|
||||||
import org.hyperledger.besu.ethereum.transaction.TransactionSimulator;
|
import org.hyperledger.besu.ethereum.transaction.TransactionSimulator;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.cache.BonsaiCachedMerkleTrieLoaderModule;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.cache.BonsaiCachedMerkleTrieLoaderModule;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
|
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
|
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
|
||||||
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ import org.hyperledger.besu.cli.options.RpcWebsocketOptions;
|
|||||||
import org.hyperledger.besu.cli.options.SynchronizerOptions;
|
import org.hyperledger.besu.cli.options.SynchronizerOptions;
|
||||||
import org.hyperledger.besu.cli.options.TransactionPoolOptions;
|
import org.hyperledger.besu.cli.options.TransactionPoolOptions;
|
||||||
import org.hyperledger.besu.cli.options.storage.DataStorageOptions;
|
import org.hyperledger.besu.cli.options.storage.DataStorageOptions;
|
||||||
import org.hyperledger.besu.cli.options.storage.DiffBasedSubStorageOptions;
|
import org.hyperledger.besu.cli.options.storage.PathBasedExtraStorageOptions;
|
||||||
import org.hyperledger.besu.cli.options.unstable.QBFTOptions;
|
import org.hyperledger.besu.cli.options.unstable.QBFTOptions;
|
||||||
import org.hyperledger.besu.cli.presynctasks.PreSynchronizationTaskRunner;
|
import org.hyperledger.besu.cli.presynctasks.PreSynchronizationTaskRunner;
|
||||||
import org.hyperledger.besu.cli.presynctasks.PrivateDatabaseMigrationPreSyncTask;
|
import org.hyperledger.besu.cli.presynctasks.PrivateDatabaseMigrationPreSyncTask;
|
||||||
@@ -134,9 +134,9 @@ import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier;
|
|||||||
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProvider;
|
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProvider;
|
||||||
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProviderBuilder;
|
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProviderBuilder;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
|
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.DiffBasedSubStorageConfiguration;
|
|
||||||
import org.hyperledger.besu.ethereum.worldstate.ImmutableDataStorageConfiguration;
|
import org.hyperledger.besu.ethereum.worldstate.ImmutableDataStorageConfiguration;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.ImmutableDiffBasedSubStorageConfiguration;
|
import org.hyperledger.besu.ethereum.worldstate.ImmutablePathBasedExtraStorageConfiguration;
|
||||||
|
import org.hyperledger.besu.ethereum.worldstate.PathBasedExtraStorageConfiguration;
|
||||||
import org.hyperledger.besu.evm.precompile.AbstractAltBnPrecompiledContract;
|
import org.hyperledger.besu.evm.precompile.AbstractAltBnPrecompiledContract;
|
||||||
import org.hyperledger.besu.evm.precompile.BigIntegerModularExponentiationPrecompiledContract;
|
import org.hyperledger.besu.evm.precompile.BigIntegerModularExponentiationPrecompiledContract;
|
||||||
import org.hyperledger.besu.evm.precompile.KZGPointEvalPrecompiledContract;
|
import org.hyperledger.besu.evm.precompile.KZGPointEvalPrecompiledContract;
|
||||||
@@ -1652,7 +1652,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
|
|||||||
"--Xsnapsync-synchronizer-flat option can only be used when --Xbonsai-full-flat-db-enabled is true",
|
"--Xsnapsync-synchronizer-flat option can only be used when --Xbonsai-full-flat-db-enabled is true",
|
||||||
dataStorageOptions
|
dataStorageOptions
|
||||||
.toDomainObject()
|
.toDomainObject()
|
||||||
.getDiffBasedSubStorageConfiguration()
|
.getPathBasedExtraStorageConfiguration()
|
||||||
.getUnstable()
|
.getUnstable()
|
||||||
.getFullFlatDbEnabled(),
|
.getFullFlatDbEnabled(),
|
||||||
asList(
|
asList(
|
||||||
@@ -1805,8 +1805,8 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
|
|||||||
.apiConfiguration(apiConfigurationSupplier.get())
|
.apiConfiguration(apiConfigurationSupplier.get())
|
||||||
.besuComponent(besuComponent);
|
.besuComponent(besuComponent);
|
||||||
if (DataStorageFormat.BONSAI.equals(getDataStorageConfiguration().getDataStorageFormat())) {
|
if (DataStorageFormat.BONSAI.equals(getDataStorageConfiguration().getDataStorageFormat())) {
|
||||||
final DiffBasedSubStorageConfiguration subStorageConfiguration =
|
final PathBasedExtraStorageConfiguration subStorageConfiguration =
|
||||||
getDataStorageConfiguration().getDiffBasedSubStorageConfiguration();
|
getDataStorageConfiguration().getPathBasedExtraStorageConfiguration();
|
||||||
besuControllerBuilder.isParallelTxProcessingEnabled(
|
besuControllerBuilder.isParallelTxProcessingEnabled(
|
||||||
subStorageConfiguration.getUnstable().isParallelTxProcessingEnabled());
|
subStorageConfiguration.getUnstable().isParallelTxProcessingEnabled());
|
||||||
}
|
}
|
||||||
@@ -2144,30 +2144,30 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
|
|||||||
|
|
||||||
if (SyncMode.FULL.equals(getDefaultSyncModeIfNotSet())
|
if (SyncMode.FULL.equals(getDefaultSyncModeIfNotSet())
|
||||||
&& DataStorageFormat.BONSAI.equals(dataStorageConfiguration.getDataStorageFormat())) {
|
&& DataStorageFormat.BONSAI.equals(dataStorageConfiguration.getDataStorageFormat())) {
|
||||||
final DiffBasedSubStorageConfiguration diffBasedSubStorageConfiguration =
|
final PathBasedExtraStorageConfiguration pathBasedExtraStorageConfiguration =
|
||||||
dataStorageConfiguration.getDiffBasedSubStorageConfiguration();
|
dataStorageConfiguration.getPathBasedExtraStorageConfiguration();
|
||||||
if (diffBasedSubStorageConfiguration.getLimitTrieLogsEnabled()) {
|
if (pathBasedExtraStorageConfiguration.getLimitTrieLogsEnabled()) {
|
||||||
if (CommandLineUtils.isOptionSet(
|
if (CommandLineUtils.isOptionSet(
|
||||||
commandLine, DiffBasedSubStorageOptions.LIMIT_TRIE_LOGS_ENABLED)) {
|
commandLine, PathBasedExtraStorageOptions.LIMIT_TRIE_LOGS_ENABLED)) {
|
||||||
throw new ParameterException(
|
throw new ParameterException(
|
||||||
commandLine,
|
commandLine,
|
||||||
String.format(
|
String.format(
|
||||||
"Cannot enable %s with --sync-mode=%s and --data-storage-format=%s. You must set %s or use a different sync-mode",
|
"Cannot enable %s with --sync-mode=%s and --data-storage-format=%s. You must set %s or use a different sync-mode",
|
||||||
DiffBasedSubStorageOptions.LIMIT_TRIE_LOGS_ENABLED,
|
PathBasedExtraStorageOptions.LIMIT_TRIE_LOGS_ENABLED,
|
||||||
SyncMode.FULL,
|
SyncMode.FULL,
|
||||||
DataStorageFormat.BONSAI,
|
DataStorageFormat.BONSAI,
|
||||||
DiffBasedSubStorageOptions.LIMIT_TRIE_LOGS_ENABLED + "=false"));
|
PathBasedExtraStorageOptions.LIMIT_TRIE_LOGS_ENABLED + "=false"));
|
||||||
}
|
}
|
||||||
|
|
||||||
dataStorageConfiguration =
|
dataStorageConfiguration =
|
||||||
ImmutableDataStorageConfiguration.copyOf(dataStorageConfiguration)
|
ImmutableDataStorageConfiguration.copyOf(dataStorageConfiguration)
|
||||||
.withDiffBasedSubStorageConfiguration(
|
.withPathBasedExtraStorageConfiguration(
|
||||||
ImmutableDiffBasedSubStorageConfiguration.copyOf(
|
ImmutablePathBasedExtraStorageConfiguration.copyOf(
|
||||||
dataStorageConfiguration.getDiffBasedSubStorageConfiguration())
|
dataStorageConfiguration.getPathBasedExtraStorageConfiguration())
|
||||||
.withLimitTrieLogsEnabled(false));
|
.withLimitTrieLogsEnabled(false));
|
||||||
logger.warn(
|
logger.warn(
|
||||||
"Forcing {}, since it cannot be enabled with --sync-mode={} and --data-storage-format={}.",
|
"Forcing {}, since it cannot be enabled with --sync-mode={} and --data-storage-format={}.",
|
||||||
DiffBasedSubStorageOptions.LIMIT_TRIE_LOGS_ENABLED + "=false",
|
PathBasedExtraStorageOptions.LIMIT_TRIE_LOGS_ENABLED + "=false",
|
||||||
SyncMode.FULL,
|
SyncMode.FULL,
|
||||||
DataStorageFormat.BONSAI);
|
DataStorageFormat.BONSAI);
|
||||||
}
|
}
|
||||||
@@ -2734,8 +2734,8 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (DataStorageFormat.BONSAI.equals(getDataStorageConfiguration().getDataStorageFormat())) {
|
if (DataStorageFormat.BONSAI.equals(getDataStorageConfiguration().getDataStorageFormat())) {
|
||||||
final DiffBasedSubStorageConfiguration subStorageConfiguration =
|
final PathBasedExtraStorageConfiguration subStorageConfiguration =
|
||||||
getDataStorageConfiguration().getDiffBasedSubStorageConfiguration();
|
getDataStorageConfiguration().getPathBasedExtraStorageConfiguration();
|
||||||
if (subStorageConfiguration.getLimitTrieLogsEnabled()) {
|
if (subStorageConfiguration.getLimitTrieLogsEnabled()) {
|
||||||
builder.setLimitTrieLogsEnabled();
|
builder.setLimitTrieLogsEnabled();
|
||||||
builder.setTrieLogRetentionLimit(subStorageConfiguration.getMaxLayersToLoad());
|
builder.setTrieLogRetentionLimit(subStorageConfiguration.getMaxLayersToLoad());
|
||||||
|
|||||||
@@ -50,12 +50,12 @@ public class DataStorageOptions implements CLIOptions<DataStorageConfiguration>
|
|||||||
private Boolean receiptCompactionEnabled = DEFAULT_RECEIPT_COMPACTION_ENABLED;
|
private Boolean receiptCompactionEnabled = DEFAULT_RECEIPT_COMPACTION_ENABLED;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options specific to diff-based storage modes. Holds the necessary parameters to configure
|
* Options specific to path-based storage modes. Holds the necessary parameters to configure
|
||||||
* diff-based storage, such as the Bonsai mode or Verkle in the future.
|
* path-based storage, such as the Bonsai mode or Verkle in the future.
|
||||||
*/
|
*/
|
||||||
@Mixin
|
@Mixin
|
||||||
private DiffBasedSubStorageOptions diffBasedSubStorageOptions =
|
private PathBasedExtraStorageOptions pathBasedExtraStorageOptions =
|
||||||
DiffBasedSubStorageOptions.create();
|
PathBasedExtraStorageOptions.create();
|
||||||
|
|
||||||
/** Default Constructor. */
|
/** Default Constructor. */
|
||||||
DataStorageOptions() {}
|
DataStorageOptions() {}
|
||||||
@@ -75,7 +75,7 @@ public class DataStorageOptions implements CLIOptions<DataStorageConfiguration>
|
|||||||
* @param commandLine the full commandLine to check all the options specified by the user
|
* @param commandLine the full commandLine to check all the options specified by the user
|
||||||
*/
|
*/
|
||||||
public void validate(final CommandLine commandLine) {
|
public void validate(final CommandLine commandLine) {
|
||||||
diffBasedSubStorageOptions.validate(commandLine, dataStorageFormat);
|
pathBasedExtraStorageOptions.validate(commandLine, dataStorageFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -88,8 +88,9 @@ public class DataStorageOptions implements CLIOptions<DataStorageConfiguration>
|
|||||||
final DataStorageOptions dataStorageOptions = DataStorageOptions.create();
|
final DataStorageOptions dataStorageOptions = DataStorageOptions.create();
|
||||||
dataStorageOptions.dataStorageFormat = domainObject.getDataStorageFormat();
|
dataStorageOptions.dataStorageFormat = domainObject.getDataStorageFormat();
|
||||||
dataStorageOptions.receiptCompactionEnabled = domainObject.getReceiptCompactionEnabled();
|
dataStorageOptions.receiptCompactionEnabled = domainObject.getReceiptCompactionEnabled();
|
||||||
dataStorageOptions.diffBasedSubStorageOptions =
|
dataStorageOptions.pathBasedExtraStorageOptions =
|
||||||
DiffBasedSubStorageOptions.fromConfig(domainObject.getDiffBasedSubStorageConfiguration());
|
PathBasedExtraStorageOptions.fromConfig(
|
||||||
|
domainObject.getPathBasedExtraStorageConfiguration());
|
||||||
return dataStorageOptions;
|
return dataStorageOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,14 +100,14 @@ public class DataStorageOptions implements CLIOptions<DataStorageConfiguration>
|
|||||||
ImmutableDataStorageConfiguration.builder()
|
ImmutableDataStorageConfiguration.builder()
|
||||||
.dataStorageFormat(dataStorageFormat)
|
.dataStorageFormat(dataStorageFormat)
|
||||||
.receiptCompactionEnabled(receiptCompactionEnabled)
|
.receiptCompactionEnabled(receiptCompactionEnabled)
|
||||||
.diffBasedSubStorageConfiguration(diffBasedSubStorageOptions.toDomainObject());
|
.pathBasedExtraStorageConfiguration(pathBasedExtraStorageOptions.toDomainObject());
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getCLIOptions() {
|
public List<String> getCLIOptions() {
|
||||||
final List<String> cliOptions = CommandLineUtils.getCLIOptions(this, new DataStorageOptions());
|
final List<String> cliOptions = CommandLineUtils.getCLIOptions(this, new DataStorageOptions());
|
||||||
cliOptions.addAll(diffBasedSubStorageOptions.getCLIOptions());
|
cliOptions.addAll(pathBasedExtraStorageOptions.getCLIOptions());
|
||||||
return cliOptions;
|
return cliOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,17 +14,17 @@
|
|||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.cli.options.storage;
|
package org.hyperledger.besu.cli.options.storage;
|
||||||
|
|
||||||
import static org.hyperledger.besu.ethereum.worldstate.DiffBasedSubStorageConfiguration.DEFAULT_LIMIT_TRIE_LOGS_ENABLED;
|
import static org.hyperledger.besu.ethereum.worldstate.PathBasedExtraStorageConfiguration.DEFAULT_LIMIT_TRIE_LOGS_ENABLED;
|
||||||
import static org.hyperledger.besu.ethereum.worldstate.DiffBasedSubStorageConfiguration.DEFAULT_MAX_LAYERS_TO_LOAD;
|
import static org.hyperledger.besu.ethereum.worldstate.PathBasedExtraStorageConfiguration.DEFAULT_MAX_LAYERS_TO_LOAD;
|
||||||
import static org.hyperledger.besu.ethereum.worldstate.DiffBasedSubStorageConfiguration.DEFAULT_TRIE_LOG_PRUNING_WINDOW_SIZE;
|
import static org.hyperledger.besu.ethereum.worldstate.PathBasedExtraStorageConfiguration.DEFAULT_TRIE_LOG_PRUNING_WINDOW_SIZE;
|
||||||
import static org.hyperledger.besu.ethereum.worldstate.DiffBasedSubStorageConfiguration.DiffBasedUnstable.DEFAULT_CODE_USING_CODE_HASH_ENABLED;
|
import static org.hyperledger.besu.ethereum.worldstate.PathBasedExtraStorageConfiguration.MINIMUM_TRIE_LOG_RETENTION_LIMIT;
|
||||||
import static org.hyperledger.besu.ethereum.worldstate.DiffBasedSubStorageConfiguration.DiffBasedUnstable.DEFAULT_FULL_FLAT_DB_ENABLED;
|
import static org.hyperledger.besu.ethereum.worldstate.PathBasedExtraStorageConfiguration.PathBasedUnstable.DEFAULT_CODE_USING_CODE_HASH_ENABLED;
|
||||||
import static org.hyperledger.besu.ethereum.worldstate.DiffBasedSubStorageConfiguration.MINIMUM_TRIE_LOG_RETENTION_LIMIT;
|
import static org.hyperledger.besu.ethereum.worldstate.PathBasedExtraStorageConfiguration.PathBasedUnstable.DEFAULT_FULL_FLAT_DB_ENABLED;
|
||||||
|
|
||||||
import org.hyperledger.besu.cli.options.CLIOptions;
|
import org.hyperledger.besu.cli.options.CLIOptions;
|
||||||
import org.hyperledger.besu.cli.util.CommandLineUtils;
|
import org.hyperledger.besu.cli.util.CommandLineUtils;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.DiffBasedSubStorageConfiguration;
|
import org.hyperledger.besu.ethereum.worldstate.ImmutablePathBasedExtraStorageConfiguration;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.ImmutableDiffBasedSubStorageConfiguration;
|
import org.hyperledger.besu.ethereum.worldstate.PathBasedExtraStorageConfiguration;
|
||||||
import org.hyperledger.besu.plugin.services.storage.DataStorageFormat;
|
import org.hyperledger.besu.plugin.services.storage.DataStorageFormat;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -33,7 +33,8 @@ import picocli.CommandLine;
|
|||||||
import picocli.CommandLine.Option;
|
import picocli.CommandLine.Option;
|
||||||
|
|
||||||
/** The Data storage CLI options. */
|
/** The Data storage CLI options. */
|
||||||
public class DiffBasedSubStorageOptions implements CLIOptions<DiffBasedSubStorageConfiguration> {
|
public class PathBasedExtraStorageOptions
|
||||||
|
implements CLIOptions<PathBasedExtraStorageConfiguration> {
|
||||||
|
|
||||||
/** The maximum number of historical layers to load. */
|
/** The maximum number of historical layers to load. */
|
||||||
public static final String MAX_LAYERS_TO_LOAD = "--bonsai-historical-block-limit";
|
public static final String MAX_LAYERS_TO_LOAD = "--bonsai-historical-block-limit";
|
||||||
@@ -80,10 +81,10 @@ public class DiffBasedSubStorageOptions implements CLIOptions<DiffBasedSubStorag
|
|||||||
private Integer trieLogPruningWindowSize = DEFAULT_TRIE_LOG_PRUNING_WINDOW_SIZE;
|
private Integer trieLogPruningWindowSize = DEFAULT_TRIE_LOG_PRUNING_WINDOW_SIZE;
|
||||||
|
|
||||||
@CommandLine.ArgGroup(validate = false)
|
@CommandLine.ArgGroup(validate = false)
|
||||||
private final DiffBasedSubStorageOptions.Unstable unstableOptions = new Unstable();
|
private final PathBasedExtraStorageOptions.Unstable unstableOptions = new Unstable();
|
||||||
|
|
||||||
/** Default Constructor. */
|
/** Default Constructor. */
|
||||||
DiffBasedSubStorageOptions() {}
|
PathBasedExtraStorageOptions() {}
|
||||||
|
|
||||||
/** The unstable options for data storage. */
|
/** The unstable options for data storage. */
|
||||||
public static class Unstable {
|
public static class Unstable {
|
||||||
@@ -125,8 +126,8 @@ public class DiffBasedSubStorageOptions implements CLIOptions<DiffBasedSubStorag
|
|||||||
*
|
*
|
||||||
* @return the data storage options
|
* @return the data storage options
|
||||||
*/
|
*/
|
||||||
public static DiffBasedSubStorageOptions create() {
|
public static PathBasedExtraStorageOptions create() {
|
||||||
return new DiffBasedSubStorageOptions();
|
return new PathBasedExtraStorageOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -168,7 +169,7 @@ public class DiffBasedSubStorageOptions implements CLIOptions<DiffBasedSubStorag
|
|||||||
if (unstableOptions.isParallelTxProcessingEnabled) {
|
if (unstableOptions.isParallelTxProcessingEnabled) {
|
||||||
throw new CommandLine.ParameterException(
|
throw new CommandLine.ParameterException(
|
||||||
commandLine,
|
commandLine,
|
||||||
"Transaction parallelization is not supported unless operating in a 'diffbased' mode, such as Bonsai.");
|
"Transaction parallelization is not supported unless operating in a 'pathbased' mode, such as Bonsai.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -179,9 +180,9 @@ public class DiffBasedSubStorageOptions implements CLIOptions<DiffBasedSubStorag
|
|||||||
* @param domainObject to be reversed
|
* @param domainObject to be reversed
|
||||||
* @return the options that correspond to the configuration
|
* @return the options that correspond to the configuration
|
||||||
*/
|
*/
|
||||||
public static DiffBasedSubStorageOptions fromConfig(
|
public static PathBasedExtraStorageOptions fromConfig(
|
||||||
final DiffBasedSubStorageConfiguration domainObject) {
|
final PathBasedExtraStorageConfiguration domainObject) {
|
||||||
final DiffBasedSubStorageOptions dataStorageOptions = DiffBasedSubStorageOptions.create();
|
final PathBasedExtraStorageOptions dataStorageOptions = PathBasedExtraStorageOptions.create();
|
||||||
dataStorageOptions.maxLayersToLoad = domainObject.getMaxLayersToLoad();
|
dataStorageOptions.maxLayersToLoad = domainObject.getMaxLayersToLoad();
|
||||||
dataStorageOptions.limitTrieLogsEnabled = domainObject.getLimitTrieLogsEnabled();
|
dataStorageOptions.limitTrieLogsEnabled = domainObject.getLimitTrieLogsEnabled();
|
||||||
dataStorageOptions.trieLogPruningWindowSize = domainObject.getTrieLogPruningWindowSize();
|
dataStorageOptions.trieLogPruningWindowSize = domainObject.getTrieLogPruningWindowSize();
|
||||||
@@ -196,13 +197,13 @@ public class DiffBasedSubStorageOptions implements CLIOptions<DiffBasedSubStorag
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final DiffBasedSubStorageConfiguration toDomainObject() {
|
public final PathBasedExtraStorageConfiguration toDomainObject() {
|
||||||
return ImmutableDiffBasedSubStorageConfiguration.builder()
|
return ImmutablePathBasedExtraStorageConfiguration.builder()
|
||||||
.maxLayersToLoad(maxLayersToLoad)
|
.maxLayersToLoad(maxLayersToLoad)
|
||||||
.limitTrieLogsEnabled(limitTrieLogsEnabled)
|
.limitTrieLogsEnabled(limitTrieLogsEnabled)
|
||||||
.trieLogPruningWindowSize(trieLogPruningWindowSize)
|
.trieLogPruningWindowSize(trieLogPruningWindowSize)
|
||||||
.unstable(
|
.unstable(
|
||||||
ImmutableDiffBasedSubStorageConfiguration.DiffBasedUnstable.builder()
|
ImmutablePathBasedExtraStorageConfiguration.PathBasedUnstable.builder()
|
||||||
.fullFlatDbEnabled(unstableOptions.fullFlatDbEnabled)
|
.fullFlatDbEnabled(unstableOptions.fullFlatDbEnabled)
|
||||||
.codeStoredByCodeHashEnabled(unstableOptions.codeUsingCodeHashEnabled)
|
.codeStoredByCodeHashEnabled(unstableOptions.codeUsingCodeHashEnabled)
|
||||||
.isParallelTxProcessingEnabled(unstableOptions.isParallelTxProcessingEnabled)
|
.isParallelTxProcessingEnabled(unstableOptions.isParallelTxProcessingEnabled)
|
||||||
@@ -212,6 +213,6 @@ public class DiffBasedSubStorageOptions implements CLIOptions<DiffBasedSubStorag
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getCLIOptions() {
|
public List<String> getCLIOptions() {
|
||||||
return CommandLineUtils.getCLIOptions(this, new DiffBasedSubStorageOptions());
|
return CommandLineUtils.getCLIOptions(this, new PathBasedExtraStorageOptions());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,10 +15,10 @@
|
|||||||
package org.hyperledger.besu.cli.subcommands.storage;
|
package org.hyperledger.besu.cli.subcommands.storage;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static org.hyperledger.besu.cli.options.storage.DiffBasedSubStorageOptions.MAX_LAYERS_TO_LOAD;
|
import static org.hyperledger.besu.cli.options.storage.PathBasedExtraStorageOptions.MAX_LAYERS_TO_LOAD;
|
||||||
import static org.hyperledger.besu.cli.options.storage.DiffBasedSubStorageOptions.TRIE_LOG_PRUNING_WINDOW_SIZE;
|
import static org.hyperledger.besu.cli.options.storage.PathBasedExtraStorageOptions.TRIE_LOG_PRUNING_WINDOW_SIZE;
|
||||||
import static org.hyperledger.besu.controller.BesuController.DATABASE_PATH;
|
import static org.hyperledger.besu.controller.BesuController.DATABASE_PATH;
|
||||||
import static org.hyperledger.besu.ethereum.worldstate.DiffBasedSubStorageConfiguration.DEFAULT_TRIE_LOG_PRUNING_WINDOW_SIZE;
|
import static org.hyperledger.besu.ethereum.worldstate.PathBasedExtraStorageConfiguration.DEFAULT_TRIE_LOG_PRUNING_WINDOW_SIZE;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
import org.hyperledger.besu.ethereum.chain.Blockchain;
|
import org.hyperledger.besu.ethereum.chain.Blockchain;
|
||||||
@@ -26,11 +26,11 @@ import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
|
|||||||
import org.hyperledger.besu.ethereum.core.BlockHeader;
|
import org.hyperledger.besu.ethereum.core.BlockHeader;
|
||||||
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput;
|
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput;
|
||||||
import org.hyperledger.besu.ethereum.rlp.RLP;
|
import org.hyperledger.besu.ethereum.rlp.RLP;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.trielog.TrieLogFactoryImpl;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.trielog.TrieLogFactoryImpl;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.storage.DiffBasedWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.storage.PathBasedWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.trielog.TrieLogLayer;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.trielog.TrieLogLayer;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
|
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.DiffBasedSubStorageConfiguration;
|
import org.hyperledger.besu.ethereum.worldstate.PathBasedExtraStorageConfiguration;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
@@ -65,7 +65,7 @@ public class TrieLogHelper {
|
|||||||
|
|
||||||
boolean prune(
|
boolean prune(
|
||||||
final DataStorageConfiguration config,
|
final DataStorageConfiguration config,
|
||||||
final DiffBasedWorldStateKeyValueStorage rootWorldStateStorage,
|
final PathBasedWorldStateKeyValueStorage rootWorldStateStorage,
|
||||||
final MutableBlockchain blockchain,
|
final MutableBlockchain blockchain,
|
||||||
final Path dataDirectoryPath) {
|
final Path dataDirectoryPath) {
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ public class TrieLogHelper {
|
|||||||
|
|
||||||
validatePruneConfiguration(config);
|
validatePruneConfiguration(config);
|
||||||
|
|
||||||
final long layersToRetain = config.getDiffBasedSubStorageConfiguration().getMaxLayersToLoad();
|
final long layersToRetain = config.getPathBasedExtraStorageConfiguration().getMaxLayersToLoad();
|
||||||
|
|
||||||
final long chainHeight = blockchain.getChainHeadBlockNumber();
|
final long chainHeight = blockchain.getChainHeadBlockNumber();
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ public class TrieLogHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void processTrieLogBatches(
|
private void processTrieLogBatches(
|
||||||
final DiffBasedWorldStateKeyValueStorage rootWorldStateStorage,
|
final PathBasedWorldStateKeyValueStorage rootWorldStateStorage,
|
||||||
final MutableBlockchain blockchain,
|
final MutableBlockchain blockchain,
|
||||||
final long chainHeight,
|
final long chainHeight,
|
||||||
final long lastBlockNumberToRetainTrieLogsFor,
|
final long lastBlockNumberToRetainTrieLogsFor,
|
||||||
@@ -150,7 +150,7 @@ public class TrieLogHelper {
|
|||||||
|
|
||||||
private void saveTrieLogBatches(
|
private void saveTrieLogBatches(
|
||||||
final String batchFileName,
|
final String batchFileName,
|
||||||
final DiffBasedWorldStateKeyValueStorage rootWorldStateStorage,
|
final PathBasedWorldStateKeyValueStorage rootWorldStateStorage,
|
||||||
final List<Hash> trieLogKeys) {
|
final List<Hash> trieLogKeys) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -162,7 +162,7 @@ public class TrieLogHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void restoreTrieLogBatches(
|
private void restoreTrieLogBatches(
|
||||||
final DiffBasedWorldStateKeyValueStorage rootWorldStateStorage,
|
final PathBasedWorldStateKeyValueStorage rootWorldStateStorage,
|
||||||
final long batchNumber,
|
final long batchNumber,
|
||||||
final String batchFileNameBase) {
|
final String batchFileNameBase) {
|
||||||
|
|
||||||
@@ -215,7 +215,7 @@ public class TrieLogHelper {
|
|||||||
final MutableBlockchain blockchain,
|
final MutableBlockchain blockchain,
|
||||||
final long chainHeight,
|
final long chainHeight,
|
||||||
final long lastBlockNumberToRetainTrieLogsFor,
|
final long lastBlockNumberToRetainTrieLogsFor,
|
||||||
final DiffBasedWorldStateKeyValueStorage rootWorldStateStorage,
|
final PathBasedWorldStateKeyValueStorage rootWorldStateStorage,
|
||||||
final long layersToRetain) {
|
final long layersToRetain) {
|
||||||
|
|
||||||
if (lastBlockNumberToRetainTrieLogsFor < 0) {
|
if (lastBlockNumberToRetainTrieLogsFor < 0) {
|
||||||
@@ -255,7 +255,7 @@ public class TrieLogHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void recreateTrieLogs(
|
private void recreateTrieLogs(
|
||||||
final DiffBasedWorldStateKeyValueStorage rootWorldStateStorage,
|
final PathBasedWorldStateKeyValueStorage rootWorldStateStorage,
|
||||||
final long batchNumber,
|
final long batchNumber,
|
||||||
final String batchFileNameBase)
|
final String batchFileNameBase)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
@@ -275,7 +275,7 @@ public class TrieLogHelper {
|
|||||||
final int chunkSize,
|
final int chunkSize,
|
||||||
final List<byte[]> keys,
|
final List<byte[]> keys,
|
||||||
final IdentityHashMap<byte[], byte[]> trieLogsToRetain,
|
final IdentityHashMap<byte[], byte[]> trieLogsToRetain,
|
||||||
final DiffBasedWorldStateKeyValueStorage rootWorldStateStorage) {
|
final PathBasedWorldStateKeyValueStorage rootWorldStateStorage) {
|
||||||
|
|
||||||
var updater = rootWorldStateStorage.updater();
|
var updater = rootWorldStateStorage.updater();
|
||||||
int endIndex = Math.min(startIndex + chunkSize, keys.size());
|
int endIndex = Math.min(startIndex + chunkSize, keys.size());
|
||||||
@@ -292,14 +292,14 @@ public class TrieLogHelper {
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void validatePruneConfiguration(final DataStorageConfiguration config) {
|
void validatePruneConfiguration(final DataStorageConfiguration config) {
|
||||||
final DiffBasedSubStorageConfiguration subStorageConfiguration =
|
final PathBasedExtraStorageConfiguration subStorageConfiguration =
|
||||||
config.getDiffBasedSubStorageConfiguration();
|
config.getPathBasedExtraStorageConfiguration();
|
||||||
checkArgument(
|
checkArgument(
|
||||||
subStorageConfiguration.getMaxLayersToLoad()
|
subStorageConfiguration.getMaxLayersToLoad()
|
||||||
>= DiffBasedSubStorageConfiguration.MINIMUM_TRIE_LOG_RETENTION_LIMIT,
|
>= PathBasedExtraStorageConfiguration.MINIMUM_TRIE_LOG_RETENTION_LIMIT,
|
||||||
String.format(
|
String.format(
|
||||||
MAX_LAYERS_TO_LOAD + " minimum value is %d",
|
MAX_LAYERS_TO_LOAD + " minimum value is %d",
|
||||||
DiffBasedSubStorageConfiguration.MINIMUM_TRIE_LOG_RETENTION_LIMIT));
|
PathBasedExtraStorageConfiguration.MINIMUM_TRIE_LOG_RETENTION_LIMIT));
|
||||||
checkArgument(
|
checkArgument(
|
||||||
subStorageConfiguration.getTrieLogPruningWindowSize() > 0,
|
subStorageConfiguration.getTrieLogPruningWindowSize() > 0,
|
||||||
String.format(
|
String.format(
|
||||||
@@ -316,7 +316,7 @@ public class TrieLogHelper {
|
|||||||
|
|
||||||
private void saveTrieLogsInFile(
|
private void saveTrieLogsInFile(
|
||||||
final List<Hash> trieLogsKeys,
|
final List<Hash> trieLogsKeys,
|
||||||
final DiffBasedWorldStateKeyValueStorage rootWorldStateStorage,
|
final PathBasedWorldStateKeyValueStorage rootWorldStateStorage,
|
||||||
final String batchFileName)
|
final String batchFileName)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
@@ -353,7 +353,7 @@ public class TrieLogHelper {
|
|||||||
|
|
||||||
private void saveTrieLogsAsRlpInFile(
|
private void saveTrieLogsAsRlpInFile(
|
||||||
final List<Hash> trieLogsKeys,
|
final List<Hash> trieLogsKeys,
|
||||||
final DiffBasedWorldStateKeyValueStorage rootWorldStateStorage,
|
final PathBasedWorldStateKeyValueStorage rootWorldStateStorage,
|
||||||
final String batchFileName) {
|
final String batchFileName) {
|
||||||
File file = new File(batchFileName);
|
File file = new File(batchFileName);
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
@@ -399,7 +399,7 @@ public class TrieLogHelper {
|
|||||||
|
|
||||||
private IdentityHashMap<byte[], byte[]> getTrieLogs(
|
private IdentityHashMap<byte[], byte[]> getTrieLogs(
|
||||||
final List<Hash> trieLogKeys,
|
final List<Hash> trieLogKeys,
|
||||||
final DiffBasedWorldStateKeyValueStorage rootWorldStateStorage) {
|
final PathBasedWorldStateKeyValueStorage rootWorldStateStorage) {
|
||||||
IdentityHashMap<byte[], byte[]> trieLogsToRetain = new IdentityHashMap<>();
|
IdentityHashMap<byte[], byte[]> trieLogsToRetain = new IdentityHashMap<>();
|
||||||
|
|
||||||
LOG.info("Obtaining trielogs from db, this may take a few minutes...");
|
LOG.info("Obtaining trielogs from db, this may take a few minutes...");
|
||||||
@@ -412,7 +412,7 @@ public class TrieLogHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TrieLogCount getCount(
|
TrieLogCount getCount(
|
||||||
final DiffBasedWorldStateKeyValueStorage rootWorldStateStorage,
|
final PathBasedWorldStateKeyValueStorage rootWorldStateStorage,
|
||||||
final int limit,
|
final int limit,
|
||||||
final Blockchain blockchain) {
|
final Blockchain blockchain) {
|
||||||
final AtomicInteger total = new AtomicInteger();
|
final AtomicInteger total = new AtomicInteger();
|
||||||
@@ -453,7 +453,7 @@ public class TrieLogHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void importTrieLog(
|
void importTrieLog(
|
||||||
final DiffBasedWorldStateKeyValueStorage rootWorldStateStorage, final Path trieLogFilePath) {
|
final PathBasedWorldStateKeyValueStorage rootWorldStateStorage, final Path trieLogFilePath) {
|
||||||
|
|
||||||
var trieLog = readTrieLogsAsRlpFromFile(trieLogFilePath.toString());
|
var trieLog = readTrieLogsAsRlpFromFile(trieLogFilePath.toString());
|
||||||
|
|
||||||
@@ -463,7 +463,7 @@ public class TrieLogHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void exportTrieLog(
|
void exportTrieLog(
|
||||||
final DiffBasedWorldStateKeyValueStorage rootWorldStateStorage,
|
final PathBasedWorldStateKeyValueStorage rootWorldStateStorage,
|
||||||
final List<Hash> trieLogHash,
|
final List<Hash> trieLogHash,
|
||||||
final Path directoryPath)
|
final Path directoryPath)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|||||||
@@ -25,11 +25,11 @@ import org.hyperledger.besu.controller.BesuController;
|
|||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
|
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
|
||||||
import org.hyperledger.besu.ethereum.storage.StorageProvider;
|
import org.hyperledger.besu.ethereum.storage.StorageProvider;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.trielog.TrieLogPruner;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.trielog.TrieLogPruner;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
|
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.ImmutableDataStorageConfiguration;
|
import org.hyperledger.besu.ethereum.worldstate.ImmutableDataStorageConfiguration;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.ImmutableDiffBasedSubStorageConfiguration;
|
import org.hyperledger.besu.ethereum.worldstate.ImmutablePathBasedExtraStorageConfiguration;
|
||||||
import org.hyperledger.besu.plugin.services.storage.DataStorageFormat;
|
import org.hyperledger.besu.plugin.services.storage.DataStorageFormat;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -91,9 +91,9 @@ public class TrieLogSubCommand implements Runnable {
|
|||||||
.setupControllerBuilder()
|
.setupControllerBuilder()
|
||||||
.dataStorageConfiguration(
|
.dataStorageConfiguration(
|
||||||
ImmutableDataStorageConfiguration.copyOf(config)
|
ImmutableDataStorageConfiguration.copyOf(config)
|
||||||
.withDiffBasedSubStorageConfiguration(
|
.withPathBasedExtraStorageConfiguration(
|
||||||
ImmutableDiffBasedSubStorageConfiguration.copyOf(
|
ImmutablePathBasedExtraStorageConfiguration.copyOf(
|
||||||
config.getDiffBasedSubStorageConfiguration())
|
config.getPathBasedExtraStorageConfiguration())
|
||||||
.withLimitTrieLogsEnabled(false)))
|
.withLimitTrieLogsEnabled(false)))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ package org.hyperledger.besu.components;
|
|||||||
import org.hyperledger.besu.cli.BesuCommand;
|
import org.hyperledger.besu.cli.BesuCommand;
|
||||||
import org.hyperledger.besu.ethereum.eth.transactions.BlobCache;
|
import org.hyperledger.besu.ethereum.eth.transactions.BlobCache;
|
||||||
import org.hyperledger.besu.ethereum.eth.transactions.BlobCacheModule;
|
import org.hyperledger.besu.ethereum.eth.transactions.BlobCacheModule;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.cache.BonsaiCachedMerkleTrieLoader;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.cache.BonsaiCachedMerkleTrieLoader;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.cache.BonsaiCachedMerkleTrieLoaderModule;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.cache.BonsaiCachedMerkleTrieLoaderModule;
|
||||||
import org.hyperledger.besu.metrics.MetricsSystemModule;
|
import org.hyperledger.besu.metrics.MetricsSystemModule;
|
||||||
import org.hyperledger.besu.plugin.services.MetricsSystem;
|
import org.hyperledger.besu.plugin.services.MetricsSystem;
|
||||||
import org.hyperledger.besu.services.BesuPluginContextImpl;
|
import org.hyperledger.besu.services.BesuPluginContextImpl;
|
||||||
|
|||||||
@@ -85,14 +85,14 @@ import org.hyperledger.besu.ethereum.p2p.config.SubProtocolConfiguration;
|
|||||||
import org.hyperledger.besu.ethereum.storage.StorageProvider;
|
import org.hyperledger.besu.ethereum.storage.StorageProvider;
|
||||||
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier;
|
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier;
|
||||||
import org.hyperledger.besu.ethereum.transaction.TransactionSimulator;
|
import org.hyperledger.besu.ethereum.transaction.TransactionSimulator;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.BonsaiWorldStateProvider;
|
|
||||||
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.diffbased.common.trielog.TrieLogManager;
|
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.trielog.TrieLogPruner;
|
|
||||||
import org.hyperledger.besu.ethereum.trie.forest.ForestWorldStateArchive;
|
import org.hyperledger.besu.ethereum.trie.forest.ForestWorldStateArchive;
|
||||||
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.BonsaiWorldStateProvider;
|
||||||
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.cache.BonsaiCachedMerkleTrieLoader;
|
||||||
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
|
||||||
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.trielog.TrieLogManager;
|
||||||
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.trielog.TrieLogPruner;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
|
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.DiffBasedSubStorageConfiguration;
|
import org.hyperledger.besu.ethereum.worldstate.PathBasedExtraStorageConfiguration;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
|
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive.WorldStateHealer;
|
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive.WorldStateHealer;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.WorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.worldstate.WorldStateKeyValueStorage;
|
||||||
@@ -786,8 +786,8 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
|
|||||||
protocolContext, protocolSchedule, miningConfiguration);
|
protocolContext, protocolSchedule, miningConfiguration);
|
||||||
|
|
||||||
if (DataStorageFormat.BONSAI.equals(dataStorageConfiguration.getDataStorageFormat())) {
|
if (DataStorageFormat.BONSAI.equals(dataStorageConfiguration.getDataStorageFormat())) {
|
||||||
final DiffBasedSubStorageConfiguration subStorageConfiguration =
|
final PathBasedExtraStorageConfiguration subStorageConfiguration =
|
||||||
dataStorageConfiguration.getDiffBasedSubStorageConfiguration();
|
dataStorageConfiguration.getPathBasedExtraStorageConfiguration();
|
||||||
if (subStorageConfiguration.getLimitTrieLogsEnabled()) {
|
if (subStorageConfiguration.getLimitTrieLogsEnabled()) {
|
||||||
final TrieLogManager trieLogManager =
|
final TrieLogManager trieLogManager =
|
||||||
((BonsaiWorldStateProvider) worldStateArchive).getTrieLogManager();
|
((BonsaiWorldStateProvider) worldStateArchive).getTrieLogManager();
|
||||||
@@ -850,8 +850,8 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
|
|||||||
final Blockchain blockchain,
|
final Blockchain blockchain,
|
||||||
final EthScheduler scheduler) {
|
final EthScheduler scheduler) {
|
||||||
final boolean isProofOfStake = genesisConfigOptions.getTerminalTotalDifficulty().isPresent();
|
final boolean isProofOfStake = genesisConfigOptions.getTerminalTotalDifficulty().isPresent();
|
||||||
final DiffBasedSubStorageConfiguration subStorageConfiguration =
|
final PathBasedExtraStorageConfiguration subStorageConfiguration =
|
||||||
dataStorageConfiguration.getDiffBasedSubStorageConfiguration();
|
dataStorageConfiguration.getPathBasedExtraStorageConfiguration();
|
||||||
final TrieLogPruner trieLogPruner =
|
final TrieLogPruner trieLogPruner =
|
||||||
new TrieLogPruner(
|
new TrieLogPruner(
|
||||||
(BonsaiWorldStateKeyValueStorage) worldStateStorage,
|
(BonsaiWorldStateKeyValueStorage) worldStateStorage,
|
||||||
@@ -1140,7 +1140,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
|
|||||||
blockchain,
|
blockchain,
|
||||||
Optional.of(
|
Optional.of(
|
||||||
dataStorageConfiguration
|
dataStorageConfiguration
|
||||||
.getDiffBasedSubStorageConfiguration()
|
.getPathBasedExtraStorageConfiguration()
|
||||||
.getMaxLayersToLoad()),
|
.getMaxLayersToLoad()),
|
||||||
bonsaiCachedMerkleTrieLoader,
|
bonsaiCachedMerkleTrieLoader,
|
||||||
besuComponent.map(BesuComponent::getBesuPluginContext).orElse(null),
|
besuComponent.map(BesuComponent::getBesuPluginContext).orElse(null),
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import org.hyperledger.besu.ethereum.transaction.BlockSimulator;
|
|||||||
import org.hyperledger.besu.ethereum.transaction.BlockStateCall;
|
import org.hyperledger.besu.ethereum.transaction.BlockStateCall;
|
||||||
import org.hyperledger.besu.ethereum.transaction.CallParameter;
|
import org.hyperledger.besu.ethereum.transaction.CallParameter;
|
||||||
import org.hyperledger.besu.ethereum.transaction.TransactionSimulator;
|
import org.hyperledger.besu.ethereum.transaction.TransactionSimulator;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.provider.WorldStateQueryParams;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.provider.WorldStateQueryParams;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
|
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
|
||||||
import org.hyperledger.besu.plugin.Unstable;
|
import org.hyperledger.besu.plugin.Unstable;
|
||||||
import org.hyperledger.besu.plugin.data.BlockOverrides;
|
import org.hyperledger.besu.plugin.data.BlockOverrides;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.services;
|
package org.hyperledger.besu.services;
|
||||||
|
|
||||||
import static org.hyperledger.besu.ethereum.trie.diffbased.common.provider.WorldStateQueryParams.withBlockHeaderAndUpdateNodeHead;
|
import static org.hyperledger.besu.ethereum.trie.pathbased.common.provider.WorldStateQueryParams.withBlockHeaderAndUpdateNodeHead;
|
||||||
|
|
||||||
import org.hyperledger.besu.consensus.merge.MergeContext;
|
import org.hyperledger.besu.consensus.merge.MergeContext;
|
||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
@@ -26,9 +26,9 @@ import org.hyperledger.besu.ethereum.core.Synchronizer;
|
|||||||
import org.hyperledger.besu.ethereum.eth.sync.state.SyncState;
|
import org.hyperledger.besu.ethereum.eth.sync.state.SyncState;
|
||||||
import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode;
|
import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode;
|
||||||
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
|
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.provider.DiffBasedWorldStateProvider;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.provider.PathBasedWorldStateProvider;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.storage.DiffBasedWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.storage.PathBasedWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
|
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
|
||||||
import org.hyperledger.besu.plugin.data.BlockBody;
|
import org.hyperledger.besu.plugin.data.BlockBody;
|
||||||
import org.hyperledger.besu.plugin.data.BlockHeader;
|
import org.hyperledger.besu.plugin.data.BlockHeader;
|
||||||
@@ -51,7 +51,7 @@ public class SynchronizationServiceImpl implements SynchronizationService {
|
|||||||
private final Synchronizer synchronizer;
|
private final Synchronizer synchronizer;
|
||||||
|
|
||||||
private final SyncState syncState;
|
private final SyncState syncState;
|
||||||
private final Optional<DiffBasedWorldStateProvider> worldStateArchive;
|
private final Optional<PathBasedWorldStateProvider> worldStateArchive;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for SynchronizationServiceImpl.
|
* Constructor for SynchronizationServiceImpl.
|
||||||
@@ -74,8 +74,8 @@ public class SynchronizationServiceImpl implements SynchronizationService {
|
|||||||
this.syncState = syncState;
|
this.syncState = syncState;
|
||||||
this.worldStateArchive =
|
this.worldStateArchive =
|
||||||
Optional.ofNullable(worldStateArchive)
|
Optional.ofNullable(worldStateArchive)
|
||||||
.filter(z -> z instanceof DiffBasedWorldStateProvider)
|
.filter(z -> z instanceof PathBasedWorldStateProvider)
|
||||||
.map(DiffBasedWorldStateProvider.class::cast);
|
.map(PathBasedWorldStateProvider.class::cast);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -147,14 +147,14 @@ public class SynchronizationServiceImpl implements SynchronizationService {
|
|||||||
worldStateArchive.ifPresent(
|
worldStateArchive.ifPresent(
|
||||||
archive -> {
|
archive -> {
|
||||||
archive.getWorldStateSharedSpec().setTrieDisabled(true);
|
archive.getWorldStateSharedSpec().setTrieDisabled(true);
|
||||||
final DiffBasedWorldStateKeyValueStorage worldStateStorage =
|
final PathBasedWorldStateKeyValueStorage worldStateStorage =
|
||||||
archive.getWorldStateKeyValueStorage();
|
archive.getWorldStateKeyValueStorage();
|
||||||
final Optional<Hash> worldStateBlockHash = worldStateStorage.getWorldStateBlockHash();
|
final Optional<Hash> worldStateBlockHash = worldStateStorage.getWorldStateBlockHash();
|
||||||
final Optional<Bytes> worldStateRootHash = worldStateStorage.getWorldStateRootHash();
|
final Optional<Bytes> worldStateRootHash = worldStateStorage.getWorldStateRootHash();
|
||||||
if (worldStateRootHash.isPresent() && worldStateBlockHash.isPresent()) {
|
if (worldStateRootHash.isPresent() && worldStateBlockHash.isPresent()) {
|
||||||
worldStateStorage.clearTrie();
|
worldStateStorage.clearTrie();
|
||||||
// keep root and block hash in the trie branch
|
// keep root and block hash in the trie branch
|
||||||
final DiffBasedWorldStateKeyValueStorage.Updater updater = worldStateStorage.updater();
|
final PathBasedWorldStateKeyValueStorage.Updater updater = worldStateStorage.updater();
|
||||||
updater.saveWorldState(
|
updater.saveWorldState(
|
||||||
worldStateBlockHash.get(), Bytes32.wrap(worldStateRootHash.get()), Bytes.EMPTY);
|
worldStateBlockHash.get(), Bytes32.wrap(worldStateRootHash.get()), Bytes.EMPTY);
|
||||||
updater.commit();
|
updater.commit();
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ import org.hyperledger.besu.ethereum.eth.transactions.BlobCacheModule;
|
|||||||
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
|
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
|
||||||
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
|
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
|
||||||
import org.hyperledger.besu.ethereum.privacy.storage.PrivacyStorageProvider;
|
import org.hyperledger.besu.ethereum.privacy.storage.PrivacyStorageProvider;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.cache.BonsaiCachedMerkleTrieLoaderModule;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.cache.BonsaiCachedMerkleTrieLoaderModule;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
|
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
|
||||||
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
||||||
import org.hyperledger.besu.evm.precompile.PrecompiledContract;
|
import org.hyperledger.besu.evm.precompile.PrecompiledContract;
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ import org.hyperledger.besu.ethereum.privacy.storage.PrivacyGroupHeadBlockMap;
|
|||||||
import org.hyperledger.besu.ethereum.privacy.storage.PrivacyStorageProvider;
|
import org.hyperledger.besu.ethereum.privacy.storage.PrivacyStorageProvider;
|
||||||
import org.hyperledger.besu.ethereum.privacy.storage.PrivateStateStorage;
|
import org.hyperledger.besu.ethereum.privacy.storage.PrivateStateStorage;
|
||||||
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
|
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.cache.BonsaiCachedMerkleTrieLoaderModule;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.cache.BonsaiCachedMerkleTrieLoaderModule;
|
||||||
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
||||||
import org.hyperledger.besu.evm.log.LogsBloomFilter;
|
import org.hyperledger.besu.evm.log.LogsBloomFilter;
|
||||||
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;
|
|||||||
import org.hyperledger.besu.ethereum.eth.transactions.BlobCacheModule;
|
import org.hyperledger.besu.ethereum.eth.transactions.BlobCacheModule;
|
||||||
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
|
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
|
||||||
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
|
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.cache.BonsaiCachedMerkleTrieLoaderModule;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.cache.BonsaiCachedMerkleTrieLoaderModule;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
|
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
|
||||||
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
||||||
import org.hyperledger.besu.evm.precompile.PrecompiledContract;
|
import org.hyperledger.besu.evm.precompile.PrecompiledContract;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;
|
|||||||
import org.hyperledger.besu.ethereum.eth.transactions.BlobCacheModule;
|
import org.hyperledger.besu.ethereum.eth.transactions.BlobCacheModule;
|
||||||
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
|
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
|
||||||
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
|
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.cache.BonsaiCachedMerkleTrieLoader;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.cache.BonsaiCachedMerkleTrieLoader;
|
||||||
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
||||||
import org.hyperledger.besu.metrics.MetricsSystemModule;
|
import org.hyperledger.besu.metrics.MetricsSystemModule;
|
||||||
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
||||||
|
|||||||
@@ -1282,7 +1282,7 @@ public class BesuCommandTest extends CommandTestAbstract {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void diffbasedLimitTrieLogsEnabledByDefault() {
|
public void pathbasedLimitTrieLogsEnabledByDefault() {
|
||||||
parseCommand();
|
parseCommand();
|
||||||
verify(mockControllerBuilder)
|
verify(mockControllerBuilder)
|
||||||
.dataStorageConfiguration(dataStorageConfigurationArgumentCaptor.capture());
|
.dataStorageConfiguration(dataStorageConfigurationArgumentCaptor.capture());
|
||||||
@@ -1292,7 +1292,7 @@ public class BesuCommandTest extends CommandTestAbstract {
|
|||||||
assertThat(dataStorageConfiguration.getDataStorageFormat()).isEqualTo(BONSAI);
|
assertThat(dataStorageConfiguration.getDataStorageFormat()).isEqualTo(BONSAI);
|
||||||
assertThat(
|
assertThat(
|
||||||
dataStorageConfiguration
|
dataStorageConfiguration
|
||||||
.getDiffBasedSubStorageConfiguration()
|
.getPathBasedExtraStorageConfiguration()
|
||||||
.getLimitTrieLogsEnabled())
|
.getLimitTrieLogsEnabled())
|
||||||
.isTrue();
|
.isTrue();
|
||||||
assertThat(commandOutput.toString(UTF_8)).isEmpty();
|
assertThat(commandOutput.toString(UTF_8)).isEmpty();
|
||||||
@@ -1311,7 +1311,7 @@ public class BesuCommandTest extends CommandTestAbstract {
|
|||||||
assertThat(dataStorageConfiguration.getDataStorageFormat()).isEqualTo(BONSAI);
|
assertThat(dataStorageConfiguration.getDataStorageFormat()).isEqualTo(BONSAI);
|
||||||
assertThat(
|
assertThat(
|
||||||
dataStorageConfiguration
|
dataStorageConfiguration
|
||||||
.getDiffBasedSubStorageConfiguration()
|
.getPathBasedExtraStorageConfiguration()
|
||||||
.getLimitTrieLogsEnabled())
|
.getLimitTrieLogsEnabled())
|
||||||
.isFalse();
|
.isFalse();
|
||||||
verify(mockLogger)
|
verify(mockLogger)
|
||||||
@@ -1348,7 +1348,8 @@ public class BesuCommandTest extends CommandTestAbstract {
|
|||||||
final DataStorageConfiguration dataStorageConfiguration =
|
final DataStorageConfiguration dataStorageConfiguration =
|
||||||
dataStorageConfigurationArgumentCaptor.getValue();
|
dataStorageConfigurationArgumentCaptor.getValue();
|
||||||
assertThat(dataStorageConfiguration.getDataStorageFormat()).isEqualTo(BONSAI);
|
assertThat(dataStorageConfiguration.getDataStorageFormat()).isEqualTo(BONSAI);
|
||||||
assertThat(dataStorageConfiguration.getDiffBasedSubStorageConfiguration().getMaxLayersToLoad())
|
assertThat(
|
||||||
|
dataStorageConfiguration.getPathBasedExtraStorageConfiguration().getMaxLayersToLoad())
|
||||||
.isEqualTo(11);
|
.isEqualTo(11);
|
||||||
assertThat(commandOutput.toString(UTF_8)).isEmpty();
|
assertThat(commandOutput.toString(UTF_8)).isEmpty();
|
||||||
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
|
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
|
||||||
@@ -2525,7 +2526,7 @@ public class BesuCommandTest extends CommandTestAbstract {
|
|||||||
besuCommand
|
besuCommand
|
||||||
.getDataStorageOptions()
|
.getDataStorageOptions()
|
||||||
.toDomainObject()
|
.toDomainObject()
|
||||||
.getDiffBasedSubStorageConfiguration()
|
.getPathBasedExtraStorageConfiguration()
|
||||||
.getUnstable()
|
.getUnstable()
|
||||||
.getFullFlatDbEnabled())
|
.getFullFlatDbEnabled())
|
||||||
.isTrue();
|
.isTrue();
|
||||||
@@ -2538,7 +2539,7 @@ public class BesuCommandTest extends CommandTestAbstract {
|
|||||||
besuCommand
|
besuCommand
|
||||||
.dataStorageOptions
|
.dataStorageOptions
|
||||||
.toDomainObject()
|
.toDomainObject()
|
||||||
.getDiffBasedSubStorageConfiguration()
|
.getPathBasedExtraStorageConfiguration()
|
||||||
.getUnstable()
|
.getUnstable()
|
||||||
.getFullFlatDbEnabled())
|
.getFullFlatDbEnabled())
|
||||||
.isFalse();
|
.isFalse();
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ class ConfigurationOverviewBuilderTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void setDiffbasedLimitTrieLogsEnabled() {
|
void setPathBasedLimitTrieLogsEnabled() {
|
||||||
final String noTrieLogRetentionLimitSet = builder.build();
|
final String noTrieLogRetentionLimitSet = builder.build();
|
||||||
assertThat(noTrieLogRetentionLimitSet).doesNotContain("Limit trie logs enabled");
|
assertThat(noTrieLogRetentionLimitSet).doesNotContain("Limit trie logs enabled");
|
||||||
|
|
||||||
|
|||||||
@@ -15,13 +15,13 @@
|
|||||||
package org.hyperledger.besu.cli.options.stable;
|
package org.hyperledger.besu.cli.options.stable;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.hyperledger.besu.ethereum.worldstate.DiffBasedSubStorageConfiguration.MINIMUM_TRIE_LOG_RETENTION_LIMIT;
|
import static org.hyperledger.besu.ethereum.worldstate.PathBasedExtraStorageConfiguration.MINIMUM_TRIE_LOG_RETENTION_LIMIT;
|
||||||
|
|
||||||
import org.hyperledger.besu.cli.options.AbstractCLIOptionsTest;
|
import org.hyperledger.besu.cli.options.AbstractCLIOptionsTest;
|
||||||
import org.hyperledger.besu.cli.options.storage.DataStorageOptions;
|
import org.hyperledger.besu.cli.options.storage.DataStorageOptions;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
|
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.ImmutableDataStorageConfiguration;
|
import org.hyperledger.besu.ethereum.worldstate.ImmutableDataStorageConfiguration;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.ImmutableDiffBasedSubStorageConfiguration;
|
import org.hyperledger.besu.ethereum.worldstate.ImmutablePathBasedExtraStorageConfiguration;
|
||||||
import org.hyperledger.besu.plugin.services.storage.DataStorageFormat;
|
import org.hyperledger.besu.plugin.services.storage.DataStorageFormat;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@@ -35,7 +35,7 @@ public class DataStorageOptionsTest
|
|||||||
dataStorageConfiguration ->
|
dataStorageConfiguration ->
|
||||||
assertThat(
|
assertThat(
|
||||||
dataStorageConfiguration
|
dataStorageConfiguration
|
||||||
.getDiffBasedSubStorageConfiguration()
|
.getPathBasedExtraStorageConfiguration()
|
||||||
.getTrieLogPruningWindowSize())
|
.getTrieLogPruningWindowSize())
|
||||||
.isEqualTo(600),
|
.isEqualTo(600),
|
||||||
"--bonsai-limit-trie-logs-enabled",
|
"--bonsai-limit-trie-logs-enabled",
|
||||||
@@ -49,7 +49,7 @@ public class DataStorageOptionsTest
|
|||||||
dataStorageConfiguration ->
|
dataStorageConfiguration ->
|
||||||
assertThat(
|
assertThat(
|
||||||
dataStorageConfiguration
|
dataStorageConfiguration
|
||||||
.getDiffBasedSubStorageConfiguration()
|
.getPathBasedExtraStorageConfiguration()
|
||||||
.getTrieLogPruningWindowSize())
|
.getTrieLogPruningWindowSize())
|
||||||
.isEqualTo(600),
|
.isEqualTo(600),
|
||||||
"--Xbonsai-limit-trie-logs-enabled",
|
"--Xbonsai-limit-trie-logs-enabled",
|
||||||
@@ -63,14 +63,14 @@ public class DataStorageOptionsTest
|
|||||||
dataStorageConfiguration ->
|
dataStorageConfiguration ->
|
||||||
assertThat(
|
assertThat(
|
||||||
dataStorageConfiguration
|
dataStorageConfiguration
|
||||||
.getDiffBasedSubStorageConfiguration()
|
.getPathBasedExtraStorageConfiguration()
|
||||||
.getLimitTrieLogsEnabled())
|
.getLimitTrieLogsEnabled())
|
||||||
.isEqualTo(false),
|
.isEqualTo(false),
|
||||||
"--bonsai-limit-trie-logs-enabled=false");
|
"--bonsai-limit-trie-logs-enabled=false");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void diffbasedTrieLogPruningWindowSizeShouldBePositive() {
|
public void pathbasedTrieLogPruningWindowSizeShouldBePositive() {
|
||||||
internalTestFailure(
|
internalTestFailure(
|
||||||
"--bonsai-trie-logs-pruning-window-size=0 must be greater than 0",
|
"--bonsai-trie-logs-pruning-window-size=0 must be greater than 0",
|
||||||
"--bonsai-limit-trie-logs-enabled",
|
"--bonsai-limit-trie-logs-enabled",
|
||||||
@@ -79,7 +79,7 @@ public class DataStorageOptionsTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void diffbasedTrieLogPruningWindowSizeShouldBeAboveRetentionLimit() {
|
public void pathbasedTrieLogPruningWindowSizeShouldBeAboveRetentionLimit() {
|
||||||
internalTestFailure(
|
internalTestFailure(
|
||||||
"--bonsai-trie-logs-pruning-window-size=512 must be greater than --bonsai-historical-block-limit=512",
|
"--bonsai-trie-logs-pruning-window-size=512 must be greater than --bonsai-historical-block-limit=512",
|
||||||
"--bonsai-limit-trie-logs-enabled",
|
"--bonsai-limit-trie-logs-enabled",
|
||||||
@@ -93,7 +93,7 @@ public class DataStorageOptionsTest
|
|||||||
dataStorageConfiguration ->
|
dataStorageConfiguration ->
|
||||||
assertThat(
|
assertThat(
|
||||||
dataStorageConfiguration
|
dataStorageConfiguration
|
||||||
.getDiffBasedSubStorageConfiguration()
|
.getPathBasedExtraStorageConfiguration()
|
||||||
.getMaxLayersToLoad())
|
.getMaxLayersToLoad())
|
||||||
.isEqualTo(MINIMUM_TRIE_LOG_RETENTION_LIMIT + 1),
|
.isEqualTo(MINIMUM_TRIE_LOG_RETENTION_LIMIT + 1),
|
||||||
"--bonsai-limit-trie-logs-enabled",
|
"--bonsai-limit-trie-logs-enabled",
|
||||||
@@ -107,7 +107,7 @@ public class DataStorageOptionsTest
|
|||||||
dataStorageConfiguration ->
|
dataStorageConfiguration ->
|
||||||
assertThat(
|
assertThat(
|
||||||
dataStorageConfiguration
|
dataStorageConfiguration
|
||||||
.getDiffBasedSubStorageConfiguration()
|
.getPathBasedExtraStorageConfiguration()
|
||||||
.getMaxLayersToLoad())
|
.getMaxLayersToLoad())
|
||||||
.isEqualTo(MINIMUM_TRIE_LOG_RETENTION_LIMIT),
|
.isEqualTo(MINIMUM_TRIE_LOG_RETENTION_LIMIT),
|
||||||
"--bonsai-limit-trie-logs-enabled",
|
"--bonsai-limit-trie-logs-enabled",
|
||||||
@@ -125,12 +125,12 @@ public class DataStorageOptionsTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void diffbasedCodeUsingCodeHashEnabledCanBeEnabled() {
|
public void pathbasedCodeUsingCodeHashEnabledCanBeEnabled() {
|
||||||
internalTestSuccess(
|
internalTestSuccess(
|
||||||
dataStorageConfiguration ->
|
dataStorageConfiguration ->
|
||||||
assertThat(
|
assertThat(
|
||||||
dataStorageConfiguration
|
dataStorageConfiguration
|
||||||
.getDiffBasedSubStorageConfiguration()
|
.getPathBasedExtraStorageConfiguration()
|
||||||
.getUnstable()
|
.getUnstable()
|
||||||
.getCodeStoredByCodeHashEnabled())
|
.getCodeStoredByCodeHashEnabled())
|
||||||
.isEqualTo(true),
|
.isEqualTo(true),
|
||||||
@@ -139,12 +139,12 @@ public class DataStorageOptionsTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void diffbasedCodeUsingCodeHashEnabledCanBeDisabled() {
|
public void pathbasedCodeUsingCodeHashEnabledCanBeDisabled() {
|
||||||
internalTestSuccess(
|
internalTestSuccess(
|
||||||
dataStorageConfiguration ->
|
dataStorageConfiguration ->
|
||||||
assertThat(
|
assertThat(
|
||||||
dataStorageConfiguration
|
dataStorageConfiguration
|
||||||
.getDiffBasedSubStorageConfiguration()
|
.getPathBasedExtraStorageConfiguration()
|
||||||
.getUnstable()
|
.getUnstable()
|
||||||
.getCodeStoredByCodeHashEnabled())
|
.getCodeStoredByCodeHashEnabled())
|
||||||
.isEqualTo(false),
|
.isEqualTo(false),
|
||||||
@@ -185,8 +185,8 @@ public class DataStorageOptionsTest
|
|||||||
protected DataStorageConfiguration createCustomizedDomainObject() {
|
protected DataStorageConfiguration createCustomizedDomainObject() {
|
||||||
return ImmutableDataStorageConfiguration.builder()
|
return ImmutableDataStorageConfiguration.builder()
|
||||||
.dataStorageFormat(DataStorageFormat.BONSAI)
|
.dataStorageFormat(DataStorageFormat.BONSAI)
|
||||||
.diffBasedSubStorageConfiguration(
|
.pathBasedExtraStorageConfiguration(
|
||||||
ImmutableDiffBasedSubStorageConfiguration.builder()
|
ImmutablePathBasedExtraStorageConfiguration.builder()
|
||||||
.maxLayersToLoad(513L)
|
.maxLayersToLoad(513L)
|
||||||
.limitTrieLogsEnabled(true)
|
.limitTrieLogsEnabled(true)
|
||||||
.trieLogPruningWindowSize(514)
|
.trieLogPruningWindowSize(514)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ package org.hyperledger.besu.cli.subcommands.storage;
|
|||||||
import static java.util.Collections.singletonList;
|
import static java.util.Collections.singletonList;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||||
import static org.hyperledger.besu.ethereum.worldstate.DiffBasedSubStorageConfiguration.DEFAULT_TRIE_LOG_PRUNING_WINDOW_SIZE;
|
import static org.hyperledger.besu.ethereum.worldstate.PathBasedExtraStorageConfiguration.DEFAULT_TRIE_LOG_PRUNING_WINDOW_SIZE;
|
||||||
import static org.hyperledger.besu.plugin.services.storage.DataStorageFormat.BONSAI;
|
import static org.hyperledger.besu.plugin.services.storage.DataStorageFormat.BONSAI;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
@@ -30,12 +30,12 @@ import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
|
|||||||
import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider;
|
import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider;
|
||||||
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
|
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
|
||||||
import org.hyperledger.besu.ethereum.storage.StorageProvider;
|
import org.hyperledger.besu.ethereum.storage.StorageProvider;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.trielog.TrieLogFactoryImpl;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.trielog.TrieLogFactoryImpl;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.trielog.TrieLogLayer;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.trielog.TrieLogLayer;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
|
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.ImmutableDataStorageConfiguration;
|
import org.hyperledger.besu.ethereum.worldstate.ImmutableDataStorageConfiguration;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.ImmutableDiffBasedSubStorageConfiguration;
|
import org.hyperledger.besu.ethereum.worldstate.ImmutablePathBasedExtraStorageConfiguration;
|
||||||
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
@@ -135,8 +135,8 @@ class TrieLogHelperTest {
|
|||||||
DataStorageConfiguration dataStorageConfiguration =
|
DataStorageConfiguration dataStorageConfiguration =
|
||||||
ImmutableDataStorageConfiguration.builder()
|
ImmutableDataStorageConfiguration.builder()
|
||||||
.dataStorageFormat(BONSAI)
|
.dataStorageFormat(BONSAI)
|
||||||
.diffBasedSubStorageConfiguration(
|
.pathBasedExtraStorageConfiguration(
|
||||||
ImmutableDiffBasedSubStorageConfiguration.builder()
|
ImmutablePathBasedExtraStorageConfiguration.builder()
|
||||||
.maxLayersToLoad(3L)
|
.maxLayersToLoad(3L)
|
||||||
.limitTrieLogsEnabled(true)
|
.limitTrieLogsEnabled(true)
|
||||||
.build())
|
.build())
|
||||||
@@ -176,8 +176,8 @@ class TrieLogHelperTest {
|
|||||||
DataStorageConfiguration dataStorageConfiguration =
|
DataStorageConfiguration dataStorageConfiguration =
|
||||||
ImmutableDataStorageConfiguration.builder()
|
ImmutableDataStorageConfiguration.builder()
|
||||||
.dataStorageFormat(BONSAI)
|
.dataStorageFormat(BONSAI)
|
||||||
.diffBasedSubStorageConfiguration(
|
.pathBasedExtraStorageConfiguration(
|
||||||
ImmutableDiffBasedSubStorageConfiguration.builder()
|
ImmutablePathBasedExtraStorageConfiguration.builder()
|
||||||
.maxLayersToLoad(2L)
|
.maxLayersToLoad(2L)
|
||||||
.limitTrieLogsEnabled(true)
|
.limitTrieLogsEnabled(true)
|
||||||
.build())
|
.build())
|
||||||
@@ -199,8 +199,8 @@ class TrieLogHelperTest {
|
|||||||
DataStorageConfiguration dataStorageConfiguration =
|
DataStorageConfiguration dataStorageConfiguration =
|
||||||
ImmutableDataStorageConfiguration.builder()
|
ImmutableDataStorageConfiguration.builder()
|
||||||
.dataStorageFormat(BONSAI)
|
.dataStorageFormat(BONSAI)
|
||||||
.diffBasedSubStorageConfiguration(
|
.pathBasedExtraStorageConfiguration(
|
||||||
ImmutableDiffBasedSubStorageConfiguration.builder()
|
ImmutablePathBasedExtraStorageConfiguration.builder()
|
||||||
.maxLayersToLoad(10L)
|
.maxLayersToLoad(10L)
|
||||||
.limitTrieLogsEnabled(true)
|
.limitTrieLogsEnabled(true)
|
||||||
.build())
|
.build())
|
||||||
@@ -222,8 +222,8 @@ class TrieLogHelperTest {
|
|||||||
DataStorageConfiguration dataStorageConfiguration =
|
DataStorageConfiguration dataStorageConfiguration =
|
||||||
ImmutableDataStorageConfiguration.builder()
|
ImmutableDataStorageConfiguration.builder()
|
||||||
.dataStorageFormat(BONSAI)
|
.dataStorageFormat(BONSAI)
|
||||||
.diffBasedSubStorageConfiguration(
|
.pathBasedExtraStorageConfiguration(
|
||||||
ImmutableDiffBasedSubStorageConfiguration.builder()
|
ImmutablePathBasedExtraStorageConfiguration.builder()
|
||||||
.maxLayersToLoad(2L)
|
.maxLayersToLoad(2L)
|
||||||
.limitTrieLogsEnabled(true)
|
.limitTrieLogsEnabled(true)
|
||||||
.build())
|
.build())
|
||||||
@@ -246,8 +246,8 @@ class TrieLogHelperTest {
|
|||||||
DataStorageConfiguration dataStorageConfiguration =
|
DataStorageConfiguration dataStorageConfiguration =
|
||||||
ImmutableDataStorageConfiguration.builder()
|
ImmutableDataStorageConfiguration.builder()
|
||||||
.dataStorageFormat(BONSAI)
|
.dataStorageFormat(BONSAI)
|
||||||
.diffBasedSubStorageConfiguration(
|
.pathBasedExtraStorageConfiguration(
|
||||||
ImmutableDiffBasedSubStorageConfiguration.builder()
|
ImmutablePathBasedExtraStorageConfiguration.builder()
|
||||||
.maxLayersToLoad(6L)
|
.maxLayersToLoad(6L)
|
||||||
.limitTrieLogsEnabled(true)
|
.limitTrieLogsEnabled(true)
|
||||||
.build())
|
.build())
|
||||||
@@ -271,8 +271,8 @@ class TrieLogHelperTest {
|
|||||||
DataStorageConfiguration dataStorageConfiguration =
|
DataStorageConfiguration dataStorageConfiguration =
|
||||||
ImmutableDataStorageConfiguration.builder()
|
ImmutableDataStorageConfiguration.builder()
|
||||||
.dataStorageFormat(BONSAI)
|
.dataStorageFormat(BONSAI)
|
||||||
.diffBasedSubStorageConfiguration(
|
.pathBasedExtraStorageConfiguration(
|
||||||
ImmutableDiffBasedSubStorageConfiguration.builder()
|
ImmutablePathBasedExtraStorageConfiguration.builder()
|
||||||
.maxLayersToLoad(3L)
|
.maxLayersToLoad(3L)
|
||||||
.limitTrieLogsEnabled(true)
|
.limitTrieLogsEnabled(true)
|
||||||
.build())
|
.build())
|
||||||
@@ -303,8 +303,8 @@ class TrieLogHelperTest {
|
|||||||
DataStorageConfiguration dataStorageConfiguration =
|
DataStorageConfiguration dataStorageConfiguration =
|
||||||
ImmutableDataStorageConfiguration.builder()
|
ImmutableDataStorageConfiguration.builder()
|
||||||
.dataStorageFormat(BONSAI)
|
.dataStorageFormat(BONSAI)
|
||||||
.diffBasedSubStorageConfiguration(
|
.pathBasedExtraStorageConfiguration(
|
||||||
ImmutableDiffBasedSubStorageConfiguration.builder()
|
ImmutablePathBasedExtraStorageConfiguration.builder()
|
||||||
.maxLayersToLoad(511L)
|
.maxLayersToLoad(511L)
|
||||||
.limitTrieLogsEnabled(true)
|
.limitTrieLogsEnabled(true)
|
||||||
.build())
|
.build())
|
||||||
@@ -324,8 +324,8 @@ class TrieLogHelperTest {
|
|||||||
DataStorageConfiguration dataStorageConfiguration =
|
DataStorageConfiguration dataStorageConfiguration =
|
||||||
ImmutableDataStorageConfiguration.builder()
|
ImmutableDataStorageConfiguration.builder()
|
||||||
.dataStorageFormat(BONSAI)
|
.dataStorageFormat(BONSAI)
|
||||||
.diffBasedSubStorageConfiguration(
|
.pathBasedExtraStorageConfiguration(
|
||||||
ImmutableDiffBasedSubStorageConfiguration.builder()
|
ImmutablePathBasedExtraStorageConfiguration.builder()
|
||||||
.maxLayersToLoad(512L)
|
.maxLayersToLoad(512L)
|
||||||
.limitTrieLogsEnabled(true)
|
.limitTrieLogsEnabled(true)
|
||||||
.trieLogPruningWindowSize(0)
|
.trieLogPruningWindowSize(0)
|
||||||
@@ -345,8 +345,8 @@ class TrieLogHelperTest {
|
|||||||
DataStorageConfiguration dataStorageConfiguration =
|
DataStorageConfiguration dataStorageConfiguration =
|
||||||
ImmutableDataStorageConfiguration.builder()
|
ImmutableDataStorageConfiguration.builder()
|
||||||
.dataStorageFormat(BONSAI)
|
.dataStorageFormat(BONSAI)
|
||||||
.diffBasedSubStorageConfiguration(
|
.pathBasedExtraStorageConfiguration(
|
||||||
ImmutableDiffBasedSubStorageConfiguration.builder()
|
ImmutablePathBasedExtraStorageConfiguration.builder()
|
||||||
.maxLayersToLoad(512L)
|
.maxLayersToLoad(512L)
|
||||||
.limitTrieLogsEnabled(true)
|
.limitTrieLogsEnabled(true)
|
||||||
.trieLogPruningWindowSize(512)
|
.trieLogPruningWindowSize(512)
|
||||||
@@ -368,8 +368,8 @@ class TrieLogHelperTest {
|
|||||||
DataStorageConfiguration dataStorageConfiguration =
|
DataStorageConfiguration dataStorageConfiguration =
|
||||||
ImmutableDataStorageConfiguration.builder()
|
ImmutableDataStorageConfiguration.builder()
|
||||||
.dataStorageFormat(BONSAI)
|
.dataStorageFormat(BONSAI)
|
||||||
.diffBasedSubStorageConfiguration(
|
.pathBasedExtraStorageConfiguration(
|
||||||
ImmutableDiffBasedSubStorageConfiguration.builder()
|
ImmutablePathBasedExtraStorageConfiguration.builder()
|
||||||
.maxLayersToLoad(3L)
|
.maxLayersToLoad(3L)
|
||||||
.limitTrieLogsEnabled(true)
|
.limitTrieLogsEnabled(true)
|
||||||
.build())
|
.build())
|
||||||
|
|||||||
@@ -58,9 +58,9 @@ class TrieLogSubCommandTest extends CommandTestAbstract {
|
|||||||
.dataStorageConfiguration(dataStorageConfigurationArgumentCaptor.capture());
|
.dataStorageConfiguration(dataStorageConfigurationArgumentCaptor.capture());
|
||||||
final List<DataStorageConfiguration> configs =
|
final List<DataStorageConfiguration> configs =
|
||||||
dataStorageConfigurationArgumentCaptor.getAllValues();
|
dataStorageConfigurationArgumentCaptor.getAllValues();
|
||||||
assertThat(configs.get(0).getDiffBasedSubStorageConfiguration().getLimitTrieLogsEnabled())
|
assertThat(configs.get(0).getPathBasedExtraStorageConfiguration().getLimitTrieLogsEnabled())
|
||||||
.isTrue();
|
.isTrue();
|
||||||
assertThat(configs.get(1).getDiffBasedSubStorageConfiguration().getLimitTrieLogsEnabled())
|
assertThat(configs.get(1).getPathBasedExtraStorageConfiguration().getLimitTrieLogsEnabled())
|
||||||
.isFalse();
|
.isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ class TrieLogSubCommandTest extends CommandTestAbstract {
|
|||||||
.allMatch(
|
.allMatch(
|
||||||
dataStorageConfiguration ->
|
dataStorageConfiguration ->
|
||||||
dataStorageConfiguration
|
dataStorageConfiguration
|
||||||
.getDiffBasedSubStorageConfiguration()
|
.getPathBasedExtraStorageConfiguration()
|
||||||
.getLimitTrieLogsEnabled());
|
.getLimitTrieLogsEnabled());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
|
|||||||
import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket;
|
import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket;
|
||||||
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStoragePrefixedKeyBlockchainStorage;
|
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStoragePrefixedKeyBlockchainStorage;
|
||||||
import org.hyperledger.besu.ethereum.storage.keyvalue.VariablesKeyValueStorage;
|
import org.hyperledger.besu.ethereum.storage.keyvalue.VariablesKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.provider.WorldStateQueryParams;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.provider.WorldStateQueryParams;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
|
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
|
||||||
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
||||||
import org.hyperledger.besu.plugin.data.AddedBlockContext;
|
import org.hyperledger.besu.plugin.data.AddedBlockContext;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ package org.hyperledger.besu.consensus.merge.blockcreation;
|
|||||||
|
|
||||||
import static java.util.stream.Collectors.joining;
|
import static java.util.stream.Collectors.joining;
|
||||||
import static org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator.ForkchoiceResult.Status.INVALID;
|
import static org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator.ForkchoiceResult.Status.INVALID;
|
||||||
import static org.hyperledger.besu.ethereum.trie.diffbased.common.provider.WorldStateQueryParams.withBlockHeaderAndUpdateNodeHead;
|
import static org.hyperledger.besu.ethereum.trie.pathbased.common.provider.WorldStateQueryParams.withBlockHeaderAndUpdateNodeHead;
|
||||||
|
|
||||||
import org.hyperledger.besu.consensus.merge.MergeContext;
|
import org.hyperledger.besu.consensus.merge.MergeContext;
|
||||||
import org.hyperledger.besu.consensus.merge.PayloadWrapper;
|
import org.hyperledger.besu.consensus.merge.PayloadWrapper;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ package org.hyperledger.besu.ethereum.api.graphql.internal.pojoadapter;
|
|||||||
import org.hyperledger.besu.datatypes.Address;
|
import org.hyperledger.besu.datatypes.Address;
|
||||||
import org.hyperledger.besu.datatypes.Wei;
|
import org.hyperledger.besu.datatypes.Wei;
|
||||||
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
|
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.BonsaiAccount;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.BonsaiAccount;
|
||||||
import org.hyperledger.besu.evm.account.Account;
|
import org.hyperledger.besu.evm.account.Account;
|
||||||
import org.hyperledger.besu.evm.account.AccountState;
|
import org.hyperledger.besu.evm.account.AccountState;
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
|
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
|
||||||
|
|
||||||
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.UNKNOWN_BLOCK;
|
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.UNKNOWN_BLOCK;
|
||||||
import static org.hyperledger.besu.ethereum.trie.diffbased.common.provider.WorldStateQueryParams.withBlockHeaderAndUpdateNodeHead;
|
import static org.hyperledger.besu.ethereum.trie.pathbased.common.provider.WorldStateQueryParams.withBlockHeaderAndUpdateNodeHead;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
import org.hyperledger.besu.ethereum.ProtocolContext;
|
import org.hyperledger.besu.ethereum.ProtocolContext;
|
||||||
@@ -30,7 +30,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
|
|||||||
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
|
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
|
||||||
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
|
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
|
||||||
import org.hyperledger.besu.ethereum.core.BlockHeader;
|
import org.hyperledger.besu.ethereum.core.BlockHeader;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.provider.DiffBasedWorldStateProvider;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.provider.PathBasedWorldStateProvider;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@@ -90,9 +90,9 @@ public class DebugSetHead extends AbstractBlockParameterOrBlockHashMethod {
|
|||||||
if (maybeMoveWorldstate.orElse(Boolean.FALSE)) {
|
if (maybeMoveWorldstate.orElse(Boolean.FALSE)) {
|
||||||
var archive = blockchainQueries.getWorldStateArchive();
|
var archive = blockchainQueries.getWorldStateArchive();
|
||||||
|
|
||||||
// Only DiffBasedWorldState's need to be moved:
|
// Only PathBasedWorldState's need to be moved:
|
||||||
if (archive instanceof DiffBasedWorldStateProvider diffBasedArchive) {
|
if (archive instanceof PathBasedWorldStateProvider pathBasedArchive) {
|
||||||
if (rollIncrementally(maybeBlockHeader.get(), blockchain, diffBasedArchive)) {
|
if (rollIncrementally(maybeBlockHeader.get(), blockchain, pathBasedArchive)) {
|
||||||
return JsonRpcSuccessResponse.SUCCESS_RESULT;
|
return JsonRpcSuccessResponse.SUCCESS_RESULT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,11 +108,11 @@ public class DebugSetHead extends AbstractBlockParameterOrBlockHashMethod {
|
|||||||
private boolean rollIncrementally(
|
private boolean rollIncrementally(
|
||||||
final BlockHeader target,
|
final BlockHeader target,
|
||||||
final MutableBlockchain blockchain,
|
final MutableBlockchain blockchain,
|
||||||
final DiffBasedWorldStateProvider archive) {
|
final PathBasedWorldStateProvider archive) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (archive.isWorldStateAvailable(target.getStateRoot(), target.getBlockHash())) {
|
if (archive.isWorldStateAvailable(target.getStateRoot(), target.getBlockHash())) {
|
||||||
// WARNING, this can be dangerous for a DiffBasedWorldstate if a concurrent
|
// WARNING, this can be dangerous for a PathBasedWorldstate if a concurrent
|
||||||
// process attempts to move or modify the head worldstate.
|
// process attempts to move or modify the head worldstate.
|
||||||
// Ensure no block processing is occuring when using this feature.
|
// Ensure no block processing is occuring when using this feature.
|
||||||
// No engine-api, block import, sync, mining or other rpc calls should be running.
|
// No engine-api, block import, sync, mining or other rpc calls should be running.
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.privateProcessor;
|
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.privateProcessor;
|
||||||
|
|
||||||
import static org.hyperledger.besu.ethereum.trie.diffbased.common.provider.WorldStateQueryParams.withStateRootAndBlockHashAndUpdateNodeHead;
|
import static org.hyperledger.besu.ethereum.trie.pathbased.common.provider.WorldStateQueryParams.withStateRootAndBlockHashAndUpdateNodeHead;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.Address;
|
import org.hyperledger.besu.datatypes.Address;
|
||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ package org.hyperledger.besu.ethereum.api.query;
|
|||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static org.hyperledger.besu.ethereum.api.query.cache.TransactionLogBloomCacher.BLOCKS_PER_BLOOM_CACHE;
|
import static org.hyperledger.besu.ethereum.api.query.cache.TransactionLogBloomCacher.BLOCKS_PER_BLOOM_CACHE;
|
||||||
import static org.hyperledger.besu.ethereum.mainnet.feemarket.ExcessBlobGasCalculator.calculateExcessBlobGasForParent;
|
import static org.hyperledger.besu.ethereum.mainnet.feemarket.ExcessBlobGasCalculator.calculateExcessBlobGasForParent;
|
||||||
import static org.hyperledger.besu.ethereum.trie.diffbased.common.provider.WorldStateQueryParams.withBlockHeaderAndNoUpdateNodeHead;
|
import static org.hyperledger.besu.ethereum.trie.pathbased.common.provider.WorldStateQueryParams.withBlockHeaderAndNoUpdateNodeHead;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.Address;
|
import org.hyperledger.besu.datatypes.Address;
|
||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ package org.hyperledger.besu.ethereum.blockcreation;
|
|||||||
|
|
||||||
import static org.hyperledger.besu.ethereum.core.BlockHeaderBuilder.createPending;
|
import static org.hyperledger.besu.ethereum.core.BlockHeaderBuilder.createPending;
|
||||||
import static org.hyperledger.besu.ethereum.mainnet.feemarket.ExcessBlobGasCalculator.calculateExcessBlobGasForParent;
|
import static org.hyperledger.besu.ethereum.mainnet.feemarket.ExcessBlobGasCalculator.calculateExcessBlobGasForParent;
|
||||||
import static org.hyperledger.besu.ethereum.trie.diffbased.common.provider.WorldStateQueryParams.withBlockHeaderAndNoUpdateNodeHead;
|
import static org.hyperledger.besu.ethereum.trie.pathbased.common.provider.WorldStateQueryParams.withBlockHeaderAndNoUpdateNodeHead;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.Address;
|
import org.hyperledger.besu.datatypes.Address;
|
||||||
import org.hyperledger.besu.datatypes.BlobGas;
|
import org.hyperledger.besu.datatypes.BlobGas;
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
|
|||||||
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStoragePrefixedKeyBlockchainStorage;
|
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStoragePrefixedKeyBlockchainStorage;
|
||||||
import org.hyperledger.besu.ethereum.storage.keyvalue.VariablesKeyValueStorage;
|
import org.hyperledger.besu.ethereum.storage.keyvalue.VariablesKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
|
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.provider.WorldStateQueryParams;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.provider.WorldStateQueryParams;
|
||||||
import org.hyperledger.besu.evm.gascalculator.GasCalculator;
|
import org.hyperledger.besu.evm.gascalculator.GasCalculator;
|
||||||
import org.hyperledger.besu.evm.gascalculator.LondonGasCalculator;
|
import org.hyperledger.besu.evm.gascalculator.LondonGasCalculator;
|
||||||
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ package org.hyperledger.besu.ethereum.vm;
|
|||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.entry;
|
import static org.assertj.core.api.Assertions.entry;
|
||||||
import static org.hyperledger.besu.ethereum.trie.diffbased.common.provider.WorldStateQueryParams.withStateRootAndBlockHashAndUpdateNodeHead;
|
import static org.hyperledger.besu.ethereum.trie.pathbased.common.provider.WorldStateQueryParams.withStateRootAndBlockHashAndUpdateNodeHead;
|
||||||
|
|
||||||
import org.hyperledger.besu.config.GenesisConfig;
|
import org.hyperledger.besu.config.GenesisConfig;
|
||||||
import org.hyperledger.besu.crypto.KeyPair;
|
import org.hyperledger.besu.crypto.KeyPair;
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import org.hyperledger.besu.ethereum.mainnet.BlockProcessor;
|
|||||||
import org.hyperledger.besu.ethereum.mainnet.BodyValidationMode;
|
import org.hyperledger.besu.ethereum.mainnet.BodyValidationMode;
|
||||||
import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode;
|
import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode;
|
||||||
import org.hyperledger.besu.ethereum.trie.MerkleTrieException;
|
import org.hyperledger.besu.ethereum.trie.MerkleTrieException;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.provider.WorldStateQueryParams;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.provider.WorldStateQueryParams;
|
||||||
import org.hyperledger.besu.plugin.services.exception.StorageException;
|
import org.hyperledger.besu.plugin.services.exception.StorageException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ import org.hyperledger.besu.ethereum.mainnet.systemcall.BlockProcessingContext;
|
|||||||
import org.hyperledger.besu.ethereum.privacy.storage.PrivateMetadataUpdater;
|
import org.hyperledger.besu.ethereum.privacy.storage.PrivateMetadataUpdater;
|
||||||
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
|
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
|
||||||
import org.hyperledger.besu.ethereum.trie.MerkleTrieException;
|
import org.hyperledger.besu.ethereum.trie.MerkleTrieException;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.worldview.BonsaiWorldState;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.worldview.BonsaiWorldState;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.worldview.BonsaiWorldStateUpdateAccumulator;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.worldview.BonsaiWorldStateUpdateAccumulator;
|
||||||
import org.hyperledger.besu.evm.blockhash.BlockHashLookup;
|
import org.hyperledger.besu.evm.blockhash.BlockHashLookup;
|
||||||
import org.hyperledger.besu.evm.tracing.OperationTracer;
|
import org.hyperledger.besu.evm.tracing.OperationTracer;
|
||||||
import org.hyperledger.besu.evm.worldstate.WorldState;
|
import org.hyperledger.besu.evm.worldstate.WorldState;
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
|
|||||||
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecBuilder;
|
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecBuilder;
|
||||||
import org.hyperledger.besu.ethereum.privacy.storage.PrivateMetadataUpdater;
|
import org.hyperledger.besu.ethereum.privacy.storage.PrivateMetadataUpdater;
|
||||||
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
|
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.provider.DiffBasedWorldStateProvider;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.provider.PathBasedWorldStateProvider;
|
||||||
import org.hyperledger.besu.evm.blockhash.BlockHashLookup;
|
import org.hyperledger.besu.evm.blockhash.BlockHashLookup;
|
||||||
import org.hyperledger.besu.evm.worldstate.WorldUpdater;
|
import org.hyperledger.besu.evm.worldstate.WorldUpdater;
|
||||||
import org.hyperledger.besu.metrics.BesuMetricCategory;
|
import org.hyperledger.besu.metrics.BesuMetricCategory;
|
||||||
@@ -221,7 +221,7 @@ public class MainnetParallelBlockProcessor extends MainnetBlockProcessor {
|
|||||||
final Address miningBeneficiary,
|
final Address miningBeneficiary,
|
||||||
final BlockHashLookup blockHashLookup,
|
final BlockHashLookup blockHashLookup,
|
||||||
final Wei blobGasPrice) {
|
final Wei blobGasPrice) {
|
||||||
if ((protocolContext.getWorldStateArchive() instanceof DiffBasedWorldStateProvider)) {
|
if ((protocolContext.getWorldStateArchive() instanceof PathBasedWorldStateProvider)) {
|
||||||
ParallelizedConcurrentTransactionProcessor parallelizedConcurrentTransactionProcessor =
|
ParallelizedConcurrentTransactionProcessor parallelizedConcurrentTransactionProcessor =
|
||||||
new ParallelizedConcurrentTransactionProcessor(transactionProcessor);
|
new ParallelizedConcurrentTransactionProcessor(transactionProcessor);
|
||||||
// runAsyncBlock, if activated, facilitates the non-blocking parallel execution of
|
// runAsyncBlock, if activated, facilitates the non-blocking parallel execution of
|
||||||
|
|||||||
@@ -24,10 +24,10 @@ import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor;
|
|||||||
import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams;
|
import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams;
|
||||||
import org.hyperledger.besu.ethereum.privacy.storage.PrivateMetadataUpdater;
|
import org.hyperledger.besu.ethereum.privacy.storage.PrivateMetadataUpdater;
|
||||||
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
|
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.worldview.BonsaiWorldState;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.worldview.BonsaiWorldState;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.provider.WorldStateQueryParams;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.provider.WorldStateQueryParams;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.DiffBasedWorldState;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.PathBasedWorldState;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.accumulator.DiffBasedWorldStateUpdateAccumulator;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.accumulator.PathBasedWorldStateUpdateAccumulator;
|
||||||
import org.hyperledger.besu.evm.blockhash.BlockHashLookup;
|
import org.hyperledger.besu.evm.blockhash.BlockHashLookup;
|
||||||
import org.hyperledger.besu.evm.tracing.OperationTracer;
|
import org.hyperledger.besu.evm.tracing.OperationTracer;
|
||||||
import org.hyperledger.besu.evm.worldstate.WorldView;
|
import org.hyperledger.besu.evm.worldstate.WorldView;
|
||||||
@@ -153,8 +153,8 @@ public class ParallelizedConcurrentTransactionProcessor {
|
|||||||
ws.disableCacheMerkleTrieLoader();
|
ws.disableCacheMerkleTrieLoader();
|
||||||
final ParallelizedTransactionContext.Builder contextBuilder =
|
final ParallelizedTransactionContext.Builder contextBuilder =
|
||||||
new ParallelizedTransactionContext.Builder();
|
new ParallelizedTransactionContext.Builder();
|
||||||
final DiffBasedWorldStateUpdateAccumulator<?> roundWorldStateUpdater =
|
final PathBasedWorldStateUpdateAccumulator<?> roundWorldStateUpdater =
|
||||||
(DiffBasedWorldStateUpdateAccumulator<?>) ws.updater();
|
(PathBasedWorldStateUpdateAccumulator<?>) ws.updater();
|
||||||
final TransactionProcessingResult result =
|
final TransactionProcessingResult result =
|
||||||
transactionProcessor.processTransaction(
|
transactionProcessor.processTransaction(
|
||||||
roundWorldStateUpdater,
|
roundWorldStateUpdater,
|
||||||
@@ -244,16 +244,16 @@ public class ParallelizedConcurrentTransactionProcessor {
|
|||||||
final int transactionLocation,
|
final int transactionLocation,
|
||||||
final Optional<Counter> confirmedParallelizedTransactionCounter,
|
final Optional<Counter> confirmedParallelizedTransactionCounter,
|
||||||
final Optional<Counter> conflictingButCachedTransactionCounter) {
|
final Optional<Counter> conflictingButCachedTransactionCounter) {
|
||||||
final DiffBasedWorldState diffBasedWorldState = (DiffBasedWorldState) worldState;
|
final PathBasedWorldState pathBasedWorldState = (PathBasedWorldState) worldState;
|
||||||
final DiffBasedWorldStateUpdateAccumulator blockAccumulator =
|
final PathBasedWorldStateUpdateAccumulator blockAccumulator =
|
||||||
(DiffBasedWorldStateUpdateAccumulator) diffBasedWorldState.updater();
|
(PathBasedWorldStateUpdateAccumulator) pathBasedWorldState.updater();
|
||||||
final ParallelizedTransactionContext parallelizedTransactionContext =
|
final ParallelizedTransactionContext parallelizedTransactionContext =
|
||||||
parallelizedTransactionContextByLocation.remove(transactionLocation);
|
parallelizedTransactionContextByLocation.remove(transactionLocation);
|
||||||
/*
|
/*
|
||||||
* If `parallelizedTransactionContext` is not null, it means that the transaction had time to complete in the background.
|
* If `parallelizedTransactionContext` is not null, it means that the transaction had time to complete in the background.
|
||||||
*/
|
*/
|
||||||
if (parallelizedTransactionContext != null) {
|
if (parallelizedTransactionContext != null) {
|
||||||
final DiffBasedWorldStateUpdateAccumulator<?> transactionAccumulator =
|
final PathBasedWorldStateUpdateAccumulator<?> transactionAccumulator =
|
||||||
parallelizedTransactionContext.transactionAccumulator();
|
parallelizedTransactionContext.transactionAccumulator();
|
||||||
final TransactionProcessingResult transactionProcessingResult =
|
final TransactionProcessingResult transactionProcessingResult =
|
||||||
parallelizedTransactionContext.transactionProcessingResult();
|
parallelizedTransactionContext.transactionProcessingResult();
|
||||||
|
|||||||
@@ -16,18 +16,18 @@ package org.hyperledger.besu.ethereum.mainnet.parallelization;
|
|||||||
|
|
||||||
import org.hyperledger.besu.datatypes.Wei;
|
import org.hyperledger.besu.datatypes.Wei;
|
||||||
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
|
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.accumulator.DiffBasedWorldStateUpdateAccumulator;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.accumulator.PathBasedWorldStateUpdateAccumulator;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public final class ParallelizedTransactionContext {
|
public final class ParallelizedTransactionContext {
|
||||||
private final DiffBasedWorldStateUpdateAccumulator<?> transactionAccumulator;
|
private final PathBasedWorldStateUpdateAccumulator<?> transactionAccumulator;
|
||||||
private final TransactionProcessingResult transactionProcessingResult;
|
private final TransactionProcessingResult transactionProcessingResult;
|
||||||
private final boolean isMiningBeneficiaryTouchedPreRewardByTransaction;
|
private final boolean isMiningBeneficiaryTouchedPreRewardByTransaction;
|
||||||
private final Wei miningBeneficiaryReward;
|
private final Wei miningBeneficiaryReward;
|
||||||
|
|
||||||
public ParallelizedTransactionContext(
|
public ParallelizedTransactionContext(
|
||||||
final DiffBasedWorldStateUpdateAccumulator<?> transactionAccumulator,
|
final PathBasedWorldStateUpdateAccumulator<?> transactionAccumulator,
|
||||||
final TransactionProcessingResult transactionProcessingResult,
|
final TransactionProcessingResult transactionProcessingResult,
|
||||||
final boolean isMiningBeneficiaryTouchedPreRewardByTransaction,
|
final boolean isMiningBeneficiaryTouchedPreRewardByTransaction,
|
||||||
final Wei miningBeneficiaryReward) {
|
final Wei miningBeneficiaryReward) {
|
||||||
@@ -38,7 +38,7 @@ public final class ParallelizedTransactionContext {
|
|||||||
this.miningBeneficiaryReward = miningBeneficiaryReward;
|
this.miningBeneficiaryReward = miningBeneficiaryReward;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DiffBasedWorldStateUpdateAccumulator<?> transactionAccumulator() {
|
public PathBasedWorldStateUpdateAccumulator<?> transactionAccumulator() {
|
||||||
return transactionAccumulator;
|
return transactionAccumulator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,13 +93,13 @@ public final class ParallelizedTransactionContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
private DiffBasedWorldStateUpdateAccumulator<?> transactionAccumulator;
|
private PathBasedWorldStateUpdateAccumulator<?> transactionAccumulator;
|
||||||
private TransactionProcessingResult transactionProcessingResult;
|
private TransactionProcessingResult transactionProcessingResult;
|
||||||
private boolean isMiningBeneficiaryTouchedPreRewardByTransaction;
|
private boolean isMiningBeneficiaryTouchedPreRewardByTransaction;
|
||||||
private Wei miningBeneficiaryReward = Wei.ZERO;
|
private Wei miningBeneficiaryReward = Wei.ZERO;
|
||||||
|
|
||||||
public Builder transactionAccumulator(
|
public Builder transactionAccumulator(
|
||||||
final DiffBasedWorldStateUpdateAccumulator<?> transactionAccumulator) {
|
final PathBasedWorldStateUpdateAccumulator<?> transactionAccumulator) {
|
||||||
this.transactionAccumulator = transactionAccumulator;
|
this.transactionAccumulator = transactionAccumulator;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,10 +17,10 @@ package org.hyperledger.besu.ethereum.mainnet.parallelization;
|
|||||||
import org.hyperledger.besu.datatypes.Address;
|
import org.hyperledger.besu.datatypes.Address;
|
||||||
import org.hyperledger.besu.datatypes.StorageSlotKey;
|
import org.hyperledger.besu.datatypes.StorageSlotKey;
|
||||||
import org.hyperledger.besu.ethereum.core.Transaction;
|
import org.hyperledger.besu.ethereum.core.Transaction;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.DiffBasedAccount;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.PathBasedAccount;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.DiffBasedValue;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.PathBasedValue;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.accumulator.DiffBasedWorldStateUpdateAccumulator;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.accumulator.PathBasedWorldStateUpdateAccumulator;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.accumulator.preload.StorageConsumingMap;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.accumulator.preload.StorageConsumingMap;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -55,7 +55,7 @@ public class TransactionCollisionDetector {
|
|||||||
final Transaction transaction,
|
final Transaction transaction,
|
||||||
final Address miningBeneficiary,
|
final Address miningBeneficiary,
|
||||||
final ParallelizedTransactionContext parallelizedTransactionContext,
|
final ParallelizedTransactionContext parallelizedTransactionContext,
|
||||||
final DiffBasedWorldStateUpdateAccumulator<? extends DiffBasedAccount> blockAccumulator) {
|
final PathBasedWorldStateUpdateAccumulator<? extends PathBasedAccount> blockAccumulator) {
|
||||||
final Set<Address> addressesTouchedByTransaction =
|
final Set<Address> addressesTouchedByTransaction =
|
||||||
getAddressesTouchedByTransaction(
|
getAddressesTouchedByTransaction(
|
||||||
transaction, Optional.of(parallelizedTransactionContext.transactionAccumulator()));
|
transaction, Optional.of(parallelizedTransactionContext.transactionAccumulator()));
|
||||||
@@ -97,21 +97,21 @@ public class TransactionCollisionDetector {
|
|||||||
*/
|
*/
|
||||||
public Set<Address> getAddressesTouchedByTransaction(
|
public Set<Address> getAddressesTouchedByTransaction(
|
||||||
final Transaction transaction,
|
final Transaction transaction,
|
||||||
final Optional<DiffBasedWorldStateUpdateAccumulator<?>> accumulator) {
|
final Optional<PathBasedWorldStateUpdateAccumulator<?>> accumulator) {
|
||||||
HashSet<Address> addresses = new HashSet<>();
|
HashSet<Address> addresses = new HashSet<>();
|
||||||
addresses.add(transaction.getSender());
|
addresses.add(transaction.getSender());
|
||||||
if (transaction.getTo().isPresent()) {
|
if (transaction.getTo().isPresent()) {
|
||||||
addresses.add(transaction.getTo().get());
|
addresses.add(transaction.getTo().get());
|
||||||
}
|
}
|
||||||
accumulator.ifPresent(
|
accumulator.ifPresent(
|
||||||
diffBasedWorldStateUpdateAccumulator -> {
|
pathBasedWorldStateUpdateAccumulator -> {
|
||||||
diffBasedWorldStateUpdateAccumulator
|
pathBasedWorldStateUpdateAccumulator
|
||||||
.getAccountsToUpdate()
|
.getAccountsToUpdate()
|
||||||
.forEach(
|
.forEach(
|
||||||
(address, diffBasedValue) -> {
|
(address, pathBasedValue) -> {
|
||||||
addresses.add(address);
|
addresses.add(address);
|
||||||
});
|
});
|
||||||
addresses.addAll(diffBasedWorldStateUpdateAccumulator.getDeletedAccountAddresses());
|
addresses.addAll(pathBasedWorldStateUpdateAccumulator.getDeletedAccountAddresses());
|
||||||
});
|
});
|
||||||
|
|
||||||
return addresses;
|
return addresses;
|
||||||
@@ -134,12 +134,12 @@ public class TransactionCollisionDetector {
|
|||||||
* returned.
|
* returned.
|
||||||
*/
|
*/
|
||||||
private Set<StorageSlotKey> getSlotsTouchedByTransactionAndByAddress(
|
private Set<StorageSlotKey> getSlotsTouchedByTransactionAndByAddress(
|
||||||
final Optional<DiffBasedWorldStateUpdateAccumulator<?>> accumulator, final Address address) {
|
final Optional<PathBasedWorldStateUpdateAccumulator<?>> accumulator, final Address address) {
|
||||||
HashSet<StorageSlotKey> slots = new HashSet<>();
|
HashSet<StorageSlotKey> slots = new HashSet<>();
|
||||||
accumulator.ifPresent(
|
accumulator.ifPresent(
|
||||||
diffBasedWorldStateUpdateAccumulator -> {
|
pathBasedWorldStateUpdateAccumulator -> {
|
||||||
final StorageConsumingMap<StorageSlotKey, DiffBasedValue<UInt256>> map =
|
final StorageConsumingMap<StorageSlotKey, PathBasedValue<UInt256>> map =
|
||||||
diffBasedWorldStateUpdateAccumulator.getStorageToUpdate().get(address);
|
pathBasedWorldStateUpdateAccumulator.getStorageToUpdate().get(address);
|
||||||
if (map != null) {
|
if (map != null) {
|
||||||
map.forEach(
|
map.forEach(
|
||||||
(storageSlotKey, slot) -> {
|
(storageSlotKey, slot) -> {
|
||||||
@@ -170,19 +170,19 @@ public class TransactionCollisionDetector {
|
|||||||
*/
|
*/
|
||||||
private Optional<AccountUpdateContext> getAddressTouchedByBlock(
|
private Optional<AccountUpdateContext> getAddressTouchedByBlock(
|
||||||
final Address addressToFind,
|
final Address addressToFind,
|
||||||
final Optional<DiffBasedWorldStateUpdateAccumulator<? extends DiffBasedAccount>>
|
final Optional<PathBasedWorldStateUpdateAccumulator<? extends PathBasedAccount>>
|
||||||
maybeBlockAccumulator) {
|
maybeBlockAccumulator) {
|
||||||
if (maybeBlockAccumulator.isPresent()) {
|
if (maybeBlockAccumulator.isPresent()) {
|
||||||
final DiffBasedWorldStateUpdateAccumulator<? extends DiffBasedAccount> blockAccumulator =
|
final PathBasedWorldStateUpdateAccumulator<? extends PathBasedAccount> blockAccumulator =
|
||||||
maybeBlockAccumulator.get();
|
maybeBlockAccumulator.get();
|
||||||
final DiffBasedValue<? extends DiffBasedAccount> diffBasedValue =
|
final PathBasedValue<? extends PathBasedAccount> pathBasedValue =
|
||||||
blockAccumulator.getAccountsToUpdate().get(addressToFind);
|
blockAccumulator.getAccountsToUpdate().get(addressToFind);
|
||||||
if (diffBasedValue != null) {
|
if (pathBasedValue != null) {
|
||||||
return Optional.of(
|
return Optional.of(
|
||||||
new AccountUpdateContext(
|
new AccountUpdateContext(
|
||||||
addressToFind,
|
addressToFind,
|
||||||
areAccountDetailsEqualExcludingStorage(
|
areAccountDetailsEqualExcludingStorage(
|
||||||
diffBasedValue.getPrior(), diffBasedValue.getUpdated())));
|
pathBasedValue.getPrior(), pathBasedValue.getUpdated())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
@@ -203,12 +203,12 @@ public class TransactionCollisionDetector {
|
|||||||
* are found, or the address has no associated updates, an empty set is returned.
|
* are found, or the address has no associated updates, an empty set is returned.
|
||||||
*/
|
*/
|
||||||
private Set<StorageSlotKey> getSlotsTouchedByBlockAndByAddress(
|
private Set<StorageSlotKey> getSlotsTouchedByBlockAndByAddress(
|
||||||
final Optional<DiffBasedWorldStateUpdateAccumulator<?>> accumulator, final Address address) {
|
final Optional<PathBasedWorldStateUpdateAccumulator<?>> accumulator, final Address address) {
|
||||||
HashSet<StorageSlotKey> slots = new HashSet<>();
|
HashSet<StorageSlotKey> slots = new HashSet<>();
|
||||||
accumulator.ifPresent(
|
accumulator.ifPresent(
|
||||||
diffBasedWorldStateUpdateAccumulator -> {
|
pathBasedWorldStateUpdateAccumulator -> {
|
||||||
final StorageConsumingMap<StorageSlotKey, DiffBasedValue<UInt256>> map =
|
final StorageConsumingMap<StorageSlotKey, PathBasedValue<UInt256>> map =
|
||||||
diffBasedWorldStateUpdateAccumulator.getStorageToUpdate().get(address);
|
pathBasedWorldStateUpdateAccumulator.getStorageToUpdate().get(address);
|
||||||
if (map != null) {
|
if (map != null) {
|
||||||
map.forEach(
|
map.forEach(
|
||||||
(storageSlotKey, slot) -> {
|
(storageSlotKey, slot) -> {
|
||||||
@@ -235,7 +235,7 @@ public class TransactionCollisionDetector {
|
|||||||
* @return true if the account state properties are equal excluding storage, false otherwise.
|
* @return true if the account state properties are equal excluding storage, false otherwise.
|
||||||
*/
|
*/
|
||||||
private boolean areAccountDetailsEqualExcludingStorage(
|
private boolean areAccountDetailsEqualExcludingStorage(
|
||||||
final DiffBasedAccount prior, final DiffBasedAccount next) {
|
final PathBasedAccount prior, final PathBasedAccount next) {
|
||||||
return (prior == null && next == null)
|
return (prior == null && next == null)
|
||||||
|| (prior != null
|
|| (prior != null
|
||||||
&& next != null
|
&& next != null
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIV
|
|||||||
import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_IS_PERSISTING_PRIVATE_STATE;
|
import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_IS_PERSISTING_PRIVATE_STATE;
|
||||||
import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_PRIVATE_METADATA_UPDATER;
|
import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_PRIVATE_METADATA_UPDATER;
|
||||||
import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_TRANSACTION_HASH;
|
import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_TRANSACTION_HASH;
|
||||||
import static org.hyperledger.besu.ethereum.trie.diffbased.common.provider.WorldStateQueryParams.withStateRootAndUpdateNodeHead;
|
import static org.hyperledger.besu.ethereum.trie.pathbased.common.provider.WorldStateQueryParams.withStateRootAndUpdateNodeHead;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
import org.hyperledger.besu.enclave.Enclave;
|
import org.hyperledger.besu.enclave.Enclave;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.mainnet.precompiles.privacy;
|
package org.hyperledger.besu.ethereum.mainnet.precompiles.privacy;
|
||||||
|
|
||||||
import static org.hyperledger.besu.ethereum.trie.diffbased.common.provider.WorldStateQueryParams.withStateRootAndUpdateNodeHead;
|
import static org.hyperledger.besu.ethereum.trie.pathbased.common.provider.WorldStateQueryParams.withStateRootAndUpdateNodeHead;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
import org.hyperledger.besu.ethereum.core.MutableWorldState;
|
import org.hyperledger.besu.ethereum.core.MutableWorldState;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_IS_PER
|
|||||||
import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_PRIVATE_METADATA_UPDATER;
|
import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_PRIVATE_METADATA_UPDATER;
|
||||||
import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_TRANSACTION_HASH;
|
import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_TRANSACTION_HASH;
|
||||||
import static org.hyperledger.besu.ethereum.privacy.PrivateStateRootResolver.EMPTY_ROOT_HASH;
|
import static org.hyperledger.besu.ethereum.privacy.PrivateStateRootResolver.EMPTY_ROOT_HASH;
|
||||||
import static org.hyperledger.besu.ethereum.trie.diffbased.common.provider.WorldStateQueryParams.withStateRootAndUpdateNodeHead;
|
import static org.hyperledger.besu.ethereum.trie.pathbased.common.provider.WorldStateQueryParams.withStateRootAndUpdateNodeHead;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.Address;
|
import org.hyperledger.besu.datatypes.Address;
|
||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIV
|
|||||||
import static org.hyperledger.besu.ethereum.privacy.group.FlexibleGroupManagement.CAN_EXECUTE_METHOD_SIGNATURE;
|
import static org.hyperledger.besu.ethereum.privacy.group.FlexibleGroupManagement.CAN_EXECUTE_METHOD_SIGNATURE;
|
||||||
import static org.hyperledger.besu.ethereum.privacy.group.FlexibleGroupManagement.GET_PARTICIPANTS_METHOD_SIGNATURE;
|
import static org.hyperledger.besu.ethereum.privacy.group.FlexibleGroupManagement.GET_PARTICIPANTS_METHOD_SIGNATURE;
|
||||||
import static org.hyperledger.besu.ethereum.privacy.group.FlexibleGroupManagement.GET_VERSION_METHOD_SIGNATURE;
|
import static org.hyperledger.besu.ethereum.privacy.group.FlexibleGroupManagement.GET_VERSION_METHOD_SIGNATURE;
|
||||||
import static org.hyperledger.besu.ethereum.trie.diffbased.common.provider.WorldStateQueryParams.withStateRootAndBlockHashAndUpdateNodeHead;
|
import static org.hyperledger.besu.ethereum.trie.pathbased.common.provider.WorldStateQueryParams.withStateRootAndBlockHashAndUpdateNodeHead;
|
||||||
|
|
||||||
import org.hyperledger.besu.crypto.SECPSignature;
|
import org.hyperledger.besu.crypto.SECPSignature;
|
||||||
import org.hyperledger.besu.crypto.SignatureAlgorithm;
|
import org.hyperledger.besu.crypto.SignatureAlgorithm;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
package org.hyperledger.besu.ethereum.privacy;
|
package org.hyperledger.besu.ethereum.privacy;
|
||||||
|
|
||||||
import static org.hyperledger.besu.ethereum.privacy.PrivateStateRootResolver.EMPTY_ROOT_HASH;
|
import static org.hyperledger.besu.ethereum.privacy.PrivateStateRootResolver.EMPTY_ROOT_HASH;
|
||||||
import static org.hyperledger.besu.ethereum.trie.diffbased.common.provider.WorldStateQueryParams.withStateRootAndUpdateNodeHead;
|
import static org.hyperledger.besu.ethereum.trie.pathbased.common.provider.WorldStateQueryParams.withStateRootAndUpdateNodeHead;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.Address;
|
import org.hyperledger.besu.datatypes.Address;
|
||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.privacy;
|
package org.hyperledger.besu.ethereum.privacy;
|
||||||
|
|
||||||
import static org.hyperledger.besu.ethereum.trie.diffbased.common.provider.WorldStateQueryParams.withBlockHeaderAndUpdateNodeHead;
|
import static org.hyperledger.besu.ethereum.trie.pathbased.common.provider.WorldStateQueryParams.withBlockHeaderAndUpdateNodeHead;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
import org.hyperledger.besu.ethereum.chain.Blockchain;
|
import org.hyperledger.besu.ethereum.chain.Blockchain;
|
||||||
|
|||||||
@@ -14,8 +14,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.privacy;
|
package org.hyperledger.besu.ethereum.privacy;
|
||||||
|
|
||||||
import static org.hyperledger.besu.ethereum.trie.diffbased.common.provider.WorldStateQueryParams.withBlockHeaderAndUpdateNodeHead;
|
import static org.hyperledger.besu.ethereum.trie.pathbased.common.provider.WorldStateQueryParams.withBlockHeaderAndUpdateNodeHead;
|
||||||
import static org.hyperledger.besu.ethereum.trie.diffbased.common.provider.WorldStateQueryParams.withStateRootAndBlockHashAndUpdateNodeHead;
|
import static org.hyperledger.besu.ethereum.trie.pathbased.common.provider.WorldStateQueryParams.withStateRootAndBlockHashAndUpdateNodeHead;
|
||||||
|
|
||||||
import org.hyperledger.besu.crypto.SECPSignature;
|
import org.hyperledger.besu.crypto.SECPSignature;
|
||||||
import org.hyperledger.besu.crypto.SignatureAlgorithm;
|
import org.hyperledger.besu.crypto.SignatureAlgorithm;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
package org.hyperledger.besu.ethereum.privacy.storage.migration;
|
package org.hyperledger.besu.ethereum.privacy.storage.migration;
|
||||||
|
|
||||||
import static org.hyperledger.besu.ethereum.privacy.storage.PrivateStateKeyValueStorage.SCHEMA_VERSION_1_4_0;
|
import static org.hyperledger.besu.ethereum.privacy.storage.PrivateStateKeyValueStorage.SCHEMA_VERSION_1_4_0;
|
||||||
import static org.hyperledger.besu.ethereum.trie.diffbased.common.provider.WorldStateQueryParams.withBlockHeaderAndUpdateNodeHead;
|
import static org.hyperledger.besu.ethereum.trie.pathbased.common.provider.WorldStateQueryParams.withBlockHeaderAndUpdateNodeHead;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.Address;
|
import org.hyperledger.besu.datatypes.Address;
|
||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ package org.hyperledger.besu.ethereum.processing;
|
|||||||
|
|
||||||
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
|
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
|
||||||
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
|
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.accumulator.DiffBasedWorldStateUpdateAccumulator;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.accumulator.PathBasedWorldStateUpdateAccumulator;
|
||||||
import org.hyperledger.besu.evm.log.Log;
|
import org.hyperledger.besu.evm.log.Log;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -55,7 +55,7 @@ public class TransactionProcessingResult
|
|||||||
private final ValidationResult<TransactionInvalidReason> validationResult;
|
private final ValidationResult<TransactionInvalidReason> validationResult;
|
||||||
private final Optional<Bytes> revertReason;
|
private final Optional<Bytes> revertReason;
|
||||||
|
|
||||||
public DiffBasedWorldStateUpdateAccumulator<?> accumulator;
|
public PathBasedWorldStateUpdateAccumulator<?> accumulator;
|
||||||
|
|
||||||
public static TransactionProcessingResult invalid(
|
public static TransactionProcessingResult invalid(
|
||||||
final ValidationResult<TransactionInvalidReason> validationResult) {
|
final ValidationResult<TransactionInvalidReason> validationResult) {
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ import org.hyperledger.besu.ethereum.chain.VariablesStorage;
|
|||||||
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
|
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
|
||||||
import org.hyperledger.besu.ethereum.mainnet.ScheduleBasedBlockHeaderFunctions;
|
import org.hyperledger.besu.ethereum.mainnet.ScheduleBasedBlockHeaderFunctions;
|
||||||
import org.hyperledger.besu.ethereum.storage.StorageProvider;
|
import org.hyperledger.besu.ethereum.storage.StorageProvider;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
|
|
||||||
import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage;
|
||||||
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
|
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.WorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.worldstate.WorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.WorldStatePreimageStorage;
|
import org.hyperledger.besu.ethereum.worldstate.WorldStatePreimageStorage;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
package org.hyperledger.besu.ethereum.transaction;
|
package org.hyperledger.besu.ethereum.transaction;
|
||||||
|
|
||||||
import static org.hyperledger.besu.ethereum.transaction.BlockStateCalls.fillBlockStateCalls;
|
import static org.hyperledger.besu.ethereum.transaction.BlockStateCalls.fillBlockStateCalls;
|
||||||
import static org.hyperledger.besu.ethereum.trie.diffbased.common.provider.WorldStateQueryParams.withBlockHeaderAndNoUpdateNodeHead;
|
import static org.hyperledger.besu.ethereum.trie.pathbased.common.provider.WorldStateQueryParams.withBlockHeaderAndNoUpdateNodeHead;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.Address;
|
import org.hyperledger.besu.datatypes.Address;
|
||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ package org.hyperledger.besu.ethereum.transaction;
|
|||||||
|
|
||||||
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||||
import static org.hyperledger.besu.ethereum.mainnet.feemarket.ExcessBlobGasCalculator.calculateExcessBlobGasForParent;
|
import static org.hyperledger.besu.ethereum.mainnet.feemarket.ExcessBlobGasCalculator.calculateExcessBlobGasForParent;
|
||||||
import static org.hyperledger.besu.ethereum.trie.diffbased.common.provider.WorldStateQueryParams.withBlockHeaderAndNoUpdateNodeHead;
|
import static org.hyperledger.besu.ethereum.trie.pathbased.common.provider.WorldStateQueryParams.withBlockHeaderAndNoUpdateNodeHead;
|
||||||
|
|
||||||
import org.hyperledger.besu.crypto.SECPSignature;
|
import org.hyperledger.besu.crypto.SECPSignature;
|
||||||
import org.hyperledger.besu.crypto.SignatureAlgorithm;
|
import org.hyperledger.besu.crypto.SignatureAlgorithm;
|
||||||
|
|||||||
@@ -14,18 +14,18 @@
|
|||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.common;
|
package org.hyperledger.besu.ethereum.trie.common;
|
||||||
|
|
||||||
import static org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.WorldStateConfig.createStatefulConfigWithTrie;
|
import static org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.WorldStateConfig.createStatefulConfigWithTrie;
|
||||||
|
|
||||||
import org.hyperledger.besu.ethereum.core.MutableWorldState;
|
import org.hyperledger.besu.ethereum.core.MutableWorldState;
|
||||||
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProvider;
|
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProvider;
|
||||||
import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStatePreimageKeyValueStorage;
|
import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStatePreimageKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.cache.BonsaiCachedMerkleTrieLoader;
|
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.cache.NoOpBonsaiCachedWorldStorageManager;
|
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
|
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.worldview.BonsaiWorldState;
|
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.trielog.NoOpTrieLogManager;
|
|
||||||
import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.trie.forest.worldview.ForestMutableWorldState;
|
import org.hyperledger.besu.ethereum.trie.forest.worldview.ForestMutableWorldState;
|
||||||
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.cache.BonsaiCachedMerkleTrieLoader;
|
||||||
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.cache.NoOpBonsaiCachedWorldStorageManager;
|
||||||
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
|
||||||
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.worldview.BonsaiWorldState;
|
||||||
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.trielog.NoOpTrieLogManager;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
|
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
|
||||||
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
||||||
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ import org.hyperledger.besu.ethereum.core.MutableWorldState;
|
|||||||
import org.hyperledger.besu.ethereum.proof.WorldStateProof;
|
import org.hyperledger.besu.ethereum.proof.WorldStateProof;
|
||||||
import org.hyperledger.besu.ethereum.proof.WorldStateProofProvider;
|
import org.hyperledger.besu.ethereum.proof.WorldStateProofProvider;
|
||||||
import org.hyperledger.besu.ethereum.trie.MerkleTrie;
|
import org.hyperledger.besu.ethereum.trie.MerkleTrie;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.provider.WorldStateQueryParams;
|
|
||||||
import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.trie.forest.worldview.ForestMutableWorldState;
|
import org.hyperledger.besu.ethereum.trie.forest.worldview.ForestMutableWorldState;
|
||||||
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.provider.WorldStateQueryParams;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
|
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.WorldStatePreimageStorage;
|
import org.hyperledger.besu.ethereum.worldstate.WorldStatePreimageStorage;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorageCoordinator;
|
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorageCoordinator;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.bonsai;
|
package org.hyperledger.besu.ethereum.trie.pathbased.bonsai;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.AccountValue;
|
import org.hyperledger.besu.datatypes.AccountValue;
|
||||||
import org.hyperledger.besu.datatypes.Address;
|
import org.hyperledger.besu.datatypes.Address;
|
||||||
@@ -22,9 +22,9 @@ import org.hyperledger.besu.ethereum.rlp.RLP;
|
|||||||
import org.hyperledger.besu.ethereum.rlp.RLPException;
|
import org.hyperledger.besu.ethereum.rlp.RLPException;
|
||||||
import org.hyperledger.besu.ethereum.rlp.RLPInput;
|
import org.hyperledger.besu.ethereum.rlp.RLPInput;
|
||||||
import org.hyperledger.besu.ethereum.rlp.RLPOutput;
|
import org.hyperledger.besu.ethereum.rlp.RLPOutput;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.DiffBasedAccount;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.PathBasedAccount;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.DiffBasedWorldView;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.PathBasedWorldView;
|
||||||
import org.hyperledger.besu.evm.ModificationNotAllowedException;
|
import org.hyperledger.besu.evm.ModificationNotAllowedException;
|
||||||
import org.hyperledger.besu.evm.account.AccountStorageEntry;
|
import org.hyperledger.besu.evm.account.AccountStorageEntry;
|
||||||
import org.hyperledger.besu.evm.worldstate.UpdateTrackingAccount;
|
import org.hyperledger.besu.evm.worldstate.UpdateTrackingAccount;
|
||||||
@@ -35,11 +35,11 @@ import java.util.Objects;
|
|||||||
import org.apache.tuweni.bytes.Bytes;
|
import org.apache.tuweni.bytes.Bytes;
|
||||||
import org.apache.tuweni.bytes.Bytes32;
|
import org.apache.tuweni.bytes.Bytes32;
|
||||||
|
|
||||||
public class BonsaiAccount extends DiffBasedAccount {
|
public class BonsaiAccount extends PathBasedAccount {
|
||||||
private Hash storageRoot;
|
private Hash storageRoot;
|
||||||
|
|
||||||
public BonsaiAccount(
|
public BonsaiAccount(
|
||||||
final DiffBasedWorldView context,
|
final PathBasedWorldView context,
|
||||||
final Address address,
|
final Address address,
|
||||||
final Hash addressHash,
|
final Hash addressHash,
|
||||||
final long nonce,
|
final long nonce,
|
||||||
@@ -52,7 +52,7 @@ public class BonsaiAccount extends DiffBasedAccount {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BonsaiAccount(
|
public BonsaiAccount(
|
||||||
final DiffBasedWorldView context,
|
final PathBasedWorldView context,
|
||||||
final Address address,
|
final Address address,
|
||||||
final AccountValue stateTrieAccount,
|
final AccountValue stateTrieAccount,
|
||||||
final boolean mutable) {
|
final boolean mutable) {
|
||||||
@@ -72,7 +72,7 @@ public class BonsaiAccount extends DiffBasedAccount {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BonsaiAccount(
|
public BonsaiAccount(
|
||||||
final BonsaiAccount toCopy, final DiffBasedWorldView context, final boolean mutable) {
|
final BonsaiAccount toCopy, final PathBasedWorldView context, final boolean mutable) {
|
||||||
super(
|
super(
|
||||||
context,
|
context,
|
||||||
toCopy.address,
|
toCopy.address,
|
||||||
@@ -87,7 +87,7 @@ public class BonsaiAccount extends DiffBasedAccount {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BonsaiAccount(
|
public BonsaiAccount(
|
||||||
final DiffBasedWorldView context, final UpdateTrackingAccount<BonsaiAccount> tracked) {
|
final PathBasedWorldView context, final UpdateTrackingAccount<BonsaiAccount> tracked) {
|
||||||
super(
|
super(
|
||||||
context,
|
context,
|
||||||
tracked.getAddress(),
|
tracked.getAddress(),
|
||||||
@@ -102,7 +102,7 @@ public class BonsaiAccount extends DiffBasedAccount {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static BonsaiAccount fromRLP(
|
public static BonsaiAccount fromRLP(
|
||||||
final DiffBasedWorldView context,
|
final PathBasedWorldView context,
|
||||||
final Address address,
|
final Address address,
|
||||||
final Bytes encoded,
|
final Bytes encoded,
|
||||||
final boolean mutable)
|
final boolean mutable)
|
||||||
@@ -12,19 +12,19 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.bonsai;
|
package org.hyperledger.besu.ethereum.trie.pathbased.bonsai;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.Address;
|
import org.hyperledger.besu.datatypes.Address;
|
||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
import org.hyperledger.besu.ethereum.chain.Blockchain;
|
import org.hyperledger.besu.ethereum.chain.Blockchain;
|
||||||
import org.hyperledger.besu.ethereum.rlp.RLP;
|
import org.hyperledger.besu.ethereum.rlp.RLP;
|
||||||
import org.hyperledger.besu.ethereum.trie.common.PmtStateTrieAccountValue;
|
import org.hyperledger.besu.ethereum.trie.common.PmtStateTrieAccountValue;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.cache.BonsaiCachedMerkleTrieLoader;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.cache.BonsaiCachedMerkleTrieLoader;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.cache.BonsaiCachedWorldStorageManager;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.cache.BonsaiCachedWorldStorageManager;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.worldview.BonsaiWorldState;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.worldview.BonsaiWorldState;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.provider.DiffBasedWorldStateProvider;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.provider.PathBasedWorldStateProvider;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.trielog.TrieLogManager;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.trielog.TrieLogManager;
|
||||||
import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie;
|
import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie;
|
||||||
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
||||||
import org.hyperledger.besu.plugin.ServiceManager;
|
import org.hyperledger.besu.plugin.ServiceManager;
|
||||||
@@ -40,7 +40,7 @@ import org.apache.tuweni.bytes.Bytes;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class BonsaiWorldStateProvider extends DiffBasedWorldStateProvider {
|
public class BonsaiWorldStateProvider extends PathBasedWorldStateProvider {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(BonsaiWorldStateProvider.class);
|
private static final Logger LOG = LoggerFactory.getLogger(BonsaiWorldStateProvider.class);
|
||||||
private final BonsaiCachedMerkleTrieLoader bonsaiCachedMerkleTrieLoader;
|
private final BonsaiCachedMerkleTrieLoader bonsaiCachedMerkleTrieLoader;
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.bonsai.cache;
|
package org.hyperledger.besu.ethereum.trie.pathbased.bonsai.cache;
|
||||||
|
|
||||||
import static org.hyperledger.besu.metrics.BesuMetricCategory.BLOCKCHAIN;
|
import static org.hyperledger.besu.metrics.BesuMetricCategory.BLOCKCHAIN;
|
||||||
|
|
||||||
@@ -21,8 +21,8 @@ import org.hyperledger.besu.datatypes.Hash;
|
|||||||
import org.hyperledger.besu.datatypes.StorageSlotKey;
|
import org.hyperledger.besu.datatypes.StorageSlotKey;
|
||||||
import org.hyperledger.besu.ethereum.trie.MerkleTrie;
|
import org.hyperledger.besu.ethereum.trie.MerkleTrie;
|
||||||
import org.hyperledger.besu.ethereum.trie.MerkleTrieException;
|
import org.hyperledger.besu.ethereum.trie.MerkleTrieException;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.StorageSubscriber;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.StorageSubscriber;
|
||||||
import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie;
|
import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie;
|
||||||
import org.hyperledger.besu.metrics.ObservableMetricsSystem;
|
import org.hyperledger.besu.metrics.ObservableMetricsSystem;
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.bonsai.cache;
|
package org.hyperledger.besu.ethereum.trie.pathbased.bonsai.cache;
|
||||||
|
|
||||||
import org.hyperledger.besu.metrics.ObservableMetricsSystem;
|
import org.hyperledger.besu.metrics.ObservableMetricsSystem;
|
||||||
import org.hyperledger.besu.plugin.services.MetricsSystem;
|
import org.hyperledger.besu.plugin.services.MetricsSystem;
|
||||||
@@ -12,33 +12,33 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.bonsai.cache;
|
package org.hyperledger.besu.ethereum.trie.pathbased.bonsai.cache;
|
||||||
|
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.BonsaiWorldStateProvider;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.BonsaiWorldStateProvider;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.BonsaiSnapshotWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.storage.BonsaiSnapshotWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.BonsaiWorldStateLayerStorage;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.storage.BonsaiWorldStateLayerStorage;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.worldview.BonsaiWorldState;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.worldview.BonsaiWorldState;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.cache.DiffBasedCachedWorldStorageManager;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.cache.PathBasedCachedWorldStorageManager;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.provider.DiffBasedWorldStateProvider;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.provider.PathBasedWorldStateProvider;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.storage.DiffBasedWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.storage.PathBasedWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.DiffBasedWorldState;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.PathBasedWorldState;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.WorldStateConfig;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.WorldStateConfig;
|
||||||
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
||||||
|
|
||||||
public class BonsaiCachedWorldStorageManager extends DiffBasedCachedWorldStorageManager {
|
public class BonsaiCachedWorldStorageManager extends PathBasedCachedWorldStorageManager {
|
||||||
|
|
||||||
public BonsaiCachedWorldStorageManager(
|
public BonsaiCachedWorldStorageManager(
|
||||||
final BonsaiWorldStateProvider archive,
|
final BonsaiWorldStateProvider archive,
|
||||||
final DiffBasedWorldStateKeyValueStorage worldStateKeyValueStorage,
|
final PathBasedWorldStateKeyValueStorage worldStateKeyValueStorage,
|
||||||
final WorldStateConfig worldStateConfig) {
|
final WorldStateConfig worldStateConfig) {
|
||||||
super(archive, worldStateKeyValueStorage, worldStateConfig);
|
super(archive, worldStateKeyValueStorage, worldStateConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DiffBasedWorldState createWorldState(
|
public PathBasedWorldState createWorldState(
|
||||||
final DiffBasedWorldStateProvider archive,
|
final PathBasedWorldStateProvider archive,
|
||||||
final DiffBasedWorldStateKeyValueStorage worldStateKeyValueStorage,
|
final PathBasedWorldStateKeyValueStorage worldStateKeyValueStorage,
|
||||||
final EvmConfiguration evmConfiguration) {
|
final EvmConfiguration evmConfiguration) {
|
||||||
return new BonsaiWorldState(
|
return new BonsaiWorldState(
|
||||||
(BonsaiWorldStateProvider) archive,
|
(BonsaiWorldStateProvider) archive,
|
||||||
@@ -48,15 +48,15 @@ public class BonsaiCachedWorldStorageManager extends DiffBasedCachedWorldStorage
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DiffBasedWorldStateKeyValueStorage createLayeredKeyValueStorage(
|
public PathBasedWorldStateKeyValueStorage createLayeredKeyValueStorage(
|
||||||
final DiffBasedWorldStateKeyValueStorage worldStateKeyValueStorage) {
|
final PathBasedWorldStateKeyValueStorage worldStateKeyValueStorage) {
|
||||||
return new BonsaiWorldStateLayerStorage(
|
return new BonsaiWorldStateLayerStorage(
|
||||||
(BonsaiWorldStateKeyValueStorage) worldStateKeyValueStorage);
|
(BonsaiWorldStateKeyValueStorage) worldStateKeyValueStorage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DiffBasedWorldStateKeyValueStorage createSnapshotKeyValueStorage(
|
public PathBasedWorldStateKeyValueStorage createSnapshotKeyValueStorage(
|
||||||
final DiffBasedWorldStateKeyValueStorage worldStateKeyValueStorage) {
|
final PathBasedWorldStateKeyValueStorage worldStateKeyValueStorage) {
|
||||||
return new BonsaiSnapshotWorldStateKeyValueStorage(
|
return new BonsaiSnapshotWorldStateKeyValueStorage(
|
||||||
(BonsaiWorldStateKeyValueStorage) worldStateKeyValueStorage);
|
(BonsaiWorldStateKeyValueStorage) worldStateKeyValueStorage);
|
||||||
}
|
}
|
||||||
@@ -12,13 +12,13 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.bonsai.cache;
|
package org.hyperledger.besu.ethereum.trie.pathbased.bonsai.cache;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
import org.hyperledger.besu.ethereum.core.BlockHeader;
|
import org.hyperledger.besu.ethereum.core.BlockHeader;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.DiffBasedWorldState;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.PathBasedWorldState;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.WorldStateConfig;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.WorldStateConfig;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
@@ -34,7 +34,7 @@ public class NoOpBonsaiCachedWorldStorageManager extends BonsaiCachedWorldStorag
|
|||||||
public synchronized void addCachedLayer(
|
public synchronized void addCachedLayer(
|
||||||
final BlockHeader blockHeader,
|
final BlockHeader blockHeader,
|
||||||
final Hash worldStateRootHash,
|
final Hash worldStateRootHash,
|
||||||
final DiffBasedWorldState forWorldState) {
|
final PathBasedWorldState forWorldState) {
|
||||||
// no cache
|
// no cache
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,17 +44,17 @@ public class NoOpBonsaiCachedWorldStorageManager extends BonsaiCachedWorldStorag
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<DiffBasedWorldState> getWorldState(final Hash blockHash) {
|
public Optional<PathBasedWorldState> getWorldState(final Hash blockHash) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<DiffBasedWorldState> getNearestWorldState(final BlockHeader blockHeader) {
|
public Optional<PathBasedWorldState> getNearestWorldState(final BlockHeader blockHeader) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<DiffBasedWorldState> getHeadWorldState(
|
public Optional<PathBasedWorldState> getHeadWorldState(
|
||||||
final Function<Hash, Optional<BlockHeader>> hashBlockHeaderFunction) {
|
final Function<Hash, Optional<BlockHeader>> hashBlockHeaderFunction) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
@@ -12,12 +12,12 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.bonsai.cache;
|
package org.hyperledger.besu.ethereum.trie.pathbased.bonsai.cache;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.Address;
|
import org.hyperledger.besu.datatypes.Address;
|
||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
import org.hyperledger.besu.datatypes.StorageSlotKey;
|
import org.hyperledger.besu.datatypes.StorageSlotKey;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
||||||
|
|
||||||
public class NoopBonsaiCachedMerkleTrieLoader extends BonsaiCachedMerkleTrieLoader {
|
public class NoopBonsaiCachedMerkleTrieLoader extends BonsaiCachedMerkleTrieLoader {
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage;
|
package org.hyperledger.besu.ethereum.trie.pathbased.bonsai.storage;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.Address;
|
import org.hyperledger.besu.datatypes.Address;
|
||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
@@ -12,12 +12,12 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage;
|
package org.hyperledger.besu.ethereum.trie.pathbased.bonsai.storage;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
import org.hyperledger.besu.datatypes.StorageSlotKey;
|
import org.hyperledger.besu.datatypes.StorageSlotKey;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.StorageSubscriber;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.StorageSubscriber;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.storage.DiffBasedSnapshotWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.storage.PathBasedSnapshotWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.plugin.services.exception.StorageException;
|
import org.hyperledger.besu.plugin.services.exception.StorageException;
|
||||||
import org.hyperledger.besu.plugin.services.storage.KeyValueStorage;
|
import org.hyperledger.besu.plugin.services.storage.KeyValueStorage;
|
||||||
import org.hyperledger.besu.plugin.services.storage.SnappableKeyValueStorage;
|
import org.hyperledger.besu.plugin.services.storage.SnappableKeyValueStorage;
|
||||||
@@ -32,7 +32,7 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class BonsaiSnapshotWorldStateKeyValueStorage extends BonsaiWorldStateKeyValueStorage
|
public class BonsaiSnapshotWorldStateKeyValueStorage extends BonsaiWorldStateKeyValueStorage
|
||||||
implements DiffBasedSnapshotWorldStateKeyValueStorage, StorageSubscriber {
|
implements PathBasedSnapshotWorldStateKeyValueStorage, StorageSubscriber {
|
||||||
|
|
||||||
protected final BonsaiWorldStateKeyValueStorage parentWorldStateStorage;
|
protected final BonsaiWorldStateKeyValueStorage parentWorldStateStorage;
|
||||||
private static final Logger LOG =
|
private static final Logger LOG =
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage;
|
package org.hyperledger.besu.ethereum.trie.pathbased.bonsai.storage;
|
||||||
|
|
||||||
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.ACCOUNT_INFO_STATE;
|
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.ACCOUNT_INFO_STATE;
|
||||||
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.ACCOUNT_STORAGE_STORAGE;
|
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.ACCOUNT_STORAGE_STORAGE;
|
||||||
@@ -25,10 +25,10 @@ import org.hyperledger.besu.ethereum.storage.StorageProvider;
|
|||||||
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier;
|
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier;
|
||||||
import org.hyperledger.besu.ethereum.trie.MerkleTrie;
|
import org.hyperledger.besu.ethereum.trie.MerkleTrie;
|
||||||
import org.hyperledger.besu.ethereum.trie.common.PmtStateTrieAccountValue;
|
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.pathbased.bonsai.storage.flat.BonsaiFlatDbStrategy;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.flat.BonsaiFlatDbStrategyProvider;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.storage.flat.BonsaiFlatDbStrategyProvider;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.storage.DiffBasedWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.storage.PathBasedWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.storage.flat.FlatDbStrategy;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.storage.flat.FlatDbStrategy;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
|
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.FlatDbMode;
|
import org.hyperledger.besu.ethereum.worldstate.FlatDbMode;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.WorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.worldstate.WorldStateKeyValueStorage;
|
||||||
@@ -48,7 +48,7 @@ import java.util.function.Supplier;
|
|||||||
import org.apache.tuweni.bytes.Bytes;
|
import org.apache.tuweni.bytes.Bytes;
|
||||||
import org.apache.tuweni.bytes.Bytes32;
|
import org.apache.tuweni.bytes.Bytes32;
|
||||||
|
|
||||||
public class BonsaiWorldStateKeyValueStorage extends DiffBasedWorldStateKeyValueStorage
|
public class BonsaiWorldStateKeyValueStorage extends PathBasedWorldStateKeyValueStorage
|
||||||
implements WorldStateKeyValueStorage {
|
implements WorldStateKeyValueStorage {
|
||||||
protected final BonsaiFlatDbStrategyProvider flatDbStrategyProvider;
|
protected final BonsaiFlatDbStrategyProvider flatDbStrategyProvider;
|
||||||
|
|
||||||
@@ -190,7 +190,7 @@ public class BonsaiWorldStateKeyValueStorage extends DiffBasedWorldStateKeyValue
|
|||||||
getFlatDbStrategy());
|
getFlatDbStrategy());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Updater implements DiffBasedWorldStateKeyValueStorage.Updater {
|
public static class Updater implements PathBasedWorldStateKeyValueStorage.Updater {
|
||||||
|
|
||||||
private final SegmentedKeyValueStorageTransaction composedWorldStateTransaction;
|
private final SegmentedKeyValueStorageTransaction composedWorldStateTransaction;
|
||||||
private final KeyValueStorageTransaction trieLogStorageTransaction;
|
private final KeyValueStorageTransaction trieLogStorageTransaction;
|
||||||
@@ -12,17 +12,17 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage;
|
package org.hyperledger.besu.ethereum.trie.pathbased.bonsai.storage;
|
||||||
|
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.StorageSubscriber;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.StorageSubscriber;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.storage.DiffBasedLayeredWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.storage.PathBasedLayeredWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.FlatDbMode;
|
import org.hyperledger.besu.ethereum.worldstate.FlatDbMode;
|
||||||
import org.hyperledger.besu.plugin.services.storage.KeyValueStorage;
|
import org.hyperledger.besu.plugin.services.storage.KeyValueStorage;
|
||||||
import org.hyperledger.besu.plugin.services.storage.SnappedKeyValueStorage;
|
import org.hyperledger.besu.plugin.services.storage.SnappedKeyValueStorage;
|
||||||
import org.hyperledger.besu.services.kvstore.LayeredKeyValueStorage;
|
import org.hyperledger.besu.services.kvstore.LayeredKeyValueStorage;
|
||||||
|
|
||||||
public class BonsaiWorldStateLayerStorage extends BonsaiSnapshotWorldStateKeyValueStorage
|
public class BonsaiWorldStateLayerStorage extends BonsaiSnapshotWorldStateKeyValueStorage
|
||||||
implements DiffBasedLayeredWorldStateKeyValueStorage, StorageSubscriber {
|
implements PathBasedLayeredWorldStateKeyValueStorage, StorageSubscriber {
|
||||||
|
|
||||||
public BonsaiWorldStateLayerStorage(final BonsaiWorldStateKeyValueStorage parent) {
|
public BonsaiWorldStateLayerStorage(final BonsaiWorldStateKeyValueStorage parent) {
|
||||||
this(
|
this(
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.flat;
|
package org.hyperledger.besu.ethereum.trie.pathbased.bonsai.storage.flat;
|
||||||
|
|
||||||
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.ACCOUNT_INFO_STATE;
|
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.ACCOUNT_INFO_STATE;
|
||||||
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.ACCOUNT_STORAGE_STORAGE;
|
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.ACCOUNT_STORAGE_STORAGE;
|
||||||
@@ -21,8 +21,8 @@ import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIden
|
|||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
import org.hyperledger.besu.datatypes.StorageSlotKey;
|
import org.hyperledger.besu.datatypes.StorageSlotKey;
|
||||||
import org.hyperledger.besu.ethereum.trie.NodeLoader;
|
import org.hyperledger.besu.ethereum.trie.NodeLoader;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.storage.flat.CodeStorageStrategy;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.storage.flat.CodeStorageStrategy;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.storage.flat.FlatDbStrategy;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.storage.flat.FlatDbStrategy;
|
||||||
import org.hyperledger.besu.plugin.services.MetricsSystem;
|
import org.hyperledger.besu.plugin.services.MetricsSystem;
|
||||||
import org.hyperledger.besu.plugin.services.storage.SegmentedKeyValueStorage;
|
import org.hyperledger.besu.plugin.services.storage.SegmentedKeyValueStorage;
|
||||||
import org.hyperledger.besu.plugin.services.storage.SegmentedKeyValueStorageTransaction;
|
import org.hyperledger.besu.plugin.services.storage.SegmentedKeyValueStorageTransaction;
|
||||||
@@ -12,13 +12,13 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.flat;
|
package org.hyperledger.besu.ethereum.trie.pathbased.bonsai.storage.flat;
|
||||||
|
|
||||||
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.TRIE_BRANCH_STORAGE;
|
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.TRIE_BRANCH_STORAGE;
|
||||||
|
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.storage.flat.CodeStorageStrategy;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.storage.flat.CodeStorageStrategy;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.storage.flat.FlatDbStrategy;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.storage.flat.FlatDbStrategy;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.storage.flat.FlatDbStrategyProvider;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.storage.flat.FlatDbStrategyProvider;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
|
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.FlatDbMode;
|
import org.hyperledger.besu.ethereum.worldstate.FlatDbMode;
|
||||||
import org.hyperledger.besu.plugin.services.MetricsSystem;
|
import org.hyperledger.besu.plugin.services.MetricsSystem;
|
||||||
@@ -41,7 +41,7 @@ public class BonsaiFlatDbStrategyProvider extends FlatDbStrategyProvider {
|
|||||||
protected FlatDbMode getRequestedFlatDbMode(
|
protected FlatDbMode getRequestedFlatDbMode(
|
||||||
final DataStorageConfiguration dataStorageConfiguration) {
|
final DataStorageConfiguration dataStorageConfiguration) {
|
||||||
return dataStorageConfiguration
|
return dataStorageConfiguration
|
||||||
.getDiffBasedSubStorageConfiguration()
|
.getPathBasedExtraStorageConfiguration()
|
||||||
.getUnstable()
|
.getUnstable()
|
||||||
.getFullFlatDbEnabled()
|
.getFullFlatDbEnabled()
|
||||||
? FlatDbMode.FULL
|
? FlatDbMode.FULL
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.flat;
|
package org.hyperledger.besu.ethereum.trie.pathbased.bonsai.storage.flat;
|
||||||
|
|
||||||
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.ACCOUNT_INFO_STATE;
|
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.ACCOUNT_INFO_STATE;
|
||||||
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.ACCOUNT_STORAGE_STORAGE;
|
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.ACCOUNT_STORAGE_STORAGE;
|
||||||
@@ -20,7 +20,7 @@ import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIden
|
|||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
import org.hyperledger.besu.datatypes.StorageSlotKey;
|
import org.hyperledger.besu.datatypes.StorageSlotKey;
|
||||||
import org.hyperledger.besu.ethereum.trie.NodeLoader;
|
import org.hyperledger.besu.ethereum.trie.NodeLoader;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.storage.flat.CodeStorageStrategy;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.storage.flat.CodeStorageStrategy;
|
||||||
import org.hyperledger.besu.metrics.BesuMetricCategory;
|
import org.hyperledger.besu.metrics.BesuMetricCategory;
|
||||||
import org.hyperledger.besu.plugin.services.MetricsSystem;
|
import org.hyperledger.besu.plugin.services.MetricsSystem;
|
||||||
import org.hyperledger.besu.plugin.services.metrics.Counter;
|
import org.hyperledger.besu.plugin.services.metrics.Counter;
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.flat;
|
package org.hyperledger.besu.ethereum.trie.pathbased.bonsai.storage.flat;
|
||||||
|
|
||||||
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.ACCOUNT_INFO_STATE;
|
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.ACCOUNT_INFO_STATE;
|
||||||
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.ACCOUNT_STORAGE_STORAGE;
|
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.ACCOUNT_STORAGE_STORAGE;
|
||||||
@@ -20,7 +20,7 @@ import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIden
|
|||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
import org.hyperledger.besu.datatypes.StorageSlotKey;
|
import org.hyperledger.besu.datatypes.StorageSlotKey;
|
||||||
import org.hyperledger.besu.ethereum.trie.NodeLoader;
|
import org.hyperledger.besu.ethereum.trie.NodeLoader;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.storage.flat.CodeStorageStrategy;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.storage.flat.CodeStorageStrategy;
|
||||||
import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie;
|
import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie;
|
||||||
import org.hyperledger.besu.ethereum.trie.patricia.StoredNodeFactory;
|
import org.hyperledger.besu.ethereum.trie.patricia.StoredNodeFactory;
|
||||||
import org.hyperledger.besu.metrics.BesuMetricCategory;
|
import org.hyperledger.besu.metrics.BesuMetricCategory;
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.bonsai.trielog;
|
package org.hyperledger.besu.ethereum.trie.pathbased.bonsai.trielog;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.AccountValue;
|
import org.hyperledger.besu.datatypes.AccountValue;
|
||||||
import org.hyperledger.besu.datatypes.Address;
|
import org.hyperledger.besu.datatypes.Address;
|
||||||
@@ -23,8 +23,8 @@ import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
|
|||||||
import org.hyperledger.besu.ethereum.rlp.RLPInput;
|
import org.hyperledger.besu.ethereum.rlp.RLPInput;
|
||||||
import org.hyperledger.besu.ethereum.rlp.RLPOutput;
|
import org.hyperledger.besu.ethereum.rlp.RLPOutput;
|
||||||
import org.hyperledger.besu.ethereum.trie.common.PmtStateTrieAccountValue;
|
import org.hyperledger.besu.ethereum.trie.common.PmtStateTrieAccountValue;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.DiffBasedValue;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.PathBasedValue;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.trielog.TrieLogLayer;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.trielog.TrieLogLayer;
|
||||||
import org.hyperledger.besu.plugin.data.BlockHeader;
|
import org.hyperledger.besu.plugin.data.BlockHeader;
|
||||||
import org.hyperledger.besu.plugin.services.trielogs.TrieLog;
|
import org.hyperledger.besu.plugin.services.trielogs.TrieLog;
|
||||||
import org.hyperledger.besu.plugin.services.trielogs.TrieLogAccumulator;
|
import org.hyperledger.besu.plugin.services.trielogs.TrieLogAccumulator;
|
||||||
@@ -168,7 +168,7 @@ public class TrieLogFactoryImpl implements TrieLogFactory {
|
|||||||
input.leaveList();
|
input.leaveList();
|
||||||
newLayer
|
newLayer
|
||||||
.getAccountChanges()
|
.getAccountChanges()
|
||||||
.put(address, new DiffBasedValue<>(oldValue, newValue, isCleared));
|
.put(address, new PathBasedValue<>(oldValue, newValue, isCleared));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.nextIsNull()) {
|
if (input.nextIsNull()) {
|
||||||
@@ -179,13 +179,13 @@ public class TrieLogFactoryImpl implements TrieLogFactory {
|
|||||||
final Bytes newCode = nullOrValue(input, RLPInput::readBytes);
|
final Bytes newCode = nullOrValue(input, RLPInput::readBytes);
|
||||||
final boolean isCleared = getOptionalIsCleared(input);
|
final boolean isCleared = getOptionalIsCleared(input);
|
||||||
input.leaveList();
|
input.leaveList();
|
||||||
newLayer.getCodeChanges().put(address, new DiffBasedValue<>(oldCode, newCode, isCleared));
|
newLayer.getCodeChanges().put(address, new PathBasedValue<>(oldCode, newCode, isCleared));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.nextIsNull()) {
|
if (input.nextIsNull()) {
|
||||||
input.skipNext();
|
input.skipNext();
|
||||||
} else {
|
} else {
|
||||||
final Map<StorageSlotKey, DiffBasedValue<UInt256>> storageChanges = new TreeMap<>();
|
final Map<StorageSlotKey, PathBasedValue<UInt256>> storageChanges = new TreeMap<>();
|
||||||
input.enterList();
|
input.enterList();
|
||||||
while (!input.isEndOfCurrentList()) {
|
while (!input.isEndOfCurrentList()) {
|
||||||
input.enterList();
|
input.enterList();
|
||||||
@@ -194,7 +194,7 @@ public class TrieLogFactoryImpl implements TrieLogFactory {
|
|||||||
final UInt256 oldValue = nullOrValue(input, RLPInput::readUInt256Scalar);
|
final UInt256 oldValue = nullOrValue(input, RLPInput::readUInt256Scalar);
|
||||||
final UInt256 newValue = nullOrValue(input, RLPInput::readUInt256Scalar);
|
final UInt256 newValue = nullOrValue(input, RLPInput::readUInt256Scalar);
|
||||||
final boolean isCleared = getOptionalIsCleared(input);
|
final boolean isCleared = getOptionalIsCleared(input);
|
||||||
storageChanges.put(storageSlotKey, new DiffBasedValue<>(oldValue, newValue, isCleared));
|
storageChanges.put(storageSlotKey, new PathBasedValue<>(oldValue, newValue, isCleared));
|
||||||
input.leaveList();
|
input.leaveList();
|
||||||
}
|
}
|
||||||
input.leaveList();
|
input.leaveList();
|
||||||
@@ -12,10 +12,10 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.bonsai.worldview;
|
package org.hyperledger.besu.ethereum.trie.pathbased.bonsai.worldview;
|
||||||
|
|
||||||
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.TRIE_BRANCH_STORAGE;
|
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.TRIE_BRANCH_STORAGE;
|
||||||
import static org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.DiffBasedWorldView.encodeTrieValue;
|
import static org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.PathBasedWorldView.encodeTrieValue;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.Address;
|
import org.hyperledger.besu.datatypes.Address;
|
||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
@@ -25,20 +25,20 @@ import org.hyperledger.besu.ethereum.trie.MerkleTrie;
|
|||||||
import org.hyperledger.besu.ethereum.trie.MerkleTrieException;
|
import org.hyperledger.besu.ethereum.trie.MerkleTrieException;
|
||||||
import org.hyperledger.besu.ethereum.trie.NoOpMerkleTrie;
|
import org.hyperledger.besu.ethereum.trie.NoOpMerkleTrie;
|
||||||
import org.hyperledger.besu.ethereum.trie.NodeLoader;
|
import org.hyperledger.besu.ethereum.trie.NodeLoader;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.BonsaiAccount;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.BonsaiAccount;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.BonsaiWorldStateProvider;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.BonsaiWorldStateProvider;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.cache.BonsaiCachedMerkleTrieLoader;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.cache.BonsaiCachedMerkleTrieLoader;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.cache.NoopBonsaiCachedMerkleTrieLoader;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.cache.NoopBonsaiCachedMerkleTrieLoader;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.BonsaiWorldStateLayerStorage;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.storage.BonsaiWorldStateLayerStorage;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.DiffBasedValue;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.PathBasedValue;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.cache.DiffBasedCachedWorldStorageManager;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.cache.PathBasedCachedWorldStorageManager;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.storage.DiffBasedWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.storage.PathBasedWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.trielog.TrieLogManager;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.trielog.TrieLogManager;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.DiffBasedWorldState;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.PathBasedWorldState;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.WorldStateConfig;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.WorldStateConfig;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.accumulator.DiffBasedWorldStateUpdateAccumulator;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.accumulator.PathBasedWorldStateUpdateAccumulator;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.accumulator.preload.StorageConsumingMap;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.accumulator.preload.StorageConsumingMap;
|
||||||
import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie;
|
import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie;
|
||||||
import org.hyperledger.besu.evm.account.Account;
|
import org.hyperledger.besu.evm.account.Account;
|
||||||
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
||||||
@@ -59,7 +59,7 @@ import org.apache.tuweni.bytes.Bytes32;
|
|||||||
import org.apache.tuweni.rlp.RLP;
|
import org.apache.tuweni.rlp.RLP;
|
||||||
import org.apache.tuweni.units.bigints.UInt256;
|
import org.apache.tuweni.units.bigints.UInt256;
|
||||||
|
|
||||||
public class BonsaiWorldState extends DiffBasedWorldState {
|
public class BonsaiWorldState extends PathBasedWorldState {
|
||||||
|
|
||||||
protected BonsaiCachedMerkleTrieLoader bonsaiCachedMerkleTrieLoader;
|
protected BonsaiCachedMerkleTrieLoader bonsaiCachedMerkleTrieLoader;
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ public class BonsaiWorldState extends DiffBasedWorldState {
|
|||||||
public BonsaiWorldState(
|
public BonsaiWorldState(
|
||||||
final BonsaiWorldStateKeyValueStorage worldStateKeyValueStorage,
|
final BonsaiWorldStateKeyValueStorage worldStateKeyValueStorage,
|
||||||
final BonsaiCachedMerkleTrieLoader bonsaiCachedMerkleTrieLoader,
|
final BonsaiCachedMerkleTrieLoader bonsaiCachedMerkleTrieLoader,
|
||||||
final DiffBasedCachedWorldStorageManager cachedWorldStorageManager,
|
final PathBasedCachedWorldStorageManager cachedWorldStorageManager,
|
||||||
final TrieLogManager trieLogManager,
|
final TrieLogManager trieLogManager,
|
||||||
final EvmConfiguration evmConfiguration,
|
final EvmConfiguration evmConfiguration,
|
||||||
final WorldStateConfig worldStateConfig) {
|
final WorldStateConfig worldStateConfig) {
|
||||||
@@ -111,8 +111,8 @@ public class BonsaiWorldState extends DiffBasedWorldState {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Hash calculateRootHash(
|
protected Hash calculateRootHash(
|
||||||
final Optional<DiffBasedWorldStateKeyValueStorage.Updater> maybeStateUpdater,
|
final Optional<PathBasedWorldStateKeyValueStorage.Updater> maybeStateUpdater,
|
||||||
final DiffBasedWorldStateUpdateAccumulator<?> worldStateUpdater) {
|
final PathBasedWorldStateUpdateAccumulator<?> worldStateUpdater) {
|
||||||
return internalCalculateRootHash(
|
return internalCalculateRootHash(
|
||||||
maybeStateUpdater.map(BonsaiWorldStateKeyValueStorage.Updater.class::cast),
|
maybeStateUpdater.map(BonsaiWorldStateKeyValueStorage.Updater.class::cast),
|
||||||
(BonsaiWorldStateUpdateAccumulator) worldStateUpdater);
|
(BonsaiWorldStateUpdateAccumulator) worldStateUpdater);
|
||||||
@@ -126,7 +126,7 @@ public class BonsaiWorldState extends DiffBasedWorldState {
|
|||||||
|
|
||||||
// This must be done before updating the accounts so
|
// This must be done before updating the accounts so
|
||||||
// that we can get the storage state hash
|
// that we can get the storage state hash
|
||||||
Stream<Map.Entry<Address, StorageConsumingMap<StorageSlotKey, DiffBasedValue<UInt256>>>>
|
Stream<Map.Entry<Address, StorageConsumingMap<StorageSlotKey, PathBasedValue<UInt256>>>>
|
||||||
storageStream = worldStateUpdater.getStorageToUpdate().entrySet().stream();
|
storageStream = worldStateUpdater.getStorageToUpdate().entrySet().stream();
|
||||||
if (maybeStateUpdater.isEmpty()) {
|
if (maybeStateUpdater.isEmpty()) {
|
||||||
storageStream =
|
storageStream =
|
||||||
@@ -170,10 +170,10 @@ public class BonsaiWorldState extends DiffBasedWorldState {
|
|||||||
final Optional<BonsaiWorldStateKeyValueStorage.Updater> maybeStateUpdater,
|
final Optional<BonsaiWorldStateKeyValueStorage.Updater> maybeStateUpdater,
|
||||||
final BonsaiWorldStateUpdateAccumulator worldStateUpdater,
|
final BonsaiWorldStateUpdateAccumulator worldStateUpdater,
|
||||||
final MerkleTrie<Bytes, Bytes> accountTrie) {
|
final MerkleTrie<Bytes, Bytes> accountTrie) {
|
||||||
for (final Map.Entry<Address, DiffBasedValue<BonsaiAccount>> accountUpdate :
|
for (final Map.Entry<Address, PathBasedValue<BonsaiAccount>> accountUpdate :
|
||||||
worldStateUpdater.getAccountsToUpdate().entrySet()) {
|
worldStateUpdater.getAccountsToUpdate().entrySet()) {
|
||||||
final Bytes accountKey = accountUpdate.getKey();
|
final Bytes accountKey = accountUpdate.getKey();
|
||||||
final DiffBasedValue<BonsaiAccount> bonsaiValue = accountUpdate.getValue();
|
final PathBasedValue<BonsaiAccount> bonsaiValue = accountUpdate.getValue();
|
||||||
final BonsaiAccount updatedAccount = bonsaiValue.getUpdated();
|
final BonsaiAccount updatedAccount = bonsaiValue.getUpdated();
|
||||||
try {
|
try {
|
||||||
if (updatedAccount == null) {
|
if (updatedAccount == null) {
|
||||||
@@ -203,7 +203,7 @@ public class BonsaiWorldState extends DiffBasedWorldState {
|
|||||||
final BonsaiWorldStateUpdateAccumulator worldStateUpdater) {
|
final BonsaiWorldStateUpdateAccumulator worldStateUpdater) {
|
||||||
maybeStateUpdater.ifPresent(
|
maybeStateUpdater.ifPresent(
|
||||||
bonsaiUpdater -> {
|
bonsaiUpdater -> {
|
||||||
for (final Map.Entry<Address, DiffBasedValue<Bytes>> codeUpdate :
|
for (final Map.Entry<Address, PathBasedValue<Bytes>> codeUpdate :
|
||||||
worldStateUpdater.getCodeToUpdate().entrySet()) {
|
worldStateUpdater.getCodeToUpdate().entrySet()) {
|
||||||
final Bytes updatedCode = codeUpdate.getValue().getUpdated();
|
final Bytes updatedCode = codeUpdate.getValue().getUpdated();
|
||||||
final Hash accountHash = codeUpdate.getKey().addressHash();
|
final Hash accountHash = codeUpdate.getKey().addressHash();
|
||||||
@@ -233,12 +233,12 @@ public class BonsaiWorldState extends DiffBasedWorldState {
|
|||||||
private void updateAccountStorageState(
|
private void updateAccountStorageState(
|
||||||
final Optional<BonsaiWorldStateKeyValueStorage.Updater> maybeStateUpdater,
|
final Optional<BonsaiWorldStateKeyValueStorage.Updater> maybeStateUpdater,
|
||||||
final BonsaiWorldStateUpdateAccumulator worldStateUpdater,
|
final BonsaiWorldStateUpdateAccumulator worldStateUpdater,
|
||||||
final Map.Entry<Address, StorageConsumingMap<StorageSlotKey, DiffBasedValue<UInt256>>>
|
final Map.Entry<Address, StorageConsumingMap<StorageSlotKey, PathBasedValue<UInt256>>>
|
||||||
storageAccountUpdate) {
|
storageAccountUpdate) {
|
||||||
final Address updatedAddress = storageAccountUpdate.getKey();
|
final Address updatedAddress = storageAccountUpdate.getKey();
|
||||||
final Hash updatedAddressHash = updatedAddress.addressHash();
|
final Hash updatedAddressHash = updatedAddress.addressHash();
|
||||||
if (worldStateUpdater.getAccountsToUpdate().containsKey(updatedAddress)) {
|
if (worldStateUpdater.getAccountsToUpdate().containsKey(updatedAddress)) {
|
||||||
final DiffBasedValue<BonsaiAccount> accountValue =
|
final PathBasedValue<BonsaiAccount> accountValue =
|
||||||
worldStateUpdater.getAccountsToUpdate().get(updatedAddress);
|
worldStateUpdater.getAccountsToUpdate().get(updatedAddress);
|
||||||
final BonsaiAccount accountOriginal = accountValue.getPrior();
|
final BonsaiAccount accountOriginal = accountValue.getPrior();
|
||||||
final Hash storageRoot =
|
final Hash storageRoot =
|
||||||
@@ -254,7 +254,7 @@ public class BonsaiWorldState extends DiffBasedWorldState {
|
|||||||
storageRoot);
|
storageRoot);
|
||||||
|
|
||||||
// for manicured tries and composting, collect branches here (not implemented)
|
// for manicured tries and composting, collect branches here (not implemented)
|
||||||
for (final Map.Entry<StorageSlotKey, DiffBasedValue<UInt256>> storageUpdate :
|
for (final Map.Entry<StorageSlotKey, PathBasedValue<UInt256>> storageUpdate :
|
||||||
storageAccountUpdate.getValue().entrySet()) {
|
storageAccountUpdate.getValue().entrySet()) {
|
||||||
final Hash slotHash = storageUpdate.getKey().getSlotHash();
|
final Hash slotHash = storageUpdate.getKey().getSlotHash();
|
||||||
final UInt256 updatedStorage = storageUpdate.getValue().getUpdated();
|
final UInt256 updatedStorage = storageUpdate.getValue().getUpdated();
|
||||||
@@ -320,7 +320,7 @@ public class BonsaiWorldState extends DiffBasedWorldState {
|
|||||||
(location, key) -> getStorageTrieNode(addressHash, location, key),
|
(location, key) -> getStorageTrieNode(addressHash, location, key),
|
||||||
oldAccount.getStorageRoot());
|
oldAccount.getStorageRoot());
|
||||||
try {
|
try {
|
||||||
final StorageConsumingMap<StorageSlotKey, DiffBasedValue<UInt256>> storageToDelete =
|
final StorageConsumingMap<StorageSlotKey, PathBasedValue<UInt256>> storageToDelete =
|
||||||
worldStateUpdater.getStorageToUpdate().get(address);
|
worldStateUpdater.getStorageToUpdate().get(address);
|
||||||
Map<Bytes32, Bytes> entriesToDelete = storageTrie.entriesFrom(Bytes32.ZERO, 256);
|
Map<Bytes32, Bytes> entriesToDelete = storageTrie.entriesFrom(Bytes32.ZERO, 256);
|
||||||
while (!entriesToDelete.isEmpty()) {
|
while (!entriesToDelete.isEmpty()) {
|
||||||
@@ -335,7 +335,7 @@ public class BonsaiWorldState extends DiffBasedWorldState {
|
|||||||
address.addressHash(), storageSlotKey.getSlotHash()));
|
address.addressHash(), storageSlotKey.getSlotHash()));
|
||||||
storageToDelete
|
storageToDelete
|
||||||
.computeIfAbsent(
|
.computeIfAbsent(
|
||||||
storageSlotKey, key -> new DiffBasedValue<>(slotValue, null, true))
|
storageSlotKey, key -> new PathBasedValue<>(slotValue, null, true))
|
||||||
.setPrior(slotValue);
|
.setPrior(slotValue);
|
||||||
});
|
});
|
||||||
entriesToDelete.keySet().forEach(storageTrie::remove);
|
entriesToDelete.keySet().forEach(storageTrie::remove);
|
||||||
@@ -12,33 +12,33 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.bonsai.worldview;
|
package org.hyperledger.besu.ethereum.trie.pathbased.bonsai.worldview;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.AccountValue;
|
import org.hyperledger.besu.datatypes.AccountValue;
|
||||||
import org.hyperledger.besu.datatypes.Address;
|
import org.hyperledger.besu.datatypes.Address;
|
||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
import org.hyperledger.besu.datatypes.StorageSlotKey;
|
import org.hyperledger.besu.datatypes.StorageSlotKey;
|
||||||
import org.hyperledger.besu.datatypes.Wei;
|
import org.hyperledger.besu.datatypes.Wei;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.BonsaiAccount;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.BonsaiAccount;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.DiffBasedValue;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.PathBasedValue;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.DiffBasedWorldView;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.PathBasedWorldView;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.accumulator.DiffBasedWorldStateUpdateAccumulator;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.accumulator.PathBasedWorldStateUpdateAccumulator;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.accumulator.preload.Consumer;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.accumulator.preload.Consumer;
|
||||||
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
||||||
import org.hyperledger.besu.evm.worldstate.UpdateTrackingAccount;
|
import org.hyperledger.besu.evm.worldstate.UpdateTrackingAccount;
|
||||||
|
|
||||||
public class BonsaiWorldStateUpdateAccumulator
|
public class BonsaiWorldStateUpdateAccumulator
|
||||||
extends DiffBasedWorldStateUpdateAccumulator<BonsaiAccount> {
|
extends PathBasedWorldStateUpdateAccumulator<BonsaiAccount> {
|
||||||
public BonsaiWorldStateUpdateAccumulator(
|
public BonsaiWorldStateUpdateAccumulator(
|
||||||
final DiffBasedWorldView world,
|
final PathBasedWorldView world,
|
||||||
final Consumer<DiffBasedValue<BonsaiAccount>> accountPreloader,
|
final Consumer<PathBasedValue<BonsaiAccount>> accountPreloader,
|
||||||
final Consumer<StorageSlotKey> storagePreloader,
|
final Consumer<StorageSlotKey> storagePreloader,
|
||||||
final EvmConfiguration evmConfiguration) {
|
final EvmConfiguration evmConfiguration) {
|
||||||
super(world, accountPreloader, storagePreloader, evmConfiguration);
|
super(world, accountPreloader, storagePreloader, evmConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DiffBasedWorldStateUpdateAccumulator<BonsaiAccount> copy() {
|
public PathBasedWorldStateUpdateAccumulator<BonsaiAccount> copy() {
|
||||||
final BonsaiWorldStateUpdateAccumulator copy =
|
final BonsaiWorldStateUpdateAccumulator copy =
|
||||||
new BonsaiWorldStateUpdateAccumulator(
|
new BonsaiWorldStateUpdateAccumulator(
|
||||||
wrappedWorldView(),
|
wrappedWorldView(),
|
||||||
@@ -56,13 +56,13 @@ public class BonsaiWorldStateUpdateAccumulator
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected BonsaiAccount copyAccount(
|
protected BonsaiAccount copyAccount(
|
||||||
final BonsaiAccount toCopy, final DiffBasedWorldView context, final boolean mutable) {
|
final BonsaiAccount toCopy, final PathBasedWorldView context, final boolean mutable) {
|
||||||
return new BonsaiAccount(toCopy, context, mutable);
|
return new BonsaiAccount(toCopy, context, mutable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected BonsaiAccount createAccount(
|
protected BonsaiAccount createAccount(
|
||||||
final DiffBasedWorldView context,
|
final PathBasedWorldView context,
|
||||||
final Address address,
|
final Address address,
|
||||||
final AccountValue stateTrieAccount,
|
final AccountValue stateTrieAccount,
|
||||||
final boolean mutable) {
|
final boolean mutable) {
|
||||||
@@ -71,7 +71,7 @@ public class BonsaiWorldStateUpdateAccumulator
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected BonsaiAccount createAccount(
|
protected BonsaiAccount createAccount(
|
||||||
final DiffBasedWorldView context,
|
final PathBasedWorldView context,
|
||||||
final Address address,
|
final Address address,
|
||||||
final Hash addressHash,
|
final Hash addressHash,
|
||||||
final long nonce,
|
final long nonce,
|
||||||
@@ -85,7 +85,7 @@ public class BonsaiWorldStateUpdateAccumulator
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected BonsaiAccount createAccount(
|
protected BonsaiAccount createAccount(
|
||||||
final DiffBasedWorldView context, final UpdateTrackingAccount<BonsaiAccount> tracked) {
|
final PathBasedWorldView context, final UpdateTrackingAccount<BonsaiAccount> tracked) {
|
||||||
return new BonsaiAccount(context, tracked);
|
return new BonsaiAccount(context, tracked);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -12,14 +12,14 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.common;
|
package org.hyperledger.besu.ethereum.trie.pathbased.common;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.AccountValue;
|
import org.hyperledger.besu.datatypes.AccountValue;
|
||||||
import org.hyperledger.besu.datatypes.Address;
|
import org.hyperledger.besu.datatypes.Address;
|
||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
import org.hyperledger.besu.datatypes.Wei;
|
import org.hyperledger.besu.datatypes.Wei;
|
||||||
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
|
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.DiffBasedWorldView;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.PathBasedWorldView;
|
||||||
import org.hyperledger.besu.evm.ModificationNotAllowedException;
|
import org.hyperledger.besu.evm.ModificationNotAllowedException;
|
||||||
import org.hyperledger.besu.evm.account.MutableAccount;
|
import org.hyperledger.besu.evm.account.MutableAccount;
|
||||||
|
|
||||||
@@ -29,8 +29,8 @@ import java.util.Map;
|
|||||||
import org.apache.tuweni.bytes.Bytes;
|
import org.apache.tuweni.bytes.Bytes;
|
||||||
import org.apache.tuweni.units.bigints.UInt256;
|
import org.apache.tuweni.units.bigints.UInt256;
|
||||||
|
|
||||||
public abstract class DiffBasedAccount implements MutableAccount, AccountValue {
|
public abstract class PathBasedAccount implements MutableAccount, AccountValue {
|
||||||
protected final DiffBasedWorldView context;
|
protected final PathBasedWorldView context;
|
||||||
protected boolean immutable;
|
protected boolean immutable;
|
||||||
protected final Address address;
|
protected final Address address;
|
||||||
protected final Hash addressHash;
|
protected final Hash addressHash;
|
||||||
@@ -42,12 +42,12 @@ public abstract class DiffBasedAccount implements MutableAccount, AccountValue {
|
|||||||
protected final Map<UInt256, UInt256> updatedStorage = new HashMap<>();
|
protected final Map<UInt256, UInt256> updatedStorage = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new DiffBasedAccount instance without the account's code. This constructor is used
|
* Constructs a new PathBasedAccount instance without the account's code. This constructor is used
|
||||||
* when the account's code is not required or will not be read from the database. It initializes
|
* when the account's code is not required or will not be read from the database. It initializes
|
||||||
* the account with its context, address, address hash, nonce, balance, code hash, and mutability
|
* the account with its context, address, address hash, nonce, balance, code hash, and mutability
|
||||||
* status.
|
* status.
|
||||||
*
|
*
|
||||||
* @param context The DiffBasedWorldView context in which this account exists.
|
* @param context The PathBasedWorldView context in which this account exists.
|
||||||
* @param address The Ethereum address of this account.
|
* @param address The Ethereum address of this account.
|
||||||
* @param addressHash The hash of the account's address.
|
* @param addressHash The hash of the account's address.
|
||||||
* @param nonce The nonce of the account, representing the number of transactions sent from this
|
* @param nonce The nonce of the account, representing the number of transactions sent from this
|
||||||
@@ -57,8 +57,8 @@ public abstract class DiffBasedAccount implements MutableAccount, AccountValue {
|
|||||||
* @param mutable A boolean indicating if the account is mutable. If false, the account is
|
* @param mutable A boolean indicating if the account is mutable. If false, the account is
|
||||||
* considered immutable.
|
* considered immutable.
|
||||||
*/
|
*/
|
||||||
public DiffBasedAccount(
|
public PathBasedAccount(
|
||||||
final DiffBasedWorldView context,
|
final PathBasedWorldView context,
|
||||||
final Address address,
|
final Address address,
|
||||||
final Hash addressHash,
|
final Hash addressHash,
|
||||||
final long nonce,
|
final long nonce,
|
||||||
@@ -76,12 +76,12 @@ public abstract class DiffBasedAccount implements MutableAccount, AccountValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new DiffBasedAccount instance with the account's code. This constructor is used
|
* Constructs a new PathBasedAccount instance with the account's code. This constructor is used
|
||||||
* when all account information, including its code, are available. It initializes the account
|
* when all account information, including its code, are available. It initializes the account
|
||||||
* with its context, address, address hash, nonce, balance, code hash, the actual code, and
|
* with its context, address, address hash, nonce, balance, code hash, the actual code, and
|
||||||
* mutability status.
|
* mutability status.
|
||||||
*
|
*
|
||||||
* @param context The DiffBasedWorldView context in which this account exists.
|
* @param context The PathBasedWorldView context in which this account exists.
|
||||||
* @param address The Ethereum address of this account.
|
* @param address The Ethereum address of this account.
|
||||||
* @param addressHash The hash of the account's address.
|
* @param addressHash The hash of the account's address.
|
||||||
* @param nonce The nonce of the account, representing the number of transactions sent from this
|
* @param nonce The nonce of the account, representing the number of transactions sent from this
|
||||||
@@ -93,8 +93,8 @@ public abstract class DiffBasedAccount implements MutableAccount, AccountValue {
|
|||||||
* @param mutable A boolean indicating if the account is mutable. If false, the account is
|
* @param mutable A boolean indicating if the account is mutable. If false, the account is
|
||||||
* considered immutable.
|
* considered immutable.
|
||||||
*/
|
*/
|
||||||
public DiffBasedAccount(
|
public PathBasedAccount(
|
||||||
final DiffBasedWorldView context,
|
final PathBasedWorldView context,
|
||||||
final Address address,
|
final Address address,
|
||||||
final Hash addressHash,
|
final Hash addressHash,
|
||||||
final long nonce,
|
final long nonce,
|
||||||
@@ -12,35 +12,35 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.common;
|
package org.hyperledger.besu.ethereum.trie.pathbased.common;
|
||||||
|
|
||||||
import org.hyperledger.besu.plugin.services.trielogs.TrieLog;
|
import org.hyperledger.besu.plugin.services.trielogs.TrieLog;
|
||||||
|
|
||||||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||||
|
|
||||||
public class DiffBasedValue<T> implements TrieLog.LogTuple<T> {
|
public class PathBasedValue<T> implements TrieLog.LogTuple<T> {
|
||||||
private T prior;
|
private T prior;
|
||||||
private T updated;
|
private T updated;
|
||||||
private boolean lastStepCleared;
|
private boolean lastStepCleared;
|
||||||
|
|
||||||
private boolean clearedAtLeastOnce;
|
private boolean clearedAtLeastOnce;
|
||||||
|
|
||||||
public DiffBasedValue(final T prior, final T updated) {
|
public PathBasedValue(final T prior, final T updated) {
|
||||||
this.prior = prior;
|
this.prior = prior;
|
||||||
this.updated = updated;
|
this.updated = updated;
|
||||||
this.lastStepCleared = false;
|
this.lastStepCleared = false;
|
||||||
this.clearedAtLeastOnce = false;
|
this.clearedAtLeastOnce = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DiffBasedValue(final T prior, final T updated, final boolean lastStepCleared) {
|
public PathBasedValue(final T prior, final T updated, final boolean lastStepCleared) {
|
||||||
this.prior = prior;
|
this.prior = prior;
|
||||||
this.updated = updated;
|
this.updated = updated;
|
||||||
this.lastStepCleared = lastStepCleared;
|
this.lastStepCleared = lastStepCleared;
|
||||||
this.clearedAtLeastOnce = lastStepCleared;
|
this.clearedAtLeastOnce = lastStepCleared;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DiffBasedValue(
|
public PathBasedValue(
|
||||||
final T prior,
|
final T prior,
|
||||||
final T updated,
|
final T updated,
|
||||||
final boolean lastStepCleared,
|
final boolean lastStepCleared,
|
||||||
@@ -61,12 +61,12 @@ public class DiffBasedValue<T> implements TrieLog.LogTuple<T> {
|
|||||||
return updated;
|
return updated;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DiffBasedValue<T> setPrior(final T prior) {
|
public PathBasedValue<T> setPrior(final T prior) {
|
||||||
this.prior = prior;
|
this.prior = prior;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DiffBasedValue<T> setUpdated(final T updated) {
|
public PathBasedValue<T> setUpdated(final T updated) {
|
||||||
this.lastStepCleared = updated == null;
|
this.lastStepCleared = updated == null;
|
||||||
if (lastStepCleared) {
|
if (lastStepCleared) {
|
||||||
this.clearedAtLeastOnce = true;
|
this.clearedAtLeastOnce = true;
|
||||||
@@ -92,7 +92,7 @@ public class DiffBasedValue<T> implements TrieLog.LogTuple<T> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "DiffBasedValue{"
|
return "PathBasedValue{"
|
||||||
+ "prior="
|
+ "prior="
|
||||||
+ prior
|
+ prior
|
||||||
+ ", updated="
|
+ ", updated="
|
||||||
@@ -110,7 +110,7 @@ public class DiffBasedValue<T> implements TrieLog.LogTuple<T> {
|
|||||||
if (o == null || getClass() != o.getClass()) {
|
if (o == null || getClass() != o.getClass()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
DiffBasedValue<?> that = (DiffBasedValue<?>) o;
|
PathBasedValue<?> that = (PathBasedValue<?>) o;
|
||||||
return new EqualsBuilder()
|
return new EqualsBuilder()
|
||||||
.append(lastStepCleared, that.lastStepCleared)
|
.append(lastStepCleared, that.lastStepCleared)
|
||||||
.append(prior, that.prior)
|
.append(prior, that.prior)
|
||||||
@@ -127,7 +127,7 @@ public class DiffBasedValue<T> implements TrieLog.LogTuple<T> {
|
|||||||
.toHashCode();
|
.toHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DiffBasedValue<T> copy() {
|
public PathBasedValue<T> copy() {
|
||||||
return new DiffBasedValue<T>(prior, updated, lastStepCleared, clearedAtLeastOnce);
|
return new PathBasedValue<T>(prior, updated, lastStepCleared, clearedAtLeastOnce);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.common;
|
package org.hyperledger.besu.ethereum.trie.pathbased.common;
|
||||||
|
|
||||||
public interface StorageSubscriber {
|
public interface StorageSubscriber {
|
||||||
default void onClearStorage() {}
|
default void onClearStorage() {}
|
||||||
@@ -12,20 +12,20 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.common.cache;
|
package org.hyperledger.besu.ethereum.trie.pathbased.common.cache;
|
||||||
|
|
||||||
import static org.hyperledger.besu.ethereum.trie.diffbased.common.provider.WorldStateQueryParams.withBlockHeaderAndNoUpdateNodeHead;
|
import static org.hyperledger.besu.ethereum.trie.pathbased.common.provider.WorldStateQueryParams.withBlockHeaderAndNoUpdateNodeHead;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
import org.hyperledger.besu.ethereum.chain.Blockchain;
|
import org.hyperledger.besu.ethereum.chain.Blockchain;
|
||||||
import org.hyperledger.besu.ethereum.core.BlockHeader;
|
import org.hyperledger.besu.ethereum.core.BlockHeader;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.worldview.BonsaiWorldState;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.worldview.BonsaiWorldState;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.StorageSubscriber;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.StorageSubscriber;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.provider.DiffBasedWorldStateProvider;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.provider.PathBasedWorldStateProvider;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.storage.DiffBasedLayeredWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.storage.PathBasedLayeredWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.storage.DiffBasedWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.storage.PathBasedWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.DiffBasedWorldState;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.PathBasedWorldState;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.WorldStateConfig;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.WorldStateConfig;
|
||||||
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -43,11 +43,11 @@ import org.apache.tuweni.bytes.Bytes32;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public abstract class DiffBasedCachedWorldStorageManager implements StorageSubscriber {
|
public abstract class PathBasedCachedWorldStorageManager implements StorageSubscriber {
|
||||||
public static final long RETAINED_LAYERS = 512; // at least 256 + typical rollbacks
|
public static final long RETAINED_LAYERS = 512; // at least 256 + typical rollbacks
|
||||||
private static final Logger LOG =
|
private static final Logger LOG =
|
||||||
LoggerFactory.getLogger(DiffBasedCachedWorldStorageManager.class);
|
LoggerFactory.getLogger(PathBasedCachedWorldStorageManager.class);
|
||||||
private final DiffBasedWorldStateProvider archive;
|
private final PathBasedWorldStateProvider archive;
|
||||||
private final EvmConfiguration evmConfiguration;
|
private final EvmConfiguration evmConfiguration;
|
||||||
protected final WorldStateConfig worldStateConfig;
|
protected final WorldStateConfig worldStateConfig;
|
||||||
private final Cache<Hash, BlockHeader> stateRootToBlockHeaderCache =
|
private final Cache<Hash, BlockHeader> stateRootToBlockHeaderCache =
|
||||||
@@ -56,13 +56,13 @@ public abstract class DiffBasedCachedWorldStorageManager implements StorageSubsc
|
|||||||
.expireAfterWrite(100, TimeUnit.MINUTES)
|
.expireAfterWrite(100, TimeUnit.MINUTES)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
private final DiffBasedWorldStateKeyValueStorage rootWorldStateStorage;
|
private final PathBasedWorldStateKeyValueStorage rootWorldStateStorage;
|
||||||
private final Map<Bytes32, DiffBasedCachedWorldView> cachedWorldStatesByHash;
|
private final Map<Bytes32, PathBasedCachedWorldView> cachedWorldStatesByHash;
|
||||||
|
|
||||||
private DiffBasedCachedWorldStorageManager(
|
private PathBasedCachedWorldStorageManager(
|
||||||
final DiffBasedWorldStateProvider archive,
|
final PathBasedWorldStateProvider archive,
|
||||||
final DiffBasedWorldStateKeyValueStorage worldStateKeyValueStorage,
|
final PathBasedWorldStateKeyValueStorage worldStateKeyValueStorage,
|
||||||
final Map<Bytes32, DiffBasedCachedWorldView> cachedWorldStatesByHash,
|
final Map<Bytes32, PathBasedCachedWorldView> cachedWorldStatesByHash,
|
||||||
final EvmConfiguration evmConfiguration,
|
final EvmConfiguration evmConfiguration,
|
||||||
final WorldStateConfig worldStateConfig) {
|
final WorldStateConfig worldStateConfig) {
|
||||||
worldStateKeyValueStorage.subscribe(this);
|
worldStateKeyValueStorage.subscribe(this);
|
||||||
@@ -73,9 +73,9 @@ public abstract class DiffBasedCachedWorldStorageManager implements StorageSubsc
|
|||||||
this.worldStateConfig = worldStateConfig;
|
this.worldStateConfig = worldStateConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DiffBasedCachedWorldStorageManager(
|
public PathBasedCachedWorldStorageManager(
|
||||||
final DiffBasedWorldStateProvider archive,
|
final PathBasedWorldStateProvider archive,
|
||||||
final DiffBasedWorldStateKeyValueStorage worldStateKeyValueStorage,
|
final PathBasedWorldStateKeyValueStorage worldStateKeyValueStorage,
|
||||||
final WorldStateConfig worldStateConfig) {
|
final WorldStateConfig worldStateConfig) {
|
||||||
this(
|
this(
|
||||||
archive,
|
archive,
|
||||||
@@ -88,20 +88,20 @@ public abstract class DiffBasedCachedWorldStorageManager implements StorageSubsc
|
|||||||
public synchronized void addCachedLayer(
|
public synchronized void addCachedLayer(
|
||||||
final BlockHeader blockHeader,
|
final BlockHeader blockHeader,
|
||||||
final Hash worldStateRootHash,
|
final Hash worldStateRootHash,
|
||||||
final DiffBasedWorldState forWorldState) {
|
final PathBasedWorldState forWorldState) {
|
||||||
final Optional<DiffBasedCachedWorldView> cachedDiffBasedWorldView =
|
final Optional<PathBasedCachedWorldView> cachedPathBasedWorldView =
|
||||||
Optional.ofNullable(this.cachedWorldStatesByHash.get(blockHeader.getBlockHash()));
|
Optional.ofNullable(this.cachedWorldStatesByHash.get(blockHeader.getBlockHash()));
|
||||||
if (cachedDiffBasedWorldView.isPresent()) {
|
if (cachedPathBasedWorldView.isPresent()) {
|
||||||
// only replace if it is a layered storage
|
// only replace if it is a layered storage
|
||||||
if (forWorldState.isModifyingHeadWorldState()
|
if (forWorldState.isModifyingHeadWorldState()
|
||||||
&& cachedDiffBasedWorldView.get().getWorldStateStorage()
|
&& cachedPathBasedWorldView.get().getWorldStateStorage()
|
||||||
instanceof DiffBasedLayeredWorldStateKeyValueStorage) {
|
instanceof PathBasedLayeredWorldStateKeyValueStorage) {
|
||||||
LOG.atDebug()
|
LOG.atDebug()
|
||||||
.setMessage("updating layered world state for block {}, state root hash {}")
|
.setMessage("updating layered world state for block {}, state root hash {}")
|
||||||
.addArgument(blockHeader::toLogString)
|
.addArgument(blockHeader::toLogString)
|
||||||
.addArgument(worldStateRootHash::toShortHexString)
|
.addArgument(worldStateRootHash::toShortHexString)
|
||||||
.log();
|
.log();
|
||||||
cachedDiffBasedWorldView
|
cachedPathBasedWorldView
|
||||||
.get()
|
.get()
|
||||||
.updateWorldStateStorage(
|
.updateWorldStateStorage(
|
||||||
createSnapshotKeyValueStorage(forWorldState.getWorldStateStorage()));
|
createSnapshotKeyValueStorage(forWorldState.getWorldStateStorage()));
|
||||||
@@ -115,15 +115,15 @@ public abstract class DiffBasedCachedWorldStorageManager implements StorageSubsc
|
|||||||
if (forWorldState.isModifyingHeadWorldState()) {
|
if (forWorldState.isModifyingHeadWorldState()) {
|
||||||
cachedWorldStatesByHash.put(
|
cachedWorldStatesByHash.put(
|
||||||
blockHeader.getHash(),
|
blockHeader.getHash(),
|
||||||
new DiffBasedCachedWorldView(
|
new PathBasedCachedWorldView(
|
||||||
blockHeader, createSnapshotKeyValueStorage(forWorldState.getWorldStateStorage())));
|
blockHeader, createSnapshotKeyValueStorage(forWorldState.getWorldStateStorage())));
|
||||||
} else {
|
} else {
|
||||||
// otherwise, add the layer to the cache
|
// otherwise, add the layer to the cache
|
||||||
cachedWorldStatesByHash.put(
|
cachedWorldStatesByHash.put(
|
||||||
blockHeader.getHash(),
|
blockHeader.getHash(),
|
||||||
new DiffBasedCachedWorldView(
|
new PathBasedCachedWorldView(
|
||||||
blockHeader,
|
blockHeader,
|
||||||
((DiffBasedLayeredWorldStateKeyValueStorage) forWorldState.getWorldStateStorage())
|
((PathBasedLayeredWorldStateKeyValueStorage) forWorldState.getWorldStateStorage())
|
||||||
.clone()));
|
.clone()));
|
||||||
}
|
}
|
||||||
// add stateroot -> blockHeader cache entry
|
// add stateroot -> blockHeader cache entry
|
||||||
@@ -146,7 +146,7 @@ public abstract class DiffBasedCachedWorldStorageManager implements StorageSubsc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<DiffBasedWorldState> getWorldState(final Hash blockHash) {
|
public Optional<PathBasedWorldState> getWorldState(final Hash blockHash) {
|
||||||
if (cachedWorldStatesByHash.containsKey(blockHash)) {
|
if (cachedWorldStatesByHash.containsKey(blockHash)) {
|
||||||
// return a new worldstate using worldstate storage and an isolated copy of the updater
|
// return a new worldstate using worldstate storage and an isolated copy of the updater
|
||||||
return Optional.ofNullable(cachedWorldStatesByHash.get(blockHash))
|
return Optional.ofNullable(cachedWorldStatesByHash.get(blockHash))
|
||||||
@@ -165,7 +165,7 @@ public abstract class DiffBasedCachedWorldStorageManager implements StorageSubsc
|
|||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<DiffBasedWorldState> getNearestWorldState(final BlockHeader blockHeader) {
|
public Optional<PathBasedWorldState> getNearestWorldState(final BlockHeader blockHeader) {
|
||||||
LOG.atDebug()
|
LOG.atDebug()
|
||||||
.setMessage("getting nearest worldstate for {}")
|
.setMessage("getting nearest worldstate for {}")
|
||||||
.addArgument(blockHeader.toLogString())
|
.addArgument(blockHeader.toLogString())
|
||||||
@@ -173,7 +173,7 @@ public abstract class DiffBasedCachedWorldStorageManager implements StorageSubsc
|
|||||||
|
|
||||||
return Optional.ofNullable(
|
return Optional.ofNullable(
|
||||||
cachedWorldStatesByHash.get(blockHeader.getParentHash())) // search parent block
|
cachedWorldStatesByHash.get(blockHeader.getParentHash())) // search parent block
|
||||||
.map(DiffBasedCachedWorldView::getWorldStateStorage)
|
.map(PathBasedCachedWorldView::getWorldStateStorage)
|
||||||
.or(
|
.or(
|
||||||
() -> {
|
() -> {
|
||||||
// or else search the nearest state in the cache
|
// or else search the nearest state in the cache
|
||||||
@@ -182,13 +182,13 @@ public abstract class DiffBasedCachedWorldStorageManager implements StorageSubsc
|
|||||||
.addArgument(blockHeader.toLogString())
|
.addArgument(blockHeader.toLogString())
|
||||||
.log();
|
.log();
|
||||||
|
|
||||||
final List<DiffBasedCachedWorldView> cachedDiffBasedWorldViews =
|
final List<PathBasedCachedWorldView> cachedPathBasedWorldViews =
|
||||||
new ArrayList<>(cachedWorldStatesByHash.values());
|
new ArrayList<>(cachedWorldStatesByHash.values());
|
||||||
return cachedDiffBasedWorldViews.stream()
|
return cachedPathBasedWorldViews.stream()
|
||||||
.sorted(
|
.sorted(
|
||||||
Comparator.comparingLong(
|
Comparator.comparingLong(
|
||||||
view -> Math.abs(blockHeader.getNumber() - view.getBlockNumber())))
|
view -> Math.abs(blockHeader.getNumber() - view.getBlockNumber())))
|
||||||
.map(DiffBasedCachedWorldView::getWorldStateStorage)
|
.map(PathBasedCachedWorldView::getWorldStateStorage)
|
||||||
.findFirst();
|
.findFirst();
|
||||||
})
|
})
|
||||||
.map(
|
.map(
|
||||||
@@ -197,7 +197,7 @@ public abstract class DiffBasedCachedWorldStorageManager implements StorageSubsc
|
|||||||
archive, createLayeredKeyValueStorage(storage), evmConfiguration));
|
archive, createLayeredKeyValueStorage(storage), evmConfiguration));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<DiffBasedWorldState> getHeadWorldState(
|
public Optional<PathBasedWorldState> getHeadWorldState(
|
||||||
final Function<Hash, Optional<BlockHeader>> hashBlockHeaderFunction) {
|
final Function<Hash, Optional<BlockHeader>> hashBlockHeaderFunction) {
|
||||||
|
|
||||||
LOG.atDebug().setMessage("getting head worldstate").log();
|
LOG.atDebug().setMessage("getting head worldstate").log();
|
||||||
@@ -242,13 +242,13 @@ public abstract class DiffBasedCachedWorldStorageManager implements StorageSubsc
|
|||||||
* @param rootHash rootHash to supply worldstate storage for
|
* @param rootHash rootHash to supply worldstate storage for
|
||||||
* @return Optional worldstate storage
|
* @return Optional worldstate storage
|
||||||
*/
|
*/
|
||||||
public synchronized Optional<DiffBasedWorldStateKeyValueStorage> getStorageByRootHash(
|
public synchronized Optional<PathBasedWorldStateKeyValueStorage> getStorageByRootHash(
|
||||||
final Hash rootHash) {
|
final Hash rootHash) {
|
||||||
return Optional.ofNullable(stateRootToBlockHeaderCache.getIfPresent(rootHash))
|
return Optional.ofNullable(stateRootToBlockHeaderCache.getIfPresent(rootHash))
|
||||||
.flatMap(
|
.flatMap(
|
||||||
header ->
|
header ->
|
||||||
Optional.ofNullable(cachedWorldStatesByHash.get(header.getHash()))
|
Optional.ofNullable(cachedWorldStatesByHash.get(header.getHash()))
|
||||||
.map(DiffBasedCachedWorldView::getWorldStateStorage)
|
.map(PathBasedCachedWorldView::getWorldStateStorage)
|
||||||
.or(
|
.or(
|
||||||
() -> {
|
() -> {
|
||||||
// if not cached already, maybe fetch and cache this worldstate
|
// if not cached already, maybe fetch and cache this worldstate
|
||||||
@@ -287,14 +287,14 @@ public abstract class DiffBasedCachedWorldStorageManager implements StorageSubsc
|
|||||||
this.cachedWorldStatesByHash.clear();
|
this.cachedWorldStatesByHash.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract DiffBasedWorldState createWorldState(
|
public abstract PathBasedWorldState createWorldState(
|
||||||
final DiffBasedWorldStateProvider archive,
|
final PathBasedWorldStateProvider archive,
|
||||||
final DiffBasedWorldStateKeyValueStorage worldStateKeyValueStorage,
|
final PathBasedWorldStateKeyValueStorage worldStateKeyValueStorage,
|
||||||
final EvmConfiguration evmConfiguration);
|
final EvmConfiguration evmConfiguration);
|
||||||
|
|
||||||
public abstract DiffBasedWorldStateKeyValueStorage createLayeredKeyValueStorage(
|
public abstract PathBasedWorldStateKeyValueStorage createLayeredKeyValueStorage(
|
||||||
final DiffBasedWorldStateKeyValueStorage worldStateKeyValueStorage);
|
final PathBasedWorldStateKeyValueStorage worldStateKeyValueStorage);
|
||||||
|
|
||||||
public abstract DiffBasedWorldStateKeyValueStorage createSnapshotKeyValueStorage(
|
public abstract PathBasedWorldStateKeyValueStorage createSnapshotKeyValueStorage(
|
||||||
final DiffBasedWorldStateKeyValueStorage worldStateKeyValueStorage);
|
final PathBasedWorldStateKeyValueStorage worldStateKeyValueStorage);
|
||||||
}
|
}
|
||||||
@@ -12,30 +12,30 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.common.cache;
|
package org.hyperledger.besu.ethereum.trie.pathbased.common.cache;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
import org.hyperledger.besu.ethereum.core.BlockHeader;
|
import org.hyperledger.besu.ethereum.core.BlockHeader;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.StorageSubscriber;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.StorageSubscriber;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.storage.DiffBasedWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.storage.PathBasedWorldStateKeyValueStorage;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class DiffBasedCachedWorldView implements StorageSubscriber {
|
public class PathBasedCachedWorldView implements StorageSubscriber {
|
||||||
private DiffBasedWorldStateKeyValueStorage worldStateKeyValueStorage;
|
private PathBasedWorldStateKeyValueStorage worldStateKeyValueStorage;
|
||||||
private final BlockHeader blockHeader;
|
private final BlockHeader blockHeader;
|
||||||
private long worldViewSubscriberId;
|
private long worldViewSubscriberId;
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(DiffBasedCachedWorldView.class);
|
private static final Logger LOG = LoggerFactory.getLogger(PathBasedCachedWorldView.class);
|
||||||
|
|
||||||
public DiffBasedCachedWorldView(
|
public PathBasedCachedWorldView(
|
||||||
final BlockHeader blockHeader, final DiffBasedWorldStateKeyValueStorage worldView) {
|
final BlockHeader blockHeader, final PathBasedWorldStateKeyValueStorage worldView) {
|
||||||
this.blockHeader = blockHeader;
|
this.blockHeader = blockHeader;
|
||||||
this.worldStateKeyValueStorage = worldView;
|
this.worldStateKeyValueStorage = worldView;
|
||||||
this.worldViewSubscriberId = worldStateKeyValueStorage.subscribe(this);
|
this.worldViewSubscriberId = worldStateKeyValueStorage.subscribe(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DiffBasedWorldStateKeyValueStorage getWorldStateStorage() {
|
public PathBasedWorldStateKeyValueStorage getWorldStateStorage() {
|
||||||
return worldStateKeyValueStorage;
|
return worldStateKeyValueStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,10 +57,10 @@ public class DiffBasedCachedWorldView implements StorageSubscriber {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void updateWorldStateStorage(
|
public synchronized void updateWorldStateStorage(
|
||||||
final DiffBasedWorldStateKeyValueStorage newWorldStateStorage) {
|
final PathBasedWorldStateKeyValueStorage newWorldStateStorage) {
|
||||||
long newSubscriberId = newWorldStateStorage.subscribe(this);
|
long newSubscriberId = newWorldStateStorage.subscribe(this);
|
||||||
this.worldStateKeyValueStorage.unSubscribe(this.worldViewSubscriberId);
|
this.worldStateKeyValueStorage.unSubscribe(this.worldViewSubscriberId);
|
||||||
final DiffBasedWorldStateKeyValueStorage oldWorldStateStorage = this.worldStateKeyValueStorage;
|
final PathBasedWorldStateKeyValueStorage oldWorldStateStorage = this.worldStateKeyValueStorage;
|
||||||
this.worldStateKeyValueStorage = newWorldStateStorage;
|
this.worldStateKeyValueStorage = newWorldStateStorage;
|
||||||
this.worldViewSubscriberId = newSubscriberId;
|
this.worldViewSubscriberId = newSubscriberId;
|
||||||
try {
|
try {
|
||||||
@@ -12,9 +12,9 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.common.provider;
|
package org.hyperledger.besu.ethereum.trie.pathbased.common.provider;
|
||||||
|
|
||||||
import static org.hyperledger.besu.ethereum.trie.diffbased.common.provider.WorldStateQueryParams.withBlockHeaderAndNoUpdateNodeHead;
|
import static org.hyperledger.besu.ethereum.trie.pathbased.common.provider.WorldStateQueryParams.withBlockHeaderAndNoUpdateNodeHead;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.Address;
|
import org.hyperledger.besu.datatypes.Address;
|
||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
@@ -24,12 +24,12 @@ import org.hyperledger.besu.ethereum.core.MutableWorldState;
|
|||||||
import org.hyperledger.besu.ethereum.proof.WorldStateProof;
|
import org.hyperledger.besu.ethereum.proof.WorldStateProof;
|
||||||
import org.hyperledger.besu.ethereum.proof.WorldStateProofProvider;
|
import org.hyperledger.besu.ethereum.proof.WorldStateProofProvider;
|
||||||
import org.hyperledger.besu.ethereum.trie.MerkleTrieException;
|
import org.hyperledger.besu.ethereum.trie.MerkleTrieException;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.cache.DiffBasedCachedWorldStorageManager;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.cache.PathBasedCachedWorldStorageManager;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.storage.DiffBasedWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.storage.PathBasedWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.trielog.TrieLogManager;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.trielog.TrieLogManager;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.DiffBasedWorldState;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.PathBasedWorldState;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.WorldStateConfig;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.WorldStateConfig;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.accumulator.DiffBasedWorldStateUpdateAccumulator;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.accumulator.PathBasedWorldStateUpdateAccumulator;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
|
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorageCoordinator;
|
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorageCoordinator;
|
||||||
import org.hyperledger.besu.evm.worldstate.WorldState;
|
import org.hyperledger.besu.evm.worldstate.WorldState;
|
||||||
@@ -46,21 +46,21 @@ import org.apache.tuweni.units.bigints.UInt256;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public abstract class DiffBasedWorldStateProvider implements WorldStateArchive {
|
public abstract class PathBasedWorldStateProvider implements WorldStateArchive {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(DiffBasedWorldStateProvider.class);
|
private static final Logger LOG = LoggerFactory.getLogger(PathBasedWorldStateProvider.class);
|
||||||
|
|
||||||
protected final Blockchain blockchain;
|
protected final Blockchain blockchain;
|
||||||
|
|
||||||
protected final TrieLogManager trieLogManager;
|
protected final TrieLogManager trieLogManager;
|
||||||
protected DiffBasedCachedWorldStorageManager cachedWorldStorageManager;
|
protected PathBasedCachedWorldStorageManager cachedWorldStorageManager;
|
||||||
protected DiffBasedWorldState headWorldState;
|
protected PathBasedWorldState headWorldState;
|
||||||
protected final DiffBasedWorldStateKeyValueStorage worldStateKeyValueStorage;
|
protected final PathBasedWorldStateKeyValueStorage worldStateKeyValueStorage;
|
||||||
// Configuration that will be shared by all instances of world state at their creation
|
// Configuration that will be shared by all instances of world state at their creation
|
||||||
protected final WorldStateConfig worldStateConfig;
|
protected final WorldStateConfig worldStateConfig;
|
||||||
|
|
||||||
public DiffBasedWorldStateProvider(
|
public PathBasedWorldStateProvider(
|
||||||
final DiffBasedWorldStateKeyValueStorage worldStateKeyValueStorage,
|
final PathBasedWorldStateKeyValueStorage worldStateKeyValueStorage,
|
||||||
final Blockchain blockchain,
|
final Blockchain blockchain,
|
||||||
final Optional<Long> maxLayersToLoad,
|
final Optional<Long> maxLayersToLoad,
|
||||||
final ServiceManager pluginContext) {
|
final ServiceManager pluginContext) {
|
||||||
@@ -70,12 +70,12 @@ public abstract class DiffBasedWorldStateProvider implements WorldStateArchive {
|
|||||||
new TrieLogManager(
|
new TrieLogManager(
|
||||||
blockchain,
|
blockchain,
|
||||||
worldStateKeyValueStorage,
|
worldStateKeyValueStorage,
|
||||||
maxLayersToLoad.orElse(DiffBasedCachedWorldStorageManager.RETAINED_LAYERS),
|
maxLayersToLoad.orElse(PathBasedCachedWorldStorageManager.RETAINED_LAYERS),
|
||||||
pluginContext));
|
pluginContext));
|
||||||
}
|
}
|
||||||
|
|
||||||
public DiffBasedWorldStateProvider(
|
public PathBasedWorldStateProvider(
|
||||||
final DiffBasedWorldStateKeyValueStorage worldStateKeyValueStorage,
|
final PathBasedWorldStateKeyValueStorage worldStateKeyValueStorage,
|
||||||
final Blockchain blockchain,
|
final Blockchain blockchain,
|
||||||
final TrieLogManager trieLogManager) {
|
final TrieLogManager trieLogManager) {
|
||||||
|
|
||||||
@@ -87,11 +87,11 @@ public abstract class DiffBasedWorldStateProvider implements WorldStateArchive {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void provideCachedWorldStorageManager(
|
protected void provideCachedWorldStorageManager(
|
||||||
final DiffBasedCachedWorldStorageManager cachedWorldStorageManager) {
|
final PathBasedCachedWorldStorageManager cachedWorldStorageManager) {
|
||||||
this.cachedWorldStorageManager = cachedWorldStorageManager;
|
this.cachedWorldStorageManager = cachedWorldStorageManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void loadHeadWorldState(final DiffBasedWorldState headWorldState) {
|
protected void loadHeadWorldState(final PathBasedWorldState headWorldState) {
|
||||||
this.headWorldState = headWorldState;
|
this.headWorldState = headWorldState;
|
||||||
blockchain
|
blockchain
|
||||||
.getBlockHeader(headWorldState.getWorldStateBlockHash())
|
.getBlockHeader(headWorldState.getWorldStateBlockHash())
|
||||||
@@ -233,7 +233,7 @@ public abstract class DiffBasedWorldStateProvider implements WorldStateArchive {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Optional<MutableWorldState> rollFullWorldStateToBlockHash(
|
private Optional<MutableWorldState> rollFullWorldStateToBlockHash(
|
||||||
final DiffBasedWorldState mutableState, final Hash blockHash) {
|
final PathBasedWorldState mutableState, final Hash blockHash) {
|
||||||
if (blockHash.equals(mutableState.blockHash())) {
|
if (blockHash.equals(mutableState.blockHash())) {
|
||||||
return Optional.of(mutableState);
|
return Optional.of(mutableState);
|
||||||
} else {
|
} else {
|
||||||
@@ -282,19 +282,19 @@ public abstract class DiffBasedWorldStateProvider implements WorldStateArchive {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// attempt the state rolling
|
// attempt the state rolling
|
||||||
final DiffBasedWorldStateUpdateAccumulator<?> diffBasedUpdater =
|
final PathBasedWorldStateUpdateAccumulator<?> pathBasedUpdater =
|
||||||
(DiffBasedWorldStateUpdateAccumulator<?>) mutableState.updater();
|
(PathBasedWorldStateUpdateAccumulator<?>) mutableState.updater();
|
||||||
try {
|
try {
|
||||||
for (final TrieLog rollBack : rollBacks) {
|
for (final TrieLog rollBack : rollBacks) {
|
||||||
LOG.debug("Attempting Rollback of {}", rollBack.getBlockHash());
|
LOG.debug("Attempting Rollback of {}", rollBack.getBlockHash());
|
||||||
diffBasedUpdater.rollBack(rollBack);
|
pathBasedUpdater.rollBack(rollBack);
|
||||||
}
|
}
|
||||||
for (int i = rollForwards.size() - 1; i >= 0; i--) {
|
for (int i = rollForwards.size() - 1; i >= 0; i--) {
|
||||||
final var forward = rollForwards.get(i);
|
final var forward = rollForwards.get(i);
|
||||||
LOG.debug("Attempting Rollforward of {}", rollForwards.get(i).getBlockHash());
|
LOG.debug("Attempting Rollforward of {}", rollForwards.get(i).getBlockHash());
|
||||||
diffBasedUpdater.rollForward(forward);
|
pathBasedUpdater.rollForward(forward);
|
||||||
}
|
}
|
||||||
diffBasedUpdater.commit();
|
pathBasedUpdater.commit();
|
||||||
|
|
||||||
mutableState.persist(blockchain.getBlockHeader(blockHash).get());
|
mutableState.persist(blockchain.getBlockHeader(blockHash).get());
|
||||||
|
|
||||||
@@ -308,7 +308,7 @@ public abstract class DiffBasedWorldStateProvider implements WorldStateArchive {
|
|||||||
throw re;
|
throw re;
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
// if we fail we must clean up the updater
|
// if we fail we must clean up the updater
|
||||||
diffBasedUpdater.reset();
|
pathBasedUpdater.reset();
|
||||||
LOG.atDebug()
|
LOG.atDebug()
|
||||||
.setMessage("State rolling failed on {} for block hash {}")
|
.setMessage("State rolling failed on {} for block hash {}")
|
||||||
.addArgument(mutableState.getWorldStateStorage().getClass().getSimpleName())
|
.addArgument(mutableState.getWorldStateStorage().getClass().getSimpleName())
|
||||||
@@ -334,7 +334,7 @@ public abstract class DiffBasedWorldStateProvider implements WorldStateArchive {
|
|||||||
return worldStateConfig;
|
return worldStateConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DiffBasedWorldStateKeyValueStorage getWorldStateKeyValueStorage() {
|
public PathBasedWorldStateKeyValueStorage getWorldStateKeyValueStorage() {
|
||||||
return worldStateKeyValueStorage;
|
return worldStateKeyValueStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,7 +342,7 @@ public abstract class DiffBasedWorldStateProvider implements WorldStateArchive {
|
|||||||
return trieLogManager;
|
return trieLogManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DiffBasedCachedWorldStorageManager getCachedWorldStorageManager() {
|
public PathBasedCachedWorldStorageManager getCachedWorldStorageManager() {
|
||||||
return cachedWorldStorageManager;
|
return cachedWorldStorageManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -360,8 +360,8 @@ public abstract class DiffBasedWorldStateProvider implements WorldStateArchive {
|
|||||||
final Address accountAddress,
|
final Address accountAddress,
|
||||||
final List<UInt256> accountStorageKeys,
|
final List<UInt256> accountStorageKeys,
|
||||||
final Function<Optional<WorldStateProof>, ? extends Optional<U>> mapper) {
|
final Function<Optional<WorldStateProof>, ? extends Optional<U>> mapper) {
|
||||||
try (DiffBasedWorldState ws =
|
try (PathBasedWorldState ws =
|
||||||
(DiffBasedWorldState)
|
(PathBasedWorldState)
|
||||||
getWorldState(withBlockHeaderAndNoUpdateNodeHead(blockHeader)).orElse(null)) {
|
getWorldState(withBlockHeaderAndNoUpdateNodeHead(blockHeader)).orElse(null)) {
|
||||||
if (ws != null) {
|
if (ws != null) {
|
||||||
final WorldStateProofProvider worldStateProofProvider =
|
final WorldStateProofProvider worldStateProofProvider =
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.common.provider;
|
package org.hyperledger.besu.ethereum.trie.pathbased.common.provider;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
import org.hyperledger.besu.ethereum.core.BlockHeader;
|
import org.hyperledger.besu.ethereum.core.BlockHeader;
|
||||||
@@ -12,10 +12,10 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.common.storage;
|
package org.hyperledger.besu.ethereum.trie.pathbased.common.storage;
|
||||||
|
|
||||||
public interface DiffBasedLayeredWorldStateKeyValueStorage
|
public interface PathBasedLayeredWorldStateKeyValueStorage
|
||||||
extends DiffBasedSnapshotWorldStateKeyValueStorage {
|
extends PathBasedSnapshotWorldStateKeyValueStorage {
|
||||||
|
|
||||||
DiffBasedWorldStateKeyValueStorage clone();
|
PathBasedWorldStateKeyValueStorage clone();
|
||||||
}
|
}
|
||||||
@@ -12,9 +12,9 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.common.storage;
|
package org.hyperledger.besu.ethereum.trie.pathbased.common.storage;
|
||||||
|
|
||||||
public interface DiffBasedSnapshotWorldStateKeyValueStorage {
|
public interface PathBasedSnapshotWorldStateKeyValueStorage {
|
||||||
|
|
||||||
DiffBasedWorldStateKeyValueStorage getParentWorldStateStorage();
|
PathBasedWorldStateKeyValueStorage getParentWorldStateStorage();
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.common.storage;
|
package org.hyperledger.besu.ethereum.trie.pathbased.common.storage;
|
||||||
|
|
||||||
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.ACCOUNT_INFO_STATE;
|
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.ACCOUNT_INFO_STATE;
|
||||||
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.ACCOUNT_STORAGE_STORAGE;
|
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.ACCOUNT_STORAGE_STORAGE;
|
||||||
@@ -22,8 +22,8 @@ import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIden
|
|||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
import org.hyperledger.besu.ethereum.storage.StorageProvider;
|
import org.hyperledger.besu.ethereum.storage.StorageProvider;
|
||||||
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier;
|
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.StorageSubscriber;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.StorageSubscriber;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.storage.flat.FlatDbStrategy;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.storage.flat.FlatDbStrategy;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.FlatDbMode;
|
import org.hyperledger.besu.ethereum.worldstate.FlatDbMode;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.WorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.worldstate.WorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.plugin.services.storage.DataStorageFormat;
|
import org.hyperledger.besu.plugin.services.storage.DataStorageFormat;
|
||||||
@@ -47,10 +47,10 @@ import org.apache.tuweni.bytes.Bytes32;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public abstract class DiffBasedWorldStateKeyValueStorage
|
public abstract class PathBasedWorldStateKeyValueStorage
|
||||||
implements WorldStateKeyValueStorage, AutoCloseable {
|
implements WorldStateKeyValueStorage, AutoCloseable {
|
||||||
private static final Logger LOG =
|
private static final Logger LOG =
|
||||||
LoggerFactory.getLogger(DiffBasedWorldStateKeyValueStorage.class);
|
LoggerFactory.getLogger(PathBasedWorldStateKeyValueStorage.class);
|
||||||
|
|
||||||
// 0x776f726c64526f6f74
|
// 0x776f726c64526f6f74
|
||||||
public static final byte[] WORLD_ROOT_HASH_KEY = "worldRoot".getBytes(StandardCharsets.UTF_8);
|
public static final byte[] WORLD_ROOT_HASH_KEY = "worldRoot".getBytes(StandardCharsets.UTF_8);
|
||||||
@@ -66,7 +66,7 @@ public abstract class DiffBasedWorldStateKeyValueStorage
|
|||||||
protected final SegmentedKeyValueStorage composedWorldStateStorage;
|
protected final SegmentedKeyValueStorage composedWorldStateStorage;
|
||||||
protected final KeyValueStorage trieLogStorage;
|
protected final KeyValueStorage trieLogStorage;
|
||||||
|
|
||||||
public DiffBasedWorldStateKeyValueStorage(final StorageProvider provider) {
|
public PathBasedWorldStateKeyValueStorage(final StorageProvider provider) {
|
||||||
this.composedWorldStateStorage =
|
this.composedWorldStateStorage =
|
||||||
provider.getStorageBySegmentIdentifiers(
|
provider.getStorageBySegmentIdentifiers(
|
||||||
List.of(
|
List.of(
|
||||||
@@ -75,7 +75,7 @@ public abstract class DiffBasedWorldStateKeyValueStorage
|
|||||||
provider.getStorageBySegmentIdentifier(KeyValueSegmentIdentifier.TRIE_LOG_STORAGE);
|
provider.getStorageBySegmentIdentifier(KeyValueSegmentIdentifier.TRIE_LOG_STORAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DiffBasedWorldStateKeyValueStorage(
|
public PathBasedWorldStateKeyValueStorage(
|
||||||
final SegmentedKeyValueStorage composedWorldStateStorage,
|
final SegmentedKeyValueStorage composedWorldStateStorage,
|
||||||
final KeyValueStorage trieLogStorage) {
|
final KeyValueStorage trieLogStorage) {
|
||||||
this.composedWorldStateStorage = composedWorldStateStorage;
|
this.composedWorldStateStorage = composedWorldStateStorage;
|
||||||
@@ -240,7 +240,7 @@ public abstract class DiffBasedWorldStateKeyValueStorage
|
|||||||
|
|
||||||
public interface Updater extends WorldStateKeyValueStorage.Updater {
|
public interface Updater extends WorldStateKeyValueStorage.Updater {
|
||||||
|
|
||||||
DiffBasedWorldStateKeyValueStorage.Updater saveWorldState(
|
PathBasedWorldStateKeyValueStorage.Updater saveWorldState(
|
||||||
final Bytes blockHash, final Bytes32 nodeHash, final Bytes node);
|
final Bytes blockHash, final Bytes32 nodeHash, final Bytes node);
|
||||||
|
|
||||||
SegmentedKeyValueStorageTransaction getWorldStateTransaction();
|
SegmentedKeyValueStorageTransaction getWorldStateTransaction();
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.common.storage.flat;
|
package org.hyperledger.besu.ethereum.trie.pathbased.common.storage.flat;
|
||||||
|
|
||||||
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.CODE_STORAGE;
|
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.CODE_STORAGE;
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.common.storage.flat;
|
package org.hyperledger.besu.ethereum.trie.pathbased.common.storage.flat;
|
||||||
|
|
||||||
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.CODE_STORAGE;
|
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.CODE_STORAGE;
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.common.storage.flat;
|
package org.hyperledger.besu.ethereum.trie.pathbased.common.storage.flat;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
import org.hyperledger.besu.plugin.services.storage.SegmentedKeyValueStorage;
|
import org.hyperledger.besu.plugin.services.storage.SegmentedKeyValueStorage;
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.common.storage.flat;
|
package org.hyperledger.besu.ethereum.trie.pathbased.common.storage.flat;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
import org.hyperledger.besu.metrics.BesuMetricCategory;
|
import org.hyperledger.besu.metrics.BesuMetricCategory;
|
||||||
@@ -12,11 +12,11 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.common.storage.flat;
|
package org.hyperledger.besu.ethereum.trie.pathbased.common.storage.flat;
|
||||||
|
|
||||||
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.CODE_STORAGE;
|
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.CODE_STORAGE;
|
||||||
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.TRIE_BRANCH_STORAGE;
|
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.TRIE_BRANCH_STORAGE;
|
||||||
import static org.hyperledger.besu.ethereum.trie.diffbased.common.storage.DiffBasedWorldStateKeyValueStorage.WORLD_ROOT_HASH_KEY;
|
import static org.hyperledger.besu.ethereum.trie.pathbased.common.storage.PathBasedWorldStateKeyValueStorage.WORLD_ROOT_HASH_KEY;
|
||||||
|
|
||||||
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
|
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.FlatDbMode;
|
import org.hyperledger.besu.ethereum.worldstate.FlatDbMode;
|
||||||
@@ -66,7 +66,7 @@ public abstract class FlatDbStrategyProvider {
|
|||||||
final SegmentedKeyValueStorage composedWorldStateStorage) {
|
final SegmentedKeyValueStorage composedWorldStateStorage) {
|
||||||
final boolean configCodeUsingHash =
|
final boolean configCodeUsingHash =
|
||||||
dataStorageConfiguration
|
dataStorageConfiguration
|
||||||
.getDiffBasedSubStorageConfiguration()
|
.getPathBasedExtraStorageConfiguration()
|
||||||
.getUnstable()
|
.getUnstable()
|
||||||
.getCodeStoredByCodeHashEnabled();
|
.getCodeStoredByCodeHashEnabled();
|
||||||
boolean codeUsingCodeByHash =
|
boolean codeUsingCodeByHash =
|
||||||
@@ -12,12 +12,12 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.common.trielog;
|
package org.hyperledger.besu.ethereum.trie.pathbased.common.trielog;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
import org.hyperledger.besu.ethereum.core.BlockHeader;
|
import org.hyperledger.besu.ethereum.core.BlockHeader;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.DiffBasedWorldState;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.PathBasedWorldState;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.accumulator.DiffBasedWorldStateUpdateAccumulator;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.accumulator.PathBasedWorldStateUpdateAccumulator;
|
||||||
import org.hyperledger.besu.plugin.services.trielogs.TrieLog;
|
import org.hyperledger.besu.plugin.services.trielogs.TrieLog;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -30,10 +30,10 @@ public class NoOpTrieLogManager extends TrieLogManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void saveTrieLog(
|
public synchronized void saveTrieLog(
|
||||||
final DiffBasedWorldStateUpdateAccumulator<?> localUpdater,
|
final PathBasedWorldStateUpdateAccumulator<?> localUpdater,
|
||||||
final Hash forWorldStateRootHash,
|
final Hash forWorldStateRootHash,
|
||||||
final BlockHeader forBlockHeader,
|
final BlockHeader forBlockHeader,
|
||||||
final DiffBasedWorldState forWorldState) {
|
final PathBasedWorldState forWorldState) {
|
||||||
// notify trie log added observers, synchronously
|
// notify trie log added observers, synchronously
|
||||||
TrieLog trieLog = trieLogFactory.create(localUpdater, forBlockHeader);
|
TrieLog trieLog = trieLogFactory.create(localUpdater, forBlockHeader);
|
||||||
trieLogObservers.forEach(o -> o.onTrieLogAdded(new TrieLogAddedEvent(trieLog)));
|
trieLogObservers.forEach(o -> o.onTrieLogAdded(new TrieLogAddedEvent(trieLog)));
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.common.trielog;
|
package org.hyperledger.besu.ethereum.trie.pathbased.common.trielog;
|
||||||
|
|
||||||
import org.hyperledger.besu.plugin.services.trielogs.TrieLog;
|
import org.hyperledger.besu.plugin.services.trielogs.TrieLog;
|
||||||
import org.hyperledger.besu.plugin.services.trielogs.TrieLogEvent;
|
import org.hyperledger.besu.plugin.services.trielogs.TrieLogEvent;
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.common.trielog;
|
package org.hyperledger.besu.ethereum.trie.pathbased.common.trielog;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ import org.hyperledger.besu.datatypes.AccountValue;
|
|||||||
import org.hyperledger.besu.datatypes.Address;
|
import org.hyperledger.besu.datatypes.Address;
|
||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
import org.hyperledger.besu.datatypes.StorageSlotKey;
|
import org.hyperledger.besu.datatypes.StorageSlotKey;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.DiffBasedValue;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.PathBasedValue;
|
||||||
import org.hyperledger.besu.plugin.services.trielogs.TrieLog;
|
import org.hyperledger.besu.plugin.services.trielogs.TrieLog;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -47,21 +47,21 @@ public class TrieLogLayer implements TrieLog {
|
|||||||
protected Hash blockHash;
|
protected Hash blockHash;
|
||||||
protected Optional<Long> blockNumber = Optional.empty();
|
protected Optional<Long> blockNumber = Optional.empty();
|
||||||
|
|
||||||
Map<Address, DiffBasedValue<AccountValue>> getAccounts() {
|
Map<Address, PathBasedValue<AccountValue>> getAccounts() {
|
||||||
return accounts;
|
return accounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<Address, DiffBasedValue<Bytes>> getCode() {
|
Map<Address, PathBasedValue<Bytes>> getCode() {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<Address, Map<StorageSlotKey, DiffBasedValue<UInt256>>> getStorage() {
|
Map<Address, Map<StorageSlotKey, PathBasedValue<UInt256>>> getStorage() {
|
||||||
return storage;
|
return storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final Map<Address, DiffBasedValue<AccountValue>> accounts;
|
protected final Map<Address, PathBasedValue<AccountValue>> accounts;
|
||||||
protected final Map<Address, DiffBasedValue<Bytes>> code;
|
protected final Map<Address, PathBasedValue<Bytes>> code;
|
||||||
protected final Map<Address, Map<StorageSlotKey, DiffBasedValue<UInt256>>> storage;
|
protected final Map<Address, Map<StorageSlotKey, PathBasedValue<UInt256>>> storage;
|
||||||
protected boolean frozen = false;
|
protected boolean frozen = false;
|
||||||
|
|
||||||
public TrieLogLayer() {
|
public TrieLogLayer() {
|
||||||
@@ -102,14 +102,14 @@ public class TrieLogLayer implements TrieLog {
|
|||||||
public TrieLogLayer addAccountChange(
|
public TrieLogLayer addAccountChange(
|
||||||
final Address address, final AccountValue oldValue, final AccountValue newValue) {
|
final Address address, final AccountValue oldValue, final AccountValue newValue) {
|
||||||
checkState(!frozen, "Layer is Frozen");
|
checkState(!frozen, "Layer is Frozen");
|
||||||
accounts.put(address, new DiffBasedValue<>(oldValue, newValue));
|
accounts.put(address, new PathBasedValue<>(oldValue, newValue));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TrieLogLayer addCodeChange(
|
public TrieLogLayer addCodeChange(
|
||||||
final Address address, final Bytes oldValue, final Bytes newValue, final Hash blockHash) {
|
final Address address, final Bytes oldValue, final Bytes newValue, final Hash blockHash) {
|
||||||
checkState(!frozen, "Layer is Frozen");
|
checkState(!frozen, "Layer is Frozen");
|
||||||
code.put(address, new DiffBasedValue<>(oldValue, newValue, newValue == null));
|
code.put(address, new PathBasedValue<>(oldValue, newValue, newValue == null));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,22 +121,22 @@ public class TrieLogLayer implements TrieLog {
|
|||||||
checkState(!frozen, "Layer is Frozen");
|
checkState(!frozen, "Layer is Frozen");
|
||||||
storage
|
storage
|
||||||
.computeIfAbsent(address, a -> new TreeMap<>())
|
.computeIfAbsent(address, a -> new TreeMap<>())
|
||||||
.put(slot, new DiffBasedValue<>(oldValue, newValue));
|
.put(slot, new PathBasedValue<>(oldValue, newValue));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<Address, DiffBasedValue<AccountValue>> getAccountChanges() {
|
public Map<Address, PathBasedValue<AccountValue>> getAccountChanges() {
|
||||||
return accounts;
|
return accounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<Address, DiffBasedValue<Bytes>> getCodeChanges() {
|
public Map<Address, PathBasedValue<Bytes>> getCodeChanges() {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<Address, Map<StorageSlotKey, DiffBasedValue<UInt256>>> getStorageChanges() {
|
public Map<Address, Map<StorageSlotKey, PathBasedValue<UInt256>>> getStorageChanges() {
|
||||||
return storage;
|
return storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,18 +145,18 @@ public class TrieLogLayer implements TrieLog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<StorageSlotKey, DiffBasedValue<UInt256>> getStorageChanges(final Address address) {
|
public Map<StorageSlotKey, PathBasedValue<UInt256>> getStorageChanges(final Address address) {
|
||||||
return storage.getOrDefault(address, Map.of());
|
return storage.getOrDefault(address, Map.of());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Bytes> getPriorCode(final Address address) {
|
public Optional<Bytes> getPriorCode(final Address address) {
|
||||||
return Optional.ofNullable(code.get(address)).map(DiffBasedValue::getPrior);
|
return Optional.ofNullable(code.get(address)).map(PathBasedValue::getPrior);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Bytes> getCode(final Address address) {
|
public Optional<Bytes> getCode(final Address address) {
|
||||||
return Optional.ofNullable(code.get(address)).map(DiffBasedValue::getUpdated);
|
return Optional.ofNullable(code.get(address)).map(PathBasedValue::getUpdated);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -164,7 +164,7 @@ public class TrieLogLayer implements TrieLog {
|
|||||||
final Address address, final StorageSlotKey storageSlotKey) {
|
final Address address, final StorageSlotKey storageSlotKey) {
|
||||||
return Optional.ofNullable(storage.get(address))
|
return Optional.ofNullable(storage.get(address))
|
||||||
.map(i -> i.get(storageSlotKey))
|
.map(i -> i.get(storageSlotKey))
|
||||||
.map(DiffBasedValue::getPrior);
|
.map(PathBasedValue::getPrior);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -172,24 +172,24 @@ public class TrieLogLayer implements TrieLog {
|
|||||||
final Address address, final StorageSlotKey storageSlotKey) {
|
final Address address, final StorageSlotKey storageSlotKey) {
|
||||||
return Optional.ofNullable(storage.get(address))
|
return Optional.ofNullable(storage.get(address))
|
||||||
.map(i -> i.get(storageSlotKey))
|
.map(i -> i.get(storageSlotKey))
|
||||||
.map(DiffBasedValue::getUpdated);
|
.map(PathBasedValue::getUpdated);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<AccountValue> getPriorAccount(final Address address) {
|
public Optional<AccountValue> getPriorAccount(final Address address) {
|
||||||
return Optional.ofNullable(accounts.get(address)).map(DiffBasedValue::getPrior);
|
return Optional.ofNullable(accounts.get(address)).map(PathBasedValue::getPrior);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<AccountValue> getAccount(final Address address) {
|
public Optional<AccountValue> getAccount(final Address address) {
|
||||||
return Optional.ofNullable(accounts.get(address)).map(DiffBasedValue::getUpdated);
|
return Optional.ofNullable(accounts.get(address)).map(PathBasedValue::getUpdated);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String dump() {
|
public String dump() {
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
sb.append("TrieLog{" + "blockHash=").append(blockHash).append(frozen).append('}');
|
sb.append("TrieLog{" + "blockHash=").append(blockHash).append(frozen).append('}');
|
||||||
sb.append("accounts\n");
|
sb.append("accounts\n");
|
||||||
for (final Map.Entry<Address, DiffBasedValue<AccountValue>> account : accounts.entrySet()) {
|
for (final Map.Entry<Address, PathBasedValue<AccountValue>> account : accounts.entrySet()) {
|
||||||
sb.append(" : ").append(account.getKey()).append("\n");
|
sb.append(" : ").append(account.getKey()).append("\n");
|
||||||
if (Objects.equals(account.getValue().getPrior(), account.getValue().getUpdated())) {
|
if (Objects.equals(account.getValue().getPrior(), account.getValue().getUpdated())) {
|
||||||
sb.append(" = ").append(account.getValue().getUpdated()).append("\n");
|
sb.append(" = ").append(account.getValue().getUpdated()).append("\n");
|
||||||
@@ -199,7 +199,7 @@ public class TrieLogLayer implements TrieLog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
sb.append("code").append("\n");
|
sb.append("code").append("\n");
|
||||||
for (final Map.Entry<Address, DiffBasedValue<Bytes>> code : code.entrySet()) {
|
for (final Map.Entry<Address, PathBasedValue<Bytes>> code : code.entrySet()) {
|
||||||
sb.append(" : ").append(code.getKey()).append("\n");
|
sb.append(" : ").append(code.getKey()).append("\n");
|
||||||
if (Objects.equals(code.getValue().getPrior(), code.getValue().getUpdated())) {
|
if (Objects.equals(code.getValue().getPrior(), code.getValue().getUpdated())) {
|
||||||
sb.append(" = ").append(code.getValue().getPrior()).append("\n");
|
sb.append(" = ").append(code.getValue().getPrior()).append("\n");
|
||||||
@@ -209,10 +209,10 @@ public class TrieLogLayer implements TrieLog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
sb.append("Storage").append("\n");
|
sb.append("Storage").append("\n");
|
||||||
for (final Map.Entry<Address, Map<StorageSlotKey, DiffBasedValue<UInt256>>> storage :
|
for (final Map.Entry<Address, Map<StorageSlotKey, PathBasedValue<UInt256>>> storage :
|
||||||
storage.entrySet()) {
|
storage.entrySet()) {
|
||||||
sb.append(" : ").append(storage.getKey()).append("\n");
|
sb.append(" : ").append(storage.getKey()).append("\n");
|
||||||
for (final Map.Entry<StorageSlotKey, DiffBasedValue<UInt256>> slot :
|
for (final Map.Entry<StorageSlotKey, PathBasedValue<UInt256>> slot :
|
||||||
storage.getValue().entrySet()) {
|
storage.getValue().entrySet()) {
|
||||||
final UInt256 originalValue = slot.getValue().getPrior();
|
final UInt256 originalValue = slot.getValue().getPrior();
|
||||||
final UInt256 updatedValue = slot.getValue().getUpdated();
|
final UInt256 updatedValue = slot.getValue().getUpdated();
|
||||||
@@ -12,15 +12,15 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.common.trielog;
|
package org.hyperledger.besu.ethereum.trie.pathbased.common.trielog;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
import org.hyperledger.besu.ethereum.chain.Blockchain;
|
import org.hyperledger.besu.ethereum.chain.Blockchain;
|
||||||
import org.hyperledger.besu.ethereum.core.BlockHeader;
|
import org.hyperledger.besu.ethereum.core.BlockHeader;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.trielog.TrieLogFactoryImpl;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.trielog.TrieLogFactoryImpl;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.storage.DiffBasedWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.storage.PathBasedWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.DiffBasedWorldState;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.PathBasedWorldState;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.accumulator.DiffBasedWorldStateUpdateAccumulator;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.accumulator.PathBasedWorldStateUpdateAccumulator;
|
||||||
import org.hyperledger.besu.plugin.ServiceManager;
|
import org.hyperledger.besu.plugin.ServiceManager;
|
||||||
import org.hyperledger.besu.plugin.services.TrieLogService;
|
import org.hyperledger.besu.plugin.services.TrieLogService;
|
||||||
import org.hyperledger.besu.plugin.services.trielogs.TrieLog;
|
import org.hyperledger.besu.plugin.services.trielogs.TrieLog;
|
||||||
@@ -42,7 +42,7 @@ public class TrieLogManager {
|
|||||||
private static final Logger LOG = LoggerFactory.getLogger(TrieLogManager.class);
|
private static final Logger LOG = LoggerFactory.getLogger(TrieLogManager.class);
|
||||||
public static final long LOG_RANGE_LIMIT = 1000; // restrict trielog range queries to 1k logs
|
public static final long LOG_RANGE_LIMIT = 1000; // restrict trielog range queries to 1k logs
|
||||||
protected final Blockchain blockchain;
|
protected final Blockchain blockchain;
|
||||||
protected final DiffBasedWorldStateKeyValueStorage rootWorldStateStorage;
|
protected final PathBasedWorldStateKeyValueStorage rootWorldStateStorage;
|
||||||
|
|
||||||
protected final long maxLayersToLoad;
|
protected final long maxLayersToLoad;
|
||||||
protected final Subscribers<TrieLogEvent.TrieLogObserver> trieLogObservers = Subscribers.create();
|
protected final Subscribers<TrieLogEvent.TrieLogObserver> trieLogObservers = Subscribers.create();
|
||||||
@@ -51,7 +51,7 @@ public class TrieLogManager {
|
|||||||
|
|
||||||
public TrieLogManager(
|
public TrieLogManager(
|
||||||
final Blockchain blockchain,
|
final Blockchain blockchain,
|
||||||
final DiffBasedWorldStateKeyValueStorage worldStateKeyValueStorage,
|
final PathBasedWorldStateKeyValueStorage worldStateKeyValueStorage,
|
||||||
final long maxLayersToLoad,
|
final long maxLayersToLoad,
|
||||||
final ServiceManager pluginContext) {
|
final ServiceManager pluginContext) {
|
||||||
this.blockchain = blockchain;
|
this.blockchain = blockchain;
|
||||||
@@ -61,15 +61,15 @@ public class TrieLogManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void saveTrieLog(
|
public synchronized void saveTrieLog(
|
||||||
final DiffBasedWorldStateUpdateAccumulator<?> localUpdater,
|
final PathBasedWorldStateUpdateAccumulator<?> localUpdater,
|
||||||
final Hash forWorldStateRootHash,
|
final Hash forWorldStateRootHash,
|
||||||
final BlockHeader forBlockHeader,
|
final BlockHeader forBlockHeader,
|
||||||
final DiffBasedWorldState forWorldState) {
|
final PathBasedWorldState forWorldState) {
|
||||||
// do not overwrite a trielog layer that already exists in the database.
|
// do not overwrite a trielog layer that already exists in the database.
|
||||||
// if it's only in memory we need to save it
|
// if it's only in memory we need to save it
|
||||||
// for example, in case of reorg we don't replace a trielog layer
|
// for example, in case of reorg we don't replace a trielog layer
|
||||||
if (rootWorldStateStorage.getTrieLog(forBlockHeader.getHash()).isEmpty()) {
|
if (rootWorldStateStorage.getTrieLog(forBlockHeader.getHash()).isEmpty()) {
|
||||||
final DiffBasedWorldStateKeyValueStorage.Updater stateUpdater =
|
final PathBasedWorldStateKeyValueStorage.Updater stateUpdater =
|
||||||
forWorldState.getWorldStateStorage().updater();
|
forWorldState.getWorldStateStorage().updater();
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
try {
|
try {
|
||||||
@@ -91,7 +91,7 @@ public class TrieLogManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private TrieLog prepareTrieLog(
|
private TrieLog prepareTrieLog(
|
||||||
final BlockHeader blockHeader, final DiffBasedWorldStateUpdateAccumulator<?> localUpdater) {
|
final BlockHeader blockHeader, final PathBasedWorldStateUpdateAccumulator<?> localUpdater) {
|
||||||
LOG.atDebug()
|
LOG.atDebug()
|
||||||
.setMessage("Adding layered world state for {}")
|
.setMessage("Adding layered world state for {}")
|
||||||
.addArgument(blockHeader::toLogString)
|
.addArgument(blockHeader::toLogString)
|
||||||
@@ -105,7 +105,7 @@ public class TrieLogManager {
|
|||||||
final BlockHeader blockHeader,
|
final BlockHeader blockHeader,
|
||||||
final Hash worldStateRootHash,
|
final Hash worldStateRootHash,
|
||||||
final TrieLog trieLog,
|
final TrieLog trieLog,
|
||||||
final DiffBasedWorldStateKeyValueStorage.Updater stateUpdater) {
|
final PathBasedWorldStateKeyValueStorage.Updater stateUpdater) {
|
||||||
LOG.atDebug()
|
LOG.atDebug()
|
||||||
.setMessage("Persisting trie log for block hash {} and world state root {}")
|
.setMessage("Persisting trie log for block hash {} and world state root {}")
|
||||||
.addArgument(blockHeader::toLogString)
|
.addArgument(blockHeader::toLogString)
|
||||||
@@ -175,7 +175,7 @@ public class TrieLogManager {
|
|||||||
@Override
|
@Override
|
||||||
public void saveRawTrieLogLayer(
|
public void saveRawTrieLogLayer(
|
||||||
final Hash blockHash, final long blockNumber, final Bytes trieLog) {
|
final Hash blockHash, final long blockNumber, final Bytes trieLog) {
|
||||||
final DiffBasedWorldStateKeyValueStorage.Updater updater = rootWorldStateStorage.updater();
|
final PathBasedWorldStateKeyValueStorage.Updater updater = rootWorldStateStorage.updater();
|
||||||
updater
|
updater
|
||||||
.getTrieLogStorageTransaction()
|
.getTrieLogStorageTransaction()
|
||||||
.put(blockHash.toArrayUnsafe(), trieLog.toArrayUnsafe());
|
.put(blockHash.toArrayUnsafe(), trieLog.toArrayUnsafe());
|
||||||
@@ -12,13 +12,13 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.common.trielog;
|
package org.hyperledger.besu.ethereum.trie.pathbased.common.trielog;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
import org.hyperledger.besu.ethereum.chain.Blockchain;
|
import org.hyperledger.besu.ethereum.chain.Blockchain;
|
||||||
import org.hyperledger.besu.ethereum.core.BlockHeader;
|
import org.hyperledger.besu.ethereum.core.BlockHeader;
|
||||||
import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader;
|
import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.storage.DiffBasedWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.storage.PathBasedWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.metrics.BesuMetricCategory;
|
import org.hyperledger.besu.metrics.BesuMetricCategory;
|
||||||
import org.hyperledger.besu.plugin.services.MetricsSystem;
|
import org.hyperledger.besu.plugin.services.MetricsSystem;
|
||||||
import org.hyperledger.besu.plugin.services.metrics.Counter;
|
import org.hyperledger.besu.plugin.services.metrics.Counter;
|
||||||
@@ -51,7 +51,7 @@ public class TrieLogPruner implements TrieLogEvent.TrieLogObserver {
|
|||||||
|
|
||||||
private final int pruningLimit;
|
private final int pruningLimit;
|
||||||
private final int loadingLimit;
|
private final int loadingLimit;
|
||||||
private final DiffBasedWorldStateKeyValueStorage rootWorldStateStorage;
|
private final PathBasedWorldStateKeyValueStorage rootWorldStateStorage;
|
||||||
private final Blockchain blockchain;
|
private final Blockchain blockchain;
|
||||||
private final Consumer<Runnable> executeAsync;
|
private final Consumer<Runnable> executeAsync;
|
||||||
private final long numBlocksToRetain;
|
private final long numBlocksToRetain;
|
||||||
@@ -64,7 +64,7 @@ public class TrieLogPruner implements TrieLogEvent.TrieLogObserver {
|
|||||||
TreeMultimap.create(Comparator.reverseOrder(), Comparator.naturalOrder());
|
TreeMultimap.create(Comparator.reverseOrder(), Comparator.naturalOrder());
|
||||||
|
|
||||||
public TrieLogPruner(
|
public TrieLogPruner(
|
||||||
final DiffBasedWorldStateKeyValueStorage rootWorldStateStorage,
|
final PathBasedWorldStateKeyValueStorage rootWorldStateStorage,
|
||||||
final Blockchain blockchain,
|
final Blockchain blockchain,
|
||||||
final Consumer<Runnable> executeAsync,
|
final Consumer<Runnable> executeAsync,
|
||||||
final long numBlocksToRetain,
|
final long numBlocksToRetain,
|
||||||
@@ -12,24 +12,24 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.common.worldview;
|
package org.hyperledger.besu.ethereum.trie.pathbased.common.worldview;
|
||||||
|
|
||||||
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.TRIE_BRANCH_STORAGE;
|
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.TRIE_BRANCH_STORAGE;
|
||||||
import static org.hyperledger.besu.ethereum.trie.diffbased.common.storage.DiffBasedWorldStateKeyValueStorage.WORLD_BLOCK_HASH_KEY;
|
import static org.hyperledger.besu.ethereum.trie.pathbased.common.storage.PathBasedWorldStateKeyValueStorage.WORLD_BLOCK_HASH_KEY;
|
||||||
import static org.hyperledger.besu.ethereum.trie.diffbased.common.storage.DiffBasedWorldStateKeyValueStorage.WORLD_ROOT_HASH_KEY;
|
import static org.hyperledger.besu.ethereum.trie.pathbased.common.storage.PathBasedWorldStateKeyValueStorage.WORLD_ROOT_HASH_KEY;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.Address;
|
import org.hyperledger.besu.datatypes.Address;
|
||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
import org.hyperledger.besu.datatypes.StorageSlotKey;
|
import org.hyperledger.besu.datatypes.StorageSlotKey;
|
||||||
import org.hyperledger.besu.ethereum.core.BlockHeader;
|
import org.hyperledger.besu.ethereum.core.BlockHeader;
|
||||||
import org.hyperledger.besu.ethereum.core.MutableWorldState;
|
import org.hyperledger.besu.ethereum.core.MutableWorldState;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.StorageSubscriber;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.StorageSubscriber;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.cache.DiffBasedCachedWorldStorageManager;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.cache.PathBasedCachedWorldStorageManager;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.storage.DiffBasedLayeredWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.storage.PathBasedLayeredWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.storage.DiffBasedSnapshotWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.storage.PathBasedSnapshotWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.storage.DiffBasedWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.storage.PathBasedWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.trielog.TrieLogManager;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.trielog.TrieLogManager;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.accumulator.DiffBasedWorldStateUpdateAccumulator;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.accumulator.PathBasedWorldStateUpdateAccumulator;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.WorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.worldstate.WorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.evm.account.Account;
|
import org.hyperledger.besu.evm.account.Account;
|
||||||
import org.hyperledger.besu.evm.worldstate.WorldUpdater;
|
import org.hyperledger.besu.evm.worldstate.WorldUpdater;
|
||||||
@@ -48,15 +48,15 @@ import org.apache.tuweni.units.bigints.UInt256;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public abstract class DiffBasedWorldState
|
public abstract class PathBasedWorldState
|
||||||
implements MutableWorldState, DiffBasedWorldView, StorageSubscriber {
|
implements MutableWorldState, PathBasedWorldView, StorageSubscriber {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(DiffBasedWorldState.class);
|
private static final Logger LOG = LoggerFactory.getLogger(PathBasedWorldState.class);
|
||||||
|
|
||||||
protected DiffBasedWorldStateKeyValueStorage worldStateKeyValueStorage;
|
protected PathBasedWorldStateKeyValueStorage worldStateKeyValueStorage;
|
||||||
protected final DiffBasedCachedWorldStorageManager cachedWorldStorageManager;
|
protected final PathBasedCachedWorldStorageManager cachedWorldStorageManager;
|
||||||
protected final TrieLogManager trieLogManager;
|
protected final TrieLogManager trieLogManager;
|
||||||
protected DiffBasedWorldStateUpdateAccumulator<?> accumulator;
|
protected PathBasedWorldStateUpdateAccumulator<?> accumulator;
|
||||||
|
|
||||||
protected Hash worldStateRootHash;
|
protected Hash worldStateRootHash;
|
||||||
protected Hash worldStateBlockHash;
|
protected Hash worldStateBlockHash;
|
||||||
@@ -74,9 +74,9 @@ public abstract class DiffBasedWorldState
|
|||||||
*/
|
*/
|
||||||
protected boolean isStorageFrozen;
|
protected boolean isStorageFrozen;
|
||||||
|
|
||||||
protected DiffBasedWorldState(
|
protected PathBasedWorldState(
|
||||||
final DiffBasedWorldStateKeyValueStorage worldStateKeyValueStorage,
|
final PathBasedWorldStateKeyValueStorage worldStateKeyValueStorage,
|
||||||
final DiffBasedCachedWorldStorageManager cachedWorldStorageManager,
|
final PathBasedCachedWorldStorageManager cachedWorldStorageManager,
|
||||||
final TrieLogManager trieLogManager,
|
final TrieLogManager trieLogManager,
|
||||||
final WorldStateConfig worldStateConfig) {
|
final WorldStateConfig worldStateConfig) {
|
||||||
this.worldStateKeyValueStorage = worldStateKeyValueStorage;
|
this.worldStateKeyValueStorage = worldStateKeyValueStorage;
|
||||||
@@ -99,7 +99,7 @@ public abstract class DiffBasedWorldState
|
|||||||
*
|
*
|
||||||
* @param accumulator accumulator to use.
|
* @param accumulator accumulator to use.
|
||||||
*/
|
*/
|
||||||
public void setAccumulator(final DiffBasedWorldStateUpdateAccumulator<?> accumulator) {
|
public void setAccumulator(final PathBasedWorldStateUpdateAccumulator<?> accumulator) {
|
||||||
this.accumulator = accumulator;
|
this.accumulator = accumulator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,7 +136,7 @@ public abstract class DiffBasedWorldState
|
|||||||
|
|
||||||
private boolean isModifyingHeadWorldState(
|
private boolean isModifyingHeadWorldState(
|
||||||
final WorldStateKeyValueStorage worldStateKeyValueStorage) {
|
final WorldStateKeyValueStorage worldStateKeyValueStorage) {
|
||||||
return !(worldStateKeyValueStorage instanceof DiffBasedSnapshotWorldStateKeyValueStorage);
|
return !(worldStateKeyValueStorage instanceof PathBasedSnapshotWorldStateKeyValueStorage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -150,17 +150,17 @@ public abstract class DiffBasedWorldState
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DiffBasedWorldStateKeyValueStorage getWorldStateStorage() {
|
public PathBasedWorldStateKeyValueStorage getWorldStateStorage() {
|
||||||
return worldStateKeyValueStorage;
|
return worldStateKeyValueStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DiffBasedWorldStateUpdateAccumulator<?> getAccumulator() {
|
public PathBasedWorldStateUpdateAccumulator<?> getAccumulator() {
|
||||||
return accumulator;
|
return accumulator;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Hash unsafeRootHashUpdate(
|
protected Hash unsafeRootHashUpdate(
|
||||||
final BlockHeader blockHeader,
|
final BlockHeader blockHeader,
|
||||||
final DiffBasedWorldStateKeyValueStorage.Updater stateUpdater) {
|
final PathBasedWorldStateKeyValueStorage.Updater stateUpdater) {
|
||||||
// calling calculateRootHash in order to update the state
|
// calling calculateRootHash in order to update the state
|
||||||
calculateRootHash(isStorageFrozen ? Optional.empty() : Optional.of(stateUpdater), accumulator);
|
calculateRootHash(isStorageFrozen ? Optional.empty() : Optional.of(stateUpdater), accumulator);
|
||||||
return blockHeader.getStateRoot();
|
return blockHeader.getStateRoot();
|
||||||
@@ -174,11 +174,11 @@ public abstract class DiffBasedWorldState
|
|||||||
.addArgument(maybeBlockHeader)
|
.addArgument(maybeBlockHeader)
|
||||||
.log();
|
.log();
|
||||||
|
|
||||||
final DiffBasedWorldStateUpdateAccumulator<?> localCopy = accumulator.copy();
|
final PathBasedWorldStateUpdateAccumulator<?> localCopy = accumulator.copy();
|
||||||
|
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
|
|
||||||
final DiffBasedWorldStateKeyValueStorage.Updater stateUpdater =
|
final PathBasedWorldStateKeyValueStorage.Updater stateUpdater =
|
||||||
worldStateKeyValueStorage.updater();
|
worldStateKeyValueStorage.updater();
|
||||||
Runnable saveTrieLog = () -> {};
|
Runnable saveTrieLog = () -> {};
|
||||||
|
|
||||||
@@ -340,8 +340,8 @@ public abstract class DiffBasedWorldState
|
|||||||
|
|
||||||
private void closeFrozenStorage() {
|
private void closeFrozenStorage() {
|
||||||
try {
|
try {
|
||||||
final DiffBasedLayeredWorldStateKeyValueStorage worldStateLayerStorage =
|
final PathBasedLayeredWorldStateKeyValueStorage worldStateLayerStorage =
|
||||||
(DiffBasedLayeredWorldStateKeyValueStorage) worldStateKeyValueStorage;
|
(PathBasedLayeredWorldStateKeyValueStorage) worldStateKeyValueStorage;
|
||||||
if (!isModifyingHeadWorldState(worldStateLayerStorage.getParentWorldStateStorage())) {
|
if (!isModifyingHeadWorldState(worldStateLayerStorage.getParentWorldStateStorage())) {
|
||||||
worldStateLayerStorage.getParentWorldStateStorage().close();
|
worldStateLayerStorage.getParentWorldStateStorage().close();
|
||||||
}
|
}
|
||||||
@@ -383,8 +383,8 @@ public abstract class DiffBasedWorldState
|
|||||||
public abstract Optional<Bytes> getCode(@Nonnull final Address address, final Hash codeHash);
|
public abstract Optional<Bytes> getCode(@Nonnull final Address address, final Hash codeHash);
|
||||||
|
|
||||||
protected abstract Hash calculateRootHash(
|
protected abstract Hash calculateRootHash(
|
||||||
final Optional<DiffBasedWorldStateKeyValueStorage.Updater> maybeStateUpdater,
|
final Optional<PathBasedWorldStateKeyValueStorage.Updater> maybeStateUpdater,
|
||||||
final DiffBasedWorldStateUpdateAccumulator<?> worldStateUpdater);
|
final PathBasedWorldStateUpdateAccumulator<?> worldStateUpdater);
|
||||||
|
|
||||||
protected abstract Hash getEmptyTrieHash();
|
protected abstract Hash getEmptyTrieHash();
|
||||||
}
|
}
|
||||||
@@ -12,13 +12,13 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.common.worldview;
|
package org.hyperledger.besu.ethereum.trie.pathbased.common.worldview;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.Address;
|
import org.hyperledger.besu.datatypes.Address;
|
||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
import org.hyperledger.besu.datatypes.StorageSlotKey;
|
import org.hyperledger.besu.datatypes.StorageSlotKey;
|
||||||
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
|
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.storage.DiffBasedWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.storage.PathBasedWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.evm.worldstate.WorldUpdater;
|
import org.hyperledger.besu.evm.worldstate.WorldUpdater;
|
||||||
import org.hyperledger.besu.evm.worldstate.WorldView;
|
import org.hyperledger.besu.evm.worldstate.WorldView;
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ import org.apache.tuweni.bytes.Bytes;
|
|||||||
import org.apache.tuweni.bytes.Bytes32;
|
import org.apache.tuweni.bytes.Bytes32;
|
||||||
import org.apache.tuweni.units.bigints.UInt256;
|
import org.apache.tuweni.units.bigints.UInt256;
|
||||||
|
|
||||||
public interface DiffBasedWorldView extends WorldView {
|
public interface PathBasedWorldView extends WorldView {
|
||||||
|
|
||||||
Optional<Bytes> getCode(Address address, final Hash codeHash);
|
Optional<Bytes> getCode(Address address, final Hash codeHash);
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ public interface DiffBasedWorldView extends WorldView {
|
|||||||
|
|
||||||
boolean isModifyingHeadWorldState();
|
boolean isModifyingHeadWorldState();
|
||||||
|
|
||||||
DiffBasedWorldStateKeyValueStorage getWorldStateStorage();
|
PathBasedWorldStateKeyValueStorage getWorldStateStorage();
|
||||||
|
|
||||||
WorldUpdater updater();
|
WorldUpdater updater();
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.common.worldview;
|
package org.hyperledger.besu.ethereum.trie.pathbased.common.worldview;
|
||||||
|
|
||||||
/** WorldStateConfig encapsulates the shared configuration parameters for the world state. */
|
/** WorldStateConfig encapsulates the shared configuration parameters for the world state. */
|
||||||
public class WorldStateConfig {
|
public class WorldStateConfig {
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.accumulator;
|
package org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.accumulator;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.AccountValue;
|
import org.hyperledger.besu.datatypes.AccountValue;
|
||||||
import org.hyperledger.besu.datatypes.Address;
|
import org.hyperledger.besu.datatypes.Address;
|
||||||
@@ -21,14 +21,14 @@ import org.hyperledger.besu.datatypes.StorageSlotKey;
|
|||||||
import org.hyperledger.besu.datatypes.Wei;
|
import org.hyperledger.besu.datatypes.Wei;
|
||||||
import org.hyperledger.besu.ethereum.rlp.RLP;
|
import org.hyperledger.besu.ethereum.rlp.RLP;
|
||||||
import org.hyperledger.besu.ethereum.trie.MerkleTrieException;
|
import org.hyperledger.besu.ethereum.trie.MerkleTrieException;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.DiffBasedAccount;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.PathBasedAccount;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.DiffBasedValue;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.PathBasedValue;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.storage.DiffBasedWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.storage.PathBasedWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.DiffBasedWorldState;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.PathBasedWorldState;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.DiffBasedWorldView;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.PathBasedWorldView;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.accumulator.preload.AccountConsumingMap;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.accumulator.preload.AccountConsumingMap;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.accumulator.preload.Consumer;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.accumulator.preload.Consumer;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.accumulator.preload.StorageConsumingMap;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.accumulator.preload.StorageConsumingMap;
|
||||||
import org.hyperledger.besu.evm.account.Account;
|
import org.hyperledger.besu.evm.account.Account;
|
||||||
import org.hyperledger.besu.evm.account.MutableAccount;
|
import org.hyperledger.besu.evm.account.MutableAccount;
|
||||||
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
||||||
@@ -55,31 +55,31 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public abstract class DiffBasedWorldStateUpdateAccumulator<ACCOUNT extends DiffBasedAccount>
|
public abstract class PathBasedWorldStateUpdateAccumulator<ACCOUNT extends PathBasedAccount>
|
||||||
extends AbstractWorldUpdater<DiffBasedWorldView, ACCOUNT>
|
extends AbstractWorldUpdater<PathBasedWorldView, ACCOUNT>
|
||||||
implements DiffBasedWorldView, TrieLogAccumulator {
|
implements PathBasedWorldView, TrieLogAccumulator {
|
||||||
private static final Logger LOG =
|
private static final Logger LOG =
|
||||||
LoggerFactory.getLogger(DiffBasedWorldStateUpdateAccumulator.class);
|
LoggerFactory.getLogger(PathBasedWorldStateUpdateAccumulator.class);
|
||||||
protected final Consumer<DiffBasedValue<ACCOUNT>> accountPreloader;
|
protected final Consumer<PathBasedValue<ACCOUNT>> accountPreloader;
|
||||||
protected final Consumer<StorageSlotKey> storagePreloader;
|
protected final Consumer<StorageSlotKey> storagePreloader;
|
||||||
|
|
||||||
private final AccountConsumingMap<DiffBasedValue<ACCOUNT>> accountsToUpdate;
|
private final AccountConsumingMap<PathBasedValue<ACCOUNT>> accountsToUpdate;
|
||||||
private final Map<Address, DiffBasedValue<Bytes>> codeToUpdate = new ConcurrentHashMap<>();
|
private final Map<Address, PathBasedValue<Bytes>> codeToUpdate = new ConcurrentHashMap<>();
|
||||||
private final Set<Address> storageToClear = Collections.synchronizedSet(new HashSet<>());
|
private final Set<Address> storageToClear = Collections.synchronizedSet(new HashSet<>());
|
||||||
protected final EvmConfiguration evmConfiguration;
|
protected final EvmConfiguration evmConfiguration;
|
||||||
|
|
||||||
// storage sub mapped by _hashed_ key. This is because in self_destruct calls we need to
|
// storage sub mapped by _hashed_ key. This is because in self_destruct calls we need to
|
||||||
// enumerate the old storage and delete it. Those are trie stored by hashed key by spec and the
|
// enumerate the old storage and delete it. Those are trie stored by hashed key by spec and the
|
||||||
// alternative was to keep a giant pre-image cache of the entire trie.
|
// alternative was to keep a giant pre-image cache of the entire trie.
|
||||||
private final Map<Address, StorageConsumingMap<StorageSlotKey, DiffBasedValue<UInt256>>>
|
private final Map<Address, StorageConsumingMap<StorageSlotKey, PathBasedValue<UInt256>>>
|
||||||
storageToUpdate = new ConcurrentHashMap<>();
|
storageToUpdate = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private final Map<UInt256, Hash> storageKeyHashLookup = new ConcurrentHashMap<>();
|
private final Map<UInt256, Hash> storageKeyHashLookup = new ConcurrentHashMap<>();
|
||||||
protected boolean isAccumulatorStateChanged;
|
protected boolean isAccumulatorStateChanged;
|
||||||
|
|
||||||
public DiffBasedWorldStateUpdateAccumulator(
|
public PathBasedWorldStateUpdateAccumulator(
|
||||||
final DiffBasedWorldView world,
|
final PathBasedWorldView world,
|
||||||
final Consumer<DiffBasedValue<ACCOUNT>> accountPreloader,
|
final Consumer<PathBasedValue<ACCOUNT>> accountPreloader,
|
||||||
final Consumer<StorageSlotKey> storagePreloader,
|
final Consumer<StorageSlotKey> storagePreloader,
|
||||||
final EvmConfiguration evmConfiguration) {
|
final EvmConfiguration evmConfiguration) {
|
||||||
super(world, evmConfiguration);
|
super(world, evmConfiguration);
|
||||||
@@ -90,7 +90,7 @@ public abstract class DiffBasedWorldStateUpdateAccumulator<ACCOUNT extends DiffB
|
|||||||
this.evmConfiguration = evmConfiguration;
|
this.evmConfiguration = evmConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cloneFromUpdater(final DiffBasedWorldStateUpdateAccumulator<ACCOUNT> source) {
|
public void cloneFromUpdater(final PathBasedWorldStateUpdateAccumulator<ACCOUNT> source) {
|
||||||
accountsToUpdate.putAll(source.getAccountsToUpdate());
|
accountsToUpdate.putAll(source.getAccountsToUpdate());
|
||||||
codeToUpdate.putAll(source.codeToUpdate);
|
codeToUpdate.putAll(source.codeToUpdate);
|
||||||
storageToClear.addAll(source.storageToClear);
|
storageToClear.addAll(source.storageToClear);
|
||||||
@@ -111,52 +111,52 @@ public abstract class DiffBasedWorldStateUpdateAccumulator<ACCOUNT extends DiffB
|
|||||||
* @param source The source accumulator
|
* @param source The source accumulator
|
||||||
*/
|
*/
|
||||||
public void importStateChangesFromSource(
|
public void importStateChangesFromSource(
|
||||||
final DiffBasedWorldStateUpdateAccumulator<ACCOUNT> source) {
|
final PathBasedWorldStateUpdateAccumulator<ACCOUNT> source) {
|
||||||
source
|
source
|
||||||
.getAccountsToUpdate()
|
.getAccountsToUpdate()
|
||||||
.forEach(
|
.forEach(
|
||||||
(address, diffBasedValue) -> {
|
(address, pathBasedValue) -> {
|
||||||
ACCOUNT copyPrior =
|
ACCOUNT copyPrior =
|
||||||
diffBasedValue.getPrior() != null
|
pathBasedValue.getPrior() != null
|
||||||
? copyAccount(diffBasedValue.getPrior(), this, false)
|
? copyAccount(pathBasedValue.getPrior(), this, false)
|
||||||
: null;
|
: null;
|
||||||
ACCOUNT copyUpdated =
|
ACCOUNT copyUpdated =
|
||||||
diffBasedValue.getUpdated() != null
|
pathBasedValue.getUpdated() != null
|
||||||
? copyAccount(diffBasedValue.getUpdated(), this, true)
|
? copyAccount(pathBasedValue.getUpdated(), this, true)
|
||||||
: null;
|
: null;
|
||||||
accountsToUpdate.put(
|
accountsToUpdate.put(
|
||||||
address,
|
address,
|
||||||
new DiffBasedValue<>(copyPrior, copyUpdated, diffBasedValue.isLastStepCleared()));
|
new PathBasedValue<>(copyPrior, copyUpdated, pathBasedValue.isLastStepCleared()));
|
||||||
});
|
});
|
||||||
source
|
source
|
||||||
.getCodeToUpdate()
|
.getCodeToUpdate()
|
||||||
.forEach(
|
.forEach(
|
||||||
(address, diffBasedValue) -> {
|
(address, pathBasedValue) -> {
|
||||||
codeToUpdate.put(
|
codeToUpdate.put(
|
||||||
address,
|
address,
|
||||||
new DiffBasedValue<>(
|
new PathBasedValue<>(
|
||||||
diffBasedValue.getPrior(),
|
pathBasedValue.getPrior(),
|
||||||
diffBasedValue.getUpdated(),
|
pathBasedValue.getUpdated(),
|
||||||
diffBasedValue.isLastStepCleared()));
|
pathBasedValue.isLastStepCleared()));
|
||||||
});
|
});
|
||||||
source
|
source
|
||||||
.getStorageToUpdate()
|
.getStorageToUpdate()
|
||||||
.forEach(
|
.forEach(
|
||||||
(address, slots) -> {
|
(address, slots) -> {
|
||||||
StorageConsumingMap<StorageSlotKey, DiffBasedValue<UInt256>> storageConsumingMap =
|
StorageConsumingMap<StorageSlotKey, PathBasedValue<UInt256>> storageConsumingMap =
|
||||||
storageToUpdate.computeIfAbsent(
|
storageToUpdate.computeIfAbsent(
|
||||||
address,
|
address,
|
||||||
k ->
|
k ->
|
||||||
new StorageConsumingMap<>(
|
new StorageConsumingMap<>(
|
||||||
address, new ConcurrentHashMap<>(), storagePreloader));
|
address, new ConcurrentHashMap<>(), storagePreloader));
|
||||||
slots.forEach(
|
slots.forEach(
|
||||||
(storageSlotKey, uInt256DiffBasedValue) -> {
|
(storageSlotKey, uInt256PathBasedValue) -> {
|
||||||
storageConsumingMap.put(
|
storageConsumingMap.put(
|
||||||
storageSlotKey,
|
storageSlotKey,
|
||||||
new DiffBasedValue<>(
|
new PathBasedValue<>(
|
||||||
uInt256DiffBasedValue.getPrior(),
|
uInt256PathBasedValue.getPrior(),
|
||||||
uInt256DiffBasedValue.getUpdated(),
|
uInt256PathBasedValue.getUpdated(),
|
||||||
uInt256DiffBasedValue.isLastStepCleared()));
|
uInt256PathBasedValue.isLastStepCleared()));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
storageToClear.addAll(source.storageToClear);
|
storageToClear.addAll(source.storageToClear);
|
||||||
@@ -177,53 +177,53 @@ public abstract class DiffBasedWorldStateUpdateAccumulator<ACCOUNT extends DiffB
|
|||||||
* @param source The source accumulator
|
* @param source The source accumulator
|
||||||
*/
|
*/
|
||||||
public void importPriorStateFromSource(
|
public void importPriorStateFromSource(
|
||||||
final DiffBasedWorldStateUpdateAccumulator<ACCOUNT> source) {
|
final PathBasedWorldStateUpdateAccumulator<ACCOUNT> source) {
|
||||||
|
|
||||||
source
|
source
|
||||||
.getAccountsToUpdate()
|
.getAccountsToUpdate()
|
||||||
.forEach(
|
.forEach(
|
||||||
(address, diffBasedValue) -> {
|
(address, pathBasedValue) -> {
|
||||||
ACCOUNT copyPrior =
|
ACCOUNT copyPrior =
|
||||||
diffBasedValue.getPrior() != null
|
pathBasedValue.getPrior() != null
|
||||||
? copyAccount(diffBasedValue.getPrior(), this, false)
|
? copyAccount(pathBasedValue.getPrior(), this, false)
|
||||||
: null;
|
: null;
|
||||||
ACCOUNT copyUpdated =
|
ACCOUNT copyUpdated =
|
||||||
diffBasedValue.getPrior() != null
|
pathBasedValue.getPrior() != null
|
||||||
? copyAccount(diffBasedValue.getPrior(), this, true)
|
? copyAccount(pathBasedValue.getPrior(), this, true)
|
||||||
: null;
|
: null;
|
||||||
accountsToUpdate.putIfAbsent(address, new DiffBasedValue<>(copyPrior, copyUpdated));
|
accountsToUpdate.putIfAbsent(address, new PathBasedValue<>(copyPrior, copyUpdated));
|
||||||
});
|
});
|
||||||
source
|
source
|
||||||
.getCodeToUpdate()
|
.getCodeToUpdate()
|
||||||
.forEach(
|
.forEach(
|
||||||
(address, diffBasedValue) -> {
|
(address, pathBasedValue) -> {
|
||||||
codeToUpdate.putIfAbsent(
|
codeToUpdate.putIfAbsent(
|
||||||
address,
|
address,
|
||||||
new DiffBasedValue<>(diffBasedValue.getPrior(), diffBasedValue.getPrior()));
|
new PathBasedValue<>(pathBasedValue.getPrior(), pathBasedValue.getPrior()));
|
||||||
});
|
});
|
||||||
source
|
source
|
||||||
.getStorageToUpdate()
|
.getStorageToUpdate()
|
||||||
.forEach(
|
.forEach(
|
||||||
(address, slots) -> {
|
(address, slots) -> {
|
||||||
StorageConsumingMap<StorageSlotKey, DiffBasedValue<UInt256>> storageConsumingMap =
|
StorageConsumingMap<StorageSlotKey, PathBasedValue<UInt256>> storageConsumingMap =
|
||||||
storageToUpdate.computeIfAbsent(
|
storageToUpdate.computeIfAbsent(
|
||||||
address,
|
address,
|
||||||
k ->
|
k ->
|
||||||
new StorageConsumingMap<>(
|
new StorageConsumingMap<>(
|
||||||
address, new ConcurrentHashMap<>(), storagePreloader));
|
address, new ConcurrentHashMap<>(), storagePreloader));
|
||||||
slots.forEach(
|
slots.forEach(
|
||||||
(storageSlotKey, uInt256DiffBasedValue) -> {
|
(storageSlotKey, uInt256PathBasedValue) -> {
|
||||||
storageConsumingMap.putIfAbsent(
|
storageConsumingMap.putIfAbsent(
|
||||||
storageSlotKey,
|
storageSlotKey,
|
||||||
new DiffBasedValue<>(
|
new PathBasedValue<>(
|
||||||
uInt256DiffBasedValue.getPrior(), uInt256DiffBasedValue.getPrior()));
|
uInt256PathBasedValue.getPrior(), uInt256PathBasedValue.getPrior()));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
storageKeyHashLookup.putAll(source.storageKeyHashLookup);
|
storageKeyHashLookup.putAll(source.storageKeyHashLookup);
|
||||||
this.isAccumulatorStateChanged = true;
|
this.isAccumulatorStateChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Consumer<DiffBasedValue<ACCOUNT>> getAccountPreloader() {
|
protected Consumer<PathBasedValue<ACCOUNT>> getAccountPreloader() {
|
||||||
return accountPreloader;
|
return accountPreloader;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,14 +252,14 @@ public abstract class DiffBasedWorldStateUpdateAccumulator<ACCOUNT extends DiffB
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MutableAccount createAccount(final Address address, final long nonce, final Wei balance) {
|
public MutableAccount createAccount(final Address address, final long nonce, final Wei balance) {
|
||||||
DiffBasedValue<ACCOUNT> diffBasedValue = accountsToUpdate.get(address);
|
PathBasedValue<ACCOUNT> pathBasedValue = accountsToUpdate.get(address);
|
||||||
|
|
||||||
if (diffBasedValue == null) {
|
if (pathBasedValue == null) {
|
||||||
diffBasedValue = new DiffBasedValue<>(null, null);
|
pathBasedValue = new PathBasedValue<>(null, null);
|
||||||
accountsToUpdate.put(address, diffBasedValue);
|
accountsToUpdate.put(address, pathBasedValue);
|
||||||
} else if (diffBasedValue.getUpdated() != null) {
|
} else if (pathBasedValue.getUpdated() != null) {
|
||||||
if (diffBasedValue.getUpdated().isEmpty()) {
|
if (pathBasedValue.getUpdated().isEmpty()) {
|
||||||
return track(new UpdateTrackingAccount<>(diffBasedValue.getUpdated()));
|
return track(new UpdateTrackingAccount<>(pathBasedValue.getUpdated()));
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException("Cannot create an account when one already exists");
|
throw new IllegalStateException("Cannot create an account when one already exists");
|
||||||
}
|
}
|
||||||
@@ -275,17 +275,17 @@ public abstract class DiffBasedWorldStateUpdateAccumulator<ACCOUNT extends DiffB
|
|||||||
Hash.EMPTY_TRIE_HASH,
|
Hash.EMPTY_TRIE_HASH,
|
||||||
Hash.EMPTY,
|
Hash.EMPTY,
|
||||||
true);
|
true);
|
||||||
diffBasedValue.setUpdated(newAccount);
|
pathBasedValue.setUpdated(newAccount);
|
||||||
return track(new UpdateTrackingAccount<>(newAccount));
|
return track(new UpdateTrackingAccount<>(newAccount));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<Address, DiffBasedValue<ACCOUNT>> getAccountsToUpdate() {
|
public Map<Address, PathBasedValue<ACCOUNT>> getAccountsToUpdate() {
|
||||||
return accountsToUpdate;
|
return accountsToUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<Address, DiffBasedValue<Bytes>> getCodeToUpdate() {
|
public Map<Address, PathBasedValue<Bytes>> getCodeToUpdate() {
|
||||||
return codeToUpdate;
|
return codeToUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,41 +294,41 @@ public abstract class DiffBasedWorldStateUpdateAccumulator<ACCOUNT extends DiffB
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<Address, StorageConsumingMap<StorageSlotKey, DiffBasedValue<UInt256>>>
|
public Map<Address, StorageConsumingMap<StorageSlotKey, PathBasedValue<UInt256>>>
|
||||||
getStorageToUpdate() {
|
getStorageToUpdate() {
|
||||||
return storageToUpdate;
|
return storageToUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ACCOUNT getForMutation(final Address address) {
|
protected ACCOUNT getForMutation(final Address address) {
|
||||||
return loadAccount(address, DiffBasedValue::getUpdated);
|
return loadAccount(address, PathBasedValue::getUpdated);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ACCOUNT loadAccount(
|
protected ACCOUNT loadAccount(
|
||||||
final Address address, final Function<DiffBasedValue<ACCOUNT>, ACCOUNT> accountFunction) {
|
final Address address, final Function<PathBasedValue<ACCOUNT>, ACCOUNT> accountFunction) {
|
||||||
try {
|
try {
|
||||||
final DiffBasedValue<ACCOUNT> diffBasedValue = accountsToUpdate.get(address);
|
final PathBasedValue<ACCOUNT> pathBasedValue = accountsToUpdate.get(address);
|
||||||
if (diffBasedValue == null) {
|
if (pathBasedValue == null) {
|
||||||
final Account account;
|
final Account account;
|
||||||
if (wrappedWorldView() instanceof DiffBasedWorldStateUpdateAccumulator) {
|
if (wrappedWorldView() instanceof PathBasedWorldStateUpdateAccumulator) {
|
||||||
final DiffBasedWorldStateUpdateAccumulator<ACCOUNT> worldStateUpdateAccumulator =
|
final PathBasedWorldStateUpdateAccumulator<ACCOUNT> worldStateUpdateAccumulator =
|
||||||
(DiffBasedWorldStateUpdateAccumulator<ACCOUNT>) wrappedWorldView();
|
(PathBasedWorldStateUpdateAccumulator<ACCOUNT>) wrappedWorldView();
|
||||||
account = worldStateUpdateAccumulator.loadAccount(address, accountFunction);
|
account = worldStateUpdateAccumulator.loadAccount(address, accountFunction);
|
||||||
} else {
|
} else {
|
||||||
account = wrappedWorldView().get(address);
|
account = wrappedWorldView().get(address);
|
||||||
}
|
}
|
||||||
if (account instanceof DiffBasedAccount diffBasedAccount) {
|
if (account instanceof PathBasedAccount pathBasedAccount) {
|
||||||
ACCOUNT mutableAccount = copyAccount((ACCOUNT) diffBasedAccount, this, true);
|
ACCOUNT mutableAccount = copyAccount((ACCOUNT) pathBasedAccount, this, true);
|
||||||
accountsToUpdate.put(
|
accountsToUpdate.put(
|
||||||
address, new DiffBasedValue<>((ACCOUNT) diffBasedAccount, mutableAccount));
|
address, new PathBasedValue<>((ACCOUNT) pathBasedAccount, mutableAccount));
|
||||||
return mutableAccount;
|
return mutableAccount;
|
||||||
} else {
|
} else {
|
||||||
// add the empty read in accountsToUpdate
|
// add the empty read in accountsToUpdate
|
||||||
accountsToUpdate.put(address, new DiffBasedValue<>(null, null));
|
accountsToUpdate.put(address, new PathBasedValue<>(null, null));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return accountFunction.apply(diffBasedValue);
|
return accountFunction.apply(pathBasedValue);
|
||||||
}
|
}
|
||||||
} catch (MerkleTrieException e) {
|
} catch (MerkleTrieException e) {
|
||||||
// need to throw to trigger the heal
|
// need to throw to trigger the heal
|
||||||
@@ -352,12 +352,12 @@ public abstract class DiffBasedWorldStateUpdateAccumulator<ACCOUNT extends DiffB
|
|||||||
this.isAccumulatorStateChanged = true;
|
this.isAccumulatorStateChanged = true;
|
||||||
|
|
||||||
for (final Address deletedAddress : getDeletedAccounts()) {
|
for (final Address deletedAddress : getDeletedAccounts()) {
|
||||||
final DiffBasedValue<ACCOUNT> accountValue =
|
final PathBasedValue<ACCOUNT> accountValue =
|
||||||
accountsToUpdate.computeIfAbsent(
|
accountsToUpdate.computeIfAbsent(
|
||||||
deletedAddress,
|
deletedAddress,
|
||||||
__ -> loadAccountFromParent(deletedAddress, new DiffBasedValue<>(null, null, true)));
|
__ -> loadAccountFromParent(deletedAddress, new PathBasedValue<>(null, null, true)));
|
||||||
storageToClear.add(deletedAddress);
|
storageToClear.add(deletedAddress);
|
||||||
final DiffBasedValue<Bytes> codeValue = codeToUpdate.get(deletedAddress);
|
final PathBasedValue<Bytes> codeValue = codeToUpdate.get(deletedAddress);
|
||||||
if (codeValue != null) {
|
if (codeValue != null) {
|
||||||
codeValue.setUpdated(null).setCleared();
|
codeValue.setUpdated(null).setCleared();
|
||||||
} else {
|
} else {
|
||||||
@@ -365,27 +365,27 @@ public abstract class DiffBasedWorldStateUpdateAccumulator<ACCOUNT extends DiffB
|
|||||||
.getCode(
|
.getCode(
|
||||||
deletedAddress,
|
deletedAddress,
|
||||||
Optional.ofNullable(accountValue)
|
Optional.ofNullable(accountValue)
|
||||||
.map(DiffBasedValue::getPrior)
|
.map(PathBasedValue::getPrior)
|
||||||
.map(DiffBasedAccount::getCodeHash)
|
.map(PathBasedAccount::getCodeHash)
|
||||||
.orElse(Hash.EMPTY))
|
.orElse(Hash.EMPTY))
|
||||||
.ifPresent(
|
.ifPresent(
|
||||||
deletedCode ->
|
deletedCode ->
|
||||||
codeToUpdate.put(
|
codeToUpdate.put(
|
||||||
deletedAddress, new DiffBasedValue<>(deletedCode, null, true)));
|
deletedAddress, new PathBasedValue<>(deletedCode, null, true)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// mark all updated storage as to be cleared
|
// mark all updated storage as to be cleared
|
||||||
final Map<StorageSlotKey, DiffBasedValue<UInt256>> deletedStorageUpdates =
|
final Map<StorageSlotKey, PathBasedValue<UInt256>> deletedStorageUpdates =
|
||||||
storageToUpdate.computeIfAbsent(
|
storageToUpdate.computeIfAbsent(
|
||||||
deletedAddress,
|
deletedAddress,
|
||||||
k ->
|
k ->
|
||||||
new StorageConsumingMap<>(
|
new StorageConsumingMap<>(
|
||||||
deletedAddress, new ConcurrentHashMap<>(), storagePreloader));
|
deletedAddress, new ConcurrentHashMap<>(), storagePreloader));
|
||||||
final Iterator<Map.Entry<StorageSlotKey, DiffBasedValue<UInt256>>> iter =
|
final Iterator<Map.Entry<StorageSlotKey, PathBasedValue<UInt256>>> iter =
|
||||||
deletedStorageUpdates.entrySet().iterator();
|
deletedStorageUpdates.entrySet().iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
final Map.Entry<StorageSlotKey, DiffBasedValue<UInt256>> updateEntry = iter.next();
|
final Map.Entry<StorageSlotKey, PathBasedValue<UInt256>> updateEntry = iter.next();
|
||||||
final DiffBasedValue<UInt256> updatedSlot = updateEntry.getValue();
|
final PathBasedValue<UInt256> updatedSlot = updateEntry.getValue();
|
||||||
if (updatedSlot.getPrior() == null || updatedSlot.getPrior().isZero()) {
|
if (updatedSlot.getPrior() == null || updatedSlot.getPrior().isZero()) {
|
||||||
iter.remove();
|
iter.remove();
|
||||||
} else {
|
} else {
|
||||||
@@ -405,7 +405,7 @@ public abstract class DiffBasedWorldStateUpdateAccumulator<ACCOUNT extends DiffB
|
|||||||
if (!deletedStorageUpdates.containsKey(storageSlotKey)) {
|
if (!deletedStorageUpdates.containsKey(storageSlotKey)) {
|
||||||
final UInt256 value = UInt256.fromBytes(RLP.decodeOne(entryValue));
|
final UInt256 value = UInt256.fromBytes(RLP.decodeOne(entryValue));
|
||||||
deletedStorageUpdates.put(
|
deletedStorageUpdates.put(
|
||||||
storageSlotKey, new DiffBasedValue<>(value, null, true));
|
storageSlotKey, new PathBasedValue<>(value, null, true));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -420,9 +420,9 @@ public abstract class DiffBasedWorldStateUpdateAccumulator<ACCOUNT extends DiffB
|
|||||||
tracked -> {
|
tracked -> {
|
||||||
final Address updatedAddress = tracked.getAddress();
|
final Address updatedAddress = tracked.getAddress();
|
||||||
final ACCOUNT updatedAccount;
|
final ACCOUNT updatedAccount;
|
||||||
final DiffBasedValue<ACCOUNT> updatedAccountValue =
|
final PathBasedValue<ACCOUNT> updatedAccountValue =
|
||||||
accountsToUpdate.get(updatedAddress);
|
accountsToUpdate.get(updatedAddress);
|
||||||
final Map<StorageSlotKey, DiffBasedValue<UInt256>> pendingStorageUpdates =
|
final Map<StorageSlotKey, PathBasedValue<UInt256>> pendingStorageUpdates =
|
||||||
storageToUpdate.computeIfAbsent(
|
storageToUpdate.computeIfAbsent(
|
||||||
updatedAddress,
|
updatedAddress,
|
||||||
k ->
|
k ->
|
||||||
@@ -433,9 +433,9 @@ public abstract class DiffBasedWorldStateUpdateAccumulator<ACCOUNT extends DiffB
|
|||||||
updatedAccount = createAccount(this, tracked);
|
updatedAccount = createAccount(this, tracked);
|
||||||
tracked.setWrappedAccount(updatedAccount);
|
tracked.setWrappedAccount(updatedAccount);
|
||||||
if (updatedAccountValue == null) {
|
if (updatedAccountValue == null) {
|
||||||
accountsToUpdate.put(updatedAddress, new DiffBasedValue<>(null, updatedAccount));
|
accountsToUpdate.put(updatedAddress, new PathBasedValue<>(null, updatedAccount));
|
||||||
codeToUpdate.put(
|
codeToUpdate.put(
|
||||||
updatedAddress, new DiffBasedValue<>(null, updatedAccount.getCode()));
|
updatedAddress, new PathBasedValue<>(null, updatedAccount.getCode()));
|
||||||
} else {
|
} else {
|
||||||
updatedAccountValue.setUpdated(updatedAccount);
|
updatedAccountValue.setUpdated(updatedAccount);
|
||||||
}
|
}
|
||||||
@@ -453,17 +453,17 @@ public abstract class DiffBasedWorldStateUpdateAccumulator<ACCOUNT extends DiffB
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tracked.codeWasUpdated()) {
|
if (tracked.codeWasUpdated()) {
|
||||||
final DiffBasedValue<Bytes> pendingCode =
|
final PathBasedValue<Bytes> pendingCode =
|
||||||
codeToUpdate.computeIfAbsent(
|
codeToUpdate.computeIfAbsent(
|
||||||
updatedAddress,
|
updatedAddress,
|
||||||
addr ->
|
addr ->
|
||||||
new DiffBasedValue<>(
|
new PathBasedValue<>(
|
||||||
wrappedWorldView()
|
wrappedWorldView()
|
||||||
.getCode(
|
.getCode(
|
||||||
addr,
|
addr,
|
||||||
Optional.ofNullable(updatedAccountValue)
|
Optional.ofNullable(updatedAccountValue)
|
||||||
.map(DiffBasedValue::getPrior)
|
.map(PathBasedValue::getPrior)
|
||||||
.map(DiffBasedAccount::getCodeHash)
|
.map(PathBasedAccount::getCodeHash)
|
||||||
.orElse(Hash.EMPTY))
|
.orElse(Hash.EMPTY))
|
||||||
.orElse(null),
|
.orElse(null),
|
||||||
null));
|
null));
|
||||||
@@ -486,12 +486,12 @@ public abstract class DiffBasedWorldStateUpdateAccumulator<ACCOUNT extends DiffB
|
|||||||
new StorageSlotKey(
|
new StorageSlotKey(
|
||||||
hashAndSaveSlotPreImage(keyUInt), Optional.of(keyUInt));
|
hashAndSaveSlotPreImage(keyUInt), Optional.of(keyUInt));
|
||||||
final UInt256 value = storageUpdate.getValue();
|
final UInt256 value = storageUpdate.getValue();
|
||||||
final DiffBasedValue<UInt256> pendingValue =
|
final PathBasedValue<UInt256> pendingValue =
|
||||||
pendingStorageUpdates.get(slotKey);
|
pendingStorageUpdates.get(slotKey);
|
||||||
if (pendingValue == null) {
|
if (pendingValue == null) {
|
||||||
pendingStorageUpdates.put(
|
pendingStorageUpdates.put(
|
||||||
slotKey,
|
slotKey,
|
||||||
new DiffBasedValue<>(
|
new PathBasedValue<>(
|
||||||
updatedAccount.getOriginalStorageValue(keyUInt), value));
|
updatedAccount.getOriginalStorageValue(keyUInt), value));
|
||||||
} else {
|
} else {
|
||||||
pendingValue.setUpdated(value);
|
pendingValue.setUpdated(value);
|
||||||
@@ -512,7 +512,7 @@ public abstract class DiffBasedWorldStateUpdateAccumulator<ACCOUNT extends DiffB
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Bytes> getCode(final Address address, final Hash codeHash) {
|
public Optional<Bytes> getCode(final Address address, final Hash codeHash) {
|
||||||
final DiffBasedValue<Bytes> localCode = codeToUpdate.get(address);
|
final PathBasedValue<Bytes> localCode = codeToUpdate.get(address);
|
||||||
if (localCode == null) {
|
if (localCode == null) {
|
||||||
final Optional<Bytes> code = wrappedWorldView().getCode(address, codeHash);
|
final Optional<Bytes> code = wrappedWorldView().getCode(address, codeHash);
|
||||||
if (code.isEmpty() && !codeHash.equals(Hash.EMPTY)) {
|
if (code.isEmpty() && !codeHash.equals(Hash.EMPTY)) {
|
||||||
@@ -535,17 +535,17 @@ public abstract class DiffBasedWorldStateUpdateAccumulator<ACCOUNT extends DiffB
|
|||||||
@Override
|
@Override
|
||||||
public Optional<UInt256> getStorageValueByStorageSlotKey(
|
public Optional<UInt256> getStorageValueByStorageSlotKey(
|
||||||
final Address address, final StorageSlotKey storageSlotKey) {
|
final Address address, final StorageSlotKey storageSlotKey) {
|
||||||
final Map<StorageSlotKey, DiffBasedValue<UInt256>> localAccountStorage =
|
final Map<StorageSlotKey, PathBasedValue<UInt256>> localAccountStorage =
|
||||||
storageToUpdate.get(address);
|
storageToUpdate.get(address);
|
||||||
if (localAccountStorage != null) {
|
if (localAccountStorage != null) {
|
||||||
final DiffBasedValue<UInt256> value = localAccountStorage.get(storageSlotKey);
|
final PathBasedValue<UInt256> value = localAccountStorage.get(storageSlotKey);
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
return Optional.ofNullable(value.getUpdated());
|
return Optional.ofNullable(value.getUpdated());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
final Optional<UInt256> valueUInt =
|
final Optional<UInt256> valueUInt =
|
||||||
(wrappedWorldView() instanceof DiffBasedWorldState worldState)
|
(wrappedWorldView() instanceof PathBasedWorldState worldState)
|
||||||
? worldState.getStorageValueByStorageSlotKey(address, storageSlotKey)
|
? worldState.getStorageValueByStorageSlotKey(address, storageSlotKey)
|
||||||
: wrappedWorldView().getStorageValueByStorageSlotKey(address, storageSlotKey);
|
: wrappedWorldView().getStorageValueByStorageSlotKey(address, storageSlotKey);
|
||||||
storageToUpdate
|
storageToUpdate
|
||||||
@@ -554,7 +554,7 @@ public abstract class DiffBasedWorldStateUpdateAccumulator<ACCOUNT extends DiffB
|
|||||||
key ->
|
key ->
|
||||||
new StorageConsumingMap<>(address, new ConcurrentHashMap<>(), storagePreloader))
|
new StorageConsumingMap<>(address, new ConcurrentHashMap<>(), storagePreloader))
|
||||||
.put(
|
.put(
|
||||||
storageSlotKey, new DiffBasedValue<>(valueUInt.orElse(null), valueUInt.orElse(null)));
|
storageSlotKey, new PathBasedValue<>(valueUInt.orElse(null), valueUInt.orElse(null)));
|
||||||
return valueUInt;
|
return valueUInt;
|
||||||
} catch (MerkleTrieException e) {
|
} catch (MerkleTrieException e) {
|
||||||
// need to throw to trigger the heal
|
// need to throw to trigger the heal
|
||||||
@@ -568,10 +568,10 @@ public abstract class DiffBasedWorldStateUpdateAccumulator<ACCOUNT extends DiffB
|
|||||||
// TODO maybe log the read into the trie layer?
|
// TODO maybe log the read into the trie layer?
|
||||||
StorageSlotKey storageSlotKey =
|
StorageSlotKey storageSlotKey =
|
||||||
new StorageSlotKey(hashAndSaveSlotPreImage(storageKey), Optional.of(storageKey));
|
new StorageSlotKey(hashAndSaveSlotPreImage(storageKey), Optional.of(storageKey));
|
||||||
final Map<StorageSlotKey, DiffBasedValue<UInt256>> localAccountStorage =
|
final Map<StorageSlotKey, PathBasedValue<UInt256>> localAccountStorage =
|
||||||
storageToUpdate.get(address);
|
storageToUpdate.get(address);
|
||||||
if (localAccountStorage != null) {
|
if (localAccountStorage != null) {
|
||||||
final DiffBasedValue<UInt256> value = localAccountStorage.get(storageSlotKey);
|
final PathBasedValue<UInt256> value = localAccountStorage.get(storageSlotKey);
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
if (value.isLastStepCleared()) {
|
if (value.isLastStepCleared()) {
|
||||||
return UInt256.ZERO;
|
return UInt256.ZERO;
|
||||||
@@ -595,11 +595,11 @@ public abstract class DiffBasedWorldStateUpdateAccumulator<ACCOUNT extends DiffB
|
|||||||
@Override
|
@Override
|
||||||
public Map<Bytes32, Bytes> getAllAccountStorage(final Address address, final Hash rootHash) {
|
public Map<Bytes32, Bytes> getAllAccountStorage(final Address address, final Hash rootHash) {
|
||||||
final Map<Bytes32, Bytes> results = wrappedWorldView().getAllAccountStorage(address, rootHash);
|
final Map<Bytes32, Bytes> results = wrappedWorldView().getAllAccountStorage(address, rootHash);
|
||||||
final StorageConsumingMap<StorageSlotKey, DiffBasedValue<UInt256>> diffBasedValueStorage =
|
final StorageConsumingMap<StorageSlotKey, PathBasedValue<UInt256>> pathBasedValueStorage =
|
||||||
storageToUpdate.get(address);
|
storageToUpdate.get(address);
|
||||||
if (diffBasedValueStorage != null) {
|
if (pathBasedValueStorage != null) {
|
||||||
// hash the key to match the implied storage interface of hashed slotKey
|
// hash the key to match the implied storage interface of hashed slotKey
|
||||||
diffBasedValueStorage.forEach(
|
pathBasedValueStorage.forEach(
|
||||||
(key, value) -> results.put(key.getSlotHash(), value.getUpdated()));
|
(key, value) -> results.put(key.getSlotHash(), value.getUpdated()));
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
@@ -626,7 +626,7 @@ public abstract class DiffBasedWorldStateUpdateAccumulator<ACCOUNT extends DiffB
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DiffBasedWorldStateKeyValueStorage getWorldStateStorage() {
|
public PathBasedWorldStateKeyValueStorage getWorldStateStorage() {
|
||||||
return wrappedWorldView().getWorldStateStorage();
|
return wrappedWorldView().getWorldStateStorage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -678,7 +678,7 @@ public abstract class DiffBasedWorldStateUpdateAccumulator<ACCOUNT extends DiffB
|
|||||||
// non-change, a cached read.
|
// non-change, a cached read.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DiffBasedValue<ACCOUNT> accountValue = accountsToUpdate.get(address);
|
PathBasedValue<ACCOUNT> accountValue = accountsToUpdate.get(address);
|
||||||
if (accountValue == null) {
|
if (accountValue == null) {
|
||||||
accountValue = loadAccountFromParent(address, accountValue);
|
accountValue = loadAccountFromParent(address, accountValue);
|
||||||
}
|
}
|
||||||
@@ -686,7 +686,7 @@ public abstract class DiffBasedWorldStateUpdateAccumulator<ACCOUNT extends DiffB
|
|||||||
if (expectedValue == null && replacementValue != null) {
|
if (expectedValue == null && replacementValue != null) {
|
||||||
accountsToUpdate.put(
|
accountsToUpdate.put(
|
||||||
address,
|
address,
|
||||||
new DiffBasedValue<>(null, createAccount(this, address, replacementValue, true)));
|
new PathBasedValue<>(null, createAccount(this, address, replacementValue, true)));
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
String.format(
|
String.format(
|
||||||
@@ -719,13 +719,13 @@ public abstract class DiffBasedWorldStateUpdateAccumulator<ACCOUNT extends DiffB
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private DiffBasedValue<ACCOUNT> loadAccountFromParent(
|
private PathBasedValue<ACCOUNT> loadAccountFromParent(
|
||||||
final Address address, final DiffBasedValue<ACCOUNT> defaultValue) {
|
final Address address, final PathBasedValue<ACCOUNT> defaultValue) {
|
||||||
try {
|
try {
|
||||||
final Account parentAccount = wrappedWorldView().get(address);
|
final Account parentAccount = wrappedWorldView().get(address);
|
||||||
if (parentAccount instanceof DiffBasedAccount account) {
|
if (parentAccount instanceof PathBasedAccount account) {
|
||||||
final DiffBasedValue<ACCOUNT> loadedAccountValue =
|
final PathBasedValue<ACCOUNT> loadedAccountValue =
|
||||||
new DiffBasedValue<>(copyAccount((ACCOUNT) account), ((ACCOUNT) account));
|
new PathBasedValue<>(copyAccount((ACCOUNT) account), ((ACCOUNT) account));
|
||||||
accountsToUpdate.put(address, loadedAccountValue);
|
accountsToUpdate.put(address, loadedAccountValue);
|
||||||
return loadedAccountValue;
|
return loadedAccountValue;
|
||||||
} else {
|
} else {
|
||||||
@@ -744,7 +744,7 @@ public abstract class DiffBasedWorldStateUpdateAccumulator<ACCOUNT extends DiffB
|
|||||||
// non-change, a cached read.
|
// non-change, a cached read.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DiffBasedValue<Bytes> codeValue = codeToUpdate.get(address);
|
PathBasedValue<Bytes> codeValue = codeToUpdate.get(address);
|
||||||
if (codeValue == null) {
|
if (codeValue == null) {
|
||||||
final Bytes storedCode =
|
final Bytes storedCode =
|
||||||
wrappedWorldView()
|
wrappedWorldView()
|
||||||
@@ -752,14 +752,14 @@ public abstract class DiffBasedWorldStateUpdateAccumulator<ACCOUNT extends DiffB
|
|||||||
address, Optional.ofNullable(expectedCode).map(Hash::hash).orElse(Hash.EMPTY))
|
address, Optional.ofNullable(expectedCode).map(Hash::hash).orElse(Hash.EMPTY))
|
||||||
.orElse(Bytes.EMPTY);
|
.orElse(Bytes.EMPTY);
|
||||||
if (!storedCode.isEmpty()) {
|
if (!storedCode.isEmpty()) {
|
||||||
codeValue = new DiffBasedValue<>(storedCode, storedCode);
|
codeValue = new PathBasedValue<>(storedCode, storedCode);
|
||||||
codeToUpdate.put(address, codeValue);
|
codeToUpdate.put(address, codeValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (codeValue == null) {
|
if (codeValue == null) {
|
||||||
if ((expectedCode == null || expectedCode.isEmpty()) && replacementCode != null) {
|
if ((expectedCode == null || expectedCode.isEmpty()) && replacementCode != null) {
|
||||||
codeToUpdate.put(address, new DiffBasedValue<>(null, replacementCode));
|
codeToUpdate.put(address, new PathBasedValue<>(null, replacementCode));
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
String.format(
|
String.format(
|
||||||
@@ -787,10 +787,10 @@ public abstract class DiffBasedWorldStateUpdateAccumulator<ACCOUNT extends DiffB
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<StorageSlotKey, DiffBasedValue<UInt256>> maybeCreateStorageMap(
|
private Map<StorageSlotKey, PathBasedValue<UInt256>> maybeCreateStorageMap(
|
||||||
final Map<StorageSlotKey, DiffBasedValue<UInt256>> storageMap, final Address address) {
|
final Map<StorageSlotKey, PathBasedValue<UInt256>> storageMap, final Address address) {
|
||||||
if (storageMap == null) {
|
if (storageMap == null) {
|
||||||
final StorageConsumingMap<StorageSlotKey, DiffBasedValue<UInt256>> newMap =
|
final StorageConsumingMap<StorageSlotKey, PathBasedValue<UInt256>> newMap =
|
||||||
new StorageConsumingMap<>(address, new ConcurrentHashMap<>(), storagePreloader);
|
new StorageConsumingMap<>(address, new ConcurrentHashMap<>(), storagePreloader);
|
||||||
storageToUpdate.put(address, newMap);
|
storageToUpdate.put(address, newMap);
|
||||||
return newMap;
|
return newMap;
|
||||||
@@ -812,13 +812,13 @@ public abstract class DiffBasedWorldStateUpdateAccumulator<ACCOUNT extends DiffB
|
|||||||
// corner case on deletes, non-change
|
// corner case on deletes, non-change
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Map<StorageSlotKey, DiffBasedValue<UInt256>> storageMap = storageToUpdate.get(address);
|
final Map<StorageSlotKey, PathBasedValue<UInt256>> storageMap = storageToUpdate.get(address);
|
||||||
DiffBasedValue<UInt256> slotValue = storageMap == null ? null : storageMap.get(storageSlotKey);
|
PathBasedValue<UInt256> slotValue = storageMap == null ? null : storageMap.get(storageSlotKey);
|
||||||
if (slotValue == null) {
|
if (slotValue == null) {
|
||||||
final Optional<UInt256> storageValue =
|
final Optional<UInt256> storageValue =
|
||||||
wrappedWorldView().getStorageValueByStorageSlotKey(address, storageSlotKey);
|
wrappedWorldView().getStorageValueByStorageSlotKey(address, storageSlotKey);
|
||||||
if (storageValue.isPresent()) {
|
if (storageValue.isPresent()) {
|
||||||
slotValue = new DiffBasedValue<>(storageValue.get(), storageValue.get());
|
slotValue = new PathBasedValue<>(storageValue.get(), storageValue.get());
|
||||||
storageToUpdate
|
storageToUpdate
|
||||||
.computeIfAbsent(
|
.computeIfAbsent(
|
||||||
address,
|
address,
|
||||||
@@ -830,7 +830,7 @@ public abstract class DiffBasedWorldStateUpdateAccumulator<ACCOUNT extends DiffB
|
|||||||
if (slotValue == null) {
|
if (slotValue == null) {
|
||||||
if ((expectedValue == null || expectedValue.isZero()) && replacementValue != null) {
|
if ((expectedValue == null || expectedValue.isZero()) && replacementValue != null) {
|
||||||
maybeCreateStorageMap(storageMap, address)
|
maybeCreateStorageMap(storageMap, address)
|
||||||
.put(storageSlotKey, new DiffBasedValue<>(null, replacementValue));
|
.put(storageSlotKey, new PathBasedValue<>(null, replacementValue));
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
String.format(
|
String.format(
|
||||||
@@ -857,7 +857,7 @@ public abstract class DiffBasedWorldStateUpdateAccumulator<ACCOUNT extends DiffB
|
|||||||
existingSlotValue == null ? "null" : existingSlotValue.toShortHexString()));
|
existingSlotValue == null ? "null" : existingSlotValue.toShortHexString()));
|
||||||
}
|
}
|
||||||
if (replacementValue == null && slotValue.getPrior() == null) {
|
if (replacementValue == null && slotValue.getPrior() == null) {
|
||||||
final Map<StorageSlotKey, DiffBasedValue<UInt256>> thisStorageUpdate =
|
final Map<StorageSlotKey, PathBasedValue<UInt256>> thisStorageUpdate =
|
||||||
maybeCreateStorageMap(storageMap, address);
|
maybeCreateStorageMap(storageMap, address);
|
||||||
thisStorageUpdate.remove(storageSlotKey);
|
thisStorageUpdate.remove(storageSlotKey);
|
||||||
if (thisStorageUpdate.isEmpty()) {
|
if (thisStorageUpdate.isEmpty()) {
|
||||||
@@ -929,21 +929,21 @@ public abstract class DiffBasedWorldStateUpdateAccumulator<ACCOUNT extends DiffB
|
|||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract DiffBasedWorldStateUpdateAccumulator<ACCOUNT> copy();
|
public abstract PathBasedWorldStateUpdateAccumulator<ACCOUNT> copy();
|
||||||
|
|
||||||
protected abstract ACCOUNT copyAccount(final ACCOUNT account);
|
protected abstract ACCOUNT copyAccount(final ACCOUNT account);
|
||||||
|
|
||||||
protected abstract ACCOUNT copyAccount(
|
protected abstract ACCOUNT copyAccount(
|
||||||
final ACCOUNT toCopy, final DiffBasedWorldView context, final boolean mutable);
|
final ACCOUNT toCopy, final PathBasedWorldView context, final boolean mutable);
|
||||||
|
|
||||||
protected abstract ACCOUNT createAccount(
|
protected abstract ACCOUNT createAccount(
|
||||||
final DiffBasedWorldView context,
|
final PathBasedWorldView context,
|
||||||
final Address address,
|
final Address address,
|
||||||
final AccountValue stateTrieAccount,
|
final AccountValue stateTrieAccount,
|
||||||
final boolean mutable);
|
final boolean mutable);
|
||||||
|
|
||||||
protected abstract ACCOUNT createAccount(
|
protected abstract ACCOUNT createAccount(
|
||||||
final DiffBasedWorldView context,
|
final PathBasedWorldView context,
|
||||||
final Address address,
|
final Address address,
|
||||||
final Hash addressHash,
|
final Hash addressHash,
|
||||||
final long nonce,
|
final long nonce,
|
||||||
@@ -953,7 +953,7 @@ public abstract class DiffBasedWorldStateUpdateAccumulator<ACCOUNT extends DiffB
|
|||||||
final boolean mutable);
|
final boolean mutable);
|
||||||
|
|
||||||
protected abstract ACCOUNT createAccount(
|
protected abstract ACCOUNT createAccount(
|
||||||
final DiffBasedWorldView context, final UpdateTrackingAccount<ACCOUNT> tracked);
|
final PathBasedWorldView context, final UpdateTrackingAccount<ACCOUNT> tracked);
|
||||||
|
|
||||||
protected abstract void assertCloseEnoughForDiffing(
|
protected abstract void assertCloseEnoughForDiffing(
|
||||||
final ACCOUNT source, final AccountValue account, final String context);
|
final ACCOUNT source, final AccountValue account, final String context);
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.accumulator.preload;
|
package org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.accumulator.preload;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.Address;
|
import org.hyperledger.besu.datatypes.Address;
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.accumulator.preload;
|
package org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.accumulator.preload;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.Address;
|
import org.hyperledger.besu.datatypes.Address;
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.accumulator.preload;
|
package org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.accumulator.preload;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.Address;
|
import org.hyperledger.besu.datatypes.Address;
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.worldstate;
|
package org.hyperledger.besu.ethereum.worldstate;
|
||||||
|
|
||||||
import org.hyperledger.besu.ethereum.worldstate.DiffBasedSubStorageConfiguration.DiffBasedUnstable;
|
import org.hyperledger.besu.ethereum.worldstate.PathBasedExtraStorageConfiguration.PathBasedUnstable;
|
||||||
import org.hyperledger.besu.plugin.services.storage.DataStorageFormat;
|
import org.hyperledger.besu.plugin.services.storage.DataStorageFormat;
|
||||||
|
|
||||||
import org.immutables.value.Value;
|
import org.immutables.value.Value;
|
||||||
@@ -28,7 +28,7 @@ public interface DataStorageConfiguration {
|
|||||||
DataStorageConfiguration DEFAULT_CONFIG =
|
DataStorageConfiguration DEFAULT_CONFIG =
|
||||||
ImmutableDataStorageConfiguration.builder()
|
ImmutableDataStorageConfiguration.builder()
|
||||||
.dataStorageFormat(DataStorageFormat.BONSAI)
|
.dataStorageFormat(DataStorageFormat.BONSAI)
|
||||||
.diffBasedSubStorageConfiguration(DiffBasedSubStorageConfiguration.DEFAULT)
|
.pathBasedExtraStorageConfiguration(PathBasedExtraStorageConfiguration.DEFAULT)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
DataStorageConfiguration DEFAULT_BONSAI_CONFIG = DEFAULT_CONFIG;
|
DataStorageConfiguration DEFAULT_BONSAI_CONFIG = DEFAULT_CONFIG;
|
||||||
@@ -36,23 +36,23 @@ public interface DataStorageConfiguration {
|
|||||||
DataStorageConfiguration DEFAULT_BONSAI_PARTIAL_DB_CONFIG =
|
DataStorageConfiguration DEFAULT_BONSAI_PARTIAL_DB_CONFIG =
|
||||||
ImmutableDataStorageConfiguration.builder()
|
ImmutableDataStorageConfiguration.builder()
|
||||||
.dataStorageFormat(DataStorageFormat.BONSAI)
|
.dataStorageFormat(DataStorageFormat.BONSAI)
|
||||||
.diffBasedSubStorageConfiguration(
|
.pathBasedExtraStorageConfiguration(
|
||||||
ImmutableDiffBasedSubStorageConfiguration.builder()
|
ImmutablePathBasedExtraStorageConfiguration.builder()
|
||||||
.unstable(DiffBasedUnstable.PARTIAL_MODE)
|
.unstable(PathBasedUnstable.PARTIAL_MODE)
|
||||||
.build())
|
.build())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
DataStorageConfiguration DEFAULT_FOREST_CONFIG =
|
DataStorageConfiguration DEFAULT_FOREST_CONFIG =
|
||||||
ImmutableDataStorageConfiguration.builder()
|
ImmutableDataStorageConfiguration.builder()
|
||||||
.dataStorageFormat(DataStorageFormat.FOREST)
|
.dataStorageFormat(DataStorageFormat.FOREST)
|
||||||
.diffBasedSubStorageConfiguration(DiffBasedSubStorageConfiguration.DISABLED)
|
.pathBasedExtraStorageConfiguration(PathBasedExtraStorageConfiguration.DISABLED)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
DataStorageFormat getDataStorageFormat();
|
DataStorageFormat getDataStorageFormat();
|
||||||
|
|
||||||
@Value.Default
|
@Value.Default
|
||||||
default DiffBasedSubStorageConfiguration getDiffBasedSubStorageConfiguration() {
|
default PathBasedExtraStorageConfiguration getPathBasedExtraStorageConfiguration() {
|
||||||
return DiffBasedSubStorageConfiguration.DEFAULT;
|
return PathBasedExtraStorageConfiguration.DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Value.Default
|
@Value.Default
|
||||||
|
|||||||
@@ -18,15 +18,15 @@ import org.immutables.value.Value;
|
|||||||
|
|
||||||
@Value.Immutable
|
@Value.Immutable
|
||||||
@Value.Enclosing
|
@Value.Enclosing
|
||||||
public interface DiffBasedSubStorageConfiguration {
|
public interface PathBasedExtraStorageConfiguration {
|
||||||
|
|
||||||
DiffBasedSubStorageConfiguration DEFAULT =
|
PathBasedExtraStorageConfiguration DEFAULT =
|
||||||
ImmutableDiffBasedSubStorageConfiguration.builder().build();
|
ImmutablePathBasedExtraStorageConfiguration.builder().build();
|
||||||
|
|
||||||
DiffBasedSubStorageConfiguration DISABLED =
|
PathBasedExtraStorageConfiguration DISABLED =
|
||||||
ImmutableDiffBasedSubStorageConfiguration.builder()
|
ImmutablePathBasedExtraStorageConfiguration.builder()
|
||||||
.limitTrieLogsEnabled(false)
|
.limitTrieLogsEnabled(false)
|
||||||
.unstable(DiffBasedUnstable.DISABLED)
|
.unstable(PathBasedUnstable.DISABLED)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
long DEFAULT_MAX_LAYERS_TO_LOAD = 512;
|
long DEFAULT_MAX_LAYERS_TO_LOAD = 512;
|
||||||
@@ -50,23 +50,23 @@ public interface DiffBasedSubStorageConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Value.Default
|
@Value.Default
|
||||||
default DiffBasedUnstable getUnstable() {
|
default PathBasedUnstable getUnstable() {
|
||||||
return DiffBasedUnstable.DEFAULT;
|
return PathBasedUnstable.DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Value.Immutable
|
@Value.Immutable
|
||||||
interface DiffBasedUnstable {
|
interface PathBasedUnstable {
|
||||||
|
|
||||||
DiffBasedSubStorageConfiguration.DiffBasedUnstable DEFAULT =
|
PathBasedExtraStorageConfiguration.PathBasedUnstable DEFAULT =
|
||||||
ImmutableDiffBasedSubStorageConfiguration.DiffBasedUnstable.builder().build();
|
ImmutablePathBasedExtraStorageConfiguration.PathBasedUnstable.builder().build();
|
||||||
|
|
||||||
DiffBasedSubStorageConfiguration.DiffBasedUnstable PARTIAL_MODE =
|
PathBasedExtraStorageConfiguration.PathBasedUnstable PARTIAL_MODE =
|
||||||
ImmutableDiffBasedSubStorageConfiguration.DiffBasedUnstable.builder()
|
ImmutablePathBasedExtraStorageConfiguration.PathBasedUnstable.builder()
|
||||||
.fullFlatDbEnabled(false)
|
.fullFlatDbEnabled(false)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
DiffBasedSubStorageConfiguration.DiffBasedUnstable DISABLED =
|
PathBasedExtraStorageConfiguration.PathBasedUnstable DISABLED =
|
||||||
ImmutableDiffBasedSubStorageConfiguration.DiffBasedUnstable.builder()
|
ImmutablePathBasedExtraStorageConfiguration.PathBasedUnstable.builder()
|
||||||
.fullFlatDbEnabled(false)
|
.fullFlatDbEnabled(false)
|
||||||
.codeStoredByCodeHashEnabled(false)
|
.codeStoredByCodeHashEnabled(false)
|
||||||
.isParallelTxProcessingEnabled(false)
|
.isParallelTxProcessingEnabled(false)
|
||||||
@@ -19,7 +19,7 @@ import org.hyperledger.besu.datatypes.Hash;
|
|||||||
import org.hyperledger.besu.ethereum.core.BlockHeader;
|
import org.hyperledger.besu.ethereum.core.BlockHeader;
|
||||||
import org.hyperledger.besu.ethereum.core.MutableWorldState;
|
import org.hyperledger.besu.ethereum.core.MutableWorldState;
|
||||||
import org.hyperledger.besu.ethereum.proof.WorldStateProof;
|
import org.hyperledger.besu.ethereum.proof.WorldStateProof;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.common.provider.WorldStateQueryParams;
|
import org.hyperledger.besu.ethereum.trie.pathbased.common.provider.WorldStateQueryParams;
|
||||||
import org.hyperledger.besu.evm.worldstate.WorldState;
|
import org.hyperledger.besu.evm.worldstate.WorldState;
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
|
|||||||
@@ -15,8 +15,8 @@
|
|||||||
package org.hyperledger.besu.ethereum.worldstate;
|
package org.hyperledger.besu.ethereum.worldstate;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
|
|
||||||
import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage;
|
||||||
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.plugin.services.storage.DataStorageFormat;
|
import org.hyperledger.besu.plugin.services.storage.DataStorageFormat;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|||||||
@@ -27,12 +27,12 @@ import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStoragePrefixedKey
|
|||||||
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProvider;
|
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProvider;
|
||||||
import org.hyperledger.besu.ethereum.storage.keyvalue.VariablesKeyValueStorage;
|
import org.hyperledger.besu.ethereum.storage.keyvalue.VariablesKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStatePreimageKeyValueStorage;
|
import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStatePreimageKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.BonsaiWorldStateProvider;
|
|
||||||
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.forest.ForestWorldStateArchive;
|
import org.hyperledger.besu.ethereum.trie.forest.ForestWorldStateArchive;
|
||||||
import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.trie.forest.worldview.ForestMutableWorldState;
|
import org.hyperledger.besu.ethereum.trie.forest.worldview.ForestMutableWorldState;
|
||||||
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.BonsaiWorldStateProvider;
|
||||||
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.cache.BonsaiCachedMerkleTrieLoader;
|
||||||
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
|
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorageCoordinator;
|
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorageCoordinator;
|
||||||
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import org.hyperledger.besu.datatypes.Wei;
|
|||||||
import org.hyperledger.besu.ethereum.rlp.RLP;
|
import org.hyperledger.besu.ethereum.rlp.RLP;
|
||||||
import org.hyperledger.besu.ethereum.trie.MerkleTrie;
|
import org.hyperledger.besu.ethereum.trie.MerkleTrie;
|
||||||
import org.hyperledger.besu.ethereum.trie.common.PmtStateTrieAccountValue;
|
import org.hyperledger.besu.ethereum.trie.common.PmtStateTrieAccountValue;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie;
|
import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.WorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.worldstate.WorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorageCoordinator;
|
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorageCoordinator;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
package org.hyperledger.besu.ethereum;
|
package org.hyperledger.besu.ethereum;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.WorldStateConfig.createStatefulConfigWithTrie;
|
import static org.hyperledger.besu.ethereum.trie.pathbased.common.worldview.WorldStateConfig.createStatefulConfigWithTrie;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
@@ -44,9 +44,9 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
|
|||||||
import org.hyperledger.besu.ethereum.mainnet.blockhash.FrontierBlockHashProcessor;
|
import org.hyperledger.besu.ethereum.mainnet.blockhash.FrontierBlockHashProcessor;
|
||||||
import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket;
|
import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket;
|
||||||
import org.hyperledger.besu.ethereum.storage.StorageProvider;
|
import org.hyperledger.besu.ethereum.storage.StorageProvider;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.BonsaiWorldStateProvider;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.BonsaiWorldStateProvider;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
|
||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.worldview.BonsaiWorldState;
|
import org.hyperledger.besu.ethereum.trie.pathbased.bonsai.worldview.BonsaiWorldState;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
|
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
|
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorageCoordinator;
|
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorageCoordinator;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user