Skip to content
Open
Show file tree
Hide file tree
Changes from 6 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
9 changes: 9 additions & 0 deletions sei-tendermint/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,11 @@ type RPCConfig struct {
// Maximum number of results returned by tx_search and block_search.
// 0 disables the cap (not recommended on public nodes).
MaxTxSearchResults int `mapstructure:"max-tx-search-results"`

// Maximum number of index entries a single tx_search / block_search may
// examine on the fallback scan path (CONTAINS/MATCHES/value ranges) before
// the query is rejected as too broad. 0 disables the budget.
MaxEventSearchScan int `mapstructure:"max-event-search-scan"`
}

// DefaultRPCConfig returns a default configuration for the RPC server
Expand Down Expand Up @@ -570,6 +575,7 @@ func DefaultRPCConfig() *RPCConfig {
TimeoutWrite: 30 * time.Second,

MaxTxSearchResults: 10_000,
MaxEventSearchScan: 50_000,
}
}

Expand Down Expand Up @@ -625,6 +631,9 @@ func (cfg *RPCConfig) ValidateBasic() error {
if cfg.MaxTxSearchResults < 0 {
return errors.New("max-tx-search-results can't be negative")
}
if cfg.MaxEventSearchScan < 0 {
return errors.New("max-event-search-scan can't be negative")
}
return nil
}

Expand Down
1 change: 1 addition & 0 deletions sei-tendermint/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func TestRPCConfigValidateBasic(t *testing.T) {
"TimeoutReadHeader",
"TimeoutWrite",
"MaxTxSearchResults",
"MaxEventSearchScan",
}

for _, fieldName := range fieldsToTest {
Expand Down
6 changes: 6 additions & 0 deletions sei-tendermint/config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,12 @@ timeout-write = "{{ .RPC.TimeoutWrite }}"
# Set to 0 to disable the cap (not recommended on public nodes).
max-tx-search-results = {{ .RPC.MaxTxSearchResults }}
# Maximum number of index entries a single query on the /tx_search or
# /block_search RPC endpoint may examine on the scan path
# before the query is rejected as too broad.
# Set to 0 to disable (not recommended on public nodes).
max-event-search-scan = {{ .RPC.MaxEventSearchScan }}
#######################################################################
### P2P Configuration Options ###
#######################################################################
Expand Down
1 change: 1 addition & 0 deletions sei-tendermint/internal/rpc/core/blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ func (env *Environment) BlockSearch(ctx context.Context, req *coretypes.RequestB
results, err := kvsink.SearchBlockEvents(ctx, q, indexer.SearchOptions{
Limit: env.Config.MaxTxSearchResults,
OrderDesc: orderDesc,
MaxScan: env.Config.MaxEventSearchScan,
})
if err != nil {
return nil, err
Expand Down
1 change: 1 addition & 0 deletions sei-tendermint/internal/rpc/core/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func (env *Environment) TxSearch(ctx context.Context, req *coretypes.RequestTxSe
results, err := sink.SearchTxEvents(ctx, q, indexer.SearchOptions{
Limit: env.Config.MaxTxSearchResults,
OrderDesc: orderDesc,
MaxScan: env.Config.MaxEventSearchScan,
})
if err != nil {
return nil, err
Expand Down
Loading
Loading