-
Notifications
You must be signed in to change notification settings - Fork 1
[codex] Fix reth partial archive pruning and sizing #561
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| package network | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "math" | ||
| ) | ||
|
|
||
| // ethereumStorageProfile is the single source of truth for Ethereum local | ||
| // node storage sizing. The profile is intentionally conservative because | ||
| // local-path storage does not reserve bytes up front, but sized storage | ||
| // classes do enforce these requests. | ||
| type ethereumStorageProfile struct { | ||
| ExecutionSize string | ||
| ConsensusSize string | ||
| DiskRequirementGB uint64 | ||
| Label string | ||
| } | ||
|
|
||
| func resolveEthereumStorageProfile(network, mode, executionClient string, scope ArchiveScope) ethereumStorageProfile { | ||
| if mode != "archive" { | ||
| if network == "mainnet" { | ||
| return ethereumStorageProfile{ | ||
| ExecutionSize: "500Gi", | ||
| ConsensusSize: "200Gi", | ||
| DiskRequirementGB: 700, | ||
| Label: "full mainnet", | ||
| } | ||
| } | ||
| return ethereumStorageProfile{ | ||
| ExecutionSize: "100Gi", | ||
| ConsensusSize: "50Gi", | ||
| DiskRequirementGB: 150, | ||
| Label: "full testnet", | ||
| } | ||
| } | ||
|
|
||
| if network != "mainnet" { | ||
| return ethereumStorageProfile{ | ||
| ExecutionSize: "300Gi", | ||
| ConsensusSize: "100Gi", | ||
| DiskRequirementGB: 400, | ||
| Label: "archive testnet", | ||
| } | ||
| } | ||
|
|
||
| if !partialArchiveClients[executionClient] || scope.Kind == "" || scope.Kind == "all" { | ||
| return ethereumStorageProfile{ | ||
| ExecutionSize: "4500Gi", | ||
| ConsensusSize: "500Gi", | ||
| DiskRequirementGB: 5000, | ||
| Label: "archive mainnet from genesis", | ||
| } | ||
| } | ||
|
|
||
| switch scope.Kind { | ||
| case "before": | ||
| if hf := hardforkProfileForBlock(scope.Block); hf != nil { | ||
| execGi := roundUpGiB(uint64(math.Ceil(hf.ApproxArchiveSizeTB * 1024 * 1.2))) | ||
| return ethereumStorageProfile{ | ||
| ExecutionSize: formatGi(execGi), | ||
| ConsensusSize: "500Gi", | ||
| DiskRequirementGB: execGi + 700, | ||
| Label: "partial archive mainnet " + hf.Name, | ||
| } | ||
| } | ||
|
|
||
| // A raw block before the oldest known partial-archive preset could | ||
| // retain almost all history, so size it as a full archive. | ||
| return ethereumStorageProfile{ | ||
| ExecutionSize: "4500Gi", | ||
| ConsensusSize: "500Gi", | ||
| DiskRequirementGB: 5000, | ||
| Label: "custom archive mainnet block", | ||
| } | ||
| case "distance": | ||
| execGi := executionGiForDistance(scope.Distance) | ||
| return ethereumStorageProfile{ | ||
| ExecutionSize: formatGi(execGi), | ||
| ConsensusSize: "500Gi", | ||
| DiskRequirementGB: diskRequirementForMainnetArchive(execGi), | ||
| Label: "partial archive mainnet distance", | ||
| } | ||
| default: | ||
| return ethereumStorageProfile{ | ||
| ExecutionSize: "4500Gi", | ||
| ConsensusSize: "500Gi", | ||
| DiskRequirementGB: 5000, | ||
| Label: "archive mainnet", | ||
| } | ||
| } | ||
| } | ||
|
|
||
| func hardforkProfileForBlock(block uint64) *Hardfork { | ||
| var matched *Hardfork | ||
| for i := range MainnetHardforks { | ||
| if MainnetHardforks[i].Block <= block { | ||
| matched = &MainnetHardforks[i] | ||
| continue | ||
| } | ||
| break | ||
| } | ||
| return matched | ||
| } | ||
|
|
||
| func diskRequirementForMainnetArchive(execGi uint64) uint64 { | ||
| if execGi >= 4500 { | ||
| return 5000 | ||
| } | ||
| return execGi + 700 | ||
| } | ||
|
|
||
| func executionGiForDistance(distance uint64) uint64 { | ||
| days := float64(distance*12) / float64(24*60*60) | ||
| execGi := uint64(math.Ceil(500 + days*0.82)) | ||
| if execGi < 500 { | ||
| execGi = 500 | ||
| } | ||
| if execGi > 4500 { | ||
| execGi = 4500 | ||
| } | ||
| return roundUpGiB(execGi) | ||
| } | ||
|
|
||
| func roundUpGiB(gib uint64) uint64 { | ||
| const step = 100 | ||
| if gib%step == 0 { | ||
| return gib | ||
| } | ||
| return ((gib / step) + 1) * step | ||
| } | ||
|
|
||
| func formatGi(gib uint64) string { | ||
| return fmt.Sprintf("%dGi", gib) | ||
| } | ||
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.
Just by chance if you spot this @apham0001 or @anadi2311 , do we have archive ELs for our data pipline? (I guess geth), do you know what disk space they take up?