Bws internal error fix (#6806)

Signed-off-by: Jason Frame <jason.frame@consensys.net>
pull/6218/merge
Jason Frame 8 months ago committed by GitHub
parent 9ae52a97cd
commit a7b10dbece
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinator.java
  2. 12
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/BackwardSyncContext.java
  3. 14
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/BackwardSyncContextTest.java

@ -501,10 +501,6 @@ public class MergeCoordinator implements MergeMiningCoordinator, BadChainListene
.addArgument(maybeHeadHeader.get()::toLogString)
.log();
} else {
LOG.atDebug()
.setMessage("Appending new head block hash {} to backward sync")
.addArgument(headHash::toHexString)
.log();
backwardSyncContext.maybeUpdateTargetHeight(headHash);
backwardSyncContext
.syncBackwardsUntil(headHash)

@ -125,11 +125,15 @@ public class BackwardSyncContext {
}
public synchronized CompletableFuture<Void> syncBackwardsUntil(final Hash newBlockHash) {
if (!isTrusted(newBlockHash)) {
backwardChain.addNewHash(newBlockHash);
}
if (isReady()) {
if (!isTrusted(newBlockHash)) {
LOG.atDebug()
.setMessage("Appending new head block hash {} to backward sync")
.addArgument(newBlockHash::toHexString)
.log();
backwardChain.addNewHash(newBlockHash);
}
final Status status = getOrStartSyncSession();
backwardChain
.getBlock(newBlockHash)

@ -231,6 +231,20 @@ public class BackwardSyncContextTest {
assertThat(localBlockchain.getChainHeadBlock()).isEqualTo(remoteBlockchain.getChainHeadBlock());
}
@Test
public void shouldNotSyncUntilHashWhenNotInSync() {
doReturn(false).when(context).isReady();
final Hash hash = getBlockByNumber(REMOTE_HEIGHT).getHash();
final CompletableFuture<Void> future = context.syncBackwardsUntil(hash);
respondUntilFutureIsDone(future);
assertThatThrownBy(future::get)
.isInstanceOf(ExecutionException.class)
.hasMessageContaining("Backward sync is not ready");
assertThat(backwardChain.getFirstHashToAppend()).isEmpty();
}
@Test
public void shouldSyncUntilRemoteBranch() throws Exception {

Loading…
Cancel
Save