Skip to content

Commit e04baee

Browse files
tzakianTimothy Zakian
and
Timothy Zakian
authored
[2/n][object runtime type tags][adapter-only] Normalize to defining ID when converting from TypeInput to TypeTag (#22081)
## Description When converting `TypeInput`s to `TypeTag`s in the adapter also remap all IDs to be defining-id based. This should not cause any discernible change in behavior outside of error cases. This adds the invariant that all typetags will be defining ID based from the adapter down into (and including) the object runtime, with the exception of where we explicitly want runtime IDs for typename in natives. ## Test plan CI + 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. - [X] Protocol: Normalize all type inputs to be defining ID based when converting from `TypeInput`s in the adapter. - [ ] Nodes (Validators and Full nodes): - [ ] gRPC: - [ ] JSON-RPC: - [ ] GraphQL: - [ ] CLI: - [ ] Rust SDK: --------- Co-authored-by: Timothy Zakian <timothyzakian@mac.lan>
1 parent 547193d commit e04baee

File tree

15 files changed

+1553
-75
lines changed

15 files changed

+1553
-75
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright (c) Mysten Labs, Inc.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
//# init --addresses A0=0x0 A1=0x0 A2=0x0 --accounts A
5+
6+
//# publish --upgradeable --sender A
7+
module A0::m {
8+
public struct A {}
9+
}
10+
11+
//# upgrade --package A0 --upgrade-capability 1,1 --sender A
12+
module A1::m {
13+
public struct A {}
14+
public struct B {}
15+
}
16+
17+
//# upgrade --package A1 --upgrade-capability 1,1 --sender A
18+
module A2::m {
19+
public struct A {}
20+
public struct B {}
21+
public struct C {}
22+
entry fun call<T>() { }
23+
}
24+
25+
// Resolves fine
26+
//# run A2::m::call --type-args A0::m::A --sender A
27+
28+
// Resolves fine
29+
//# run A2::m::call --type-args A1::m::A --sender A
30+
31+
// Resolves fine
32+
//# run A2::m::call --type-args A2::m::A --sender A
33+
34+
// Fails to resolve
35+
//# run A2::m::call --type-args 0x0::m::A --sender A
36+
37+
38+
// Resolves fine
39+
//# run A2::m::call --type-args A0::m::B --sender A
40+
41+
// Resolves fine
42+
//# run A2::m::call --type-args A1::m::B --sender A
43+
44+
// Resolves fine
45+
//# run A2::m::call --type-args A2::m::B --sender A
46+
47+
// Fails to resolve
48+
//# run A2::m::call --type-args 0x0::m::B --sender A
49+
50+
51+
// Resolves fine
52+
//# run A2::m::call --type-args A0::m::C --sender A
53+
54+
// Resolves fine
55+
//# run A2::m::call --type-args A1::m::C --sender A
56+
57+
// Resolves fine
58+
//# run A2::m::call --type-args A2::m::C --sender A
59+
60+
// Fails to resolve
61+
//# run A2::m::call --type-args 0x0::m::C --sender A
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
source: external-crates/move/crates/move-transactional-test-runner/src/framework.rs
3+
---
4+
processed 16 tasks
5+
6+
init:
7+
A: object(0,0)
8+
9+
task 1, lines 6-9:
10+
//# publish --upgradeable --sender A
11+
created: object(1,0), object(1,1)
12+
mutated: object(0,0)
13+
gas summary: computation_cost: 1000000, storage_cost: 5289600, storage_rebate: 0, non_refundable_storage_fee: 0
14+
15+
task 2, lines 11-15:
16+
//# upgrade --package A0 --upgrade-capability 1,1 --sender A
17+
created: object(2,0)
18+
mutated: object(0,0), object(1,1)
19+
gas summary: computation_cost: 1000000, storage_cost: 5631600, storage_rebate: 2595780, non_refundable_storage_fee: 26220
20+
21+
task 3, lines 17-25:
22+
//# upgrade --package A1 --upgrade-capability 1,1 --sender A
23+
created: object(3,0)
24+
mutated: object(0,0), object(1,1)
25+
gas summary: computation_cost: 1000000, storage_cost: 6186400, storage_rebate: 2595780, non_refundable_storage_fee: 26220
26+
27+
task 4, lines 26-28:
28+
//# run A2::m::call --type-args A0::m::A --sender A
29+
mutated: object(0,0)
30+
gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880
31+
32+
task 5, lines 29-31:
33+
//# run A2::m::call --type-args A1::m::A --sender A
34+
mutated: object(0,0)
35+
gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880
36+
37+
task 6, lines 32-34:
38+
//# run A2::m::call --type-args A2::m::A --sender A
39+
mutated: object(0,0)
40+
gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880
41+
42+
task 7, lines 35-38:
43+
//# run A2::m::call --type-args 0x0::m::A --sender A
44+
Error: Error checking transaction input objects: DependentPackageNotFound { package_id: 0x0000000000000000000000000000000000000000000000000000000000000000 }
45+
46+
task 8, lines 39-41:
47+
//# run A2::m::call --type-args A0::m::B --sender A
48+
mutated: object(0,0)
49+
gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880
50+
51+
task 9, lines 42-44:
52+
//# run A2::m::call --type-args A1::m::B --sender A
53+
mutated: object(0,0)
54+
gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880
55+
56+
task 10, lines 45-47:
57+
//# run A2::m::call --type-args A2::m::B --sender A
58+
mutated: object(0,0)
59+
gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880
60+
61+
task 11, lines 48-51:
62+
//# run A2::m::call --type-args 0x0::m::B --sender A
63+
Error: Error checking transaction input objects: DependentPackageNotFound { package_id: 0x0000000000000000000000000000000000000000000000000000000000000000 }
64+
65+
task 12, lines 52-54:
66+
//# run A2::m::call --type-args A0::m::C --sender A
67+
mutated: object(0,0)
68+
gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880
69+
70+
task 13, lines 55-57:
71+
//# run A2::m::call --type-args A1::m::C --sender A
72+
mutated: object(0,0)
73+
gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880
74+
75+
task 14, lines 58-60:
76+
//# run A2::m::call --type-args A2::m::C --sender A
77+
mutated: object(0,0)
78+
gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880
79+
80+
task 15, line 61:
81+
//# run A2::m::call --type-args 0x0::m::C --sender A
82+
Error: Error checking transaction input objects: DependentPackageNotFound { package_id: 0x0000000000000000000000000000000000000000000000000000000000000000 }
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright (c) Mysten Labs, Inc.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
//# init --addresses A0=0x0 A1=0x0 A2=0x0 --accounts A --protocol-version 82
5+
6+
//# publish --upgradeable --sender A
7+
module A0::m {
8+
public struct A {}
9+
}
10+
11+
//# upgrade --package A0 --upgrade-capability 1,1 --sender A
12+
module A1::m {
13+
public struct A {}
14+
public struct B {}
15+
}
16+
17+
//# upgrade --package A1 --upgrade-capability 1,1 --sender A
18+
module A2::m {
19+
public struct A {}
20+
public struct B {}
21+
public struct C {}
22+
entry fun call<T>() { }
23+
}
24+
25+
// Resolves fine
26+
//# run A2::m::call --type-args A0::m::A --sender A
27+
28+
// Resolves fine
29+
//# run A2::m::call --type-args A1::m::A --sender A
30+
31+
// Resolves fine
32+
//# run A2::m::call --type-args A2::m::A --sender A
33+
34+
// Fails to resolve (but error will differ slightly after this version)
35+
//# run A2::m::call --type-args 0x0::m::A --sender A
36+
37+
38+
// Fails to resolve (but error will differ slightly after this version)
39+
//# run A2::m::call --type-args A0::m::B --sender A
40+
41+
// Resolves fine
42+
//# run A2::m::call --type-args A1::m::B --sender A
43+
44+
// Resolves fine
45+
//# run A2::m::call --type-args A2::m::B --sender A
46+
47+
// Fails to resolve (but error will differ slightly after this version)
48+
//# run A2::m::call --type-args 0x0::m::B --sender A
49+
50+
51+
// Fails to resolve (but error will differ slightly after this version)
52+
//# run A2::m::call --type-args A0::m::C --sender A
53+
54+
// Fails to resolve (but error will differ slightly after this version)
55+
//# run A2::m::call --type-args A1::m::C --sender A
56+
57+
// Resolves fine
58+
//# run A2::m::call --type-args A2::m::C --sender A
59+
60+
// Fails to resolve (but error will differ slightly after this version)
61+
//# run A2::m::call --type-args 0x0::m::C --sender A
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
source: external-crates/move/crates/move-transactional-test-runner/src/framework.rs
3+
---
4+
processed 16 tasks
5+
6+
init:
7+
A: object(0,0)
8+
9+
task 1, lines 6-9:
10+
//# publish --upgradeable --sender A
11+
created: object(1,0), object(1,1)
12+
mutated: object(0,0)
13+
gas summary: computation_cost: 1000000, storage_cost: 5289600, storage_rebate: 0, non_refundable_storage_fee: 0
14+
15+
task 2, lines 11-15:
16+
//# upgrade --package A0 --upgrade-capability 1,1 --sender A
17+
created: object(2,0)
18+
mutated: object(0,0), object(1,1)
19+
gas summary: computation_cost: 1000000, storage_cost: 5631600, storage_rebate: 2595780, non_refundable_storage_fee: 26220
20+
21+
task 3, lines 17-25:
22+
//# upgrade --package A1 --upgrade-capability 1,1 --sender A
23+
created: object(3,0)
24+
mutated: object(0,0), object(1,1)
25+
gas summary: computation_cost: 1000000, storage_cost: 6186400, storage_rebate: 2595780, non_refundable_storage_fee: 26220
26+
27+
task 4, lines 26-28:
28+
//# run A2::m::call --type-args A0::m::A --sender A
29+
mutated: object(0,0)
30+
gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880
31+
32+
task 5, lines 29-31:
33+
//# run A2::m::call --type-args A1::m::A --sender A
34+
mutated: object(0,0)
35+
gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880
36+
37+
task 6, lines 32-34:
38+
//# run A2::m::call --type-args A2::m::A --sender A
39+
mutated: object(0,0)
40+
gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880
41+
42+
task 7, lines 35-38:
43+
//# run A2::m::call --type-args 0x0::m::A --sender A
44+
Error: Error checking transaction input objects: DependentPackageNotFound { package_id: 0x0000000000000000000000000000000000000000000000000000000000000000 }
45+
46+
task 8, lines 39-41:
47+
//# run A2::m::call --type-args A0::m::B --sender A
48+
mutated: object(0,0)
49+
gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880
50+
51+
task 9, lines 42-44:
52+
//# run A2::m::call --type-args A1::m::B --sender A
53+
mutated: object(0,0)
54+
gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880
55+
56+
task 10, lines 45-47:
57+
//# run A2::m::call --type-args A2::m::B --sender A
58+
mutated: object(0,0)
59+
gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880
60+
61+
task 11, lines 48-51:
62+
//# run A2::m::call --type-args 0x0::m::B --sender A
63+
Error: Error checking transaction input objects: DependentPackageNotFound { package_id: 0x0000000000000000000000000000000000000000000000000000000000000000 }
64+
65+
task 12, lines 52-54:
66+
//# run A2::m::call --type-args A0::m::C --sender A
67+
mutated: object(0,0)
68+
gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880
69+
70+
task 13, lines 55-57:
71+
//# run A2::m::call --type-args A1::m::C --sender A
72+
mutated: object(0,0)
73+
gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880
74+
75+
task 14, lines 58-60:
76+
//# run A2::m::call --type-args A2::m::C --sender A
77+
mutated: object(0,0)
78+
gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880
79+
80+
task 15, line 61:
81+
//# run A2::m::call --type-args 0x0::m::C --sender A
82+
Error: Error checking transaction input objects: DependentPackageNotFound { package_id: 0x0000000000000000000000000000000000000000000000000000000000000000 }

crates/sui-graphql-rpc/src/types/move_type.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ impl MoveType {
181181
&self,
182182
resolver: &PackageResolver,
183183
) -> Result<Option<A::MoveTypeLayout>, Error> {
184-
let Ok(tag) = self.native.as_type_tag() else {
184+
let Ok(tag) = self.native.to_type_tag() else {
185185
return Ok(None);
186186
};
187187

@@ -197,7 +197,7 @@ impl MoveType {
197197
&self,
198198
resolver: &PackageResolver,
199199
) -> Result<Option<AbilitySet>, Error> {
200-
let Ok(tag) = self.native.as_type_tag() else {
200+
let Ok(tag) = self.native.to_type_tag() else {
201201
return Ok(None);
202202
};
203203

crates/sui-open-rpc/spec/openrpc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1294,7 +1294,7 @@
12941294
"name": "Result",
12951295
"value": {
12961296
"minSupportedProtocolVersion": "1",
1297-
"maxSupportedProtocolVersion": "82",
1297+
"maxSupportedProtocolVersion": "83",
12981298
"protocolVersion": "6",
12991299
"featureFlags": {
13001300
"accept_passkey_in_multisig": false,
@@ -1364,6 +1364,7 @@
13641364
"relocate_event_module": false,
13651365
"reshare_at_same_initial_version": false,
13661366
"resolve_abort_locations_to_package_id": false,
1367+
"resolve_type_input_ids_to_defining_id": false,
13671368
"rethrow_serialization_type_layout_errors": false,
13681369
"scoring_decision_with_validity_cutoff": true,
13691370
"shared_object_deletion": false,

crates/sui-protocol-config/src/lib.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use tracing::{info, warn};
1818

1919
/// The minimum and maximum protocol versions supported by this build.
2020
const MIN_PROTOCOL_VERSION: u64 = 1;
21-
const MAX_PROTOCOL_VERSION: u64 = 82;
21+
const MAX_PROTOCOL_VERSION: u64 = 83;
2222

2323
// Record history of protocol version allocations here:
2424
//
@@ -235,7 +235,8 @@ const MAX_PROTOCOL_VERSION: u64 = 82;
235235
// Version 81: Enable median based commit timestamp in consensus on mainnet.
236236
// Enforce checkpoint timestamps are non-decreasing for testnet and mainnet.
237237
// Increase threshold for bad nodes that won't be considered leaders in consensus in mainnet
238-
// Version 82:
238+
// Version 82: Relax bounding of size of values created in the adapter.
239+
// Version 83: Resolve `TypeInput` IDs to defining ID when converting to `TypeTag`s in the adapter.
239240

240241
#[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
241242
pub struct ProtocolVersion(u64);
@@ -679,6 +680,10 @@ struct FeatureFlags {
679680
// If true, enables better errors and bounds for max ptb values
680681
#[serde(skip_serializing_if = "is_false")]
681682
max_ptb_value_size_v2: bool,
683+
684+
// If true, resolves all type input ids to be defining ID based in the adapter
685+
#[serde(skip_serializing_if = "is_false")]
686+
resolve_type_input_ids_to_defining_id: bool,
682687
}
683688

684689
fn is_false(b: &bool) -> bool {
@@ -1949,6 +1954,10 @@ impl ProtocolConfig {
19491954
pub fn max_ptb_value_size_v2(&self) -> bool {
19501955
self.feature_flags.max_ptb_value_size_v2
19511956
}
1957+
1958+
pub fn resolve_type_input_ids_to_defining_id(&self) -> bool {
1959+
self.feature_flags.resolve_type_input_ids_to_defining_id
1960+
}
19521961
}
19531962

19541963
#[cfg(not(msim))]
@@ -3484,6 +3493,9 @@ impl ProtocolConfig {
34843493
82 => {
34853494
cfg.feature_flags.max_ptb_value_size_v2 = true;
34863495
}
3496+
83 => {
3497+
cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
3498+
}
34873499
// Use this template when making changes:
34883500
//
34893501
// // modify an existing constant.

0 commit comments

Comments
 (0)