Skip to content

Commit

Permalink
Don't persist IBFT2 proposal blocks, just validate them
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
  • Loading branch information
matthew1001 committed Sep 17, 2024
1 parent 89dfa95 commit 515747c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
### Bug fixes
- Fix for `debug_traceCall` to handle transactions without specified gas price. [#7510](https://github.com/hyperledger/besu/pull/7510)

- Fix for IBFT2 chains using the BONSAI DB format [#7631](https://github.com/hyperledger/besu/pull/7631)

## 24.9.1

### Upcoming Breaking Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public synchronized void startTimer(final ConsensusRoundIdentifier round) {
// Once we are up to round 2 start logging round expiries
if (round.getRoundNumber() >= 2) {
LOG.info(
"QBFT round {} expired. Moved to round {} which will expire in {} seconds",
"BFT round {} expired. Moved to round {} which will expire in {} seconds",
round.getRoundNumber() - 1,
round.getRoundNumber(),
(expiryTime / 1000));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ public boolean validateProposal(final Proposal msg) {
return false;
}

if (!validateBlock(msg.getBlock())) {
// We want to validate the block but not persist it yet as it's just a proposal. If it turns
// out to be an accepted block it will be persisted at block import time
if (!validateBlockWithoutPersisting(msg.getBlock())) {
return false;
}

Expand All @@ -93,14 +95,14 @@ public boolean validateProposal(final Proposal msg) {
msg.getSignedPayload(), msg.getBlock(), blockInterface);
}

private boolean validateBlock(final Block block) {
private boolean validateBlockWithoutPersisting(final Block block) {

final BlockValidator blockValidator =
protocolSchedule.getByBlockHeader(block.getHeader()).getBlockValidator();

final var validationResult =
blockValidator.validateAndProcessBlock(
protocolContext, block, HeaderValidationMode.LIGHT, HeaderValidationMode.FULL);
protocolContext, block, HeaderValidationMode.LIGHT, HeaderValidationMode.FULL, false);

if (validationResult.isFailed()) {
LOG.info(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void setup() {

when(protocolSpec.getBlockValidator()).thenReturn(blockValidator);
when(protocolSchedule.getByBlockHeader(any())).thenReturn(protocolSpec);
when(blockValidator.validateAndProcessBlock(any(), any(), any(), any()))
when(blockValidator.validateAndProcessBlock(any(), any(), any(), any(), eq(false)))
.thenReturn(new BlockProcessingResult(Optional.empty()));

when(roundChangeCertificateValidator.validateProposalMessageMatchesLatestPrepareCertificate(
Expand Down Expand Up @@ -168,7 +168,7 @@ public void ifProposalConsistencyChecksFailProposalIsIllegal() {

@Test
public void blockValidationFailureFailsValidation() {
when(blockValidator.validateAndProcessBlock(any(), any(), any(), any()))
when(blockValidator.validateAndProcessBlock(any(), any(), any(), any(), eq(false)))
.thenReturn(new BlockProcessingResult("Failed"));

final Proposal proposalMsg =
Expand Down

0 comments on commit 515747c

Please sign in to comment.