sui icon indicating copy to clipboard operation
sui copied to clipboard

Congestion control triggered transaction cancellation

Open halfprice opened this issue 1 year ago • 1 comments

Description

This PR implements congestion control triggered transaction cancellation. The motivation for the cancellation is that we don't want a transaction to be deferred for too long, which impacts user perceived latency. When a transaction is deferred for max_deferral_rounds_for_congestion_control rounds, we will cancel the transaction.

To cancel a transaction, we cannot simply drop it on the floor and return an error, since if there is any owned object used in the transaction, those owned objects are still locked. So we need to actually send the transaction to the execution engine, unlock the owned object, and return error immediately without running the transaction. User will also be charged for gas for cancelled transaction as well.

The cancellation logic works as follows. During shared object assignment in consensus handler, we assign special object versions to shared objects in a cancelled transaction (SequenceNumber::CONGESTED, and SequenceNumber::CANCELLED_READ, both are larger than SequenceNumber::MAX). The version not only indicates transaction cancellation, in our case, it also informs which objects are congested. The special version is how consensus handler communicates with transaction manager and execution engine regarding whether a transaction should be cancelled.

Follow up PRs:

  • We need to record cancelled transaction shared object version assignment in a new consensus commit prologue transaction.
  • Replay cancelled transaction is currently not handled in this PR.
  • If an object queue is already long enough, we may want to cancel transactions at the end of the queue if there is no hope to execute them in the future.

Test plan

Added unit test to tests:

  • Shared object version assignment
  • Consensus handler cancellation logic
  • Transaction manager cancellation logic
  • Execution engine cancellation logic

Added a integration test fo a controlled e2e test.


Release notes

Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.

For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.

  • [ ] Protocol:
  • [ ] Nodes (Validators and Full nodes):
  • [ ] Indexer:
  • [ ] JSON-RPC:
  • [ ] GraphQL:
  • [ ] CLI:
  • [ ] Rust SDK:

halfprice avatar Apr 17 '24 07:04 halfprice

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sui-core ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 7, 2024 9:48pm
sui-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 7, 2024 9:48pm
3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview May 7, 2024 9:48pm
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview May 7, 2024 9:48pm
sui-typescript-docs ⬜️ Ignored (Inspect) Visit Preview May 7, 2024 9:48pm

vercel[bot] avatar Apr 17 '24 07:04 vercel[bot]