Skip to content

Conversation

@lxfind
Copy link
Contributor

@lxfind lxfind commented Dec 21, 2025

Description

This PR gets rid of the dependency to the need to read old accumulator objects. This is necessary since we may not always have access to old accumulator objects due to pruning.
In order to do this, we introduce a new primitive in the writeback cache (get_latest_account_amount). This function reads the latest balance of the specified accumulator object, together with its current version. The implementation guarantees that the version is accurate. This is easy to do if the object exists, as we can just get its version, but in the case if the object does not exist, in order to get its current version, we must derive it from the root accumulator object. To deal with potential data races where the root is being mutated, we have to make sure that we read the root version before and after the read of the accumulator object, and only return if they are the same. This leads to a loop. In practice, this loop should not run more than a few times as the read of these objects should all be cached and are very fast.

With the primitive above, when we initialize an account in the eager scheduler, we know exactly the version of it. This is recorded in the account state. When we settle funds, if the version being settled is prior to the last updated version, we can just ignore the settlement; we only apply the settlement if it's actually newer.
We also skip schedule if the version of the accumulator object is newer than the withdraw.

To make the logic cleaner and more obvious, the account state and pending withdraw impls are refactored out to separate files.

Test plan

Added more unit tests and integration tests.


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):
  • gRPC:
  • JSON-RPC:
  • GraphQL:
  • CLI:
  • Rust SDK:
  • Indexing Framework:

@lxfind lxfind temporarily deployed to sui-typescript-aws-kms-test-env December 21, 2025 05:45 — with GitHub Actions Inactive
@vercel
Copy link

vercel bot commented Dec 21, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
sui-docs Error Error Dec 22, 2025 11:51pm
2 Skipped Deployments
Project Deployment Review Updated (UTC)
multisig-toolkit Ignored Ignored Preview Dec 22, 2025 11:51pm
sui-kiosk Ignored Ignored Preview Dec 22, 2025 11:51pm

@lxfind lxfind changed the title Rewrite withdraw scheduler Do not depend on old accumulator objects Dec 22, 2025
@lxfind lxfind force-pushed the xun/address-balance-eager-scheduler-rewrite branch from 6208a26 to 0c0d35e Compare December 22, 2025 19:26
@lxfind lxfind temporarily deployed to sui-typescript-aws-kms-test-env December 22, 2025 19:26 — with GitHub Actions Inactive
@lxfind lxfind requested a review from mystenmark December 22, 2025 19:26
@lxfind lxfind force-pushed the xun/address-balance-eager-scheduler-rewrite branch from 0c0d35e to 56a6083 Compare December 22, 2025 21:30
@lxfind lxfind temporarily deployed to sui-typescript-aws-kms-test-env December 22, 2025 21:30 — with GitHub Actions Inactive
@lxfind lxfind force-pushed the xun/address-balance-eager-scheduler-rewrite branch from 56a6083 to 8b4cb6f Compare December 22, 2025 22:12
@lxfind lxfind had a problem deploying to sui-typescript-aws-kms-test-env December 22, 2025 22:12 — with GitHub Actions Failure
@lxfind lxfind temporarily deployed to sui-typescript-aws-kms-test-env December 22, 2025 22:28 — with GitHub Actions Inactive
@lxfind lxfind force-pushed the xun/address-balance-eager-scheduler-rewrite branch from 8b4cb6f to 14222d7 Compare December 22, 2025 23:50
@lxfind lxfind had a problem deploying to sui-typescript-aws-kms-test-env December 22, 2025 23:50 — with GitHub Actions Failure
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