Skip to content

Commit

Permalink
Add WIP comments
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Dudley <[email protected]>
  • Loading branch information
siladu committed Oct 10, 2023
1 parent 8142eb6 commit e197c5c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,14 @@ public void run() {
out.println("Subcommand only works with Bonsai");
}

// KeyValueStorage trieLogStorage =
// KeyValueStorage trieLogStorage =
//
// besuController.getStorageProvider().getStorageBySegmentIdentifier(KeyValueSegmentIdentifier.TRIE_LOG_STORAGE);
// Optional<byte[]> bytes =
// trieLogStorage.get(Bytes.fromHexString(targetBlockHash.toString()).toArrayUnsafe());
// LOG.atInfo().setMessage("result: {}")
// .addArgument(HexFormat.of().formatHex(bytes.orElse(new byte[0])))
// .log();
// Optional<byte[]> bytes =
// trieLogStorage.get(Bytes.fromHexString(targetBlockHash.toString()).toArrayUnsafe());
// LOG.atInfo().setMessage("result: {}")
// .addArgument(HexFormat.of().formatHex(bytes.orElse(new byte[0])))
// .log();
} catch (final Exception e) {
LOG.error("TODO SLD", e);
spec.commandLine().usage(System.out);
Expand Down Expand Up @@ -415,7 +416,7 @@ public void run() {
Hash hash = Hash.wrap(Bytes32.wrap(hashAsBytes));

final Optional<BlockHeader> header = blockchain.getBlockHeader(hash);
if (header.isEmpty()) {
if (header.isEmpty()) { // TODO SLD what if we're still producing this block?
// Orphaned trie logs are neither in the canonical blockchain nor forks.
// Likely created during block production
recordResult(trieLogStorage.tryDelete(hashAsBytes), prunedCount, hash);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ public boolean isWorldStateAvailable(final Hash rootHash, final Hash blockHash)
|| worldStateStorage.isWorldStateAvailable(rootHash, blockHash);
}

// TODO SLD protection against pruned trie logs when rolling back/forward etc so we're not relying
// on 512 max layers config.

// TODO SLD during reorg, prune trie logs, then another reorg -> roll forward - could be a problem
// with roll forward?

@Override
public Optional<MutableWorldState> getMutable(
final BlockHeader blockHeader, final boolean shouldPersistState) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ public long getMaxLayersToLoad() {

@Override
public Optional<TrieLog> getTrieLogLayer(final Hash blockHash) {
// TODO SLD check CACHE1 first?
return rootWorldStateStorage.getTrieLog(blockHash).map(trieLogFactory::deserialize);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@ public void persist(final BlockHeader blockHeader) {
verifyWorldStateRoot(newWorldStateRootHash, blockHeader);
saveTrieLog =
() -> {
// TODO SLD if isFrozen pushTo CACHE1 else persist ? To avoid persisting when
// producing block (cache to keep optimisation between build and newPayload import)
trieLogManager.saveTrieLog(localCopy, newWorldStateRootHash, blockHeader, this);
// not save a frozen state in the cache
if (!isFrozen) {
Expand Down

0 comments on commit e197c5c

Please sign in to comment.