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(common): allow specifying concurrency in transactionQueue #2589

Merged
merged 5 commits into from
Apr 2, 2024

Conversation

holic
Copy link
Member

@holic holic commented Apr 2, 2024

After hearing from @Kooshaba about Sky Strife latency, specifically when playing from Japan, I did a bit of testing with a fresh template deployed to Redstone Holesky to find out where some of the latency was coming from. There's quite a few factors at play:

  • each tx requires gas estimation, and viem does two RPC round trips: one to get max priority fee per gas and one to get the gas estimate of the call
    • the former can likely be cached but I am unclear how safe it is to do so (is this a hardcoded chain value? or something that fluctuates based on demand?)
    • the latter can possibly be cached for recurring calls to the same methods with same/similar args (Sky Strife does some variant of this) but would need some thought to get this right, if not just leave this to user land to figure out
  • the transaction queue defaults to processing a single item at a time, to ensure no nonce errors, but with all the rpc round trips, that means 1-2s before a tx is even submitted (given Japan latency), then waiting for the next block to be mined, and this is super apparent once you queue up more than a couple txs

Even though increasing the concurrency will lead to nonce errors, it may be an acceptable trade-off for certain games/applications where its safe to retry after nonce failure and its fine to have somewhat out-of-order operations.

Copy link

changeset-bot bot commented Apr 2, 2024

🦋 Changeset detected

Latest commit: 6ba28df

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 24 packages
Name Type
@latticexyz/common Patch
@latticexyz/block-logs-stream Patch
@latticexyz/cli Patch
@latticexyz/config Patch
@latticexyz/dev-tools Patch
@latticexyz/faucet Patch
@latticexyz/protocol-parser Patch
@latticexyz/query Patch
@latticexyz/store-indexer Patch
@latticexyz/store-sync Patch
@latticexyz/store Patch
@latticexyz/world-modules Patch
@latticexyz/world Patch
@latticexyz/react Patch
@latticexyz/abi-ts Patch
create-mud Patch
@latticexyz/gas-report Patch
@latticexyz/recs Patch
@latticexyz/schema-type Patch
@latticexyz/services Patch
solhint-config-mud Patch
solhint-plugin-mud Patch
@latticexyz/utils Patch
mock-game-contracts Patch

Not sure what this means? Click here to learn what changesets are.

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

@holic holic marked this pull request as ready for review April 2, 2024 03:18
@holic holic requested review from alvrs and yonadaa as code owners April 2, 2024 03:18
Copy link
Contributor

@Kooshaba Kooshaba left a comment

Choose a reason for hiding this comment

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

makes sense to me. i think even a concurrency of 2 will already be a huge win for UX in sky strife.

@holic holic merged commit 620e4ec into main Apr 2, 2024
12 checks passed
@holic holic deleted the holic/transaction-queue-concurrency branch April 2, 2024 03:38
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