Skip to content

Commit

Permalink
cherry-pick release of 22.4.4
Browse files Browse the repository at this point in the history
49e4fd8 -> worldstate not avail (#4069)
6aa8812 -> stateroot mismatch (#4041)
043191a -> jwt auth on websockets (#4039)
90f891b -> do not move head on exec and propose (#4013)
b5fa62c -> sync check before processing remote transactions (4035)
3baa4da -> upgrade for websockets (#4019)
5024c07 -> sepolia TTD (#4024)
5ee9be8 -> heal step in snap (#3920)
261b1e0 -> remove peer block height requirements (#3911)

Signed-off-by: garyschulte <[email protected]>
  • Loading branch information
garyschulte committed Jul 7, 2022
1 parent 68bfc99 commit 649aff1
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 132 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,119 +248,6 @@ public void updateForkChoiceShouldPersistLastFinalizedBlockHash() {
verify(mergeContext).setSafeBlock(lastFinalizedHeader);
}

@Test
public void updateForkChoiceShouldFailIfLastFinalizedNotDescendantOfPreviousFinalized() {
BlockHeader terminalHeader = terminalPowBlock();
coordinator.executeBlock(new Block(terminalHeader, BlockBody.empty()));

BlockHeader prevFinalizedHeader = nextBlockHeader(terminalHeader);
Block prevFinalizedBlock = new Block(prevFinalizedHeader, BlockBody.empty());
coordinator.executeBlock(prevFinalizedBlock);

when(mergeContext.getFinalized()).thenReturn(Optional.of(prevFinalizedHeader));

// not descendant of previous finalized block
BlockHeader lastFinalizedHeader = disjointBlockHeader(prevFinalizedHeader);
Block lastFinalizedBlock = new Block(lastFinalizedHeader, BlockBody.empty());
coordinator.executeBlock(lastFinalizedBlock);

BlockHeader headBlockHeader = nextBlockHeader(lastFinalizedHeader);
Block headBlock = new Block(headBlockHeader, BlockBody.empty());
coordinator.executeBlock(headBlock);
when(blockchain.getBlockHeader(lastFinalizedBlock.getHash()))
.thenReturn(Optional.of(lastFinalizedHeader));
when(blockchain.getBlockHeader(headBlockHeader.getHash()))
.thenReturn(Optional.of(headBlockHeader));
var res =
coordinator.updateForkChoice(
headBlockHeader,
lastFinalizedBlock.getHash(),
lastFinalizedBlock.getHash(),
Optional.empty());
assertThat(res.isValid()).isFalse();
assertThat(res.getStatus()).isEqualTo(ForkchoiceResult.Status.INVALID);

verify(blockchain, never()).setFinalized(lastFinalizedBlock.getHash());
verify(mergeContext, never()).setFinalized(lastFinalizedHeader);
verify(blockchain, never()).setSafeBlock(lastFinalizedBlock.getHash());
verify(mergeContext, never()).setSafeBlock(lastFinalizedHeader);
}

@Test
public void updateForkChoiceShouldFailIfHeadNotDescendantOfLastFinalized() {
BlockHeader terminalHeader = terminalPowBlock();
coordinator.executeBlock(new Block(terminalHeader, BlockBody.empty()));

BlockHeader prevFinalizedHeader = nextBlockHeader(terminalHeader);
Block prevFinalizedBlock = new Block(prevFinalizedHeader, BlockBody.empty());
coordinator.executeBlock(prevFinalizedBlock);

when(mergeContext.getFinalized()).thenReturn(Optional.of(prevFinalizedHeader));

BlockHeader lastFinalizedHeader = nextBlockHeader(prevFinalizedHeader);
Block lastFinalizedBlock = new Block(lastFinalizedHeader, BlockBody.empty());
coordinator.executeBlock(lastFinalizedBlock);

// not descendant of last finalized block
BlockHeader headBlockHeader = disjointBlockHeader(lastFinalizedHeader);
Block headBlock = new Block(headBlockHeader, BlockBody.empty());
coordinator.executeBlock(headBlock);
when(blockchain.getBlockHeader(lastFinalizedBlock.getHash()))
.thenReturn(Optional.of(lastFinalizedHeader));
when(blockchain.getBlockHeader(headBlockHeader.getHash()))
.thenReturn(Optional.of(headBlockHeader));
var res =
coordinator.updateForkChoice(
headBlockHeader,
lastFinalizedBlock.getHash(),
lastFinalizedBlock.getHash(),
Optional.empty());
assertThat(res.isValid()).isFalse();
assertThat(res.getStatus()).isEqualTo(ForkchoiceResult.Status.INVALID);

verify(blockchain, never()).setFinalized(lastFinalizedBlock.getHash());
verify(mergeContext, never()).setFinalized(lastFinalizedHeader);
verify(blockchain, never()).setSafeBlock(lastFinalizedBlock.getHash());
verify(mergeContext, never()).setSafeBlock(lastFinalizedHeader);
}

@Test
public void updateForkChoiceShouldFailIfFinalizedBlockNotFound() {
BlockHeader terminalHeader = terminalPowBlock();
coordinator.executeBlock(new Block(terminalHeader, BlockBody.empty()));

BlockHeader prevFinalizedHeader = nextBlockHeader(terminalHeader);
Block prevFinalizedBlock = new Block(prevFinalizedHeader, BlockBody.empty());
coordinator.executeBlock(prevFinalizedBlock);

when(mergeContext.getFinalized()).thenReturn(Optional.of(prevFinalizedHeader));

BlockHeader lastFinalizedHeader = nextBlockHeader(prevFinalizedHeader);
Block lastFinalizedBlock = new Block(lastFinalizedHeader, BlockBody.empty());
// note this block is not executed, so not known by us

BlockHeader headBlockHeader = nextBlockHeader(lastFinalizedHeader);
Block headBlock = new Block(headBlockHeader, BlockBody.empty());
coordinator.executeBlock(headBlock);
when(blockchain.getBlockHeader(lastFinalizedBlock.getHash())).thenReturn(Optional.empty());
when(blockchain.getBlockHeader(headBlockHeader.getHash()))
.thenReturn(Optional.of(headBlockHeader))
.thenReturn(Optional.of(headBlockHeader));
var res =
coordinator.updateForkChoice(
headBlockHeader,
lastFinalizedBlock.getHash(),
lastFinalizedBlock.getHash(),
Optional.empty());
assertThat(res.isValid()).isFalse();
assertThat(res.getStatus()).isEqualTo(ForkchoiceResult.Status.INVALID);

verify(blockchain, never()).setFinalized(lastFinalizedBlock.getHash());
verify(mergeContext, never()).setFinalized(lastFinalizedHeader);
verify(blockchain, never()).setSafeBlock(lastFinalizedBlock.getHash());
verify(mergeContext, never()).setSafeBlock(lastFinalizedHeader);
}

@Test
public void assertGetOrSyncForBlockAlreadyPresent() {
BlockHeader mockHeader =
Expand Down Expand Up @@ -615,24 +502,6 @@ private BlockHeader nextBlockHeader(
.buildHeader();
}

private BlockHeader disjointBlockHeader(final BlockHeader disjointFromHeader) {
Hash disjointParentHash = Hash.wrap(disjointFromHeader.getParentHash().shiftRight(1));

return headerGenerator
.difficulty(Difficulty.ZERO)
.parentHash(disjointParentHash)
.gasLimit(genesisState.getBlock().getHeader().getGasLimit())
.number(disjointFromHeader.getNumber() + 1)
.stateRoot(genesisState.getBlock().getHeader().getStateRoot())
.baseFeePerGas(
feeMarket.computeBaseFee(
genesisState.getBlock().getHeader().getNumber() + 1,
disjointFromHeader.getBaseFee().orElse(Wei.of(0x3b9aca00)),
0,
15000000l))
.buildHeader();
}

MergeCoordinator terminalAncestorMock(final long chainDepth, final boolean hasTerminalPoW) {
final Difficulty mockTTD = Difficulty.of(1000);
BlockHeaderTestFixture builder = new BlockHeaderTestFixture().baseFeePerGas(Wei.ONE);
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=22.4.3
version=22.4.4-SNAPSHOT

# Workaround for Java 16 and spotless bug 834 https://github.com/diffplug/spotless/issues/834
org.gradle.jvmargs=--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
Expand Down

0 comments on commit 649aff1

Please sign in to comment.