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: preparing for async method calls compatibility #105

Merged
merged 9 commits into from
Feb 11, 2025

Conversation

frolvanya
Copy link
Contributor

@frolvanya frolvanya commented Feb 10, 2025

Related to Near-One/omni-bridge#238

Also, for bridge-cli I decided to keep it simple:

  1. Nonce is none to let clients pick latest available nonce automatically
  2. wait_until was set to Included since it's the fastest option and it would show tx_hash asap, so user could check it in explorer

P.S: A bit more context why specifying nonce is crucial:
Right now relayer tries to process all events at the same time, so it results in creating different transactions with the same nonce, so only one tx would be processed. To resolve this we can either process each tx sequentially and wait for Final status or by having an atomic variable that would be our nonce for each chain (near, eth, base and arb) to avoid collisions. First case is very slow, so @karim-en proposed to go with a second solution

@frolvanya frolvanya requested review from karim-en and kiseln February 10, 2025 01:53
@frolvanya
Copy link
Contributor Author

frolvanya commented Feb 10, 2025

@kiseln I assume that we don't need/can't specify nonce for solana. Correct me if I'm wrong

P.S: I saw that it uses latest hash, but that means that the only way to make sure that tx won't be replayed with same signature is to process them sequentially? It won't be too long, since finalization time is short, but it's still a bit weird

image

@kiseln
Copy link
Contributor

kiseln commented Feb 10, 2025

@frolvanya transaction with the same hash will not be processed on Solana. It doesn't look like we have a problem with concurrency there since hash will change depending on the transfer payload

@@ -1,6 +1,6 @@
[package]
name = "bridge-cli"
version = "0.2.2"
version = "0.2.4"
Copy link
Contributor

Choose a reason for hiding this comment

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

I already used 0.2.4

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just synced with main. I don't know why it shows a diff 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.

But it's a good idea to prepare next version for this PR: 30533e1

pub async fn fin_transfer(
&self,
transfer_log: OmniBridgeEvent,
nonce: Option<U256>,
Copy link
Contributor

Choose a reason for hiding this comment

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

It's been confusing from the first glance that this nonce is a transaction nonce as opposed to the transfer. Since this term is used in multiple domain, should we rename it to tx_nonce everywhere for clarity?

Copy link
Contributor Author

@frolvanya frolvanya Feb 10, 2025

Choose a reason for hiding this comment

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

Fixed in eb65f3f + 0762dac

@@ -396,13 +426,16 @@ impl NearBridgeClient {
transfer_id: TransferId,
fee_recipient: Option<AccountId>,
fee: Option<Fee>,
nonce: Option<u64>,
wait_until: TxExecutionStatus,
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense to combine nonce and wait_until in a separate struct (TransactionOptions?) to separate them from domain-specific arguments

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. Fixed in eb65f3f

@frolvanya frolvanya requested a review from kiseln February 10, 2025 18:49
@frolvanya frolvanya merged commit 1267c6a into main Feb 11, 2025
16 checks passed
@frolvanya frolvanya mentioned this pull request Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants