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

[adapter] run linker during publish flow #189

Merged
merged 1 commit into from
Jan 18, 2022

Conversation

sblackshear
Copy link
Collaborator

Resolving a longstanding TODO to invoke the Move linker during the adapter's publishing flow.
This will ensure that all packages are well-typed wr.t. their dependencies on-chain.

In addition, this reorganizes the adapter publish code a bit to separate out the different kinds of checks from the update logic. This should make it easier to invoke these checks from outside the publish path (e.g., from genesis or from the client) if needed.

}
// TODO(https://github.com/MystenLabs/fastnft/issues/69): Run Move linker
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I tried adding the run of the linker in this PR, but it needs an impl StateView that is inconvenient to create without some refactoring.

Copy link
Contributor

@huitseeker huitseeker left a comment

Choose a reason for hiding this comment

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

Not that I'm a well-versed in this area of the logic, but LGTM, AFAICT


// 1. Create a module that depends on a genesis module that exists, but via an invalid handle
let mut dependent_module = file_format::empty_module();
// make `dependent_module` depend on `m`
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// make `dependent_module` depend on `m`
// make `dependent_module` depend on `id_module`

.address_identifiers
.push(*id_module.self_id().address());
dependent_module.module_handles.push(ModuleHandle {
address: AddressIdentifierIndex((dependent_module.address_identifiers.len() - 1) as u16),
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I wonder if an inner function last_index returning u16 wouldn't help make this more readable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It definitely would... This code lives in the Move repo, otherwise I would go ahead and add it in the current PR.


#[cfg(test)]
fn init_state() -> AuthorityState {
let (committee, authority_address, authority_key, store) = init_state_parameters();
AuthorityState::new_without_genesis_for_testing(
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 could just change init_state() to call new_with_genesis_modules instead of new_without_genesis_for_testing so that the initial state will have genesis. It doesn't hurt anyway.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this makes sense, but doing this forces me to make init_state async and then async-ify the rest of the tests, which is a decently sized change. Would rather hold that for a different PR.

// verifier may assume well-formedness conditions enforced by the Move verifier hold
let vm = MoveVM::new(natives)
.expect("VM creation only fails if natives are invalid, and we created the natives");
let mut gas_status = get_gas_status(None)
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 mean that linking through vm consumes gas? Is that something we want to track and deduct? (feel free to add TODO if that's the case)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The VM doesn't do any gas metering on the publish code path--I could change the budget to (e.g.) Some(15) and the semantics would be the same. I'll add a comment to explain this.

Resolving a longstanding TODO to invoke the Move linker during the adapter's publishing flow.
This will ensure that all packages are well-typed wr.t. their dependencies on-chain.

In addition, this reorganizes the adapter publish code a bit to separate out the different kinds of checks from the update logic.
@sblackshear sblackshear merged commit 9b41469 into MystenLabs:main Jan 18, 2022
mwtian pushed a commit that referenced this pull request Sep 12, 2022
mwtian pushed a commit to mwtian/sui that referenced this pull request Sep 29, 2022
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