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

[dev-inspect] Combine to a single end point #7372

Merged
merged 10 commits into from
Jan 26, 2023

Conversation

tnowacki
Copy link
Contributor

  • Merge the transaction mode and move call only mode. Specifying the gas object isn't really necessary for dev inspect

I am not entirely sure how the read_api parts of the code should change. Maybe you can help with that @666lcz :) Thanks in advance!

@tnowacki tnowacki requested review from lxfind, 666lcz and gegaowp January 13, 2023 00:14
@vercel
Copy link

vercel bot commented Jan 13, 2023

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

4 Ignored Deployments
Name Status Preview Comments Updated
explorer ⬜️ Ignored (Inspect) Jan 26, 2023 at 2:55AM (UTC)
explorer-storybook ⬜️ Ignored (Inspect) Jan 26, 2023 at 2:55AM (UTC)
frenemies ⬜️ Ignored (Inspect) Jan 26, 2023 at 2:55AM (UTC)
wallet-adapter ⬜️ Ignored (Inspect) Jan 26, 2023 at 2:55AM (UTC)

@patrickkuo
Copy link
Contributor

patrickkuo commented Jan 13, 2023

Is this same as dry_run_transaction minus the gas object? Do we still need dry_run_transaction after this? @gegaowp ?

Copy link
Contributor

@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.

Looks good from the authority/adapter side. Holding off on the accept to give @666lcz a chance to look at the API side. I'm guessing we'll need to make changes to the SDK(s) downstream of the RPC changes as well? Will leave it between you to navigate that.

crates/sui-open-rpc/spec/openrpc.json Outdated Show resolved Hide resolved
crates/sui-types/src/messages.rs Outdated Show resolved Hide resolved
crates/sui-core/src/authority.rs Outdated Show resolved Hide resolved
assert!(effects.deleted.is_empty());
assert_eq!(effects.mutated[0].reference.object_id, gas_object_id);
assert!(effects.gas_used.computation_cost > 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Related to my question about the gas schedule, can we make any kind of claim that for a valid move call, if you send a dev-inspect transaction, and against exactly the same on-chain state, you send the move call, that their computation costs would match? (Presumably storage costs won't because we're not modifying the gas object?)

If we can, can we add a test to that effect? (Fine to do in a separate PR).

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 you should get the same result? Let me test 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.

Testing this btw opened up a bunch of issues now fixed. Sorry the PR is a bit drastically different after this

crates/sui-types/src/gas.rs Outdated Show resolved Hide resolved
crates/sui-types/src/gas.rs Outdated Show resolved Hide resolved
@tnowacki
Copy link
Contributor Author

Is this same as dry_run_transaction minus the gas object? Do we still need dry_run_transaction after this? @gegaowp ?

It is not. Dry run runs object ownership checks, entry rule checks, valid usage of Pure, etc. Dry run should be (long term) equivalent to running the exact transaction possibly with/without gas.

Dev inspect is a literally any transaction with any arguments.

Mentioned in the meeting this morning, but copying here for posterity. We can split that up in a few different ways, but from a client side, it might make sense to expose dev-inspect and dry-run with different flags

Copy link
Contributor

@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.

This looks good to me! Will accept to unblock, but cc @666lcz in case there are changes necessary on the SDK side

@@ -1085,26 +1085,44 @@ impl AuthorityState {
SuiTransactionEffects::try_from(effects, self.module_cache.as_ref())
}

/// The object ID for gas can be any object ID, even for an uncreated object
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this comment still make sense? This function doesn't accept a gas object ID.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, sorry, was from an intermediate version of this PR

let shared_object_refs = input_objects.filter_shared_objects();

// TODO should we error instead for 0?
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a fan of the existing solution (picking a sensible default).

@@ -320,13 +320,14 @@ async fn test_dev_inspect_object_by_bytes() {
.unwrap()
.contents()
.to_vec();
// gas used should be the same
let actual_gas_used: SuiGasCostSummary = effects.gas_used.into();
assert_eq!(actual_gas_used, dev_inspect_gas_summary);
Copy link
Contributor

Choose a reason for hiding this comment

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

🎉

Copy link
Contributor

@gegaowp gegaowp left a comment

Choose a reason for hiding this comment

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

Great move, the read_api part looks good per se, will need proper BCS encoding indeed for txn kind. Maybe we can further merge dry run and dev inspect to one.

crates/sui-json-rpc/src/read_api.rs Show resolved Hide resolved
Ok(self
.state
.dev_inspect_move_call(sender_address, move_call, epoch)
.dev_inspect_transaction(sender_address, tx_kind, gas_price.unwrap_or(1), epoch)
Copy link
Contributor

@666lcz 666lcz Jan 20, 2023

Choose a reason for hiding this comment

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

we should use reference gas price here as the default. I'll make this change in my diff as well unless there's any concern

Copy link
Contributor

@666lcz 666lcz left a comment

Choose a reason for hiding this comment

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

@tnowacki I have added TS Support. However, one of the e2e test is failing with the following error:

test/e2e/dev-inspect.test.ts > Test dev inspect > Dev inspect transaction with PayAllSui
Error: Error dev inspect transaction with request type: Error: RPC Error: SUI payment transactions use first input coin for gas payment, but found a different gas object.
 ❯ JsonRpcProvider.devInspectTransaction src/providers/json-rpc-provider.ts:737:13
    735|       return resp;
    736|     } catch (err) {
    737|       throw new Error(
       |             ^
    738|         `Error dev inspect transaction with requ…
    739|       );

Due to this check

SuiError::UnexpectedGasPaymentObject
. Should we bypass this for DevInspect?

Comment on lines 710 to 826
// TODO: remove after 0.23.0 is deployed in both DevNet and TestNet
if (version?.major == 0 && version?.minor < 23) {
return this.devInspectTransactionDeprecated(sender, tx, epoch);
Copy link
Contributor

Choose a reason for hiding this comment

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

@tnowacki We are going to release a new DevNet on Jan 25th(Wednesday). If this is not merged before the DevNet release, then we would need to update version?.minor < 23 to version?.minor < 24.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When is the cut for 0.23?

@tnowacki tnowacki enabled auto-merge (squash) January 26, 2023 02:47
@tnowacki tnowacki merged commit 72481e7 into MystenLabs:main Jan 26, 2023
@tnowacki tnowacki deleted the di-simple branch January 26, 2023 17:56
williampsmith pushed a commit that referenced this pull request Feb 3, 2023
- Merge the transaction mode and move call only mode. Specifying the gas
object isn't really necessary for dev inspect
- The two dev inspect modes (transaction and Move call) have been merged into a single endpoint
- Some transaction types have been disabled in dev inspect 

Co-authored-by: Chris Li <[email protected]>
Gkirito added a commit to coming-chat/go-sui-sdk that referenced this pull request Feb 3, 2023
0xJEth added a commit to 0xJEth/go-sui-sdk that referenced this pull request Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants