From b4f37f1ebb39b00c24304d28b8c880f4f515f7ba Mon Sep 17 00:00:00 2001 From: Matthew Whitehead Date: Tue, 11 Jun 2024 11:35:35 +0100 Subject: [PATCH 1/6] Don't persist BFT proposed blocks, only committed ones Signed-off-by: Matthew Whitehead --- .../consensus/qbft/validation/ProposalPayloadValidator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/ProposalPayloadValidator.java b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/ProposalPayloadValidator.java index bdb4ebd14c3..2c4db3d9067 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/ProposalPayloadValidator.java +++ b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/ProposalPayloadValidator.java @@ -150,7 +150,7 @@ private boolean validateBlock(final Block block) { final var validationResult = blockValidator.validateAndProcessBlock( - protocolContext, block, HeaderValidationMode.LIGHT, HeaderValidationMode.FULL); + protocolContext, block, HeaderValidationMode.LIGHT, HeaderValidationMode.FULL, false); if (!validationResult.isSuccessful()) { LOG.info( From 8e78483166287c24adfad2c6af252ebdd54efbb6 Mon Sep 17 00:00:00 2001 From: Matthew Whitehead Date: Tue, 11 Jun 2024 14:07:27 +0100 Subject: [PATCH 2/6] Fix unit tests, update copyright Signed-off-by: Matthew Whitehead --- .../qbft/validation/ProposalPayloadValidator.java | 2 +- .../consensus/qbft/validation/ProposalValidatorTest.java | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/ProposalPayloadValidator.java b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/ProposalPayloadValidator.java index 2c4db3d9067..640216e9a97 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/ProposalPayloadValidator.java +++ b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/ProposalPayloadValidator.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 ConsenSys AG. + * Copyright contributors to Hyperledger Besu. * * 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 diff --git a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validation/ProposalValidatorTest.java b/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validation/ProposalValidatorTest.java index 53876f5b87e..c28588a9d5d 100644 --- a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validation/ProposalValidatorTest.java +++ b/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validation/ProposalValidatorTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 ConsenSys AG. + * Copyright contributors to Hyperledger Besu. * * 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 @@ -111,7 +111,8 @@ QbftContext.class, emptyList(), bftExtraDataEncoder), eq(protocolContext), any(), eq(HeaderValidationMode.LIGHT), - eq(HeaderValidationMode.FULL))) + eq(HeaderValidationMode.FULL), + eq(false))) .thenReturn(new BlockProcessingResult(Optional.empty())); when(protocolSchedule.getByBlockHeader(any())).thenReturn(protocolSpec); @@ -168,7 +169,8 @@ public void validationFailsIfBlockIsInvalid() { eq(protocolContext), any(), eq(HeaderValidationMode.LIGHT), - eq(HeaderValidationMode.FULL))) + eq(HeaderValidationMode.FULL), + eq(false))) .thenReturn(new BlockProcessingResult("Failed")); assertThat(roundItem.messageValidator.validate(proposal)).isFalse(); From c921a47a82bc27d6ab8e98bbabdafd149b6dcced Mon Sep 17 00:00:00 2001 From: Matthew Whitehead Date: Tue, 11 Jun 2024 14:10:25 +0100 Subject: [PATCH 3/6] Update changelog Signed-off-by: Matthew Whitehead --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b64946ae01..cfa0fe4b4cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,9 +23,12 @@ - `admin_nodeInfo` JSON/RPC call returns the currently active EVM version [#7127](https://github.com/hyperledger/besu/pull/7127) - Improve the selection of the most profitable built block [#7174](https://github.com/hyperledger/besu/pull/7174) - Support for eth_maxPriorityFeePerGas [#5658](https://github.com/hyperledger/besu/issues/5658) + ### Bug fixes - Make `eth_gasPrice` aware of the base fee market [#7102](https://github.com/hyperledger/besu/pull/7102) - Validation errors ignored in accounts-allowlist and empty list [#7138](https://github.com/hyperledger/besu/issues/7138) +- Fix "Invalid block detected" for BFT chains using Bonsai DB [#7204](https://github.com/hyperledger/besu/pull/7204) + ## 24.5.2 ### Upcoming Breaking Changes From fae54ed068b72b262bc5001fc3371e363839e192 Mon Sep 17 00:00:00 2001 From: Matthew Whitehead Date: Wed, 12 Jun 2024 10:14:34 +0100 Subject: [PATCH 4/6] Fix unit tests Signed-off-by: Matthew Whitehead --- .../ProposalPayloadValidatorTest.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validation/ProposalPayloadValidatorTest.java b/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validation/ProposalPayloadValidatorTest.java index e80f3028924..182393484ee 100644 --- a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validation/ProposalPayloadValidatorTest.java +++ b/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validation/ProposalPayloadValidatorTest.java @@ -105,7 +105,8 @@ public void validationPassesWhenProposerAndRoundMatchAndBlockIsValid() { eq(protocolContext), eq(block), eq(HeaderValidationMode.LIGHT), - eq(HeaderValidationMode.FULL))) + eq(HeaderValidationMode.FULL), + eq(false))) .thenReturn(new BlockProcessingResult(Optional.empty())); assertThat(payloadValidator.validate(proposal.getSignedPayload())).isTrue(); @@ -129,7 +130,8 @@ public void validationPassesWhenBlockRoundDoesNotMatchProposalRound() { eq(protocolContext), eq(block), eq(HeaderValidationMode.LIGHT), - eq(HeaderValidationMode.FULL))) + eq(HeaderValidationMode.FULL), + eq(false))) .thenReturn(new BlockProcessingResult(Optional.empty())); assertThat(payloadValidator.validate(proposal.getSignedPayload())).isTrue(); @@ -152,7 +154,8 @@ public void validationFailsWhenBlockFailsValidation() { eq(protocolContext), eq(block), eq(HeaderValidationMode.LIGHT), - eq(HeaderValidationMode.FULL))) + eq(HeaderValidationMode.FULL), + eq(false))) .thenReturn(new BlockProcessingResult("Failed")); assertThat(payloadValidator.validate(proposal.getSignedPayload())).isFalse(); @@ -228,7 +231,8 @@ public void validationFailsForBlockWithIncorrectHeight() { eq(protocolContext), eq(block), eq(HeaderValidationMode.LIGHT), - eq(HeaderValidationMode.FULL))) + eq(HeaderValidationMode.FULL), + eq(false))) .thenReturn(new BlockProcessingResult(Optional.empty())); assertThat(payloadValidator.validate(proposal.getSignedPayload())).isFalse(); @@ -262,7 +266,8 @@ public void validationForCmsFailsWhenCmsFailsValidation() { eq(protocolContext), eq(block), eq(HeaderValidationMode.LIGHT), - eq(HeaderValidationMode.FULL))) + eq(HeaderValidationMode.FULL), + eq(false))) .thenReturn(new BlockProcessingResult(Optional.empty())); when(cmsValidator.validate(eq(cms), eq(hashWithoutCms))).thenReturn(false); @@ -297,7 +302,8 @@ public void validationForCmsPassesWhenCmsIsValid() { eq(protocolContext), eq(block), eq(HeaderValidationMode.LIGHT), - eq(HeaderValidationMode.FULL))) + eq(HeaderValidationMode.FULL), + eq(false))) .thenReturn(new BlockProcessingResult(Optional.empty())); when(cmsValidator.validate(eq(cms), eq(hashWithoutCms))).thenReturn(true); From beef6b77bbbbbacf5ae472d6be21a5ec71f28463 Mon Sep 17 00:00:00 2001 From: Matthew Whitehead Date: Wed, 12 Jun 2024 11:21:16 +0100 Subject: [PATCH 5/6] Increase block height wait time for acceptance tests Signed-off-by: Matthew Whitehead --- .../besu/tests/acceptance/dsl/AcceptanceTestBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBase.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBase.java index cac4deb9d9b..1d803ec372b 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBase.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBase.java @@ -178,7 +178,7 @@ private void printOutput(final Process process) { protected void waitForBlockHeight(final Node node, final long blockchainHeight) { WaitUtils.waitFor( - 120, + 180, () -> assertThat(node.execute(ethTransactions.blockNumber())) .isGreaterThanOrEqualTo(BigInteger.valueOf(blockchainHeight))); From 1bf98d37dbdda247b7aa183ff21f56037e36771f Mon Sep 17 00:00:00 2001 From: Matthew Whitehead Date: Wed, 12 Jun 2024 11:33:07 +0100 Subject: [PATCH 6/6] Revert attempt to fix flaky test. Didn't help Signed-off-by: Matthew Whitehead --- .../besu/tests/acceptance/dsl/AcceptanceTestBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBase.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBase.java index 1d803ec372b..cac4deb9d9b 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBase.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBase.java @@ -178,7 +178,7 @@ private void printOutput(final Process process) { protected void waitForBlockHeight(final Node node, final long blockchainHeight) { WaitUtils.waitFor( - 180, + 120, () -> assertThat(node.execute(ethTransactions.blockNumber())) .isGreaterThanOrEqualTo(BigInteger.valueOf(blockchainHeight)));