Skip to content
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

Enforcing aggressive logs and blocks cleanup #745

Draft
wants to merge 6 commits into
base: release/v2.10.0-ccip1.4
Choose a base branch
from

Conversation

mateusz-sekara
Copy link
Contributor

Motivation

Solution

mateusz-sekara and others added 2 commits April 23, 2024 08:47
…(#12786)

* Adding evm_chain_id, address and event_sig to data and topic indexes

* Post review fixes

* Post review fixes

* Post review fixes

* Post review fixes

* Bumping migration script number

---------

Co-authored-by: Domino Valdano <domino.valdano@smartcontract.com>
Current implementation fetches all the CommitReports within the
permissionlessExecThreshold from database and filter out result set
based on the `snoozedRoots`. It means that when everything is executed,
we keep fetching all roots to memory only to discover that we don't need
that data. During high traffic spikes, this is an unnecessary waste of
resources in the CL node and database as the dataset size grows in time
till it reaches permissionlessExec window (8 hours of logs for prod).

Example load run in which you can see how it changes over time during
steady traffic of messages

<img width="1488" alt="image"
src="https://github.com/smartcontractkit/ccip/assets/18304098/7b216dd4-1ab3-4943-9797-99a38f4f9eaa">

There are at least two solutions to make it more performant

1. Pass executed roots to the database query to fetch only unexpired
roots from the database. Unexpired roots can be determined from the
snoozedRoots cache. This is probably the most accurate approach because
it always fetches the minimal required set from the database.

You can think of the query like this
```sql
select * from evm.logs
where address = :addr
and event_sig = :event_sig
and substring(data, X, Y) not in (:executed_roots_array)
and block_timestamp > :permissionlessThresholdWindow
```

2. Make permissionlessThreshold filter "sliding". Commit Reports are
executed sequentially for most of the cases, so we can keep track of
timestamps of the oldest fully executed report. Instead of inventing a
new query for LogPoller we can achieve a lot based on the assumption
that execution is sequential. Whenever report is markedAsExecuted we
keep bumping block_timestamp filter. We already have that information in
cache and indirectly rely on that when filtering out snoozedRoots
```sql
and block_timestamp > :oldest_executed_timestamp
```

Solution 2 is easier to implement, doesn't require any changes to
LogPoller (and query perf testing) and can be handled in the plugin. We
already cache snoozedRoots so we can reuse that to move filtering to the
database by narrowing the block_timestamp search window. Assuming that
reports are executed sequentially, it should be as accurate as solution
1.

duration)
<img width="1088" alt="image"
src="https://github.com/smartcontractkit/ccip/assets/18304098/c445495d-51e7-4138-a00b-662423fa0cdf">
Copy link
Contributor

I see you updated files related to core. Please run pnpm changeset to add a changeset.

RensR and others added 2 commits April 23, 2024 11:51
* Adding evm_chain_id, address and event_sig to data and topic indexes
smartcontractkit/chainlink#12786
* Improved fetching Commit Reports from database
#726
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do not merge Do not merge at this time
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants