-
Notifications
You must be signed in to change notification settings - Fork 20.9k
core: initialize history pruning in BlockChain #31636
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 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a696ff8
core: initialize history pruning in BlockChain
fjl 3ccd6f9
cmd/geth: fix for move of prune points
fjl c4d1347
cmd/workload: fix for move of prune points
fjl 75fc954
core: fix typo
fjl 9aa4df4
core: move pruning init a bit earlier
fjl 93bb405
core: restore test
fjl d1e2199
Update historymode.go
fjl 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
// You should have received a copy of the GNU Lesser General Public License | ||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
package ethconfig | ||
package history | ||
|
||
import ( | ||
"fmt" | ||
|
@@ -27,22 +27,22 @@ import ( | |
type HistoryMode uint32 | ||
|
||
const ( | ||
// AllHistory (default) means that all chain history down to genesis block will be kept. | ||
AllHistory HistoryMode = iota | ||
// KeepAll (default) means that all chain history down to genesis block will be kept. | ||
KeepAll HistoryMode = iota | ||
|
||
// PostMergeHistory sets the history pruning point to the merge activation block. | ||
PostMergeHistory | ||
// KeepPostMerge sets the history pruning point to the merge activation block. | ||
KeepPostMerge | ||
) | ||
|
||
func (m HistoryMode) IsValid() bool { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick, i would prefer to rename it to |
||
return m <= PostMergeHistory | ||
return m <= KeepPostMerge | ||
} | ||
|
||
func (m HistoryMode) String() string { | ||
switch m { | ||
case AllHistory: | ||
case KeepAll: | ||
return "all" | ||
case PostMergeHistory: | ||
case KeepPostMerge: | ||
return "postmerge" | ||
default: | ||
return fmt.Sprintf("invalid HistoryMode(%d)", m) | ||
|
@@ -61,24 +61,24 @@ func (m HistoryMode) MarshalText() ([]byte, error) { | |
func (m *HistoryMode) UnmarshalText(text []byte) error { | ||
switch string(text) { | ||
case "all": | ||
*m = AllHistory | ||
*m = KeepAll | ||
case "postmerge": | ||
*m = PostMergeHistory | ||
*m = KeepPostMerge | ||
default: | ||
return fmt.Errorf(`unknown sync mode %q, want "all" or "postmerge"`, text) | ||
} | ||
return nil | ||
} | ||
|
||
type HistoryPrunePoint struct { | ||
type PrunePoint struct { | ||
BlockNumber uint64 | ||
BlockHash common.Hash | ||
} | ||
|
||
// HistoryPrunePoints contains the pre-defined history pruning cutoff blocks for known networks. | ||
// PrunePointsins the pre-defined history pruning cutoff blocks for known networks. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fix the typo |
||
// They point to the first post-merge block. Any pruning should truncate *up to* but excluding | ||
// given block. | ||
var HistoryPrunePoints = map[common.Hash]*HistoryPrunePoint{ | ||
var PrunePoints = map[common.Hash]*PrunePoint{ | ||
// mainnet | ||
params.MainnetGenesisHash: { | ||
BlockNumber: 15537393, | ||
|
@@ -91,7 +91,7 @@ var HistoryPrunePoints = map[common.Hash]*HistoryPrunePoint{ | |
}, | ||
} | ||
|
||
// PrunedHistoryError is returned when the requested history is pruned. | ||
// PrunedHistoryError is returned by APIs when the requested history is pruned. | ||
type PrunedHistoryError struct{} | ||
|
||
func (e *PrunedHistoryError) Error() string { return "pruned history unavailable" } | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to have a warning log here, saying that the Geth is run with KeepAll but it was pruned previously
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's something to consider, but for now, we really don't want people to use another pruning target block.