Skip to content

[ptb] Add error for init on new modules during upgrade #22855

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

Merged
merged 6 commits into from
Jul 24, 2025

Conversation

tnowacki
Copy link
Contributor

Description

  • We currently silently ignore init functions on new modules during Upgrade
    • We will eventually support init functions

Test plan

  • many new tests

Release notes

Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.

For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.

  • Protocol:
  • Nodes (Validators and Full nodes):
  • gRPC:
  • JSON-RPC:
  • GraphQL:
  • CLI:
  • Rust SDK:

@tnowacki tnowacki requested a review from a team July 23, 2025 17:33
@tnowacki tnowacki requested a review from mystenmark as a code owner July 23, 2025 17:33
@tnowacki tnowacki temporarily deployed to sui-typescript-aws-kms-test-env July 23, 2025 17:33 — with GitHub Actions Inactive
Copy link

vercel bot commented Jul 23, 2025

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

Name Status Preview Comments Updated (UTC)
sui-docs ❌ Failed (Inspect) Jul 24, 2025 10:53pm
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Jul 24, 2025 10:53pm
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Jul 24, 2025 10:53pm

Comment on lines +2169 to +2185
if let Some(m) = self
.compiled_state
.dep_modules()
.find(|m| &m.self_id() == id)
{
Ok(Some(Cow::Borrowed(m)))
} else {
let module = self
.executor
.get_object(&ObjectID::from(*id.address()))
.and_then(|obj| {
let data = obj.data.try_as_package()?.get_module(id)?;
let module = CompiledModule::deserialize_with_defaults(data).unwrap();
Some(module)
})
.unwrap_or_else(|| panic!("Internal error: Unbound module {}", id));
Ok(Some(Cow::Owned(module)))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change was left over from attempting to add upgrade on init. I can make it a separate PR but it feels fine for now?

Copy link
Contributor

@tzakian tzakian left a comment

Choose a reason for hiding this comment

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

LGTM!

@@ -794,6 +794,46 @@ mod checked {
&modules,
upgrade_ticket.policy,
)?;
if context.protocol_config.check_for_init_during_upgrade() {
// find newly added modules to the package,
// and run their init functions (if applicable)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: old comment

Copy link
Contributor

@dariorussi dariorussi left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -2162,15 +2163,27 @@ impl SuiTestAdapter {
impl<'a> GetModule for &'a SuiTestAdapter {
type Error = anyhow::Error;

type Item = &'a CompiledModule;
type Item = Cow<'a, CompiledModule>;
Copy link
Contributor

Choose a reason for hiding this comment

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

seriously?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

?

Comment on lines +831 to +834
return Err(ExecutionError::new_with_source(
ExecutionErrorKind::FeatureNotYetSupported,
"`init` in new modules on upgrade is not yet supported",
));
Copy link
Contributor

Choose a reason for hiding this comment

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

so this is effectively the new error right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct

@tnowacki tnowacki temporarily deployed to sui-typescript-aws-kms-test-env July 24, 2025 22:52 — with GitHub Actions Inactive
@tnowacki tnowacki enabled auto-merge (squash) July 24, 2025 22:52
@tnowacki tnowacki merged commit 17320d9 into MystenLabs:main Jul 24, 2025
49 of 50 checks passed
@tnowacki tnowacki deleted the upgrade-init branch July 24, 2025 23:28
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