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

feat: option to disable price feeder ticks for full nodes #522

Merged
merged 4 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 13 additions & 2 deletions pricefeeder/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,23 @@ config_path = ""

# Log level of price feeder process.
log_level = "info"

# Enable the price feeder.
enable = false
`
)

const (
FlagConfigPath = "pricefeeder.config_path"
FlagLogLevel = "pricefeeder.log_level"
FlagConfigPath = "pricefeeder.config_path"
FlagLogLevel = "pricefeeder.log_level"
FlagEnablePriceFeeder = "pricefeeder.enable"
)

// AppConfig defines the app configuration for the price feeder that must be set in the app.toml file.
type AppConfig struct {
ConfigPath string `mapstructure:"config_path"`
LogLevel string `mapstructure:"log_level"`
Enable bool `mapstructure:"enable"`
}

// ValidateBasic performs basic validation of the price feeder app config.
Expand Down Expand Up @@ -57,6 +62,12 @@ func ReadConfigFromAppOpts(opts servertypes.AppOptions) (AppConfig, error) {
}
}

if v := opts.Get(FlagEnablePriceFeeder); v != nil {
if cfg.Enable, err = cast.ToBoolE(v); err != nil {
return cfg, err
}
}

if err := cfg.ValidateBasic(); err != nil {
return cfg, err
}
Expand Down
6 changes: 3 additions & 3 deletions x/oracle/abci/endblocker.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ func EndBlocker(ctx context.Context, k keeper.Keeper) error {

params := k.GetParams(sdkCtx)

// Start price feeder if it hasn't been started.
if k.PriceFeeder.Oracle == nil {
// Start price feeder if it hasn't been started, and it is enabled.
if k.PriceFeeder.Oracle == nil && k.PriceFeeder.AppConfig.Enable {
go func() {
err := k.PriceFeeder.Start(sdkCtx.BlockHeight(), params)
if err != nil {
Expand All @@ -51,7 +51,7 @@ func EndBlocker(ctx context.Context, k keeper.Keeper) error {
}

if k.IsPeriodLastBlock(sdkCtx, params.VotePeriod) {
if k.PriceFeeder.Oracle != nil {
if k.PriceFeeder.Oracle != nil && k.PriceFeeder.AppConfig.Enable {
// Update price feeder oracle with latest params.
k.PriceFeeder.Oracle.ParamCache.UpdateParamCache(sdkCtx.BlockHeight(), k.GetParams(sdkCtx), nil)

Expand Down
Loading