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

feat: Support SequenceAware cursors for Deliveries #4889

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ameten
Copy link
Contributor

@ameten ameten commented Nov 22, 2024

Description

Support SequenceAware cursors for Deliveries

Related issues

Backward compatibility

Yes (need adding column sequence to delivered_message table before merging

Testing

E2E Ethereum and Sealevel tests

Copy link

changeset-bot bot commented Nov 22, 2024

⚠️ No Changeset found

Latest commit: 36a4c26

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

codecov bot commented Nov 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.60%. Comparing base (81ab433) to head (36a4c26).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4889   +/-   ##
=======================================
  Coverage   74.60%   74.60%           
=======================================
  Files         103      103           
  Lines        1516     1516           
  Branches      195      195           
=======================================
  Hits         1131     1131           
  Misses        364      364           
  Partials       21       21           
Components Coverage Δ
core 84.61% <ø> (ø)
hooks 77.77% <ø> (ø)
isms 79.02% <ø> (ø)
token 89.07% <ø> (ø)
middlewares 77.58% <ø> (ø)
---- 🚨 Try these New Features:

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, some suggestions

recipient: bytes_to_address(message.recipient)?,
body: message.msg_body.unwrap_or(Vec::new()),
}))
let delivery = bytes_to_address(delivery.msg_id)?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a more direct way of converting bytes to an h256 when we always expect the byte count to be 32? Feels a little awkward / misleading to be using a function intended for addresses that would support other lengths

#[instrument(skip(self))]
pub async fn retrieve_message_by_nonce(
pub async fn retrieve_delivered_message_by_sequence(
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: wonder if it's worth having the name reflect that this returns the message ID (not the message itself)

} else {
Ok(None)
}
}

/// Get the tx id associated with a dispatched message.
/// Get the delivered message associated with a sequence.
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit

Suggested change
/// Get the delivered message associated with a sequence.
/// Get the tx id of a delivered message associated with a sequence.

sequence: u32,
) -> Result<Option<Delivery>> {
if let Some(delivery) = delivered_message::Entity::find()
.filter(delivered_message::Column::Domain.eq(destination_domain))
Copy link
Collaborator

Choose a reason for hiding this comment

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

is there any meaningful benefit to selecting just the column we care about? i assume it's pretty much negligible as there isn't much data in each row


#[async_trait]
impl HyperlaneSequenceAwareIndexerStoreReader<Delivery> for HyperlaneDbStore {
/// Gets a delivered message by its nonce.
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit

Suggested change
/// Gets a delivered message by its nonce.
/// Gets a delivered message by its sequence.

}

/// Gets the block number at which the log occurred.
async fn retrieve_log_block_number_by_sequence(&self, sequence: u32) -> Result<Option<u64>> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: any thoughts / intuition on the runtime cost of this requiring 3 round trips? wondering if it's worth a single query that joins

@@ -685,18 +685,18 @@ impl SealevelMailboxIndexer {
&self.mailbox.rpc()
}

async fn get_dispatched_message_with_nonce(
async fn get_dispatched_message_with_sequence(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't feel strongly but fwiw I'm comfortable with referring to sequences as nonces for dispatched messages as they're the same. Calling this out mostly because in some other places we keep the nonce language (e.g. retrieve_dispatched_message_by_nonce that's in this PR), and consistency is nice. But agree that get_delivered_message_with_sequence is a better name

@@ -939,10 +942,23 @@ impl Indexer<H256> for SealevelMailboxIndexer {
#[async_trait]
impl SequenceAwareIndexer<H256> for SealevelMailboxIndexer {
async fn latest_sequence_count_and_tip(&self) -> ChainResult<(Option<u32>, u32)> {
// TODO: implement when sealevel scraper support is implemented
info!("Message delivery indexing not implemented");
let inbox = self
Copy link
Collaborator

Choose a reason for hiding this comment

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

might be a good idea to use / dedupe some of the existing logic we have for getting this here

let inbox_account = self.rpc().get_account(&self.inbox.0).await?;
let inbox = InboxAccount::fetch(&mut inbox_account.data.as_ref())
.map_err(ChainCommunicationError::from_other)?
.into_inner();
, e.g. with a get_inbox_account or something

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

2 participants