CCIP-1306 Using proper query for fetching single CommitReport from the LP#291
Conversation
f07a917 to
dbec116
Compare
dimkouv
left a comment
There was a problem hiding this comment.
love this!
added some nits
core/services/ocr2/plugins/ccip/internal/ccipdata/commit_store_reader.go
Outdated
Show resolved
Hide resolved
| func (c *CommitStoreV1_0_0) GetAcceptedCommitReportsGteSeqNum(ctx context.Context, seqNum uint64, confs int) ([]Event[CommitStoreReport], error) { | ||
| logs, err := c.lp.LogsDataWordGreaterThan( | ||
| func (c *CommitStoreV1_0_0) GetCommitReportMatchingSeqNum(ctx context.Context, seqNum uint64, confs int) ([]Event[CommitStoreReport], error) { | ||
| logs, err := c.lp.LogsDataWordBetween( |
There was a problem hiding this comment.
we should be erroring if len(logs) > 1 to comply with the interface comment
There was a problem hiding this comment.
I added defensive check + log without returning an error. If we get more than one it's probably a scenario which will be hard to recover from, I assume it might be some glitch/error in LP - for instance, it persisted the same Log twice or sth. Let's be defensive here, but also not break processing. Therefore I added log and returned always at most 1 element slice
core/services/ocr2/plugins/ccip/internal/ccipdata/commit_store_v1_2_0.go
Show resolved
Hide resolved
d1ab4ae to
a53c85f
Compare
| } | ||
| } | ||
|
|
||
| func Benchmark_LogsDataWordBetween(b *testing.B) { |
There was a problem hiding this comment.
@dimkouv No big difference ;) 1-2 ms on avg, let's wait with adding limit1 until we have some DSL to do that
Using LIMIT 1
Benchmark_LogsDataWordBetween
Benchmark_LogsDataWordBetween-12 42 26292686 ns/op
Benchmark_LogsDataWordBetween-12 40 26545705 ns/op
Benchmark_LogsDataWordBetween-12 42 25068981 ns/op
Benchmark_LogsDataWordBetween-12 42 24866132 ns/op
Benchmark_LogsDataWordBetween-12 43 25001792 ns/op
Benchmark_LogsDataWordBetween-12 43 25912275 ns/op
Benchmark_LogsDataWordBetween-12 43 24767023 ns/op
Benchmark_LogsDataWordBetween-12 42 26012244 ns/op
Benchmark_LogsDataWordBetween-12 48 25809934 ns/op
Benchmark_LogsDataWordBetween-12 42 24808771 ns/op
PASS
Without LIMIT
Benchmark_LogsDataWordBetween
Benchmark_LogsDataWordBetween-12 42 26762404 ns/op
Benchmark_LogsDataWordBetween-12 43 27254803 ns/op
Benchmark_LogsDataWordBetween-12 39 28243682 ns/op
Benchmark_LogsDataWordBetween-12 43 27615336 ns/op
Benchmark_LogsDataWordBetween-12 39 27010718 ns/op
Benchmark_LogsDataWordBetween-12 43 26643946 ns/op
Benchmark_LogsDataWordBetween-12 44 26516652 ns/op
Benchmark_LogsDataWordBetween-12 39 34758611 ns/op
Benchmark_LogsDataWordBetween-12 40 25562183 ns/op
Benchmark_LogsDataWordBetween-12 42 26939871 ns/op
PASS
Motivation
The current approach to fetching CommitReport based on
seqNris suboptimal. We can have query with better filters that pick exactly one report that we need instead of fetching all Commit Reports greater or equal passed sequence number. Under higher load it becomes a bottleneckSolution
Use a dedicated query
LogsDataWordBetweenthat applies lower and upper bound filters in the SQL query