-
Notifications
You must be signed in to change notification settings - Fork 377
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
Restore full functionality to trim_headers (untrim) #1270
Changes from all commits
31835f2
283f47b
423715b
d8e1fe7
f89728c
afc16e8
4259278
c28c5ce
1722d4a
6367320
5a40926
6fb780d
90e5bab
73ed5dd
c6aba4a
b4185c7
46a3ee2
4171939
eed85dc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1011,13 +1011,13 @@ bool AppInitParameterInteraction(const ArgsManager& args) | |
} | ||
|
||
if (args.GetBoolArg("-trim_headers", false)) { | ||
LogPrintf("Configured for header-trimming mode. This will reduce memory usage substantially, but we will be unable to serve as a full P2P peer, and certain header fields may be missing from JSON RPC output.\n"); | ||
LogPrintf("Configured for header-trimming mode. This will reduce memory usage substantially, but will increase IO usage when the headers need to be temporarily untrimmed.\n"); | ||
node::fTrimHeaders = true; | ||
// This calculation is driven by GetValidFedpegScripts in pegins.cpp, which walks the chain | ||
// back to current epoch start, and then an additional total_valid_epochs on top of that. | ||
// We add one epoch here for the current partial epoch, and then another one for good luck. | ||
|
||
node::nMustKeepFullHeaders = (chainparams.GetConsensus().total_valid_epochs + 2) * epoch_length; | ||
node::nMustKeepFullHeaders = chainparams.GetConsensus().total_valid_epochs * epoch_length; | ||
// This is the number of headers we can have in flight downloading at a time, beyond the | ||
// set of blocks we've already validated. Capping this is necessary to keep memory usage | ||
// bounded during IBD. | ||
|
@@ -1243,6 +1243,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) | |
const ArgsManager& args = *Assert(node.args); | ||
const CChainParams& chainparams = Params(); | ||
|
||
CBlockIndex::SetNodeContext(&node); | ||
auto opt_max_upload = ParseByteUnits(args.GetArg("-maxuploadtarget", DEFAULT_MAX_UPLOAD_TARGET), ByteUnit::M); | ||
if (!opt_max_upload) { | ||
return InitError(strprintf(_("Unable to parse -maxuploadtarget: '%s'"), args.GetArg("-maxuploadtarget", ""))); | ||
|
@@ -1712,7 +1713,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) | |
|
||
// if pruning, unset the service bit and perform the initial blockstore prune | ||
// after any wallet rescanning has taken place. | ||
if (fPruneMode || node::fTrimHeaders) { | ||
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. Why was 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. This conditional is unsetting NODE_NETWORK, without this flag enabled it means this peer can't serve historical block data (ie. it's a pruned node). This was previously necessary because we weren't able to "untrim" the headers, which this PR fixes. |
||
if (fPruneMode) { | ||
LogPrintf("Unsetting NODE_NETWORK on prune mode\n"); | ||
nLocalServices = ServiceFlags(nLocalServices & ~NODE_NETWORK); | ||
if (!fReindex) { | ||
|
@@ -1724,11 +1725,6 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) | |
} | ||
} | ||
|
||
if (node::fTrimHeaders) { | ||
LogPrintf("Unsetting NODE_NETWORK_LIMITED on header trim mode\n"); | ||
nLocalServices = ServiceFlags(nLocalServices & ~NODE_NETWORK_LIMITED); | ||
} | ||
|
||
// ********************************************************* Step 11: import blocks | ||
|
||
if (!CheckDiskSpace(gArgs.GetDataDirNet())) { | ||
|
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.
This is a circular dependency.
I'm not quite sure how to fix it -- we can't simply forward declare
ChainManager
here since the line below requires knowledge of the fields ofChainManager
: