Skip to content

Conversation

@miker83z
Copy link
Contributor

@miker83z miker83z commented Nov 15, 2025

Description of change

This PR removes the previous method for verifying the authenticate functions which worked at runtime. Then, it introduces the creation of a Package Metadata immutable object during a package publishing/upgrade. Finally, it allows to use such metadata to create AuthenticatorInfoV1 instances for accounts.

Links to any relevant issues

Fixes #8861
Fixes #8862

How the change has been tested

  • Basic tests (linting, compilation, formatting, unit/integration tests)
  • Patch-specific tests (correctness, functionality coverage)
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that new and existing unit tests pass locally with my changes

@miker83z miker83z requested review from Dkwcs and valeriyr November 15, 2025 14:28
@miker83z miker83z self-assigned this Nov 15, 2025
@vercel
Copy link

vercel bot commented Nov 15, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

6 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
apps-backend Ignored Ignored Preview Nov 24, 2025 8:46pm
apps-ui-kit Ignored Ignored Preview Nov 24, 2025 8:46pm
iota-evm-bridge Ignored Ignored Preview Nov 24, 2025 8:46pm
iota-multisig-toolkit Ignored Ignored Preview Nov 24, 2025 8:46pm
rebased-explorer Ignored Ignored Preview Nov 24, 2025 8:46pm
wallet-dashboard Ignored Ignored Preview Nov 24, 2025 8:46pm

@iota-ci iota-ci added sc-platform Issues related to the Smart Contract Platform group. vm-language Issues related to the VM & Language Team labels Nov 15, 2025
@Dkwcs
Copy link
Contributor

Dkwcs commented Nov 17, 2025

Correct me if I'm wrong, are there any possible exploits present in the runtime ?
We verify metadata during the publishing, but can we trust these data on 100% ?

@miker83z miker83z marked this pull request as ready for review November 20, 2025 11:53
@miker83z miker83z requested review from a team as code owners November 20, 2025 11:53
@miker83z miker83z removed the request for review from a team November 20, 2025 11:54
Cargo.lock Outdated
version = "3.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f288b0a4f20f9a56b5d1da57e2227c661b7b16168e2f72365f57b63326e29b24"
source = "git+https://github.com/iotaledger/iota-sim.git?branch=tokio-1.46.1#20adc0b089bf9072268eea0f059fb8ea2461702f"
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we expect this change, or should it be reverted?
I see several links updated to iota-sim.

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 pushed the changes after running a sim test and without re-running cargo check or similar. Fixed 9fc51cc

///
/// The `AuthenticatorInfo` will be attached to the account being built.
public fun builder(
authenticator: AuthenticatorInfoV1<AbstractAccount>,
Copy link
Contributor

Choose a reason for hiding this comment

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

We discussed an option of creating an account with a framework function:

public fun create_account_v1<T: key>(obj: T, info: AuthenticatorInfoV1<T>) {
    create_account_impl(obj, info)
}

So, maybe it would be better to leave the AuthenticatorInfoV1 generic parameter and not change the interface of the examples?
We don't really need to use PackageMetadataV1 here; it makes the account implementation and testing much more complex. AuthenticatorInfoV1 makes sense because we can easily limit the authenticator type that can be attached to an account.
Even if we leave the proof for a while, it will be cleaner to leave the generic parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To talk about

Comment on lines 94 to 87
): AuthenticatorInfoV1<Account> {
public fun rotate_auth_info_v1(account_id: &mut UID, proof: AuthenticatorInfoV1CompatibilityProof) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the reason for removing the return value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The return was introduced because drop was not used as ability for AuthenticatorInfoV1 . So, rotate_auth_info_v1 was never modified after adding drop to the abilities.

};

for (fn_name, account_type) in fns_metadata {
value.authenticator_metadata.push(AuthenticatorMetadataV1 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Vec can't be used here as is; we need to add validation that it doesn't contain duplicates.
There is no guarantee that it doesn't; in this struct we don't know from where this information is taken.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved the creation up, where it is sure that the verifier was run. Then I added a check for duplicates in the verifier 6878cb6

/// wrapper using the collected module metadata, storage ID, runtime ID,
/// and package version and finally freezes it. If no relevant metadata
/// is found, the function exits without creating any package metadata.
fn create_and_freeze_package_metadata_if_present(
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
fn create_and_freeze_package_metadata_if_present(
fn create_and_freeze_package_metadata_v1_if_present(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why? The inner logic can be easily modified to support a v2 in the future, I don't see necessary the creation of create_and_freeze_package_metadata_v2_if_present in that case.

/// `Account` is a phantom type representing the account type which can be authenticated.
#[allow(unused_field)]
public struct AuthenticatorInfoV1<phantom Account: key> has copy, drop, store {
public struct AuthenticatorInfoV1 has copy, drop, store {
Copy link
Contributor

Choose a reason for hiding this comment

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

What did we decide about renaming this to more suitable name?
Like AuthenticatorDescriptor or similar?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should be done in a different PR!

/// The object id of the runtime package metadata object is derived from
/// this value.
storage_id: ID,
/// Runtime ID of the package represented by this metadata
Copy link
Contributor

@Dkwcs Dkwcs Nov 21, 2025

Choose a reason for hiding this comment

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

Is this comment useful in this context?
Could we elaborate the meaning or remove it?

use std::type_name::TypeName;

/// Key type for deriving the package metadata object address
public struct PackageMetadataKey has copy, drop, store {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it should be V1 as well?

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, this can be used without versioning as we won't have the need to have 2 different keys for 2 different versions in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sc-platform Issues related to the Smart Contract Platform group. vm-language Issues related to the VM & Language Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[AA] Adapt the iota-execution publish and upgrade flows to create a PackageMetadata immutable object [AA] Create PackageMetadata type

5 participants