Signed-off-by: Karim Taam <karim.t2am@gmail.com>
pull/6209/head
Karim Taam 11 months ago
parent ccdb980692
commit 41fc466cd3
  1. 4
      besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/BackupState.java
  2. 2
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/worldview/BonsaiWorldState.java
  3. 4
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/forest/pruner/Pruner.java
  4. 3
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/WorldStateKeyValueStorage.java
  5. 2
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/WorldStateStorageCoordinator.java
  6. 3
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/LoadLocalDataStep.java
  7. 1
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/AccountTrieNodeHealingRequest.java
  8. 1
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/StorageTrieNodeHealingRequest.java
  9. 1
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/TrieNodeHealingRequest.java
  10. 3
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/AccountHealingTrackingTest.java
  11. 9
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/StorageTrieNodeHealingRequestTest.java
  12. 2
      ethereum/rlp/src/main/java/org/hyperledger/besu/ethereum/rlp/RLPOutput.java

@ -81,7 +81,7 @@ public class BackupState implements Runnable {
final BesuController besuController = createBesuController(); final BesuController besuController = createBesuController();
final MutableBlockchain blockchain = besuController.getProtocolContext().getBlockchain(); final MutableBlockchain blockchain = besuController.getProtocolContext().getBlockchain();
final ForestWorldStateKeyValueStorage worldStateKeyValueStorage = final ForestWorldStateKeyValueStorage forestWorldStateKeyValueStorage =
((ForestWorldStateArchive) besuController.getProtocolContext().getWorldStateArchive()) ((ForestWorldStateArchive) besuController.getProtocolContext().getWorldStateArchive())
.getWorldStateStorage(); .getWorldStateStorage();
final EthScheduler scheduler = new EthScheduler(1, 1, 1, 1, new NoOpMetricsSystem()); final EthScheduler scheduler = new EthScheduler(1, 1, 1, 1, new NoOpMetricsSystem());
@ -93,7 +93,7 @@ public class BackupState implements Runnable {
blockchain, blockchain,
backupDir.toPath(), backupDir.toPath(),
scheduler, scheduler,
worldStateKeyValueStorage); forestWorldStateKeyValueStorage);
final BackupStatus status = backup.requestBackup(targetBlock, compress, Optional.empty()); final BackupStatus status = backup.requestBackup(targetBlock, compress, Optional.empty());
final double refValue = Math.pow(2, 256) / 100.0d; final double refValue = Math.pow(2, 256) / 100.0d;

