Repository: coinbase/rosetta-cli
Pull request #347 (2022-08-25 22:38:21)

expend the tablesize range
Fixes # .

### Motivation
<!--
Does this solve a bug? Enable a new use-case? Improve an existing behavior? Concrete examples are helpful here.
-->

### Solution
<!--
What is the solution here from a high level. What are the key technical decisions and why were they made?
-->

### Open questions
<!--
(optional) Any open questions or feedback on design desired?
-->



Patch:
diff --git a/configuration/configuration.go b/configuration/configuration.go
index b2128a9..e3200e3 100644
--- a/configuration/configuration.go
+++ b/configuration/configuration.go
@@ -347,7 +347,7 @@ func assertConfiguration(ctx context.Context, config *Configuration) error {
 		return fmt.Errorf("the number of serial block workers %d is invalid: %w", config.SerialBlockWorkers, cliErrs.ErrNegativeSerialBlockWorkers)
 	}
 
-	if config.TableSize != nil && (*config.TableSize < 2 || *config.TableSize > 100) {
+	if config.TableSize != nil && (*config.TableSize < 1 || *config.TableSize > 100) {
 		return fmt.Errorf("table size %d is invalid: %w", *config.TableSize, cliErrs.ErrTableSizeIsOutOfRange)
 	}
 
diff --git a/configuration/types.go b/configuration/types.go
index e1ad000..3de41ac 100644
--- a/configuration/types.go
+++ b/configuration/types.go
@@ -413,10 +413,10 @@ type Configuration struct {
 	// to performance gains.
 	CompressionDisabled bool `json:"compression_disabled"`
 
-	// MemoryLimitDisabled configures storage to increase memory
+	// L0InMemoryEnabled configures storage to increase memory
 	// usage. Enabling this massively increases performance
 	// but can use 10s of GBs of RAM, even with pruning enabled.
-	MemoryLimitDisabled bool `json:"memory_limit_disabled"`
+	L0InMemoryEnabled bool `json:"l0_in_memory_enabled"`
 
 	// AllInMemoryDisabled configures storage to increase memory
 	// usage. Enabling this massively increases performance
@@ -424,12 +424,12 @@ type Configuration struct {
 	AllInMemoryEnabled bool `json:"all_in_memory_enabled"`
 
 	// TableSize unit is GB, enable users to define MaxTableSize
-	// when AllInMemoryEnabled == true or MemoryLimitDisabled== true, Cli will look up this config
-	// default value is 3, modification range is [2, 100]
+	// when AllInMemoryEnabled == true or L0InMemoryEnabled== true, Cli will look up this config
+	// default value is 2, modification range is [1, 100]
 	TableSize *int64 `json:"table_size,omitempty"`
 
-	// TableSize unit is MB, enable users to define ValueLogFileSize
-	// when AllInMemoryEnabled == true or MemoryLimitDisabled== true, Cli will look up this config
+	// ValueLogFileSize unit is MB, enable users to define ValueLogFileSize
+	// when AllInMemoryEnabled == true or L0InMemoryEnabled== true, Cli will look up this config
 	// default value is 512, modification range is [128, 2048]
 	ValueLogFileSize *int64 `json:"value_log_file_size,omitempty"`
 
diff --git a/examples/configuration/default.json b/examples/configuration/default.json
index 355e334..d2c0c4f 100644
--- a/examples/configuration/default.json
+++ b/examples/configuration/default.json
@@ -14,7 +14,7 @@
  "max_reorg_depth": 100,
  "log_configuration": false,
  "compression_disabled": false,
- "memory_limit_disabled": false,
+ "l0_in_memory_enabled": false,
  "all_in_memory_enabled": false,
  "error_stack_trace_disabled": false,
  "coin_supported": false,
diff --git a/pkg/errors/errors.go b/pkg/errors/errors.go
index 5fa4293..da824fa 100644
--- a/pkg/errors/errors.go
+++ b/pkg/errors/errors.go
@@ -30,7 +30,7 @@ var (
 	ErrNegativeSeenBlockWorkers                                          = errors.New("the number of seen block workers is negative")
 	ErrNegativeSerialBlockWorkers                                        = errors.New("the number of serial block workers is negative")
 	ErrReconciliationOutOfRange                                          = errors.New("reconciliation is out of range, it must be in the range [0, 1]")
-	ErrTableSizeIsOutOfRange                                             = errors.New("table size is out of range, it must be in the range [2, 100]")
+	ErrTableSizeIsOutOfRange                                             = errors.New("table size is out of range, it must be in the range [1, 100]")
 	ErrValueLogFileSizeIsOutOfRange                                      = errors.New("value log file size is out of range, it must be in the range [128, 2048]")
 	ErrBalanceTrackingIsDisabledForReconciliation                        = errors.New("balance tracking cannot be disabled for reconciliation")
 	ErrBalanceTrackingIsDisabledForReconciliationCoverageEndCondition    = errors.New("balance tracking cannot be disabled for reconciliation coverage end condition")


Test patch:
diff --git a/pkg/tester/construction.go b/pkg/tester/construction.go
index e6d8d46..90e6701 100644
--- a/pkg/tester/construction.go
+++ b/pkg/tester/construction.go
@@ -92,7 +92,7 @@ func InitializeConstruction(
 	if config.CompressionDisabled {
 		opts = append(opts, database.WithoutCompression())
 	}
-	if config.MemoryLimitDisabled {
+	if config.L0InMemoryEnabled {
 		opts = append(
 			opts,
 			database.WithCustomSettings(database.PerformanceBadgerOptions(dataPath)),
diff --git a/pkg/tester/data.go b/pkg/tester/data.go
index dcaec8d..0d8f603 100644
--- a/pkg/tester/data.go
+++ b/pkg/tester/data.go
@@ -68,7 +68,7 @@ const (
 	EndAtTipCheckInterval = 10 * time.Second
 
 	//MinTableSize unit is GB
-	MinTableSize = int64(2)
+	MinTableSize = int64(1)
 
 	//MaxTableSize unit is GB
 	MaxTableSize = int64(100)
@@ -179,7 +179,7 @@ func InitializeData(
 		if config.CompressionDisabled {
 			opts = append(opts, database.WithoutCompression())
 		}
-		if config.MemoryLimitDisabled {
+		if config.L0InMemoryEnabled {
 			opts = append(
 				opts,
 				database.WithCustomSettings(database.PerformanceBadgerOptions(dataPath)),
@@ -191,7 +191,7 @@ func InitializeData(
 	// according to users config. tableSize means the LSM table size, when the table more than the tableSize,
 	// will trigger a compact.
 	// In default mode, we will not change the badger DB's TableSize and ValueLogFileSize for limiting memory usage
-	if config.AllInMemoryEnabled || config.MemoryLimitDisabled {
+	if config.AllInMemoryEnabled || config.L0InMemoryEnabled {
 		if config.TableSize != nil {
 			if *config.TableSize >= MinTableSize && *config.TableSize <= MaxTableSize {
 				opts = append(