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

Update Sdk with Arbitrum support #4720

Merged
merged 11 commits into from
Apr 5, 2024
Merged

Conversation

albert-llimos
Copy link
Contributor

@albert-llimos albert-llimos commented Apr 3, 2024

Checklist

Please conduct a thorough self-review before opening the PR.

  • I am confident that the code works.
  • I have updated documentation where appropriate.

Summary

Updating SDK with the latest version that has Arbitrum support.

After doing that I found a problem with nonces. This is my hypothesis which turned out to be true:

"The error is nonce too high. I have checcked the nonce counter logic in the bouncer and it looks good, also the prints look like we are not skipping anything. Looks solid. It even seems to happen when only running all the contract swaps via the SDK in parallel, but I'm pretty sure there is no change on the SDK either on that front.
I believe what is happening is that we have a race condition when running all swaps (normal deposit swaps & contract swaps via SDK). They are all using the same nonces and if some transaction lands in the wrong order the node will reject the transaction, even though it would eventually get mined when the transaction prior to it eventually lands.
My best guess is that we are starting to see this now because the amount of parallel swaps has increased substantially with the addition of USDT and Arbitrum assets."

For contract swaps I have modifed the logic to start each swap from a different account so there can't be issues with nonces. That works.

@albert-llimos albert-llimos changed the title chore: update sdk constants Update Arbitrum Sdk constants Apr 3, 2024
Copy link

codecov bot commented Apr 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 72%. Comparing base (8feefa8) to head (8f4a88f).
Report is 3 commits behind head on main.

Additional details and impacted files
@@          Coverage Diff           @@
##            main   #4720    +/-   ##
======================================
- Coverage     72%     72%    -0%     
======================================
  Files        417     418     +1     
  Lines      69531   69445    -86     
  Branches   69531   69445    -86     
======================================
- Hits       50245   50077   -168     
- Misses     16879   16960    +81     
- Partials    2407    2408     +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@albert-llimos albert-llimos changed the title Update Arbitrum Sdk constants Update Sdk with Arbitrum support Apr 3, 2024
@albert-llimos albert-llimos marked this pull request as ready for review April 5, 2024 13:01
await approveTokenVault(
sourceAsset,
(
BigInt(amountToFineAmount(defaultAssetAmounts(sourceAsset), assetDecimals(sourceAsset))) *
Copy link
Contributor

Choose a reason for hiding this comment

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

we should pull this out into a function that takes a source asset and amount. We use this pattern of BigInt(amountToFineAmount... in a number of other places too

gasSwapScheduledHandle = observeSwapScheduled(
sourceAsset,
destChain === 'Ethereum' ? Assets.Eth : ('ArbEth' as Asset),
destChain === 'Ethereum' ? Assets.Eth : Assets.ArbEth,
Copy link
Contributor

Choose a reason for hiding this comment

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

just noticed there are lot of other places we still use asset as string, we should move to this Assets type. (ofc, would be another ticket/PR, not directly relevant)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, there is definitely some cleanup to do in multiple places. I'll aim to get it done when I get some time.

@albert-llimos albert-llimos merged commit 0646a5a into main Apr 5, 2024
46 checks passed
@albert-llimos albert-llimos deleted the chore/update-arbitrum-sdk branch April 5, 2024 13:54
syan095 added a commit that referenced this pull request Apr 8, 2024
…-validator

* origin/main:
  fix: broker flakiness on bouncer CI (#4736)
  fix: migration for earned fees (#4733)
  feat: handle prewitness deposits (#4698)
  Update Sdk with Arbitrum support (#4720)
  chore: remove insta deprecated warning (#4734)
  refactor: move vanity names to account roles pallet (#4719)
  Arbitrum backup rpc (#4730)

# Conflicts:
#	state-chain/pallets/cf-validator/src/lib.rs
#	state-chain/pallets/cf-validator/src/mock.rs
#	state-chain/pallets/cf-validator/src/tests.rs
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