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

[4/x][programmable transactions] Added MoveCall execution #8406

Merged
merged 2 commits into from
Feb 21, 2023

Conversation

tnowacki
Copy link
Contributor

  • Basically had to rewrite the Move Adapter. I wouldn't worry about the lack of code sharing as I think the current adapter can die once we migrate everything.

@tnowacki tnowacki requested a review from amnn February 18, 2023 01:31
@vercel
Copy link

vercel bot commented Feb 18, 2023

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

Name Status Preview Comments Updated
explorer ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 21, 2023 at 7:49PM (UTC)
explorer-storybook ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 21, 2023 at 7:49PM (UTC)
frenemies ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 21, 2023 at 7:49PM (UTC)
wallet-adapter ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 21, 2023 at 7:49PM (UTC)

@tnowacki
Copy link
Contributor Author

I will do some commenting later :)

@vercel vercel bot temporarily deployed to Preview – wallet-adapter February 18, 2023 01:32 Inactive
@vercel vercel bot temporarily deployed to Preview – frenemies February 18, 2023 01:32 Inactive
@vercel vercel bot temporarily deployed to Preview – explorer-storybook February 18, 2023 01:33 Inactive
- Basically had to rewrite the Move Adapter. I wouldn't worry about the lack of code sharing as I think the current adapter can die once we migrate everything.
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 -- but had a question about handling of copy (I know it kept coming up in the design as well as a source of interesting edge cases, about when to copy, when to move, when to complain about a non-drop type not being used etc).

V::try_from_value(val)
}

pub fn copy_arg<V: TryFromValue>(
Copy link
Member

Choose a reason for hiding this comment

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

I may be misunderstanding what this function is supposed to do, but I would have expected a check here that the arg was copyable (i.e. a primitive type, or has the copy ability).

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 did not do that because we will have to check the signature, and I wanted to do that before giving an ability error. For example you call

foo(x: u64)

But with a Coin as the argument. I want to give a type error, not some sort of "invalid use of copy" error.

In other words, "copy" here is more about cloning the value from a rust semantics standpoint. Maybe that would be a better name? clone_arg?

}
}

pub fn push_command_results(&mut self, results: Vec<Value>) -> Result<(), ExecutionError> {
Copy link
Member

Choose a reason for hiding this comment

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

Is it worth introducing the concept of a "Frame", that is scoped per-command, to track borrows, and hold results while they are built?

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 it totally would be if borrows weren't ensured to be empty at the end of each command. But I might not be fully understanding the suggestion. Further thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

One of the responsibilities of Frame would be to track the borrows and purge them at the end of each command.

Comment on lines +677 to +679
let layout = MoveTypeLayout::Struct(MoveStructLayout::Runtime(vec![MoveTypeLayout::Vector(
Box::new(MoveTypeLayout::U8),
)]));
Copy link
Member

Choose a reason for hiding this comment

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

I'm kind of surprised that this layout does not already exist in a more general place -- is it worth putting somewhere more general for the next person that needs to use 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.

It exists/is hard coded in the adapter. But might be worthwhile having it somewhere... just not sure where

// Returns None for all other types
pub fn is_tx_context<
E: fmt::Debug,
S: ResourceResolver<Error = E>
Copy link
Member

Choose a reason for hiding this comment

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

I feel like these trait constraints pop-up so often that they deserve an alias.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you do that???

Copy link
Contributor Author

@tnowacki tnowacki Feb 21, 2023

Choose a reason for hiding this comment

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

There is no trait alias, but I think traits support some degree of duck typing? So I added a marker trait and we will see if that works.
EDIT: Added some other magic... oh traits

Type::Vector(inner) => stack.push(&**inner),
Type::Struct(idx) => {
let Some(s) = context.session.get_struct_type(*idx) else {
invariant_violation!("Loaded struct unreachable")
Copy link
Member

Choose a reason for hiding this comment

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

This error is a little confusing to me -- what does "unreachable" mean in the context?

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'll reword

@vercel vercel bot temporarily deployed to Preview – frenemies February 21, 2023 19:12 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-adapter February 21, 2023 19:26 Inactive
@vercel vercel bot temporarily deployed to Preview – explorer-storybook February 21, 2023 19:49 Inactive
@tnowacki tnowacki merged commit 9ad77a9 into MystenLabs:main Feb 21, 2023
@tnowacki tnowacki deleted the pt-4 branch February 21, 2023 19:54
@tnowacki
Copy link
Contributor Author

cc @dariorussi who had be interested in this work

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