Skip to content

Commit

Permalink
trigger a BWS if we do not have a valid worldstate available during fcU
Browse files Browse the repository at this point in the history
raise log rolling failure loglevel to error from debug

Signed-off-by: garyschulte <garyschulte@gmail.com>
  • Loading branch information
garyschulte committed Dec 21, 2023
1 parent 47364bf commit 928c7f5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -492,12 +492,21 @@ private boolean canRetryBlockCreation(final Throwable throwable) {
@Override
public Optional<BlockHeader> getOrSyncHeadByHash(final Hash headHash, final Hash finalizedHash) {
final var chain = protocolContext.getBlockchain();
final var maybeHeadHeader = chain.getBlockHeader(headHash);

if (maybeHeadHeader.isPresent()) {
final var maybeHead =
chain
.getBlockHeader(headHash)
// ensure we have the corresponding worldstate also:
.filter(
headHeader ->
protocolContext
.getWorldStateArchive()
.isWorldStateAvailable(
headHeader.getStateRoot(), headHeader.getBlockHash()));

if (maybeHead.isPresent()) {
LOG.atDebug()
.setMessage("BlockHeader {} is already present in blockchain")
.addArgument(maybeHeadHeader.get()::toLogString)
.setMessage("BlockHeader and world state for {} is already present")
.addArgument(maybeHead.get()::toLogString)
.log();
} else {
LOG.atDebug()
Expand All @@ -509,7 +518,7 @@ public Optional<BlockHeader> getOrSyncHeadByHash(final Hash headHash, final Hash
.syncBackwardsUntil(headHash)
.thenRun(() -> updateFinalized(finalizedHash));
}
return maybeHeadHeader;
return maybeHead;
}

private void updateFinalized(final Hash finalizedHash) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ Optional<MutableWorldState> rollMutableStateToBlockHash(
} catch (final Exception e) {
// if we fail we must clean up the updater
bonsaiUpdater.reset();
LOG.debug(
LOG.error(
"State rolling failed on "
+ mutableState.getWorldStateStorage().getClass().getSimpleName()
+ " for block hash "
Expand Down

0 comments on commit 928c7f5

Please sign in to comment.