From 41ca508c2c8b2e37cffbfa0035372d8a6e9c4cb4 Mon Sep 17 00:00:00 2001 From: Calvin Kim Date: Sun, 4 Feb 2024 21:39:36 +0900 Subject: [PATCH] main, integration: making pruning the default Unless given the --prune=0 flag, the node will default to --prune=550 --- config.go | 18 +++++++----------- integration/getutreexoroots_test.go | 2 ++ .../invalidate_reconsider_block_test.go | 2 +- integration/utreexocompactstatenode_test.go | 1 + 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/config.go b/config.go index 979d2cf7..c3e5f48a 100644 --- a/config.go +++ b/config.go @@ -110,7 +110,7 @@ type config struct { UtxoCacheMaxSizeMiB uint `long:"utxocachemaxsize" description:"The maximum size in MiB of the UTXO cache"` NoUtreexo bool `long:"noutreexo" description:"Disable utreexo compact state during block validation"` NoWinService bool `long:"nowinservice" description:"Do not start as a background service on Windows -- NOTE: This flag only works on the command line, not in the config file"` - Prune uint64 `long:"prune" description:"Prune already validated blocks from the database. Must specify a target size in MiB (minimum value of 550, default of 0 to disable pruning)"` + Prune uint64 `long:"prune" description:"Prune already validated blocks from the database. Must specify a target size in MiB (minimum value of 550, default of 550. Set to 0 to disable pruning.)"` // Profiling options. Profile string `long:"profile" description:"Enable HTTP profiling on given port -- NOTE port must be between 1024 and 65536"` @@ -494,6 +494,7 @@ func loadConfig() (*config, []string, error) { TxIndex: defaultTxIndex, TTLIndex: defaultTTLIndex, AddrIndex: defaultAddrIndex, + Prune: pruneMinSize, } // Service options which are only added on Windows. @@ -1208,13 +1209,8 @@ func loadConfig() (*config, []string, error) { cfg.NoUtreexo = true } - // Set --prune=550 if the node is a utreexo node. - if !cfg.NoUtreexo { - if cfg.Prune == 0 { - cfg.Prune = pruneMinSize - } - } else { - // Set --noassumeutreexo if the node is not a utreexo node. + // Set --noassumeutreexo if the node is not a utreexo node. + if cfg.NoUtreexo { cfg.NoAssumeUtreexo = true } @@ -1304,7 +1300,7 @@ func loadConfig() (*config, []string, error) { if cfg.Prune != 0 && cfg.TxIndex { err := fmt.Errorf("%s: the --prune and --txindex options may "+ - "not be activated at the same time", funcName) + "not be activated at the same time. Set --prune=0 to disable pruning.", funcName) fmt.Fprintln(os.Stderr, err) fmt.Fprintln(os.Stderr, usageMessage) return nil, nil, err @@ -1312,7 +1308,7 @@ func loadConfig() (*config, []string, error) { if cfg.Prune != 0 && cfg.AddrIndex { err := fmt.Errorf("%s: the --prune and --addrindex options may "+ - "not be activated at the same time", funcName) + "not be activated at the same time. Set --prune=0 to disable pruning.", funcName) fmt.Fprintln(os.Stderr, err) fmt.Fprintln(os.Stderr, usageMessage) return nil, nil, err @@ -1320,7 +1316,7 @@ func loadConfig() (*config, []string, error) { if cfg.Prune != 0 && cfg.TTLIndex { err := fmt.Errorf("%s: the --prune and --ttlindex options may "+ - "not be activated at the same time", funcName) + "not be activated at the same time. Set --prune=0 to disable pruning.", funcName) fmt.Fprintln(os.Stderr, err) fmt.Fprintln(os.Stderr, usageMessage) return nil, nil, err diff --git a/integration/getutreexoroots_test.go b/integration/getutreexoroots_test.go index f3777276..16ab5566 100644 --- a/integration/getutreexoroots_test.go +++ b/integration/getutreexoroots_test.go @@ -64,6 +64,7 @@ func TestGetUtreexoRoots(t *testing.T) { "--utreexoproofindex", "--noutreexo", "--nobdkwallet", + "--prune=0", } utreexoProofNode, err := rpctest.New(&chaincfg.RegressionNetParams, nil, utreexoProofIdxArgs, "") if err != nil { @@ -79,6 +80,7 @@ func TestGetUtreexoRoots(t *testing.T) { "--flatutreexoproofindex", "--noutreexo", "--nobdkwallet", + "--prune=0", } flatUtreexoProofNode, err := rpctest.New(&chaincfg.RegressionNetParams, nil, flatUtreexoProofIdxArgs, "") if err != nil { diff --git a/integration/invalidate_reconsider_block_test.go b/integration/invalidate_reconsider_block_test.go index 7fff3b3e..1ef5d6cb 100644 --- a/integration/invalidate_reconsider_block_test.go +++ b/integration/invalidate_reconsider_block_test.go @@ -9,7 +9,7 @@ import ( func TestInvalidateAndReconsiderBlock(t *testing.T) { // Set up regtest chain. - r, err := rpctest.New(&chaincfg.RegressionNetParams, nil, []string{"--flatutreexoproofindex", "--utreexoproofindex", "--nobdkwallet"}, "") + r, err := rpctest.New(&chaincfg.RegressionNetParams, nil, []string{"--flatutreexoproofindex", "--utreexoproofindex", "--nobdkwallet", "--prune=0"}, "") if err != nil { t.Fatalf("TestInvalidateAndReconsiderBlock fail. Unable to create primary harness: %v", err) } diff --git a/integration/utreexocompactstatenode_test.go b/integration/utreexocompactstatenode_test.go index 5dfaa25d..b5dacca2 100644 --- a/integration/utreexocompactstatenode_test.go +++ b/integration/utreexocompactstatenode_test.go @@ -88,6 +88,7 @@ func TestUtreexoCSN(t *testing.T) { "--flatutreexoproofindex", "--noutreexo", "--nobdkwallet", + "--prune=0", } // Set up regtest chain for the bridge node. bridgeNode, err := rpctest.New(&chaincfg.RegressionNetParams, nil, bridgeNodeArgs, "")