Skip to content

Commit

Permalink
fix post-rebase
Browse files Browse the repository at this point in the history
Signed-off-by: garyschulte <garyschulte@gmail.com>
  • Loading branch information
garyschulte committed Feb 23, 2024
1 parent b866479 commit eaaaa49
Show file tree
Hide file tree
Showing 22 changed files with 297 additions and 204 deletions.
37 changes: 0 additions & 37 deletions besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2607,43 +2607,6 @@ public Boolean getVersionCompatibilityProtection() {
return versionCompatibilityProtection;
}

private class BesuCommandConfigurationService implements BesuConfiguration {

@Override
public Optional<String> getRpcHttpHost() {
return jsonRpcHttpOptions.isRpcHttpEnabled()
? Optional.of(jsonRpcHttpOptions.getRpcHttpHost())
: Optional.empty();
}

@Override
public Optional<Integer> getRpcHttpPort() {
return jsonRpcHttpOptions.isRpcHttpEnabled()
? Optional.of(jsonRpcHttpOptions.getRpcHttpPort())
: Optional.empty();
}

@Override
public Path getStoragePath() {
return dataDir().resolve(DATABASE_PATH);
}

@Override
public Path getDataPath() {
return dataDir();
}

@Override
public int getDatabaseVersion() {
return dataStorageOptions.toDomainObject().getDataStorageFormat().getDatabaseVersion();
}

@Override
public Wei getMinGasPrice() {
return null;
}
}

private void instantiateSignatureAlgorithmFactory() {
if (SignatureAlgorithmFactory.isInstanceSet()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public class ChainPruningOptions implements CLIOptions<ChainPrunerConfiguration>
private static final String CHAIN_PRUNING_FREQUENCY_FLAG = "--Xchain-pruning-frequency";
/** The constant DEFAULT_CHAIN_DATA_PRUNING_MIN_BLOCKS_RETAINED. */
public static final long DEFAULT_CHAIN_DATA_PRUNING_MIN_BLOCKS_RETAINED = 7200;
// TODO find a way to avoid pruning blocks after or equal pivot block during initial sync

/**
* The "CHAIN_DATA_PRUNING_MIN_BLOCKS_RETAINED_LIMIT" field sets the minimum limit for the
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ public BesuConfigurationImpl init(
return this;
}

public BesuConfigurationImpl withMiningParameters(MiningParameters miningParameters) {
public BesuConfigurationImpl withMiningParameters(final MiningParameters miningParameters) {
this.miningParameters = miningParameters;
return this;
}

public BesuConfigurationImpl withRpcHttpHost(String rpcHttpHost) {
public BesuConfigurationImpl withRpcHttpHost(final String rpcHttpHost) {
this.rpcHttpHost = Optional.of(rpcHttpHost);
return this;
}

public BesuConfigurationImpl withRpcHttpPort(int rpcHttpPort) {
public BesuConfigurationImpl withRpcHttpPort(final int rpcHttpPort) {
this.rpcHttpPort = Optional.of(rpcHttpPort);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ public SynchronizationServiceImpl(
this.protocolContext = protocolContext;
this.protocolSchedule = protocolSchedule;
this.syncState = syncState;
this.worldStateArchive = Optional.ofNullable(worldStateArchive)
.filter(z -> z instanceof BonsaiWorldStateProvider)
.map(BonsaiWorldStateProvider.class::cast);
this.worldStateArchive =
Optional.ofNullable(worldStateArchive)
.filter(z -> z instanceof BonsaiWorldStateProvider)
.map(BonsaiWorldStateProvider.class::cast);
}

@Override
Expand All @@ -66,6 +67,8 @@ public void fireNewUnverifiedForkchoiceEvent(
final MergeContext mergeContext = protocolContext.getConsensusContext(MergeContext.class);
if (mergeContext != null) {
mergeContext.fireNewUnverifiedForkchoiceEvent(head, safeBlock, finalizedBlock);
protocolContext.getBlockchain().setFinalized(finalizedBlock);
protocolContext.getBlockchain().setSafeBlock(safeBlock);
} else {
LOG.atWarn()
.setMessage(
Expand Down Expand Up @@ -97,9 +100,7 @@ public boolean setHeadUnsafe(final BlockHeader blockHeader, final BlockBody bloc

final MutableBlockchain blockchain = protocolContext.getBlockchain();

if (worldStateArchive
.flatMap(archive -> archive.getMutable(coreHeader, true))
.isPresent()) {
if (worldStateArchive.flatMap(archive -> archive.getMutable(coreHeader, true)).isPresent()) {
if (coreHeader.getParentHash().equals(blockchain.getChainHeadHash())) {
LOG.atDebug()
.setMessage(
Expand Down
4 changes: 3 additions & 1 deletion besu/src/test/java/org/hyperledger/besu/RunnerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,9 @@ private StorageProvider createKeyValueStorageProvider(
final DataStorageConfiguration dataStorageConfiguration,
final MiningParameters miningParameters) {
final var besuConfiguration = new BesuConfigurationImpl();
besuConfiguration.init(dataDir, dbDir, dataStorageConfiguration, miningParameters);
besuConfiguration
.init(dataDir, dbDir, dataStorageConfiguration)
.withMiningParameters(miningParameters);
return new KeyValueStorageProviderBuilder()
.withStorageFactory(
new RocksDBKeyValueStorageFactory(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,9 @@ private boolean blockShouldBeProcessed(
private void appendBlockHelper(
final BlockWithReceipts blockWithReceipts, final boolean storeOnly) {

// TODO: before merging fleet-mode, re-enable this check
/*if (!blockShouldBeProcessed(blockWithReceipts.getBlock(), blockWithReceipts.getReceipts())) {
if (!blockShouldBeProcessed(blockWithReceipts.getBlock(), blockWithReceipts.getReceipts())) {
return;
}*/
}

final Block block = blockWithReceipts.getBlock();
final List<TransactionReceipt> receipts = blockWithReceipts.getReceipts();
Expand Down Expand Up @@ -471,7 +470,8 @@ public synchronized void unsafeSetChainHead(
updater.commit();
}

private Difficulty calculateTotalDifficulty(final BlockHeader blockHeader) {
@Override
public Difficulty calculateTotalDifficulty(final BlockHeader blockHeader) {
if (blockHeader.getNumber() == BlockHeader.GENESIS_BLOCK_NUMBER) {
return blockHeader.getDifficulty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ void unsafeImportBlock(

void unsafeSetChainHead(final BlockHeader blockHeader, final Difficulty totalDifficulty);

Difficulty calculateTotalDifficulty(BlockHeader blockHeader);

/**
* Rolls back the canonical chainhead to the specified block number.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,11 @@ public void onClearTrieLog() {
this.cachedWorldStatesByHash.clear();
}

@Override
public void onClearTrie() {
this.cachedWorldStatesByHash.clear();
}

@Override
public void onCloseStorage() {
this.cachedWorldStatesByHash.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
package org.hyperledger.besu.ethereum.trie.bonsai.cache;

import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.bonsai.worldview.BonsaiWorldStateConfig;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.bonsai.worldview.BonsaiWorldState;
import org.hyperledger.besu.ethereum.trie.bonsai.worldview.BonsaiWorldStateConfig;

import java.util.Optional;
import java.util.function.Function;
Expand Down
Loading

0 comments on commit eaaaa49

Please sign in to comment.