-
Notifications
You must be signed in to change notification settings - Fork 21.4k
graphql: return correct logs for tx #25612
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
Conversation
graphql/graphql.go
Outdated
ret := make([]*Log, 0) | ||
for _, log := range logs { | ||
if uint64(log.TxIndex) != t.index { | ||
continue |
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.
logs
is sorted by TxIndex, so this could be improved to skip most iteration:
ix := sort.Search(len(logs), func (i int) bool { return logs[i].TxIndex == t.index })
for ix < len(logs) && logs[ix].TxIndex == t.index {
ret = append(ret, logs[ix])
ix++
}
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.
Also, it's kind of weird to use a filter here. We could just call t.r.backend.GetLogs
to get the block logs.
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.
Hmm, just realized that the filter is used here exactly because GetLogs
doesn't have access to the cache.
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.
I kind of like the simplicity even tho it's slightly less fast, if you don't have a strong feeling about it.
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.
Fix tested working on my personal node.
Would deploy 1.10.23 + your_fix on prod if no 1.10.24 official version before the merge (currently using 1.10.21 + TTD set in CLI params)
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.
I'm slightly in favor of @fjl's suggestion.
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.
LGTM
graphql/graphql.go
Outdated
ret := make([]*Log, 0) | ||
for _, log := range logs { | ||
if uint64(log.TxIndex) != t.index { | ||
continue |
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.
I'm slightly in favor of @fjl's suggestion.
graphql/graphql.go
Outdated
return nil, err | ||
} | ||
ret := make([]*Log, 0, len(logs)) | ||
ret := make([]*Log, 0) |
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.
ret := make([]*Log, 0) | |
var ret []*Log |
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.
LGTM
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.
LGTM
As part of #25459 I made a change so that graphql's tx log query goes through the usual filter system so it benefits from the newly added cache. However the filter system only handles logs on the block level, not tx level and I didn't select logs based on txindex which caused a regression.
Fixes #25583