diff --git a/crates/sui-adapter-transactional-tests/tests/upgrade/dep_override.exp b/crates/sui-adapter-transactional-tests/tests/upgrade/dep_override.exp new file mode 100644 index 0000000000000..ac0e2badc405d --- /dev/null +++ b/crates/sui-adapter-transactional-tests/tests/upgrade/dep_override.exp @@ -0,0 +1,101 @@ +processed 21 tasks + +init: +A: object(0,0) + +task 1 'publish'. lines 10-18: +created: object(1,0), object(1,1) +mutated: object(0,0) +gas summary: computation_cost: 1000000, storage_cost: 6809600, storage_rebate: 0, non_refundable_storage_fee: 0 + +task 2 'upgrade'. lines 20-28: +created: object(2,0) +mutated: object(0,0), object(1,1) +gas summary: computation_cost: 1000000, storage_cost: 6809600, storage_rebate: 2595780, non_refundable_storage_fee: 26220 + +task 3 'upgrade'. lines 30-41: +created: object(3,0) +mutated: object(0,0), object(1,1) +gas summary: computation_cost: 1000000, storage_cost: 6809600, storage_rebate: 2595780, non_refundable_storage_fee: 26220 + +task 4 'publish'. lines 44-49: +created: object(4,0), object(4,1) +mutated: object(0,0) +gas summary: computation_cost: 1000000, storage_cost: 6551200, storage_rebate: 978120, non_refundable_storage_fee: 9880 + +task 5 'upgrade'. lines 51-59: +created: object(5,0) +mutated: object(0,0), object(4,1) +gas summary: computation_cost: 1000000, storage_cost: 6551200, storage_rebate: 2595780, non_refundable_storage_fee: 26220 + +task 6 'publish'. lines 62-69: +created: object(6,0), object(6,1) +mutated: object(0,0) +gas summary: computation_cost: 1000000, storage_cost: 7030000, storage_rebate: 978120, non_refundable_storage_fee: 9880 + +task 7 'upgrade'. lines 71-78: +created: object(7,0) +mutated: object(0,0), object(6,1) +gas summary: computation_cost: 1000000, storage_cost: 7030000, storage_rebate: 2595780, non_refundable_storage_fee: 26220 + +task 8 'upgrade'. lines 80-85: +created: object(8,0) +mutated: object(0,0), object(6,1) +gas summary: computation_cost: 1000000, storage_cost: 7030000, storage_rebate: 2595780, non_refundable_storage_fee: 26220 + +task 9 'run'. lines 87-87: +created: object(9,0) +mutated: object(0,1) +gas summary: computation_cost: 1000000, storage_cost: 2325600, storage_rebate: 0, non_refundable_storage_fee: 0 + +task 10 'view-object'. lines 89-89: +Owner: Shared +Version: 2 +Contents: Test_DepDepV1::DepDepM1::Obj {id: sui::object::UID {id: sui::object::ID {bytes: fake(9,0)}}, v: 42u64} + +task 11 'run'. lines 91-91: +created: object(11,0) +mutated: object(0,1) +gas summary: computation_cost: 1000000, storage_cost: 2325600, storage_rebate: 978120, non_refundable_storage_fee: 9880 + +task 12 'view-object'. lines 93-93: +Owner: Shared +Version: 3 +Contents: Test_DepDepV1::DepDepM1::Obj {id: sui::object::UID {id: sui::object::ID {bytes: fake(11,0)}}, v: 7u64} + +task 13 'run'. lines 95-95: +created: object(13,0) +mutated: object(0,1) +gas summary: computation_cost: 1000000, storage_cost: 2325600, storage_rebate: 978120, non_refundable_storage_fee: 9880 + +task 14 'view-object'. lines 97-100: +Owner: Shared +Version: 4 +Contents: Test_DepDepV1::DepDepM1::Obj {id: sui::object::UID {id: sui::object::ID {bytes: fake(13,0)}}, v: 0u64} + +task 15 'programmable'. lines 101-103: +created: object(15,0), object(15,1) +mutated: object(0,0) +gas summary: computation_cost: 1000000, storage_cost: 3663200, storage_rebate: 978120, non_refundable_storage_fee: 9880 + +task 16 'view-object'. lines 105-105: +Owner: Shared +Version: 10 +Contents: Test_DepDepV1::DepDepM1::Obj {id: sui::object::UID {id: sui::object::ID {bytes: fake(15,0)}}, v: 0u64} + +task 17 'view-object'. lines 107-112: +Owner: Shared +Version: 10 +Contents: Test_DepDepV1::DepDepM1::Obj {id: sui::object::UID {id: sui::object::ID {bytes: fake(15,1)}}, v: 7u64} + +task 18 'upgrade'. lines 114-120: +Error: Transaction Effects Status: Publish/Upgrade Error, Missing dependency. A dependency of a published or upgraded package has not been assigned an on-chain address. +Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: PublishUpgradeMissingDependency, source: None, command: Some(1) } } + +task 19 'upgrade'. lines 122-128: +Error: Transaction Effects Status: Publish/Upgrade Error, Missing dependency. A dependency of a published or upgraded package has not been assigned an on-chain address. +Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: PublishUpgradeMissingDependency, source: None, command: Some(1) } } + +task 20 'upgrade'. lines 130-134: +Error: Transaction Effects Status: Publish/Upgrade Error, Dependency downgrade. Indirect (transitive) dependency of published or upgraded package has been assigned an on-chain version that is less than the version required by one of the package's transitive dependencies. +Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: PublishUpgradeDependencyDowngrade, source: None, command: Some(1) } } diff --git a/crates/sui-adapter-transactional-tests/tests/upgrade/dep_override.move b/crates/sui-adapter-transactional-tests/tests/upgrade/dep_override.move new file mode 100644 index 0000000000000..ada296ae10a1e --- /dev/null +++ b/crates/sui-adapter-transactional-tests/tests/upgrade/dep_override.move @@ -0,0 +1,134 @@ +// Copyright (c) Mysten Labs, Inc. +// SPDX-License-Identifier: Apache-2.0 + +//# init --addresses Test_DepDepV1=0x0 Test_DepDepV2=0x0 Test_DepDepV3=0x0 Test_DepV1=0x0 Test_DepV2=0x0 Test_V1=0x0 Test_V2=0x0 Test_V3=0x0 Test_V4=0x0 --accounts A + + +// 3 versions of the transitive dependency + + +//# publish --upgradeable --sender A +module Test_DepDepV1::DepDepM1 { + + struct Obj has key, store { id: sui::object::UID, v: u64 } + + public fun foo(ctx: &mut sui::tx_context::TxContext) { + sui::transfer::share_object(Obj { id: sui::object::new(ctx), v: 42 }) + } +} + +//# upgrade --package Test_DepDepV1 --upgrade-capability 1,1 --sender A +module Test_DepDepV2::DepDepM1 { + + struct Obj has key, store { id: sui::object::UID, v: u64 } + + public fun foo(ctx: &mut sui::tx_context::TxContext) { + sui::transfer::share_object(Obj { id: sui::object::new(ctx), v: 7 }) + } +} + +//# upgrade --package Test_DepDepV2 --upgrade-capability 1,1 --sender A +module Test_DepDepV3::DepDepM1 { + + struct Obj has key, store { id: sui::object::UID, v: u64 } + + public fun foo(ctx: &mut sui::tx_context::TxContext) { + sui::transfer::share_object(Obj { id: sui::object::new(ctx), v: 0 }) + } +} + + +// 2 versions of the direct dependency + + +//# publish --upgradeable --dependencies Test_DepDepV1 --sender A +module Test_DepV1::DepM1 { + use Test_DepDepV1::DepDepM1; + + public fun bar(ctx: &mut sui::tx_context::TxContext) { DepDepM1::foo(ctx) } +} + +//# upgrade --package Test_DepV1 --upgrade-capability 4,1 --dependencies Test_DepDepV2 --sender A +module Test_DepV2::DepM1 { + use Test_DepDepV1::DepDepM1; + + public fun bar(ctx: &mut sui::tx_context::TxContext) { DepDepM1::foo(ctx) } +} + + +// 3 versions of the root package + + +//# publish --upgradeable --dependencies Test_DepV1 Test_DepDepV1 --sender A +module Test_V1::M1 { + use Test_DepV1::DepM1; + + public entry fun baz(ctx: &mut sui::tx_context::TxContext) { DepM1::bar(ctx) } +} + +// override direct dependency + +//# upgrade --package Test_V1 --upgrade-capability 6,1 --dependencies Test_DepV2 Test_DepDepV2 --sender A +module Test_V2::M1 { + use Test_DepV1::DepM1; + + public entry fun baz(ctx: &mut sui::tx_context::TxContext) { DepM1::bar(ctx) } +} + +// override indirect dependency + +//# upgrade --package Test_V2 --upgrade-capability 6,1 --dependencies Test_DepV1 Test_DepDepV3 --sender A +module Test_V3::M1 { + use Test_DepV1::DepM1; + + public entry fun baz(ctx: &mut sui::tx_context::TxContext) { DepM1::bar(ctx) } +} + +//# run Test_V1::M1::baz + +//# view-object 9,0 + +//# run Test_V2::M1::baz + +//# view-object 11,0 + +//# run Test_V3::M1::baz + +//# view-object 13,0 + +// call same function from two different module versions but defined in both modules (should produce +// different result due to overrides) +//# programmable --sender A +//> 0: Test_V2::M1::baz(); +//> 1: Test_V3::M1::baz(); + +//# view-object 15,0 + +//# view-object 15,1 + + +// expected upgrade errors + +// missing direct dependency (should fail) + +//# upgrade --package Test_V3 --upgrade-capability 6,1 --dependencies Test_DepDepV1 --sender A +module Test_V4::M1 { + use Test_DepV1::DepM1; + public entry fun baz(ctx: &mut sui::tx_context::TxContext) { DepM1::bar(ctx) } +} + +// missing indirect dependency (should fail) + +//# upgrade --package Test_V3 --upgrade-capability 6,1 --dependencies Test_DepV2 --sender A +module Test_V4::M1 { + use Test_DepV1::DepM1; + public entry fun baz(ctx: &mut sui::tx_context::TxContext) { DepM1::bar(ctx) } +} + +// downgrade indirect dependency (should fail) + +//# upgrade --package Test_V3 --upgrade-capability 6,1 --dependencies Test_DepV2 Test_DepDepV1 --sender A +module Test_V4::M1 { + use Test_DepV1::DepM1; + public entry fun baz(ctx: &mut sui::tx_context::TxContext) { DepM1::bar(ctx) } +} diff --git a/crates/sui-adapter-transactional-tests/tests/upgrade/new_types.exp b/crates/sui-adapter-transactional-tests/tests/upgrade/new_types.exp new file mode 100644 index 0000000000000..941758653b59a --- /dev/null +++ b/crates/sui-adapter-transactional-tests/tests/upgrade/new_types.exp @@ -0,0 +1,66 @@ +processed 14 tasks + +init: +A: object(0,0) + +task 1 'publish'. lines 6-18: +created: object(1,0), object(1,1) +mutated: object(0,0) +gas summary: computation_cost: 1000000, storage_cost: 7166800, storage_rebate: 0, non_refundable_storage_fee: 0 + +task 2 'upgrade'. lines 21-33: +created: object(2,0) +mutated: object(0,0), object(1,1) +gas summary: computation_cost: 1000000, storage_cost: 7166800, storage_rebate: 2595780, non_refundable_storage_fee: 26220 + +task 3 'publish'. lines 36-47: +created: object(3,0), object(3,1) +mutated: object(0,0) +gas summary: computation_cost: 1000000, storage_cost: 6908400, storage_rebate: 978120, non_refundable_storage_fee: 9880 + +task 4 'upgrade'. lines 49-60: +created: object(4,0) +mutated: object(0,0), object(3,1) +gas summary: computation_cost: 1000000, storage_cost: 6908400, storage_rebate: 2595780, non_refundable_storage_fee: 26220 + +task 5 'upgrade'. lines 62-73: +created: object(5,0) +mutated: object(0,0), object(3,1) +gas summary: computation_cost: 1000000, storage_cost: 6908400, storage_rebate: 2595780, non_refundable_storage_fee: 26220 + +task 6 'run'. lines 76-76: +created: object(6,0) +mutated: object(0,1) +gas summary: computation_cost: 1000000, storage_cost: 2325600, storage_rebate: 0, non_refundable_storage_fee: 0 + +task 7 'view-object'. lines 78-80: +Owner: Shared +Version: 2 +Contents: Test_DepV1::DepM1::DepObj {id: sui::object::UID {id: sui::object::ID {bytes: fake(6,0)}}, v: 42u64} + +task 8 'programmable'. lines 81-83: +mutated: object(0,0), object(6,0) +gas summary: computation_cost: 1000000, storage_cost: 2325600, storage_rebate: 2302344, non_refundable_storage_fee: 23256 + +task 9 'view-object'. lines 85-88: +Owner: Shared +Version: 7 +Contents: Test_DepV1::DepM1::DepObj {id: sui::object::UID {id: sui::object::ID {bytes: fake(6,0)}}, v: 39u64} + +task 10 'programmable'. lines 89-91: +mutated: object(0,0), object(6,0) +gas summary: computation_cost: 1000000, storage_cost: 2325600, storage_rebate: 2302344, non_refundable_storage_fee: 23256 + +task 11 'view-object'. lines 93-96: +Owner: Shared +Version: 8 +Contents: Test_DepV1::DepM1::DepObj {id: sui::object::UID {id: sui::object::ID {bytes: fake(6,0)}}, v: 37u64} + +task 12 'programmable'. lines 97-99: +mutated: object(0,0), object(6,0) +gas summary: computation_cost: 1000000, storage_cost: 2325600, storage_rebate: 2302344, non_refundable_storage_fee: 23256 + +task 13 'view-object'. lines 101-101: +Owner: Shared +Version: 9 +Contents: Test_DepV1::DepM1::DepObj {id: sui::object::UID {id: sui::object::ID {bytes: fake(6,0)}}, v: 34u64} diff --git a/crates/sui-adapter-transactional-tests/tests/upgrade/new_types.move b/crates/sui-adapter-transactional-tests/tests/upgrade/new_types.move new file mode 100644 index 0000000000000..582bd0a3ca577 --- /dev/null +++ b/crates/sui-adapter-transactional-tests/tests/upgrade/new_types.move @@ -0,0 +1,101 @@ +// Copyright (c) Mysten Labs, Inc. +// SPDX-License-Identifier: Apache-2.0 + +//# init --addresses Test_DepV1=0x0 Test_DepV2=0x0 Test_V1=0x0 Test_V2=0x0 Test_V3=0x0 --accounts A + +//# publish --upgradeable --sender A +module Test_DepV1::DepM1 { + + struct DepObj has key, store { id: sui::object::UID, v: u64 } + + public fun foo(ctx: &mut sui::tx_context::TxContext) { + sui::transfer::share_object(DepObj { id: sui::object::new(ctx), v: 42 }); + } + + public fun mod_obj(o: &mut DepObj) { + o.v = o.v - 1; + } +} + + +//# upgrade --package Test_DepV1 --upgrade-capability 1,1 --sender A +module Test_DepV2::DepM1 { + + struct DepObj has key, store { id: sui::object::UID, v: u64 } + + public fun foo(ctx: &mut sui::tx_context::TxContext) { + sui::transfer::share_object(DepObj { id: sui::object::new(ctx), v: 7 }); + } + + public fun mod_obj(o: &mut DepObj) { + o.v = o.v - 2; + } +} + + +//# publish --upgradeable --dependencies Test_DepV1 --sender A +module Test_V1::M1 { + use Test_DepV1::DepM1; + + public entry fun bar(ctx: &mut sui::tx_context::TxContext) { + DepM1::foo(ctx); + } + + public fun mod_dep_obj(o: &mut DepM1::DepObj) { + DepM1::mod_obj(o); + } +} + +//# upgrade --package Test_V1 --upgrade-capability 3,1 --dependencies Test_DepV1 --sender A +module Test_V2::M1 { + use Test_DepV1::DepM1; + + public entry fun bar(ctx: &mut sui::tx_context::TxContext) { + DepM1::foo(ctx); + } + + public fun mod_dep_obj(o: &mut DepM1::DepObj) { + DepM1::mod_obj(o); + } +} + +//# upgrade --package Test_V2 --upgrade-capability 3,1 --dependencies Test_DepV2 --sender A +module Test_V3::M1 { + use Test_DepV1::DepM1; + + public entry fun bar(ctx: &mut sui::tx_context::TxContext) { + DepM1::foo(ctx); + } + + public fun mod_dep_obj(o: &mut DepM1::DepObj) { + DepM1::mod_obj(o); + } +} + + +//# run Test_DepV1::DepM1::foo + +//# view-object 6,0 + +// call functions from two different versions of the same module modifying the same object +//# programmable --sender A --inputs object(6,0) +//> 0: Test_DepV1::DepM1::mod_obj(Input(0)); +//> 1: Test_DepV2::DepM1::mod_obj(Input(0)); + +//# view-object 6,0 + +// call functions from two different versions of the same module modifying the same object defined +// in the same version of the dependent module +//# programmable --sender A --inputs object(6,0) +//> 0: Test_V1::M1::mod_dep_obj(Input(0)); +//> 1: Test_V2::M1::mod_dep_obj(Input(0)); + +//# view-object 6,0 + +// call functions from two different versions of the same module modifying the same object defined +// in different versions of the dependent module +//# programmable --sender A --inputs object(6,0) +//> 0: Test_V2::M1::mod_dep_obj(Input(0)); +//> 1: Test_V3::M1::mod_dep_obj(Input(0)); + +//# view-object 6,0