Skip to content
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

Expose merkledb defaults #3748

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions x/merkledb/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,21 @@ type MerkleDB interface {
Prefetcher
}

func NewConfig() Config {
return Config{
BranchFactor: BranchFactor16,
Hasher: DefaultHasher,
RootGenConcurrency: 0,
HistoryLength: 300,
ValueNodeCacheSize: units.MiB,
IntermediateNodeCacheSize: units.MiB,
IntermediateWriteBufferSize: units.KiB,
IntermediateWriteBatchSize: 256 * units.KiB,
TraceLevel: InfoTrace,
Tracer: trace.Noop,
}
}

type Config struct {
// BranchFactor determines the number of children each node can have.
BranchFactor BranchFactor
Expand Down
19 changes: 5 additions & 14 deletions x/merkledb/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"github.com/ava-labs/avalanchego/database/dbtest"
"github.com/ava-labs/avalanchego/database/memdb"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/trace"
"github.com/ava-labs/avalanchego/utils/hashing"
"github.com/ava-labs/avalanchego/utils/maybe"
"github.com/ava-labs/avalanchego/utils/set"
Expand All @@ -40,19 +39,11 @@ func newDB(ctx context.Context, db database.Database, config Config) (*merkleDB,
}

func newDefaultConfig() Config {
return Config{
BranchFactor: BranchFactor16,
Hasher: DefaultHasher,
RootGenConcurrency: 0,
HistoryLength: defaultHistoryLength,
ValueNodeCacheSize: units.MiB,
IntermediateNodeCacheSize: units.MiB,
IntermediateWriteBufferSize: units.KiB,
IntermediateWriteBatchSize: 256 * units.KiB,
Reg: prometheus.NewRegistry(),
TraceLevel: InfoTrace,
Tracer: trace.Noop,
}
config := NewConfig()
config.HistoryLength = defaultHistoryLength
config.Reg = prometheus.NewRegistry()

return config
}

func Test_MerkleDB_Get_Safety(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion x/merkledb/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "github.com/ava-labs/avalanchego/trace"

const (
DebugTrace TraceLevel = iota - 1
InfoTrace // Default
InfoTrace
NoTrace
)

Expand Down
Loading