Skip to content

Commit

Permalink
Revert "Healing Mechanism for Flat Database in Besu (hyperledger#5319)"
Browse files Browse the repository at this point in the history
This reverts commit 180c751.
  • Loading branch information
pinges committed Jun 19, 2023
1 parent a7106e5 commit 42dba69
Show file tree
Hide file tree
Showing 72 changed files with 612 additions and 3,129 deletions.
2 changes: 0 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ and in case a rollback is needed, before installing a previous version, the migr
- Tidy DEBUG logs by moving engine API full logging to TRACE [#5529](https://github.com/hyperledger/besu/pull/5529)
- Remove PoW validation if merge is enabled as it is not needed anymore [#5538](https://github.com/hyperledger/besu/pull/5538)
- Use BlobDB for blockchain storage to reduce initial sync time and write amplification [#5475](https://github.com/hyperledger/besu/pull/5475)
- Update to Tuweni 2.4.1. [#5513](https://github.com/hyperledger/besu/pull/5513)
- Add healing flat db mechanism with experimental CLI options `--Xsnapsync-synchronizer-flat-db-healing-enabled=true` [#5319](https://github.com/hyperledger/besu/pull/5319)

### Bug Fixes
- Fix backwards sync bug where chain is rolled back too far, especially when restarting Nimbus [#5497](https://github.com/hyperledger/besu/pull/5497)
Expand Down
8 changes: 0 additions & 8 deletions besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2168,14 +2168,6 @@ private void issueOptionWarnings() {
SyncMode.X_CHECKPOINT.equals(getDefaultSyncModeIfNotSet()),
singletonList("--Xcheckpoint-post-merge-enabled"));

CommandLineUtils.failIfOptionDoesntMeetRequirement(
commandLine,
"--Xsnapsync-synchronizer-flat option can only be used when -Xsnapsync-synchronizer-flat-db-healing-enabled is true",
unstableSynchronizerOptions.isSnapsyncFlatDbHealingEnabled(),
asList(
"--Xsnapsync-synchronizer-flat-account-healed-count-per-request",
"--Xsnapsync-synchronizer-flat-slot-healed-count-per-request"));

if (!securityModuleName.equals(DEFAULT_SECURITY_MODULE)
&& nodePrivateKeyFileOption.getNodePrivateKeyFile() != null) {
logger.warn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,6 @@ public class SynchronizerOptions implements CLIOptions<SynchronizerConfiguration
private static final String SNAP_TRIENODE_COUNT_PER_REQUEST_FLAG =
"--Xsnapsync-synchronizer-trienode-count-per-request";

private static final String SNAP_FLAT_ACCOUNT_HEALED_COUNT_PER_REQUEST_FLAG =
"--Xsnapsync-synchronizer-flat-account-healed-count-per-request";

private static final String SNAP_FLAT_STORAGE_HEALED_COUNT_PER_REQUEST_FLAG =
"--Xsnapsync-synchronizer-flat-slot-healed-count-per-request";

private static final String SNAP_FLAT_DB_HEALING_ENABLED_FLAG =
"--Xsnapsync-synchronizer-flat-db-healing-enabled";

private static final String CHECKPOINT_POST_MERGE_FLAG = "--Xcheckpoint-post-merge-enabled";

/**
Expand Down Expand Up @@ -267,7 +258,7 @@ public void parseBlockPropagationRange(final String arg) {
hidden = true,
defaultValue = "384",
paramLabel = "<INTEGER>",
description = "Snap sync storage queried per request (default: ${DEFAULT-VALUE})")
description = "Snap sync sync storage queried per request (default: ${DEFAULT-VALUE})")
private int snapsyncStorageCountPerRequest =
SnapSyncConfiguration.DEFAULT_STORAGE_COUNT_PER_REQUEST;

Expand All @@ -276,7 +267,7 @@ public void parseBlockPropagationRange(final String arg) {
hidden = true,
defaultValue = "84",
paramLabel = "<INTEGER>",
description = "Snap sync bytecode queried per request (default: ${DEFAULT-VALUE})")
description = "Snap sync sync bytecode queried per request (default: ${DEFAULT-VALUE})")
private int snapsyncBytecodeCountPerRequest =
SnapSyncConfiguration.DEFAULT_BYTECODE_COUNT_PER_REQUEST;

Expand All @@ -285,39 +276,10 @@ public void parseBlockPropagationRange(final String arg) {
hidden = true,
defaultValue = "384",
paramLabel = "<INTEGER>",
description = "Snap sync trie node queried per request (default: ${DEFAULT-VALUE})")
description = "Snap sync sync trie node queried per request (default: ${DEFAULT-VALUE})")
private int snapsyncTrieNodeCountPerRequest =
SnapSyncConfiguration.DEFAULT_TRIENODE_COUNT_PER_REQUEST;

@CommandLine.Option(
names = SNAP_FLAT_ACCOUNT_HEALED_COUNT_PER_REQUEST_FLAG,
hidden = true,
defaultValue = "128",
paramLabel = "<INTEGER>",
description =
"Snap sync flat accounts verified and healed per request (default: ${DEFAULT-VALUE})")
private int snapsyncFlatAccountHealedCountPerRequest =
SnapSyncConfiguration.DEFAULT_LOCAL_FLAT_ACCOUNT_COUNT_TO_HEAL_PER_REQUEST;

@CommandLine.Option(
names = SNAP_FLAT_STORAGE_HEALED_COUNT_PER_REQUEST_FLAG,
hidden = true,
defaultValue = "1024",
paramLabel = "<INTEGER>",
description =
"Snap sync flat slots verified and healed per request (default: ${DEFAULT-VALUE})")
private int snapsyncFlatStorageHealedCountPerRequest =
SnapSyncConfiguration.DEFAULT_LOCAL_FLAT_STORAGE_COUNT_TO_HEAL_PER_REQUEST;

@CommandLine.Option(
names = SNAP_FLAT_DB_HEALING_ENABLED_FLAG,
hidden = true,
defaultValue = "false",
paramLabel = "<Boolean>",
description = "Snap sync flat db healing enabled (default: ${DEFAULT-VALUE})")
private Boolean snapsyncFlatDbHealingEnabled =
SnapSyncConfiguration.DEFAULT_IS_FLAT_DB_HEALING_ENABLED;

@CommandLine.Option(
names = {CHECKPOINT_POST_MERGE_FLAG},
hidden = true,
Expand All @@ -336,15 +298,6 @@ public static SynchronizerOptions create() {
return new SynchronizerOptions();
}

/**
* Flag to know whether the flat db healing feature is enabled or disabled.
*
* @return true is the flat db healing is enabled
*/
public boolean isSnapsyncFlatDbHealingEnabled() {
return snapsyncFlatDbHealingEnabled;
}

/**
* Create synchronizer options from Synchronizer Configuration.
*
Expand Down Expand Up @@ -381,12 +334,6 @@ public static SynchronizerOptions fromConfig(final SynchronizerConfiguration con
config.getSnapSyncConfiguration().getBytecodeCountPerRequest();
options.snapsyncTrieNodeCountPerRequest =
config.getSnapSyncConfiguration().getTrienodeCountPerRequest();
options.snapsyncFlatAccountHealedCountPerRequest =
config.getSnapSyncConfiguration().getLocalFlatAccountCountToHealPerRequest();
options.snapsyncFlatStorageHealedCountPerRequest =
config.getSnapSyncConfiguration().getLocalFlatStorageCountToHealPerRequest();
options.snapsyncFlatDbHealingEnabled =
config.getSnapSyncConfiguration().isFlatDbHealingEnabled();
options.checkpointPostMergeSyncEnabled = config.isCheckpointPostMergeEnabled();
return options;
}
Expand Down Expand Up @@ -417,9 +364,6 @@ public SynchronizerConfiguration.Builder toDomainObject() {
.storageCountPerRequest(snapsyncStorageCountPerRequest)
.bytecodeCountPerRequest(snapsyncBytecodeCountPerRequest)
.trienodeCountPerRequest(snapsyncTrieNodeCountPerRequest)
.localFlatAccountCountToHealPerRequest(snapsyncFlatAccountHealedCountPerRequest)
.localFlatStorageCountToHealPerRequest(snapsyncFlatStorageHealedCountPerRequest)
.isFlatDbHealingEnabled(snapsyncFlatDbHealingEnabled)
.build());
builder.checkpointPostMergeEnabled(checkpointPostMergeSyncEnabled);

Expand All @@ -428,58 +372,48 @@ public SynchronizerConfiguration.Builder toDomainObject() {

@Override
public List<String> getCLIOptions() {
List<String> value =
Arrays.asList(
BLOCK_PROPAGATION_RANGE_FLAG,
OptionParser.format(blockPropagationRange),
DOWNLOADER_CHANGE_TARGET_THRESHOLD_BY_HEIGHT_FLAG,
OptionParser.format(downloaderChangeTargetThresholdByHeight),
DOWNLOADER_CHANGE_TARGET_THRESHOLD_BY_TD_FLAG,
OptionParser.format(downloaderChangeTargetThresholdByTd),
DOWNLOADER_HEADER_REQUEST_SIZE_FLAG,
OptionParser.format(downloaderHeaderRequestSize),
DOWNLOADER_CHECKPOINT_TIMEOUTS_PERMITTED_FLAG,
OptionParser.format(downloaderCheckpointTimeoutsPermitted),
DOWNLOADER_CHAIN_SEGMENT_SIZE_FLAG,
OptionParser.format(downloaderChainSegmentSize),
DOWNLOADER_PARALLELISM_FLAG,
OptionParser.format(downloaderParallelism),
TRANSACTIONS_PARALLELISM_FLAG,
OptionParser.format(transactionsParallelism),
COMPUTATION_PARALLELISM_FLAG,
OptionParser.format(computationParallelism),
PIVOT_DISTANCE_FROM_HEAD_FLAG,
OptionParser.format(fastSyncPivotDistance),
FULL_VALIDATION_RATE_FLAG,
OptionParser.format(fastSyncFullValidationRate),
WORLD_STATE_HASH_COUNT_PER_REQUEST_FLAG,
OptionParser.format(worldStateHashCountPerRequest),
WORLD_STATE_REQUEST_PARALLELISM_FLAG,
OptionParser.format(worldStateRequestParallelism),
WORLD_STATE_MAX_REQUESTS_WITHOUT_PROGRESS_FLAG,
OptionParser.format(worldStateMaxRequestsWithoutProgress),
WORLD_STATE_MIN_MILLIS_BEFORE_STALLING_FLAG,
OptionParser.format(worldStateMinMillisBeforeStalling),
WORLD_STATE_TASK_CACHE_SIZE_FLAG,
OptionParser.format(worldStateTaskCacheSize),
SNAP_PIVOT_BLOCK_WINDOW_VALIDITY_FLAG,
OptionParser.format(snapsyncPivotBlockWindowValidity),
SNAP_PIVOT_BLOCK_DISTANCE_BEFORE_CACHING_FLAG,
OptionParser.format(snapsyncPivotBlockDistanceBeforeCaching),
SNAP_STORAGE_COUNT_PER_REQUEST_FLAG,
OptionParser.format(snapsyncStorageCountPerRequest),
SNAP_BYTECODE_COUNT_PER_REQUEST_FLAG,
OptionParser.format(snapsyncBytecodeCountPerRequest),
SNAP_TRIENODE_COUNT_PER_REQUEST_FLAG,
OptionParser.format(snapsyncTrieNodeCountPerRequest));
if (isSnapsyncFlatDbHealingEnabled()) {
value.addAll(
Arrays.asList(
SNAP_FLAT_ACCOUNT_HEALED_COUNT_PER_REQUEST_FLAG,
OptionParser.format(snapsyncFlatAccountHealedCountPerRequest),
SNAP_FLAT_STORAGE_HEALED_COUNT_PER_REQUEST_FLAG,
OptionParser.format(snapsyncFlatStorageHealedCountPerRequest)));
}
return value;
return Arrays.asList(
BLOCK_PROPAGATION_RANGE_FLAG,
OptionParser.format(blockPropagationRange),
DOWNLOADER_CHANGE_TARGET_THRESHOLD_BY_HEIGHT_FLAG,
OptionParser.format(downloaderChangeTargetThresholdByHeight),
DOWNLOADER_CHANGE_TARGET_THRESHOLD_BY_TD_FLAG,
OptionParser.format(downloaderChangeTargetThresholdByTd),
DOWNLOADER_HEADER_REQUEST_SIZE_FLAG,
OptionParser.format(downloaderHeaderRequestSize),
DOWNLOADER_CHECKPOINT_TIMEOUTS_PERMITTED_FLAG,
OptionParser.format(downloaderCheckpointTimeoutsPermitted),
DOWNLOADER_CHAIN_SEGMENT_SIZE_FLAG,
OptionParser.format(downloaderChainSegmentSize),
DOWNLOADER_PARALLELISM_FLAG,
OptionParser.format(downloaderParallelism),
TRANSACTIONS_PARALLELISM_FLAG,
OptionParser.format(transactionsParallelism),
COMPUTATION_PARALLELISM_FLAG,
OptionParser.format(computationParallelism),
PIVOT_DISTANCE_FROM_HEAD_FLAG,
OptionParser.format(fastSyncPivotDistance),
FULL_VALIDATION_RATE_FLAG,
OptionParser.format(fastSyncFullValidationRate),
WORLD_STATE_HASH_COUNT_PER_REQUEST_FLAG,
OptionParser.format(worldStateHashCountPerRequest),
WORLD_STATE_REQUEST_PARALLELISM_FLAG,
OptionParser.format(worldStateRequestParallelism),
WORLD_STATE_MAX_REQUESTS_WITHOUT_PROGRESS_FLAG,
OptionParser.format(worldStateMaxRequestsWithoutProgress),
WORLD_STATE_MIN_MILLIS_BEFORE_STALLING_FLAG,
OptionParser.format(worldStateMinMillisBeforeStalling),
WORLD_STATE_TASK_CACHE_SIZE_FLAG,
OptionParser.format(worldStateTaskCacheSize),
SNAP_PIVOT_BLOCK_WINDOW_VALIDITY_FLAG,
OptionParser.format(snapsyncPivotBlockWindowValidity),
SNAP_PIVOT_BLOCK_DISTANCE_BEFORE_CACHING_FLAG,
OptionParser.format(snapsyncPivotBlockDistanceBeforeCaching),
SNAP_STORAGE_COUNT_PER_REQUEST_FLAG,
OptionParser.format(snapsyncStorageCountPerRequest),
SNAP_BYTECODE_COUNT_PER_REQUEST_FLAG,
OptionParser.format(snapsyncBytecodeCountPerRequest),
SNAP_TRIENODE_COUNT_PER_REQUEST_FLAG,
OptionParser.format(snapsyncTrieNodeCountPerRequest));
}
}
26 changes: 0 additions & 26 deletions besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5725,30 +5725,4 @@ public void txpoolSaveFileAbsolutePathOutsideDataPath() throws IOException {
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}

@Test
public void snapsyncHealingOptionShouldBeDisabledByDefault() {
final TestBesuCommand besuCommand = parseCommand();
assertThat(besuCommand.unstableSynchronizerOptions.isSnapsyncFlatDbHealingEnabled()).isFalse();
}

@Test
public void snapsyncHealingOptionShouldWork() {
final TestBesuCommand besuCommand =
parseCommand("--Xsnapsync-synchronizer-flat-db-healing-enabled", "true");
assertThat(besuCommand.unstableSynchronizerOptions.isSnapsyncFlatDbHealingEnabled()).isTrue();
}

@Test
public void snapsyncForHealingFeaturesShouldFailWhenHealingIsNotEnabled() {
parseCommand("--Xsnapsync-synchronizer-flat-account-healed-count-per-request", "100");
assertThat(commandErrorOutput.toString(UTF_8))
.contains(
"--Xsnapsync-synchronizer-flat option can only be used when -Xsnapsync-synchronizer-flat-db-healing-enabled is true");

parseCommand("--Xsnapsync-synchronizer-flat-slot-healed-count-per-request", "100");
assertThat(commandErrorOutput.toString(UTF_8))
.contains(
"--Xsnapsync-synchronizer-flat option can only be used when -Xsnapsync-synchronizer-flat-db-healing-enabled is true");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,6 @@ public MutableWorldState getMutable() {
return persistedState;
}

/**
* Prepares the state healing process for a given address and location. It prepares the state
* healing, including retrieving data from storage, identifying invalid slots or nodes, removing
* account and slot from the state trie, and committing the changes. Finally, it downgrades the
* world state storage to partial flat database mode.
*/
public void prepareStateHealing(final Address address, final Bytes location) {
final Set<Bytes> keysToDelete = new HashSet<>();
final BonsaiWorldStateKeyValueStorage.BonsaiUpdater updater = worldStateStorage.updater();
Expand Down Expand Up @@ -346,8 +340,6 @@ public void prepareStateHealing(final Address address, final Bytes location) {
}
keysToDelete.forEach(bytes -> updater.removeAccountStateTrieNode(bytes, null));
updater.commit();

worldStateStorage.downgradeToPartialFlatDbMode();
}

public TrieLogManager getTrieLogManager() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ public BonsaiSnapshotWorldStateKeyValueStorage(
final KeyValueStorage trieLogStorage,
final ObservableMetricsSystem metricsSystem) {
super(
parentWorldStateStorage.flatDbMode,
parentWorldStateStorage.flatDbReaderStrategy,
accountStorage,
codeStorage,
storageStorage,
Expand Down
Loading

0 comments on commit 42dba69

Please sign in to comment.