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

[10/x][programmable transactions] Add migration and builder #8769

Merged
merged 3 commits into from
Mar 3, 2023

Conversation

tnowacki
Copy link
Contributor

@tnowacki tnowacki commented Mar 1, 2023

Description

Adds a programmable transaction builder. APIs are there mostly for migration.

Builds on #8767

Test Plan

Not yet in use


If your changes are not user-facing and not a breaking change, you can skip the following section. Otherwise, please indicate what changed, and then add to the Release Notes section as highlighted during the release process.

Type of Change (Check all that apply)

  • user-visible impact
  • breaking change for a client SDKs
  • breaking change for FNs (FN binary must upgrade)
  • breaking change for validators or node operators (must upgrade binaries)
  • breaking change for on-chain data layout
  • necessitate either a data wipe or data migration

Release notes

@tnowacki tnowacki requested review from amnn and patrickkuo March 1, 2023 23:55
@vercel
Copy link

vercel bot commented Mar 1, 2023

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

3 Ignored Deployments
Name Status Preview Comments Updated
explorer ⬜️ Ignored (Inspect) Mar 3, 2023 at 11:28PM (UTC)
explorer-storybook ⬜️ Ignored (Inspect) Mar 3, 2023 at 11:28PM (UTC)
wallet-adapter ⬜️ Ignored (Inspect) Mar 3, 2023 at 11:28PM (UTC)

@@ -0,0 +1,244 @@
// Copyright (c) Mysten Labs, Inc.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any suggestions where this should live?

Copy link
Member

Choose a reason for hiding this comment

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

If it's only temporary, I don't think we should worry too hard about this -- but this doesn't seem like a bad place for it since SingleTransactionKind, and ProgrammableTransaction are both in a sibling module.

Copy link
Member

Choose a reason for hiding this comment

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

Having said that, you may want to re-use the builder without the migration logic in the SDK? cc @patrickkuo

Copy link
Member

@amnn amnn left a comment

Choose a reason for hiding this comment

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

LGTM!

crates/sui-types/src/messages.rs Outdated Show resolved Hide resolved
Self::ProgrammableTransaction(pt) => {
Either::Right(Either::Left(pt.shared_input_objects()))
}
_ => Either::Right(Either::Right(iter::empty())),
Copy link
Member

Choose a reason for hiding this comment

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

We should implement all dynamic dispatch like this

@@ -1586,10 +1609,10 @@ impl TransactionData {
self.kind.shared_input_objects()
}

pub fn move_calls(&self) -> Vec<&MoveCall> {
pub fn legacy_move_calls(&self) -> Vec<&MoveCall> {
Copy link
Member

Choose a reason for hiding this comment

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

Can we add a document here explaining what's legacy about these move calls, and why you may not want to use this anymore, after programmable transactions takes over the world (i.e. what goes wrong in that case, if you keep using this function).

@@ -0,0 +1,244 @@
// Copyright (c) Mysten Labs, Inc.
Copy link
Member

Choose a reason for hiding this comment

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

If it's only temporary, I don't think we should worry too hard about this -- but this doesn't seem like a bad place for it since SingleTransactionKind, and ProgrammableTransaction are both in a sibling module.

amounts,
}) => self.pay(coins, recipients, amounts)?,
SingleTransactionKind::PaySui(_) | SingleTransactionKind::PayAllSui(_) => {
anyhow::bail!(
Copy link
Member

Choose a reason for hiding this comment

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

Is this an existing limitation of PaySui and PayAllSui (that they can't exist in a batch) or a new limitation from programmable transactions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You cannot map PaySui into a SingleTransacitonKind, but only TransactionData because the coins need to be in the gas vector with gas smashing

@@ -0,0 +1,244 @@
// Copyright (c) Mysten Labs, Inc.
Copy link
Member

Choose a reason for hiding this comment

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

Having said that, you may want to re-use the builder without the migration logic in the SDK? cc @patrickkuo

crates/sui-types/src/programmable_transaction_builder.rs Outdated Show resolved Hide resolved
) -> anyhow::Result<()> {
let mut coins = coins.into_iter();
let Some(coin) = coins.next()
else {
Copy link
Member

Choose a reason for hiding this comment

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

nit: Funky formatting

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 think this is the RFC formatting for let else

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I think the RFC formatting for this let-else would be

let Some(coin) = coins.next() else {
    anyhow::bail!("coins vector is empty");
};

According to this section

Copy link
Member

Choose a reason for hiding this comment

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

Although I've got to say, the rules as written in the RFC are super ambiguous in general, and I for one welcome our rustfmt overloads, whenever they choose to impose their iron will on let-else. Until then, I don't have a strong opposition to this formatting, it just scanned strangely for me.

@tnowacki tnowacki enabled auto-merge (squash) March 2, 2023 19:05
@tnowacki tnowacki disabled auto-merge March 2, 2023 19:12
@tnowacki tnowacki enabled auto-merge (squash) March 2, 2023 22:06
@tnowacki tnowacki merged commit ce875f5 into MystenLabs:main Mar 3, 2023
@tnowacki tnowacki deleted the pt-10 branch March 31, 2023 20:44
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