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

fix: use send_gateway_tx on payload upload #13

Merged
merged 3 commits into from
Jan 8, 2025
Merged

Conversation

frenzox
Copy link
Contributor

@frenzox frenzox commented Jan 7, 2025

Describe the changes

This way we can ignore the error in case the account has already been initialized and/or in case the message has already been committed.

Also, added check to avoid uploading the message and calling the destination program in case the IncomingMessage has already been executed.

Related Issue(s)

Closes #12

This way we can ignore the error in case the account has already been
initialized.

Signed-off-by: Guilherme Felipe da Silva <[email protected]>
Signed-off-by: Guilherme Felipe da Silva <[email protected]>
@frenzox frenzox force-pushed the fix/use-send-gateway-tx branch from 495549c to dfbde96 Compare January 7, 2025 14:35
@frenzox frenzox self-assigned this Jan 7, 2025
@frenzox frenzox marked this pull request as ready for review January 7, 2025 14:45
@frenzox frenzox added the enhancement New feature or request label Jan 7, 2025
@frenzox frenzox requested review from roberts-pumpurs, tilacog and eloylp and removed request for roberts-pumpurs January 7, 2025 14:45
Copy link
Member

@eloylp eloylp left a comment

Choose a reason for hiding this comment

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

LGTM! - but wait for others who have more relayer context ;)

let incoming_message = IncomingMessage::read(&raw_incoming_message)
.ok_or_eyre("failed to read incoming message")?;

Ok(incoming_message.status == MessageStatus::Executed)
Copy link
Member

Choose a reason for hiding this comment

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

I just wonder if this would be a relatively expensive operation (One io RPC call) and how far we would be from implementing an LRU cache. I guess this need all depends how many "hits" we are expecting here. If we are hitting this check all the time, i would maybe go for it (on a separate issue). Wdyt?

Copy link
Member

Choose a reason for hiding this comment

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

In the standard flow we'd get 1 hit per 1 message upon relayer startup, no extra calls. I don't think LRU cache would help us here.

This is because the relayer gets "tasks" from the Amplifier API that are always sequential and always unique. This means that there's only ever gonna be a single "execute GMP message" task for a single message incoming message (unless the relayer gets restarted and we query the same tasks from the Amplifier API -- but even then LRU cache would not help us here)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I'm not sure how caching would help us here. I mean, it would be nice to be able to avoid this call, but we would likely have a cache miss most of the time and thus the cost of checking the cache would not be worth it.

Copy link
Member

Choose a reason for hiding this comment

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

Okay i see. So the amplifier API only works with "exactly once" and not with "at least once" semantics. Thanks !

Copy link
Member

@roberts-pumpurs roberts-pumpurs left a comment

Choose a reason for hiding this comment

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

lgtm

let incoming_message = IncomingMessage::read(&raw_incoming_message)
.ok_or_eyre("failed to read incoming message")?;

Ok(incoming_message.status == MessageStatus::Executed)
Copy link
Member

Choose a reason for hiding this comment

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

In the standard flow we'd get 1 hit per 1 message upon relayer startup, no extra calls. I don't think LRU cache would help us here.

This is because the relayer gets "tasks" from the Amplifier API that are always sequential and always unique. This means that there's only ever gonna be a single "execute GMP message" task for a single message incoming message (unless the relayer gets restarted and we query the same tasks from the Amplifier API -- but even then LRU cache would not help us here)

@frenzox frenzox merged commit 76112c9 into main Jan 8, 2025
6 checks passed
@frenzox frenzox deleted the fix/use-send-gateway-tx branch January 8, 2025 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use send_gateway_tx in the relayer
3 participants