-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
main, wire, blockchain, indexers, ffldb: Add pruning #1971
Changes from all commits
f258d0c
5c1dd21
57ec43f
0212c33
02469e1
a1736b4
57903c7
aaedc11
56f3463
47261ef
e27fcac
f161a31
8f8040e
65c7299
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 |
---|---|---|
|
@@ -66,6 +66,7 @@ const ( | |
sampleConfigFilename = "sample-btcd.conf" | ||
defaultTxIndex = false | ||
defaultAddrIndex = false | ||
pruneMinSize = 1536 | ||
) | ||
|
||
var ( | ||
|
@@ -146,6 +147,7 @@ type config struct { | |
Proxy string `long:"proxy" description:"Connect via SOCKS5 proxy (eg. 127.0.0.1:9050)"` | ||
ProxyPass string `long:"proxypass" default-mask:"-" description:"Password for proxy server"` | ||
ProxyUser string `long:"proxyuser" description:"Username for proxy server"` | ||
Prune uint64 `long:"prune" description:"Prune already validated blocks from the database. Must specify a target size in MiB (minimum value of 1536, default value of 0 will disable pruning)"` | ||
RegressionTest bool `long:"regtest" description:"Use the regression test network"` | ||
RejectNonStd bool `long:"rejectnonstd" description:"Reject non-standard transactions regardless of the default settings for the active network."` | ||
RejectReplacement bool `long:"rejectreplacement" description:"Reject transactions that attempt to replace existing transactions within the mempool through the Replace-By-Fee (RBF) signaling policy."` | ||
|
@@ -1137,6 +1139,30 @@ func loadConfig() (*config, []string, error) { | |
} | ||
} | ||
|
||
if cfg.Prune != 0 && cfg.Prune < pruneMinSize { | ||
err := fmt.Errorf("%s: the minimum value for --prune is %d. Got %d", | ||
funcName, pruneMinSize, cfg.Prune) | ||
fmt.Fprintln(os.Stderr, err) | ||
fmt.Fprintln(os.Stderr, usageMessage) | ||
return nil, nil, err | ||
} | ||
Comment on lines
+1142
to
+1148
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. Do we want to terminate here or should we just log a Warning and start up with the min value? 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. If it startups up, then the user may end up believing that their min value is correct. It's hard to catch the logs since there's a bunch at startup so I think it's better to fail. 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. Seems reasonable |
||
|
||
if cfg.Prune != 0 && cfg.TxIndex { | ||
err := fmt.Errorf("%s: the --prune and --txindex options may "+ | ||
"not be activated at the same time", funcName) | ||
fmt.Fprintln(os.Stderr, err) | ||
fmt.Fprintln(os.Stderr, usageMessage) | ||
return nil, nil, err | ||
} | ||
Comment on lines
+1150
to
+1156
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. If we are forcing this set of options to be blocked at the gate, shouldn't we return an error from |
||
|
||
if cfg.Prune != 0 && cfg.AddrIndex { | ||
err := fmt.Errorf("%s: the --prune and --addrindex options may "+ | ||
"not be activated at the same time", funcName) | ||
fmt.Fprintln(os.Stderr, err) | ||
fmt.Fprintln(os.Stderr, usageMessage) | ||
return nil, nil, err | ||
} | ||
Comment on lines
+1158
to
+1164
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. If we are forcing this set of options to be blocked at the gate, shouldn't we return an error from |
||
|
||
// Warn about missing config file only after all other configuration is | ||
// done. This prevents the warning on help messages and invalid | ||
// options. Note this should go directly before the return. | ||
|
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.
Ah, I see there's another min size here. Shouldn't we sync this with what's being checked in
database/ffldb/db.go
?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.
So the 1536 number came from the fact that we have these constants.
We need to keep 288 blocks to adhere to
NODE_NETWORK_LIMITED
BIP. Each block can be a maximum of 4MB. Each block file (XXXXXX.fdb) is 512MiB.We do the math and we need to keep 2.14 on disk .fdb files to adhere to the
NODE_NETWORK_LIMITED
rule. Can't keep .14 files so we round up to 3.512MiB * 3
is1536MiB
which is ourpruneMinSize
.As mentioned here, the check in
database/ffldb/db.go
is a different check so it's ok.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.
If I'm reading this correctly it also seems like the smallest resolution we can target is 512MiB increments which means that maybe our settings should use GiB as the unit of measurement for pruning's sake. Right now it specifies it with a uint32 of bytes, which practically means that there are effectively 6 configurations that can come out of this: 1.5, 2.0, 2.5, 3.0, 3.5, and 4.0 GiB?
I'm interpreting this because you said we can't keep partial block files so that means that we effectively only have the discrete intervals of 512MiB to work with.
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.
Each
blk
file is 512MiB and while we can delete parts of the file, it's not efficient to do so and won't have much user benefit.It's the same as Core where you give a target and core deletes
.dat
files to meet that target. It'll be in those increments you state but the user is free to give any amount (just like in Core).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.
Yeah I don't mind the intervals at all. It's hardly an issue now that the overall prune cache size isn't maxed at ~4G
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.
Ah okay, the two different limits now make sense to me, thanks for the explanation.