-
Notifications
You must be signed in to change notification settings - Fork 124
/
Copy pathconfig.go
59 lines (48 loc) · 2.37 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright (C) 2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package vm
import (
"time"
"github.com/ava-labs/avalanchego/utils/units"
"github.com/ava-labs/hypersdk/chain"
"github.com/ava-labs/hypersdk/chainindex"
hcontext "github.com/ava-labs/hypersdk/context"
)
const (
VMNamespaceKey = "vm"
)
type Config struct {
MempoolSize int `json:"mempoolSize"`
MempoolSponsorSize int `json:"mempoolSponsorSize"`
AuthVerificationCores int `json:"authVerificationCores"`
RootGenerationCores int `json:"rootGenerationCores"`
StateHistoryLength int `json:"stateHistoryLength"` // how many roots back of data to keep to serve state queries
IntermediateNodeCacheSize int `json:"intermediateNodeCacheSize"` // how many bytes to keep in intermediate cache
StateIntermediateWriteBufferSize int `json:"stateIntermediateWriteBufferSize"` // how many bytes to keep unwritten in intermediate cache
StateIntermediateWriteBatchSize int `json:"stateIntermediateWriteBatchSize"` // how many bytes to write from intermediate cache at once
ValueNodeCacheSize int `json:"valueNodeCacheSize"` // how many bytes to keep in value cache
TargetGossipDuration time.Duration `json:"targetGossipDuration"`
}
func NewConfig() Config {
return Config{
MempoolSize: 2_048,
AuthVerificationCores: 1,
RootGenerationCores: 1,
MempoolSponsorSize: 32,
StateHistoryLength: 256,
IntermediateNodeCacheSize: 4 * units.GiB,
StateIntermediateWriteBufferSize: 32 * units.MiB,
StateIntermediateWriteBatchSize: 4 * units.MiB,
ValueNodeCacheSize: 2 * units.GiB,
TargetGossipDuration: 20 * time.Millisecond,
}
}
func GetVMConfig(config hcontext.Config) (Config, error) {
return hcontext.GetConfig(config, VMNamespaceKey, NewConfig())
}
func GetChainConfig(config hcontext.Config) (chain.Config, error) {
return hcontext.GetConfig(config, chainNamespace, chain.NewDefaultConfig())
}
func GetChainIndexConfig(config hcontext.Config) (chainindex.Config, error) {
return hcontext.GetConfig(config, chainIndexNamespace, chainindex.NewDefaultConfig())
}