-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add chain data pruning experimental feature #4686
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 all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
fce33c1
Add chain pruner
wcgcyx be8f081
Add tests and options
wcgcyx af59579
Add pruning frequency
wcgcyx 16de0e9
Fix unit tests
wcgcyx 3e67042
Fix chain pruning tests
wcgcyx 0d433a3
Increase minimum blocks to retain
wcgcyx 0e545c5
Skip ancestor check in pruning mode
wcgcyx 4e0e627
Merge branch 'main' into 4476-chain-data-pruning
wcgcyx 9313b02
Insert changelog entry & fix build issue
wcgcyx 3e3596b
Fix unit test
wcgcyx d0807ff
Merge branch 'main' into 4476-chain-data-pruning
wcgcyx 4c1d792
Fix changelog & address reviews
wcgcyx 95e86a5
Fix minor issues & code cleanup
wcgcyx a63542a
Separate class for pruning storage
wcgcyx 580942a
Merge branch 'main' into 4476-chain-data-pruning
wcgcyx 328005b
Rename options
wcgcyx c34154f
Merge branch 'main' into 4476-chain-data-pruning
wcgcyx 64ba456
Move pruning to separate thread
wcgcyx a42a933
Merge branch 'main' into 4476-chain-data-pruning
wcgcyx 322b327
Merge branch 'main' into 4476-chain-data-pruning
wcgcyx cd37f0f
Merge branch 'main' into 4476-chain-data-pruning
wcgcyx ac79611
Update changelog
wcgcyx 51c6c6d
Remove global variable & decrease minimum allowed retaining block
wcgcyx 96c2934
Limit total pruning threads
wcgcyx cbc460b
Update pruner constructor
wcgcyx 99b273f
Merge branch 'main' into 4476-chain-data-pruning
wcgcyx cc4648e
Update besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
wcgcyx 8315393
Spotless & Remove unnecessary comments
wcgcyx 5992b66
More clear variable
wcgcyx 5d4da4e
Clear logging
wcgcyx 118178e
Fix bug & use monitored executors
wcgcyx 91102a7
New domain object
wcgcyx 962adb6
Fix tests
wcgcyx 1368c55
Move flag to merge context
wcgcyx d41661b
Merge branch 'main' into 4476-chain-data-pruning
wcgcyx 2a439f1
Renaming
wcgcyx d29a286
Rename tx
wcgcyx e2c088c
Merge branch 'main' into 4476-chain-data-pruning
wcgcyx 25d514d
Fix issues
wcgcyx 571a022
Merge branch 'main' into 4476-chain-data-pruning
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
90 changes: 90 additions & 0 deletions
90
besu/src/main/java/org/hyperledger/besu/cli/options/unstable/ChainPruningOptions.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,90 @@ | ||
| /* | ||
| * Copyright Hyperledger Besu Contributors. | ||
| * | ||
| * 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.cli.options.unstable; | ||
|
|
||
| import org.hyperledger.besu.cli.options.CLIOptions; | ||
| import org.hyperledger.besu.ethereum.chain.ChainPrunerConfiguration; | ||
| import org.hyperledger.besu.util.number.PositiveNumber; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.List; | ||
|
|
||
| import picocli.CommandLine; | ||
|
|
||
| public class ChainPruningOptions implements CLIOptions<ChainPrunerConfiguration> { | ||
| private static final String CHAIN_PRUNING_ENABLED_FLAG = "--Xchain-pruning-enabled"; | ||
| private static final String CHAIN_PRUNING_BLOCKS_RETAINED_FLAG = | ||
| "--Xchain-pruning-blocks-retained"; | ||
| private static final String CHAIN_PRUNING_FREQUENCY_FLAG = "--Xchain-pruning-frequency"; | ||
| public static final long DEFAULT_CHAIN_DATA_PRUNING_MIN_BLOCKS_RETAINED = 7200; | ||
| public static final int DEFAULT_CHAIN_DATA_PRUNING_FREQUENCY = 256; | ||
|
|
||
| @CommandLine.Option( | ||
| hidden = true, | ||
| names = {CHAIN_PRUNING_ENABLED_FLAG}, | ||
| description = | ||
| "Enable the chain pruner to actively prune old chain data (default: ${DEFAULT-VALUE})") | ||
| private final Boolean chainDataPruningEnabled = Boolean.FALSE; | ||
|
|
||
| @CommandLine.Option( | ||
| hidden = true, | ||
| names = {CHAIN_PRUNING_BLOCKS_RETAINED_FLAG}, | ||
| description = | ||
| "The number of recent blocks for which to keep the chain data. Must be >= " | ||
| + DEFAULT_CHAIN_DATA_PRUNING_MIN_BLOCKS_RETAINED | ||
| + " (default: ${DEFAULT-VALUE})") | ||
| private final Long chainDataPruningBlocksRetained = | ||
| DEFAULT_CHAIN_DATA_PRUNING_MIN_BLOCKS_RETAINED; | ||
|
|
||
| @CommandLine.Option( | ||
| hidden = true, | ||
| names = {CHAIN_PRUNING_FREQUENCY_FLAG}, | ||
| description = | ||
| "The number of blocks added to the chain between two pruning operations. Must be non-negative (default: ${DEFAULT-VALUE})") | ||
| private final PositiveNumber chainDataPruningBlocksFrequency = | ||
| PositiveNumber.fromInt(DEFAULT_CHAIN_DATA_PRUNING_FREQUENCY); | ||
|
|
||
| public static ChainPruningOptions create() { | ||
| return new ChainPruningOptions(); | ||
| } | ||
|
|
||
| public Boolean getChainDataPruningEnabled() { | ||
| return chainDataPruningEnabled; | ||
| } | ||
|
|
||
| public Long getChainDataPruningBlocksRetained() { | ||
| return chainDataPruningBlocksRetained; | ||
| } | ||
|
|
||
| @Override | ||
| public ChainPrunerConfiguration toDomainObject() { | ||
| return new ChainPrunerConfiguration( | ||
| chainDataPruningEnabled, | ||
| chainDataPruningBlocksRetained, | ||
| chainDataPruningBlocksFrequency.getValue()); | ||
| } | ||
|
|
||
| @Override | ||
| public List<String> getCLIOptions() { | ||
| return Arrays.asList( | ||
| CHAIN_PRUNING_ENABLED_FLAG, | ||
| chainDataPruningEnabled.toString(), | ||
| CHAIN_PRUNING_BLOCKS_RETAINED_FLAG, | ||
| chainDataPruningBlocksRetained.toString(), | ||
| CHAIN_PRUNING_FREQUENCY_FLAG, | ||
| chainDataPruningBlocksFrequency.toString()); | ||
| } | ||
| } |
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
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.