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

Refactor agent event indexing #2246

Merged
merged 51 commits into from
May 22, 2023
Merged

Refactor agent event indexing #2246

merged 51 commits into from
May 22, 2023

Conversation

asaj
Copy link
Contributor

@asaj asaj commented May 12, 2023

Description

This PR refactors event indexing in the agents, allowing similar logic to be shared across multiple event types (i.e. messages, deliveries, gas payments) and database types (i.e. the Relayer rocks DB and Scraper SQL DB).

Furthermore, it adds new syncing modes by way of MessageSyncCursors that take advantage of the monotonically increasing dispatched message nonce to sync more intelligently.

Drive-by changes

  • Fixes a bug in the existing cursor that caused the same block range to be indexed three times
  • Modifies kathy to get rid of the idea of "rounds", just sends messages with a sleep in between
  • Minor modifications to the e2e test for performance
  • Expand macros in settings
  • Add scraper to e2e test

Opportunities for improvement

  • We can further reduce RPC usage (or improve latency) by sharing the view of the latest finalized block number between cursors
  • We can speed up the effective time for (a relayer to start deliving messages | the scraper to scraper recent events) by creating forward/backward cursors for gas payments and deliveries where the backwards cursor terminates at index_settings.from
  • We can remove the need for index_settings.from by terminating backwards cursors based on the block number that the first message was dispatched at

Related issues

  • Fixes #[issue number here]

Backward compatibility

Are these changes backward compatible?

Yes

Are there any infrastructure implications, e.g. changes that would prohibit deploying older commits using this infra tooling?

None

Testing

What kind of testing have these changes undergone?

E2E tests

@asaj asaj changed the title Start preparations for backfill indexing Refactor agent event indexing May 17, 2023
rust/agents/scraper/src/db/block.rs Show resolved Hide resolved
rust/agents/scraper/src/db/message.rs Show resolved Hide resolved
rust/agents/scraper/src/db/txn.rs Show resolved Hide resolved
rust/chains/hyperlane-ethereum/src/mailbox.rs Show resolved Hide resolved
rust/hyperlane-base/src/contract_sync/metrics.rs Outdated Show resolved Hide resolved
rust/hyperlane-base/src/contract_sync/mod.rs Outdated Show resolved Hide resolved
@asaj asaj marked this pull request as ready for review May 17, 2023 12:50
Copy link
Collaborator

@tkporter tkporter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Re: alternate execution environments where we may be polling per message nonce or an IGP payment sequence number instead of looking at block ranges, how were you thinking that could fit into this interface?

rust/agents/scraper/src/chain_scraper/mod.rs Outdated Show resolved Hide resolved
rust/agents/scraper/src/chain_scraper/mod.rs Show resolved Hide resolved
rust/agents/scraper/src/chain_scraper/mod.rs Outdated Show resolved Hide resolved
rust/agents/scraper/src/db/block.rs Show resolved Hide resolved
rust/chains/hyperlane-ethereum/src/mailbox.rs Show resolved Hide resolved
rust/hyperlane-base/src/contract_sync/mod.rs Show resolved Hide resolved
@asaj asaj enabled auto-merge (squash) May 22, 2023 13:54
@asaj asaj merged commit 63562c7 into main May 22, 2023
@asaj asaj deleted the asaj/indexing branch May 22, 2023 14:27
tkporter added a commit that referenced this pull request May 25, 2023
…mAccounts based indexing (#2273)

### Description

* Pulls main, mostly to include #2246
* Fixes #2205 
* Moves to a getProgramAccounts based indexing

### Drive-by changes

n/a

### Related issues

- Fixes #2205

### Backward compatibility

_Are these changes backward compatible?_

Yes

_Are there any infrastructure implications, e.g. changes that would
prohibit deploying older commits using this infra tooling?_

None


### Testing

_What kind of testing have these changes undergone?_

Unit Tests

---------

Co-authored-by: Nam Chu Hoai <nambrot@googlemail.com>
Co-authored-by: Yorke Rhodes <yorke@hyperlane.xyz>
Co-authored-by: J M Rossy <jm.rossy@gmail.com>
Co-authored-by: Mattie Conover <git@mconover.dev>
Co-authored-by: Asa Oines <asaoines@gmail.com>
Co-authored-by: Sergei Patrikeev <serejke.best@gmail.com>
mattiekat added a commit that referenced this pull request Aug 11, 2023
### Description

This resolves the insertion conflict that is being caused by #2246 that
introduced multiple concurrent tasks to scrape. This does not address
the underlying concurrency issue I discovered, however. Please review
the issue comments for more details.

### Drive-by changes

- Cleans up logs a bit (This was useful during testing and I think is
useful globally)
- Removed an unused file

### Related issues

Fixes hyperlane-xyz/issues#493

### Backward compatibility

Yes

### Testing

Manual
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants