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

Occ enabled cfg #398

Merged
merged 2 commits into from
Jan 18, 2024
Merged
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
7 changes: 7 additions & 0 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const (

FlagChainID = "chain-id"
FlagConcurrencyWorkers = "concurrency-workers"
FlagOccEnabled = "occ-enabled"
)

var (
Expand Down Expand Up @@ -167,6 +168,7 @@ type BaseApp struct { //nolint: maligned
TracingInfo *tracing.Info

concurrencyWorkers int
occEnabled bool
}

type appStore struct {
Expand Down Expand Up @@ -318,6 +320,11 @@ func (app *BaseApp) ConcurrencyWorkers() int {
return app.concurrencyWorkers
}

// OccEnabled returns the whether OCC is enabled for the BaseApp.
func (app *BaseApp) OccEnabled() bool {
return app.occEnabled
}

// Version returns the application's version string.
func (app *BaseApp) Version() string {
return app.version
Expand Down
5 changes: 5 additions & 0 deletions baseapp/baseapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ func TestSetMinGasPrices(t *testing.T) {
require.Equal(t, minGasPrices, app.minGasPrices)
}

func TestSetOccEnabled(t *testing.T) {
app := newBaseApp(t.Name(), SetOccEnabled(true))
require.True(t, app.OccEnabled())
}

// func TestGetMaximumBlockGas(t *testing.T) {
// app := setupBaseApp(t)
// app.InitChain(context.Background(), &abci.RequestInitChain{})
Expand Down
11 changes: 11 additions & 0 deletions baseapp/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@
return func(app *BaseApp) { app.SetConcurrencyWorkers(workers) }
}

func SetOccEnabled(occEnabled bool) func(*BaseApp) {
return func(app *BaseApp) { app.SetOccEnabled(occEnabled) }
}

// SetSnapshotKeepRecent sets the recent snapshots to keep.
func SetSnapshotKeepRecent(keepRecent uint32) func(*BaseApp) {
return func(app *BaseApp) { app.SetSnapshotKeepRecent(keepRecent) }
Expand Down Expand Up @@ -301,6 +305,13 @@
app.concurrencyWorkers = workers
}

func (app *BaseApp) SetOccEnabled(occEnabled bool) {
if app.sealed {
panic("SetOccEnabled() on sealed BaseApp")

Check warning on line 310 in baseapp/options.go

View check run for this annotation

Codecov / codecov/patch

baseapp/options.go#L310

Added line #L310 was not covered by tests
}
app.occEnabled = occEnabled
}

// SetSnapshotKeepRecent sets the number of recent snapshots to keep.
func (app *BaseApp) SetSnapshotKeepRecent(snapshotKeepRecent uint32) {
if app.sealed {
Expand Down
7 changes: 7 additions & 0 deletions server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

// DefaultConcurrencyWorkers defines the default workers to use for concurrent transactions
DefaultConcurrencyWorkers = 20

// DefaultOccEanbled defines whether to use OCC for tx processing
DefaultOccEnabled = true
)

// BaseConfig defines the server's basic configuration
Expand Down Expand Up @@ -95,6 +98,8 @@
// ConcurrencyWorkers defines the number of workers to use for concurrent
// transaction execution. A value of -1 means unlimited workers. Default value is 10.
ConcurrencyWorkers int `mapstructure:"concurrency-workers"`
// Whether to enable optimistic concurrency control for tx execution, default is true
OccEnabled bool `mapstructure:"occ-enabled"`
}

// APIConfig defines the API listener configuration.
Expand Down Expand Up @@ -246,6 +251,7 @@
CompactionInterval: 0,
NoVersioning: false,
ConcurrencyWorkers: DefaultConcurrencyWorkers,
OccEnabled: DefaultOccEnabled,
},
Telemetry: telemetry.Config{
Enabled: false,
Expand Down Expand Up @@ -323,6 +329,7 @@
NumOrphanPerFile: v.GetInt("num-orphan-per-file"),
OrphanDirectory: v.GetString("orphan-dir"),
ConcurrencyWorkers: v.GetInt("concurrency-workers"),
OccEnabled: v.GetBool("occ-enabled"),

Check warning on line 332 in server/config/config.go

View check run for this annotation

Codecov / codecov/patch

server/config/config.go#L332

Added line #L332 was not covered by tests
},
Telemetry: telemetry.Config{
ServiceName: v.GetString("telemetry.service-name"),
Expand Down
5 changes: 5 additions & 0 deletions server/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,8 @@ func TestSetConcurrencyWorkers(t *testing.T) {
cfg := DefaultConfig()
require.Equal(t, DefaultConcurrencyWorkers, cfg.ConcurrencyWorkers)
}

func TestOCCEnabled(t *testing.T) {
cfg := DefaultConfig()
require.Equal(t, true, cfg.OccEnabled)
}
9 changes: 6 additions & 3 deletions server/config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const DefaultConfigTemplate = `# This is a TOML config file.
# specified in this config (e.g. 0.25token1;0.0001token2).
minimum-gas-prices = "{{ .BaseConfig.MinGasPrices }}"

# Pruning Strategies:
# Pruning Strategies:
# - default: Keep the recent 362880 blocks and prune is triggered every 10 blocks
# - nothing: all historic states will be saved, nothing will be deleted (i.e. archiving node)
# - everything: all saved states will be deleted, storing only the recent 2 blocks; pruning at every block
Expand Down Expand Up @@ -75,11 +75,11 @@ inter-block-cache = {{ .BaseConfig.InterBlockCache }}
# ["message.sender", "message.recipient"]
index-events = {{ .BaseConfig.IndexEvents }}

# IavlCacheSize set the size of the iavl tree cache.
# IavlCacheSize set the size of the iavl tree cache.
# Default cache size is 50mb.
iavl-cache-size = {{ .BaseConfig.IAVLCacheSize }}

# IAVLDisableFastNode enables or disables the fast node feature of IAVL.
# IAVLDisableFastNode enables or disables the fast node feature of IAVL.
# Default is true.
iavl-disable-fastnode = {{ .BaseConfig.IAVLDisableFastNode }}

Expand Down Expand Up @@ -107,6 +107,9 @@ orphan-dir = "{{ .BaseConfig.OrphanDirectory }}"
# concurrency-workers defines how many workers to run for concurrent transaction execution
# concurrency-workers = {{ .BaseConfig.ConcurrencyWorkers }}

# occ-enabled defines whether OCC is enabled or not for transaction execution
occ-enabled = {{ .BaseConfig.OccEnabled }}

###############################################################################
### Telemetry Configuration ###
###############################################################################
Expand Down
1 change: 1 addition & 0 deletions simapp/simd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@
baseapp.SetIAVLCacheSize(cast.ToInt(appOpts.Get(server.FlagIAVLCacheSize))),
baseapp.SetIAVLDisableFastNode(cast.ToBool(appOpts.Get(server.FlagIAVLFastNode))),
baseapp.SetCompactionInterval(cast.ToUint64(appOpts.Get(server.FlagCompactionInterval))),
baseapp.SetOccEnabled(cast.ToBool(appOpts.Get(baseapp.FlagOccEnabled))),

Check warning on line 308 in simapp/simd/cmd/root.go

View check run for this annotation

Codecov / codecov/patch

simapp/simd/cmd/root.go#L308

Added line #L308 was not covered by tests
)
}

Expand Down
Loading