Skip to content

Commit

Permalink
rename --use-cached-genesis-state-hash to --genesis-state-hash-cache-…
Browse files Browse the repository at this point in the history
…enabled

Signed-off-by: lyfsn <dev.wangyu@proton.me>
  • Loading branch information
lyfsn committed Mar 28, 2024
1 parent cb7635e commit 08f8132
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 13 deletions.
6 changes: 3 additions & 3 deletions besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,9 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
private final File genesisFile = null;

@Option(
names = {"--use-cached-genesis-state-hash"},
names = {"--genesis-state-hash-cache-enabled"},
description = "Use genesis state hash from data on startup if specified")
private final Boolean useCachedGenesisStateHash = false;
private final Boolean genesisStateHashCacheEnabled = false;

@Option(
names = "--identity",
Expand Down Expand Up @@ -1861,7 +1861,7 @@ public BesuControllerBuilder getControllerBuilder() {
.randomPeerPriority(p2PDiscoveryOptionGroup.randomPeerPriority)
.chainPruningConfiguration(unstableChainPruningOptions.toDomainObject())
.cacheLastBlocks(numberOfblocksToCache)
.useCachedGenesisStateHash(useCachedGenesisStateHash);
.genesisStateHashCacheEnabled(genesisStateHashCacheEnabled);
}

private JsonRpcConfiguration createEngineJsonRpcConfiguration(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
.orElseThrow();

/** The is genesis state hash from data. */
protected boolean useCachedGenesisStateHash;
protected boolean genesisStateHashCacheEnabled;

/** The Sync config. */
protected SynchronizerConfiguration syncConfig;
Expand Down Expand Up @@ -230,11 +230,12 @@ public BesuControllerBuilder genesisConfigFile(final GenesisConfigFile genesisCo
/**
* Genesis state hash from data besu controller builder.
*
* @param useCachedGenesisStateHash the is genesis state hash from data
* @param genesisStateHashCacheEnabled the is genesis state hash from data
* @return the besu controller builder
*/
public BesuControllerBuilder useCachedGenesisStateHash(final Boolean useCachedGenesisStateHash) {
this.useCachedGenesisStateHash = useCachedGenesisStateHash;
public BesuControllerBuilder genesisStateHashCacheEnabled(
final Boolean genesisStateHashCacheEnabled) {
this.genesisStateHashCacheEnabled = genesisStateHashCacheEnabled;
return this;
}

Expand Down Expand Up @@ -574,7 +575,7 @@ public BesuController build() {
final VariablesStorage variablesStorage = storageProvider.createVariablesStorage();

Optional<Hash> genesisStateHash = Optional.empty();
if (variablesStorage != null && this.useCachedGenesisStateHash) {
if (variablesStorage != null && this.genesisStateHashCacheEnabled) {
genesisStateHash = variablesStorage.getGenesisStateHash();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2378,7 +2378,7 @@ public void cacheLastBlocksOptionShouldWork() {

@Test
public void useCachedGenesisStateHashShouldWork() {
parseCommand("--use-cached-genesis-state-hash");
parseCommand("--genesis-state-hash-cache-enabled");

final ArgumentCaptor<EthNetworkConfig> networkArg =
ArgumentCaptor.forClass(EthNetworkConfig.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@ public void initMocks() throws Exception {
when(mockControllerBuilder.besuComponent(any(BesuComponent.class)))
.thenReturn(mockControllerBuilder);
when(mockControllerBuilder.cacheLastBlocks(any())).thenReturn(mockControllerBuilder);
when(mockControllerBuilder.useCachedGenesisStateHash(any())).thenReturn(mockControllerBuilder);
when(mockControllerBuilder.genesisStateHashCacheEnabled(any()))
.thenReturn(mockControllerBuilder);

// doReturn used because of generic BesuController
doReturn(mockController).when(mockControllerBuilder).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public void shouldNotCacheGenesisStateHashFirstBuild() {
when(storageProvider.createWorldStateStorageCoordinator(dataStorageConfiguration))
.thenReturn(new WorldStateStorageCoordinator(bonsaiWorldStateStorage));
besuControllerBuilder.dataStorageConfiguration(dataStorageConfiguration);
besuControllerBuilder.useCachedGenesisStateHash(true);
besuControllerBuilder.genesisStateHashCacheEnabled(true);

VariablesStorage mockStorage = mock(VariablesStorage.class);
when(storageProvider.createVariablesStorage()).thenReturn(mockStorage);
Expand Down Expand Up @@ -269,7 +269,7 @@ public void shouldCacheGenesisStateHashSecondBuild() {
when(storageProvider.createWorldStateStorageCoordinator(dataStorageConfiguration))
.thenReturn(new WorldStateStorageCoordinator(bonsaiWorldStateStorage));
besuControllerBuilder.dataStorageConfiguration(dataStorageConfiguration);
besuControllerBuilder.useCachedGenesisStateHash(true);
besuControllerBuilder.genesisStateHashCacheEnabled(true);

VariablesStorage mockStorage = mock(VariablesStorage.class);
when(storageProvider.createVariablesStorage()).thenReturn(mockStorage);
Expand Down
2 changes: 1 addition & 1 deletion besu/src/test/resources/everything_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ discovery-dns-url="enrtree://AM5FCQLWIZX2QFPNJAP7VUERCCRNGRHWZG3YYHIUV7BVDQ5FDPR
# chain
network="MAINNET"
genesis-file="~/genesis.json"
use-cached-genesis-state-hash=false
genesis-state-hash-cache-enabled=false
sync-mode="fast"
fast-sync-min-peers=5
network-id=303
Expand Down

0 comments on commit 08f8132

Please sign in to comment.