@ -557,7 +557,7 @@ public class BonsaiWorldState
return worldStateKeyValueStorage.getAccountStateTrieNode(location, nodeHash); return worldStateKeyValueStorage.getAccountStateTrieNode(location, nodeHash);
} }
protected void writeTrieNode( private void writeTrieNode(
final SegmentIdentifier segmentId, final SegmentIdentifier segmentId,
final SegmentedKeyValueStorageTransaction tx, final SegmentedKeyValueStorageTransaction tx,
final Bytes location, final Bytes location,

@ -179,11 +179,11 @@ public class Pruner {
} }
} }
public PruningPhase getPruningPhase() { PruningPhase getPruningPhase() {
return pruningPhase.get(); return pruningPhase.get();
} }
public enum PruningPhase { enum PruningPhase {
IDLE, IDLE,
MARK_BLOCK_CONFIRMATIONS_AWAITING, MARK_BLOCK_CONFIRMATIONS_AWAITING,
MARKING, MARKING,

@ -1,5 +1,5 @@
/* /*
* Copyright ConsenSys AG. * Copyright Hyperledger Besu Contributors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at * the License. You may obtain a copy of the License at
@ -11,7 +11,6 @@
* specific language governing permissions and limitations under the License. * specific language governing permissions and limitations under the License.
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*
*/ */
package org.hyperledger.besu.ethereum.worldstate; package org.hyperledger.besu.ethereum.worldstate;

@ -1,5 +1,5 @@
/* /*
* Copyright ConsenSys AG. * Copyright Hyperledger Besu Contributors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at * the License. You may obtain a copy of the License at

@ -69,8 +69,7 @@ public class LoadLocalDataStep {
// check if node is already stored in the worldstate // check if node is already stored in the worldstate
try { try {
if (snapSyncState.hasPivotBlockHeader()) { if (snapSyncState.hasPivotBlockHeader()) {
Optional<Bytes> existingData = Optional<Bytes> existingData = request.getExistingData(worldStateStorageCoordinator);
request.getExistingData(downloadState, worldStateStorageCoordinator);
if (existingData.isPresent()) { if (existingData.isPresent()) {
existingNodeCounter.inc(); existingNodeCounter.inc();
request.setData(existingData.get()); request.setData(existingData.get());

@ -77,7 +77,6 @@ public class AccountTrieNodeHealingRequest extends TrieNodeHealingRequest {
@Override @Override
public Optional<Bytes> getExistingData( public Optional<Bytes> getExistingData(
final SnapWorldDownloadState downloadState,
final WorldStateStorageCoordinator worldStateStorageCoordinator) { final WorldStateStorageCoordinator worldStateStorageCoordinator) {
return worldStateStorageCoordinator return worldStateStorageCoordinator
.getAccountStateTrieNode(getLocation(), getNodeHash()) .getAccountStateTrieNode(getLocation(), getNodeHash())

@ -64,7 +64,6 @@ public class StorageTrieNodeHealingRequest extends TrieNodeHealingRequest {
@Override @Override
public Optional<Bytes> getExistingData( public Optional<Bytes> getExistingData(
final SnapWorldDownloadState downloadState,
final WorldStateStorageCoordinator worldStateStorageCoordinator) { final WorldStateStorageCoordinator worldStateStorageCoordinator) {
return worldStateStorageCoordinator.getAccountStorageTrieNode( return worldStateStorageCoordinator.getAccountStorageTrieNode(
getAccountHash(), getLocation(), getNodeHash()); getAccountHash(), getLocation(), getNodeHash());

@ -181,7 +181,6 @@ public abstract class TrieNodeHealingRequest extends SnapDataRequest
} }
public abstract Optional<Bytes> getExistingData( public abstract Optional<Bytes> getExistingData(
final SnapWorldDownloadState downloadState,
final WorldStateStorageCoordinator worldStateStorageCoordinator); final WorldStateStorageCoordinator worldStateStorageCoordinator);
public abstract List<Bytes> getTrieNodePath(); public abstract List<Bytes> getTrieNodePath();

@ -219,8 +219,7 @@ public class AccountHealingTrackingTest {
accountHash, accountHash,
Hash.wrap(accountStateTrie.getRootHash()), Hash.wrap(accountStateTrie.getRootHash()),
Bytes.EMPTY); Bytes.EMPTY);
storageTrieNodeHealingRequest.getExistingData( storageTrieNodeHealingRequest.getExistingData(worldStateStorageCoordinator);
snapWorldDownloadState, worldStateStorageCoordinator);
verify(snapWorldDownloadState, never()).addAccountToHealingList(any(Bytes.class)); verify(snapWorldDownloadState, never()).addAccountToHealingList(any(Bytes.class));
} }
} }

@ -18,7 +18,6 @@ import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider;
import org.hyperledger.besu.ethereum.core.TrieGenerator; import org.hyperledger.besu.ethereum.core.TrieGenerator;
import org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapWorldDownloadState;
import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.storage.StorageProvider; import org.hyperledger.besu.ethereum.storage.StorageProvider;
import org.hyperledger.besu.ethereum.trie.MerkleTrie; import org.hyperledger.besu.ethereum.trie.MerkleTrie;
@ -42,13 +41,11 @@ import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.ArgumentsProvider; import org.junit.jupiter.params.provider.ArgumentsProvider;
import org.junit.jupiter.params.provider.ArgumentsSource; import org.junit.jupiter.params.provider.ArgumentsSource;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.junit.jupiter.MockitoExtension;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
class StorageTrieNodeHealingRequestTest { class StorageTrieNodeHealingRequestTest {
@Mock private SnapWorldDownloadState downloadState;
final List<Address> accounts = final List<Address> accounts =
List.of( List.of(
Address.fromHexString("0xdeadbeef"), Address.fromHexString("0xdeadbeef"),
@ -102,8 +99,7 @@ class StorageTrieNodeHealingRequestTest {
new StorageTrieNodeHealingRequest( new StorageTrieNodeHealingRequest(
account0StorageRoot, account0Hash, Hash.EMPTY, Bytes.EMPTY); account0StorageRoot, account0Hash, Hash.EMPTY, Bytes.EMPTY);
Assertions.assertThat(request.getExistingData(downloadState, worldStateStorageCoordinator)) Assertions.assertThat(request.getExistingData(worldStateStorageCoordinator)).isPresent();
.isPresent();
} }
@ParameterizedTest @ParameterizedTest
@ -113,7 +109,6 @@ class StorageTrieNodeHealingRequestTest {
final StorageTrieNodeHealingRequest request = final StorageTrieNodeHealingRequest request =
new StorageTrieNodeHealingRequest(Hash.EMPTY, account0Hash, Hash.EMPTY, Bytes.EMPTY); new StorageTrieNodeHealingRequest(Hash.EMPTY, account0Hash, Hash.EMPTY, Bytes.EMPTY);
Assertions.assertThat(request.getExistingData(downloadState, worldStateStorageCoordinator)) Assertions.assertThat(request.getExistingData(worldStateStorageCoordinator)).isEmpty();
.isEmpty();
} }
} }

@ -92,7 +92,7 @@ public interface RLPOutput {
/** /**
* Writes a RLP "null", that is an empty value. * Writes a RLP "null", that is an empty value.
* *
* <p>This is a shortcut for writeUInt256Scalar{@code writeBytes(Bytes.EMPTY)}. * <p>This is a shortcut for {@code writeBytes(Bytes.EMPTY)}.
*/ */
default void writeNull() { default void writeNull() {
writeBytes(Bytes.EMPTY); writeBytes(Bytes.EMPTY);

Loading…
Cancel
Save