Skip to content

Commit

Permalink
Don't persist BFT proposed blocks, only committed ones (#7204)
Browse files Browse the repository at this point in the history
* Don't persist BFT proposed blocks, only committed ones

Signed-off-by: Matthew Whitehead <[email protected]>

* Fix unit tests, update copyright

Signed-off-by: Matthew Whitehead <[email protected]>

* Update changelog

Signed-off-by: Matthew Whitehead <[email protected]>

---------

Signed-off-by: Matthew Whitehead <[email protected]>
Signed-off-by: Matt Whitehead <[email protected]>
  • Loading branch information
matthew1001 authored Jun 13, 2024
1 parent c8d0107 commit c52975b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
### 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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit c52975b

Please sign in to comment.