diff --git a/eth/filters/api.go b/eth/filters/api.go index 0fa927612f8a..4e1191f6dbe6 100644 --- a/eth/filters/api.go +++ b/eth/filters/api.go @@ -44,6 +44,9 @@ var ( // The maximum number of topic criteria allowed, vm.LOG4 - vm.LOG0 const maxTopics = 4 +// The maximum number of allowed topics within a topic criteria +const maxSubTopics = 1000 + // filter is a helper struct that holds meta information over the filter type // and associated subscription in the event system. type filter struct { @@ -620,7 +623,6 @@ func (args *TxFilterCriteria) UnmarshalJSON(data []byte) error { // data is an array consisting of strings. // JSON null values are converted to common.Hash{} and ignored by the filter manager. if len(raw.SigHashes) > 0 { - parsed, err := decodeSigHashes(raw.SigHashes) if err != nil { return err @@ -694,6 +696,10 @@ func decodeTopics(input []interface{}) ([][]common.Hash, error) { return nil, nil } + if len(input) > maxTopics { + return nil, errExceedMaxTopics + } + result := make([][]common.Hash, len(input)) for i, t := range input { @@ -711,6 +717,9 @@ func decodeTopics(input []interface{}) ([][]common.Hash, error) { case []interface{}: // or case e.g. [null, "topic0", "topic1"] + if len(topic) > maxSubTopics { + return nil, errExceedMaxTopics + } for _, rawTopic := range topic { if rawTopic == nil { // null component, match all