-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add option to clique to skip creating empty blocks #6082
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f27024b
Add option to clique to skip creating empty blocks
jframe b72a28f
Merge branch 'main' into clique_emptyblock
jframe 2aca68f
Header validation to ensure no empty blocks when createEmptyBlocks is…
jframe f433265
Merge branch 'clique_emptyblock' of github.com:jframe/besu into cliqu…
jframe cf6b478
java doc & asMap fixes
jframe 0e2de38
fix unit test failure
jframe d50342e
javadoc
jframe 00e4007
changelog entry
jframe 86b6824
Add 1 second delay between empty block build attempts
jframe 2991aca
Test to ensure the BlockMiner pre-block validation will stop import o…
jframe b58da4a
Merge remote-tracking branch 'upstream/main' into clique_emptyblock
jframe 1098f46
PR suggestions
jframe d12d53c
Merge remote-tracking branch 'upstream/main' into clique_emptyblock
jframe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...rledger/besu/consensus/clique/headervalidationrules/CliqueNoEmptyBlockValidationRule.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| /* | ||
| * Copyright ConsenSys AG. | ||
| * | ||
| * 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 | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
| * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations under the License. | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| package org.hyperledger.besu.consensus.clique.headervalidationrules; | ||
|
|
||
| import org.hyperledger.besu.datatypes.Hash; | ||
| import org.hyperledger.besu.ethereum.core.BlockHeader; | ||
| import org.hyperledger.besu.ethereum.mainnet.DetachedBlockHeaderValidationRule; | ||
|
|
||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| /** The No empty block validation rule. */ | ||
| public class CliqueNoEmptyBlockValidationRule implements DetachedBlockHeaderValidationRule { | ||
|
|
||
| private static final Logger LOG = LoggerFactory.getLogger(CliqueNoEmptyBlockValidationRule.class); | ||
|
|
||
| /** | ||
| * Responsible for ensuring there are no empty transactions. This is used when createEmptyBlocks | ||
| * is false, to ensure that no empty blocks are created. | ||
| * | ||
| * @param header the block header to validate | ||
| * @param parent the block header corresponding to the parent of the header being validated. | ||
| * @return true if the transactionsRoot in the header is not the empty trie hash. | ||
| */ | ||
| @Override | ||
| public boolean validate(final BlockHeader header, final BlockHeader parent) { | ||
| final boolean hasTransactions = !header.getTransactionsRoot().equals(Hash.EMPTY_TRIE_HASH); | ||
| if (!hasTransactions) { | ||
| LOG.info( | ||
| "Invalid block header: {} has no transactions but create empty blocks is not enabled", | ||
| header.getNumber()); | ||
|
siladu marked this conversation as resolved.
Outdated
|
||
| } | ||
| return hasTransactions; | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.