sui icon indicating copy to clipboard operation
sui copied to clipboard

move-package: add name resolution hook

Open kklas opened this issue 2 years ago • 10 comments

Description

Adds a custom_resolve_pkg_name hook in order to allow for the dependency graph to discriminate between packages based on a dynamically resolved symbol (returned by the hook) rather than just package name. When the hook isn't defined it returns the package manifest name when so this doesn't affect Sui package resolution currently. This will make it possible to consolidate source and on-chain packages (which don't have a name) within a single graph.

This is part of the work to enable compiling against on-chain dependencies https://github.com/MystenLabs/sui/pull/14178.

Test Plan

Added unit tests.


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)

  • [ ] protocol change
  • [ ] 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

kklas avatar Dec 12 '23 15:12 kklas

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

Name Status Preview Comments Updated (UTC)
mysten-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 21, 2023 11:19am
sui-typescript-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 21, 2023 11:19am
3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
explorer ⬜️ Ignored (Inspect) Visit Preview Dec 21, 2023 11:19am
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Dec 21, 2023 11:19am
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Dec 21, 2023 11:19am

vercel[bot] avatar Dec 12 '23 15:12 vercel[bot]

@kklas is attempting to deploy a commit to the Sui Foundation Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Dec 12 '23 15:12 vercel[bot]

@amnn @rvantonder I'm debating whether the custom_resolve_pkg_name (and corresponding variables) should be renamed to custom_resolve_pkg_identifier because "pkg_name" variables in dependency graph conflating between package name as defined in manifest and resolved name gets super confusing with later changes.

kklas avatar Dec 12 '23 15:12 kklas

conflating between package name as defined in manifest and resolved name gets super confusing with later changes.

A better name sounds good to me! Thoughts on custom_resolve_pkg_manifest_name or custom_resolve_pkg_name_from_manifest? I think more verbosity here will help, identifier comes across as something more general than the "real" description that causes confusion :-)

rvantonder avatar Dec 12 '23 16:12 rvantonder

(kicking off CI)

rvantonder avatar Dec 12 '23 16:12 rvantonder

Well the problem is really with referring to the thing as "package name" since with the resolution hook it's not necessarily a name anymore. E.g. with Sui on-chain resolution hooks it will be its original id.

So the first point of confusion is that dependency graph code uses types such as PM::PackageName in maps as package keys and the other is that variable names such as pkg_name are used when with the resolution hook it's not necessarilly a package name. This becomes especially tricky around places where the resolution hook gets called and propagated because all variable names become confusing when reading the code.

I was thinking we need something more generic than package name.

kklas avatar Dec 12 '23 21:12 kklas

Got it! If this is a case of just renaming, I'm generally in favor (indicating identifer is good, with appropriate comments to explain this could refer to a source package name, versus an on-chain ID).

@kklas is your sense that there's a direction that this is more than renaming, i.e., we may want types to represent these?

Either way, I think we're good to follow up with a renaming / refactor PR to be hygienic about this, and don't need to bundle it with this PR. @amnn to weigh in when he's back from PTO later this week, but I don't see this as needing to block this PR. I'll take a deeper look soon!

rvantonder avatar Dec 12 '23 22:12 rvantonder

I think it would just be a renaming in dependency_graph and resolution_graph files. PM::PackageName is a type alias to Symbol so we can just introduce a new alias like PackageIdentifier. There's a lot of pkg_name variables in these files though (~130).

kklas avatar Dec 12 '23 22:12 kklas

I will change name to identifier at the end because otherwise there will be a lot of merge conflicts with commits that are ready from before.

kklas avatar Dec 19 '23 15:12 kklas

(kicking off CI)

rvantonder avatar Dec 20 '23 22:12 rvantonder

@rvantonder what's the status?

kklas avatar Jan 03 '24 17:01 kklas

Thanks for the ping, let's merge!

rvantonder avatar Jan 03 '24 17:01 rvantonder