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

chore: backport https://github.com/skip-mev/connect/pull/705 #864

Merged
merged 4 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion abci/strategies/aggregator/mocks/mock_price_applier.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion abci/strategies/aggregator/mocks/mock_vote_aggregator.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion abci/strategies/codec/mocks/extended_commit_codec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions abci/strategies/codec/mocks/vote_extension_codec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions abci/strategies/currencypair/mocks/mock_oracle_keeper.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions abci/types/mocks/mock_oracle_keeper.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions oracle/config/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ type APIConfig struct {

// Name is the name of the provider that corresponds to this config.
Name string `json:"name"`

// MaxBlockHeightAge is the oldest an update from an on-chain data source can be without having its
// block height incremented. In the case where a data source has exceeded this limit and the block
// height is not increasing, price reporting will be skipped until the block height increases.
MaxBlockHeightAge time.Duration `json:"maxBlockHeightAge"`
}

// Endpoint holds all data necessary for an API provider to connect to a given endpoint
Expand Down Expand Up @@ -123,5 +128,9 @@ func (c *APIConfig) ValidateBasic() error {
}
}

if c.MaxBlockHeightAge < 0 {
return fmt.Errorf("max_block_height_age cannot be negative")
}

return nil
}
30 changes: 30 additions & 0 deletions oracle/config/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,36 @@ func TestAPIConfig(t *testing.T) {
},
expectedErr: false,
},
{
name: "good config with max_block_height_age",
config: config.APIConfig{
Enabled: true,
Timeout: time.Second,
Interval: time.Second,
ReconnectTimeout: time.Second,
MaxQueries: 1,
Name: "test",
Endpoints: []config.Endpoint{{URL: "http://test.com"}},
BatchSize: 1,
MaxBlockHeightAge: 10 * time.Second,
},
expectedErr: false,
},
{
name: "bad config with negative max_block_height_age",
config: config.APIConfig{
Enabled: true,
Timeout: time.Second,
Interval: time.Second,
ReconnectTimeout: time.Second,
MaxQueries: 1,
Name: "test",
Endpoints: []config.Endpoint{{URL: "http://test.com"}},
BatchSize: 1,
MaxBlockHeightAge: -10 * time.Second,
},
expectedErr: true,
},
{
name: "bad config with invalid endpoint (no url)",
config: config.APIConfig{
Expand Down
2 changes: 1 addition & 1 deletion oracle/metrics/mocks/mock_metrics.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

156 changes: 151 additions & 5 deletions oracle/mocks/PriceAggregator.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading