Skip to content

Add withdraw reservation to Transaction #22434

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

lxfind
Copy link
Contributor

@lxfind lxfind commented Jun 18, 2025

Description

Add a new CallArg to represent balance withdraw reservation.
This is not necessarily the final form. Adding it to support e2e testing and development.
Since this is all gated behind a protocol config, no transactions with withdraw reservation can be committed on-chain right now.

Test plan

CI


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:

Copy link

vercel bot commented Jun 18, 2025

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

Name Status Preview Comments Updated (UTC)
sui-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 19, 2025 5:38am
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Jun 19, 2025 5:38am
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Jun 19, 2025 5:38am

@lxfind lxfind temporarily deployed to sui-typescript-aws-kms-test-env June 18, 2025 18:16 — with GitHub Actions Inactive
@lxfind lxfind force-pushed the xun/accumulator-transaction-add-withdraw branch from 7295459 to c617989 Compare June 18, 2025 18:21
@lxfind lxfind temporarily deployed to sui-typescript-aws-kms-test-env June 18, 2025 18:21 — with GitHub Actions Inactive
@lxfind lxfind requested review from tnowacki, bmwill and mystenmark June 18, 2025 18:22
@lxfind lxfind force-pushed the xun/accumulator-transaction-add-withdraw branch from c617989 to f2690c1 Compare June 18, 2025 18:24
@lxfind lxfind temporarily deployed to sui-typescript-aws-kms-test-env June 18, 2025 18:24 — with GitHub Actions Inactive
@lxfind lxfind force-pushed the xun/accumulator-transaction-add-withdraw branch from f2690c1 to baa3f9e Compare June 18, 2025 18:35
@lxfind lxfind temporarily deployed to sui-typescript-aws-kms-test-env June 18, 2025 18:35 — with GitHub Actions Inactive
@lxfind lxfind force-pushed the xun/accumulator-transaction-add-withdraw branch from baa3f9e to f3410c9 Compare June 18, 2025 19:05
@lxfind lxfind temporarily deployed to sui-typescript-aws-kms-test-env June 18, 2025 19:05 — with GitHub Actions Inactive
Comment on lines 120 to 142
pub struct BalanceWithdrawArg {
/// The maximum amount of the balance to withdraw.
/// If None, reserve the entire balance.
pub max_amount: Option<u64>,
/// The source of the balance to withdraw.
pub withdraw_from: WithdrawFrom,
}

#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize)]
pub enum WithdrawFrom {
/// Withdraw from the sender of the transaction, with balance type T as T in Balance<T>.
Sender(TypeTag),
// TODO: Add more options here, such as Sponsor.
}
Copy link
Contributor

Choose a reason for hiding this comment

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

do we want the type T to be hoisted into BalanceWithdrawArg? I'd imagine this is something that would exist in all variant here so it probably makes more sense to hoist it out

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, that depends how powerful we want to make sponsored transactions to be.
Today a sponsored transaction can only sponsor SUI, which can be used for both gas payment and money transfer.
With address balances, indeed we could open up to allow sponsoring arbitrary Balance type T other than Sui beyond gas payment. I was initially thinking that we should keep Sponsor semantically identical to what we have today (i.e. besides gas sponsorship, there can be a separate withdraw reservation that sponsors some extra SUI)

pub struct BalanceWithdrawArg {
/// The maximum amount of the balance to withdraw.
/// If None, reserve the entire balance.
pub max_amount: Option<u64>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we just make an enum here? Fine with the option though

Comment on lines 130 to 140
/// Withdraw from the sender of the transaction, with balance type T as T in Balance<T>.
Sender(TypeTag),
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be TypeInput and I think we should move the TypeInput onto the arg itself. I don't really see a case where the type specifier wont' be necessary

Copy link
Contributor

Choose a reason for hiding this comment

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

(also TypeInput not TypeTag)

Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need TypeInput now?

Comment on lines 75 to 78
CallArg::BalanceWithdraw(_) => {
todo!("Load balance withdraw call arg")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

As a heads up, we are actively in the process of trying to get this code up and running. So let's be mindful of that as the downstream effects of having to deal with this now rather than later might make @tzakian and I cry many tears

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 don't need this piece of code working right now. I only need the CallArg to be visible in a transaction so that I can test the scheduler logic.

@@ -113,6 +116,22 @@ pub enum ObjectArg {
Receiving(ObjectRef),
}

#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize)]
pub struct BalanceWithdrawArg {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should settle on a name for the module before naming this call arg (or just be prepared to rename it)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Happy to rename to whatever

@lxfind lxfind force-pushed the xun/accumulator-transaction-add-withdraw branch from f3410c9 to 6d14a07 Compare June 19, 2025 05:02
@lxfind lxfind temporarily deployed to sui-typescript-aws-kms-test-env June 19, 2025 05:02 — with GitHub Actions Inactive
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.

3 participants