-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
fix: add max results error and default raw codec for eth_getLogs #12671
base: master
Are you sure you want to change the base?
Changes from all commits
67c4b72
0d7956c
4f9b754
6cab093
8cca81c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -22,6 +22,8 @@ import ( | |||||
"github.com/filecoin-project/lotus/chain/types" | ||||||
) | ||||||
|
||||||
var ErrMaxResultsReached = xerrors.New("max results limit reached, results truncated") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
const maxLookBackForWait = 120 // one hour of tipsets | ||||||
|
||||||
type executedMessage struct { | ||||||
|
@@ -358,9 +360,9 @@ func (si *SqliteIndexer) GetEventsForFilter(ctx context.Context, f *EventFilter) | |||||
if row.id != currentID { | ||||||
// Unfortunately we can't easily incorporate the max results limit into the query due to the | ||||||
// unpredictable number of rows caused by joins | ||||||
// Break here to stop collecting rows | ||||||
// Error here to inform the caller that we've hit the max results limit | ||||||
if f.MaxResults > 0 && len(ces) >= f.MaxResults { | ||||||
break | ||||||
return nil, ErrMaxResultsReached | ||||||
} | ||||||
|
||||||
currentID = row.id | ||||||
|
@@ -563,6 +565,9 @@ func makePrefillFilterQuery(f *EventFilter) ([]any, string, error) { | |||||
clauses = append(clauses, "("+strings.Join(subclauses, " OR ")+")") | ||||||
} | ||||||
} | ||||||
} else if f.Codec != 0 { // if no keys are specified, we can use the codec filter | ||||||
clauses = append(clauses, "ee.codec=?") | ||||||
values = append(values, f.Codec) | ||||||
} | ||||||
|
||||||
s := `SELECT | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -47,6 +47,8 @@ type EventFilter struct { | |||||
|
||||||
KeysWithCodec map[string][]types.ActorEventBlock // map of key names to a list of alternate values that may match | ||||||
MaxResults int // maximum number of results to collect, 0 is unlimited | ||||||
|
||||||
Codec uint64 // optional codec filter, only used if KeysWithCodec is not set | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
|
||||||
type Indexer interface { | ||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1768,12 +1768,19 @@ func (e *EthEventHandler) ethGetEventsForFilter(ctx context.Context, filterSpec | |||||||||||||||||||||||||||||||||||||||||||||||||
return nil, xerrors.New("cannot ask for events for a tipset at or greater than head") | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
var codec uint64 | ||||||||||||||||||||||||||||||||||||||||||||||||||
// if no keys are specified, we can use the codec filter to make sure we only get `raw` encoded events | ||||||||||||||||||||||||||||||||||||||||||||||||||
if len(pf.keys) == 0 { | ||||||||||||||||||||||||||||||||||||||||||||||||||
codec = uint64(multicodec.Raw) | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
ef := &index.EventFilter{ | ||||||||||||||||||||||||||||||||||||||||||||||||||
MinHeight: pf.minHeight, | ||||||||||||||||||||||||||||||||||||||||||||||||||
MaxHeight: pf.maxHeight, | ||||||||||||||||||||||||||||||||||||||||||||||||||
TipsetCid: pf.tipsetCid, | ||||||||||||||||||||||||||||||||||||||||||||||||||
Addresses: pf.addresses, | ||||||||||||||||||||||||||||||||||||||||||||||||||
KeysWithCodec: pf.keys, | ||||||||||||||||||||||||||||||||||||||||||||||||||
Codec: codec, | ||||||||||||||||||||||||||||||||||||||||||||||||||
MaxResults: e.EventFilterManager.MaxFilterResults, | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+1771
to
1785
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
you can avoid the conditional, it's always There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking, since @rvagg Let me know what you think about the above, otherwise I will make your suggested changes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that regardless of what But also, I think if it was a public-facing API then we might want to be a bit more careful with the layout of it. Consider, for example, we have |
||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to think about the change from a user perspective:
raw
vscbor
thing is pretty esoteric, so we can side-step that.