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

feat(iota-procotol, iota-adapter-tx-tests): Update how we handle type errors in some commands #5664

Open
wants to merge 7 commits into
base: vm-lang/upstream-nov-dic-24
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
processed 3 tasks

init:
A: object(0,0)

task 1, lines 8-9:
//# programmable --sender A
//> 0: MakeMoveVec<std::string::utf8>([]);
Error: Transaction Effects Status: Error for type argument at index 0: A type was not found in the module specified.
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: TypeArgumentError { argument_idx: 0, kind: TypeNotFound }, source: None, command: Some(0) } }

task 2, lines 11-12:
//# programmable --sender A --inputs 1
//> 0: MakeMoveVec<std::string::utf8>([Input(0)]);
Error: Transaction Effects Status: Error for type argument at index 0: A type was not found in the module specified.
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: TypeArgumentError { argument_idx: 0, kind: TypeNotFound }, source: None, command: Some(0) } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (c) Mysten Labs, Inc.
// Modifications Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0


//# init --addresses test=0x0 --accounts A

//# programmable --sender A
//> 0: MakeMoveVec<std::string::utf8>([]);

//# programmable --sender A --inputs 1
//> 0: MakeMoveVec<std::string::utf8>([Input(0)]);
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
processed 3 tasks

init:
A: object(0,0)

task 1, lines 8-9:
//# programmable --sender A
//> 0: MakeMoveVec<std::string::utf8>([]);
Error: Transaction Effects Status: MOVE VM INVARIANT VIOLATION.
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: VMInvariantViolation, source: Some(VMError { major_status: TYPE_RESOLUTION_FAILURE, sub_status: None, message: Some("Cannot find std::string::utf8 in cache"), exec_state: None, location: Undefined, indices: [], offsets: [] }), command: Some(0) } }

task 2, lines 11-12:
//# programmable --sender A --inputs 1
//> 0: MakeMoveVec<std::string::utf8>([Input(0)]);
Error: Transaction Effects Status: MOVE VM INVARIANT VIOLATION.
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: VMInvariantViolation, source: Some(VMError { major_status: TYPE_RESOLUTION_FAILURE, sub_status: None, message: Some("Cannot find std::string::utf8 in cache"), exec_state: None, location: Undefined, indices: [], offsets: [] }), command: Some(0) } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (c) Mysten Labs, Inc.
// Modifications Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0


//# init --addresses test=0x0 --accounts A --protocol-version 4

//# programmable --sender A
//> 0: MakeMoveVec<std::string::utf8>([]);

//# programmable --sender A --inputs 1
//> 0: MakeMoveVec<std::string::utf8>([Input(0)]);
1 change: 1 addition & 0 deletions crates/iota-open-rpc/spec/openrpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -1305,6 +1305,7 @@
"featureFlags": {
"accept_zklogin_in_multisig": false,
"bridge": false,
"convert_type_argument_error": false,
"disable_invariant_violation_check_in_swap_loc": true,
"disallow_new_modules_in_deps_only_packages": false,
"enable_group_ops_native_function_msm": true,
Expand Down
13 changes: 12 additions & 1 deletion crates/iota-protocol-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ pub const MAX_PROTOCOL_VERSION: u64 = 5;
// Add `Clock` based unlock to `Timelock` objects.
// Version 4: Introduce the `max_type_to_layout_nodes` config that sets the
// maximal nodes which are allowed when converting to a type layout.
// Version 5: Disallow adding new modules in `deps-only` packages.
// Version 5: Disallow adding new modules in `deps-only` packages. Enable proper
// conversion of certain type argument errors in the execution layer using the
// `convert_type_argument_error` function, which is now used in all cases.

#[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
pub struct ProtocolVersion(u64);
Expand Down Expand Up @@ -198,6 +200,10 @@ struct FeatureFlags {
// Disallow adding new modules in `deps-only` packages.
#[serde(skip_serializing_if = "is_false")]
disallow_new_modules_in_deps_only_packages: bool,

// Properly convert certain type argument errors in the execution layer.
#[serde(skip_serializing_if = "is_false")]
convert_type_argument_error: bool,
}

fn is_true(b: &bool) -> bool {
Expand Down Expand Up @@ -1168,6 +1174,10 @@ impl ProtocolConfig {
POISON_VERSION_METHODS.with(|p| p.load(Ordering::Relaxed))
}

pub fn convert_type_argument_error(&self) -> bool {
self.feature_flags.convert_type_argument_error
}

/// Convenience to get the constants at the current minimum supported
/// version. Mainly used by client code that may not yet be
/// protocol-version aware.
Expand Down Expand Up @@ -1686,6 +1696,7 @@ impl ProtocolConfig {
}
5 => {
cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
cfg.feature_flags.convert_type_argument_error = true;
Copy link
Contributor

@valeriyr valeriyr Feb 27, 2025

Choose a reason for hiding this comment

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

When we change the protocol configuration, it is necessary to add a description in the following section:

// Record history of protocol version allocations here:
...
// Version 5: Disallow adding new modules in `deps-only` packages.
//            Enable proper conversion of certain type argument errors in the execution layer.

P.S. We need to check this description when all the related issues are fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

}
// Use this template when making changes:
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ feature_flags:
zklogin_max_epoch_upper_bound_delta: 30
relocate_event_module: true
disallow_new_modules_in_deps_only_packages: true
convert_type_argument_error: true
max_tx_size_bytes: 131072
max_input_objects: 2048
max_size_written_objects: 5000000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ feature_flags:
zklogin_max_epoch_upper_bound_delta: 30
relocate_event_module: true
disallow_new_modules_in_deps_only_packages: true
convert_type_argument_error: true
max_tx_size_bytes: 131072
max_input_objects: 2048
max_size_written_objects: 5000000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ feature_flags:
passkey_auth: true
relocate_event_module: true
disallow_new_modules_in_deps_only_packages: true
convert_type_argument_error: true
max_tx_size_bytes: 131072
max_input_objects: 2048
max_size_written_objects: 5000000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,13 @@ mod checked {
"input checker ensures if args are empty, there is a type specified"
);
};
let elem_ty = context
.load_type(&tag)
.map_err(|e| context.convert_vm_error(e))?;
let elem_ty = context.load_type(&tag).map_err(|e| {
if context.protocol_config.convert_type_argument_error() {
context.convert_type_argument_error(0, e)
} else {
context.convert_vm_error(e)
}
})?;
let ty = Type::Vector(Box::new(elem_ty));
let abilities = context
.vm
Expand All @@ -172,9 +176,13 @@ mod checked {
let mut arg_iter = args.into_iter().enumerate();
let (mut used_in_non_entry_move_call, elem_ty) = match tag_opt {
Some(tag) => {
let elem_ty = context
.load_type(&tag)
.map_err(|e| context.convert_vm_error(e))?;
let elem_ty = context.load_type(&tag).map_err(|e| {
if context.protocol_config.convert_type_argument_error() {
context.convert_type_argument_error(0, e)
} else {
context.convert_vm_error(e)
}
})?;
(false, elem_ty)
}
// If no tag specified, it _must_ be an object
Expand Down