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
[sui-framework/package] Publisher
checks recognise upgrades
#12026
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
crates/sui-adapter-transactional-tests/tests/upgrade/publisher.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
processed 5 tasks | ||
|
||
init: | ||
A: object(0,0) | ||
|
||
task 1 'publish'. lines 6-17: | ||
created: object(1,0), object(1,1), object(1,2) | ||
mutated: object(0,0) | ||
gas summary: computation_cost: 1000000, storage_cost: 8557600, storage_rebate: 0, non_refundable_storage_fee: 0 | ||
|
||
task 2 'upgrade'. lines 19-35: | ||
created: object(2,0) | ||
mutated: object(0,0), object(1,2) | ||
gas summary: computation_cost: 1000000, storage_cost: 7691200, storage_rebate: 2595780, non_refundable_storage_fee: 26220 | ||
|
||
task 3 'run'. lines 37-37: | ||
mutated: object(0,0), object(1,1) | ||
gas summary: computation_cost: 1000000, storage_cost: 2812000, storage_rebate: 2783880, non_refundable_storage_fee: 28120 | ||
|
||
task 4 'run'. lines 39-39: | ||
mutated: object(0,0), object(1,1) | ||
gas summary: computation_cost: 1000000, storage_cost: 2812000, storage_rebate: 2783880, non_refundable_storage_fee: 28120 |
39 changes: 39 additions & 0 deletions
39
crates/sui-adapter-transactional-tests/tests/upgrade/publisher.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//# init --addresses A0=0x0 A1=0x0 --accounts A | ||
|
||
//# publish --upgradeable --sender A | ||
module A0::m { | ||
use sui::package; | ||
use sui::tx_context::TxContext; | ||
|
||
struct A {} | ||
struct M has drop {} | ||
|
||
fun init(m: M, ctx: &mut TxContext) { | ||
package::claim_and_keep(m, ctx); | ||
} | ||
} | ||
|
||
//# upgrade --package A0 --upgrade-capability 1,2 --sender A | ||
module A1::m { | ||
use sui::package::{Self, Publisher}; | ||
use sui::tx_context::TxContext; | ||
|
||
struct A {} | ||
struct B {} | ||
struct M has drop {} | ||
|
||
fun init(m: M, ctx: &mut TxContext) { | ||
package::claim_and_keep(m, ctx); | ||
} | ||
|
||
entry fun test<T>(p: &Publisher) { | ||
assert!(package::from_package<T>(p), 0) | ||
} | ||
} | ||
|
||
//# run A1::m::test --type-args A0::m::A --args object(1,1) --sender A | ||
|
||
//# run A1::m::test --type-args A1::m::B --args object(1,1) --sender A |
59 changes: 59 additions & 0 deletions
59
crates/sui-adapter-transactional-tests/tests/upgrade/type_names.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
processed 12 tasks | ||
|
||
init: | ||
A: object(0,0) | ||
|
||
task 1 'publish'. lines 6-17: | ||
created: object(1,0), object(1,1) | ||
mutated: object(0,0) | ||
gas summary: computation_cost: 1000000, storage_cost: 6171200, storage_rebate: 0, non_refundable_storage_fee: 0 | ||
|
||
task 2 'upgrade'. lines 19-30: | ||
created: object(2,0) | ||
mutated: object(0,0), object(1,1) | ||
gas summary: computation_cost: 1000000, storage_cost: 6520800, storage_rebate: 2595780, non_refundable_storage_fee: 26220 | ||
|
||
task 3 'upgrade'. lines 32-62: | ||
created: object(3,0) | ||
mutated: object(0,0), object(1,1) | ||
gas summary: computation_cost: 1000000, storage_cost: 9066800, storage_rebate: 2595780, non_refundable_storage_fee: 26220 | ||
|
||
task 4 'run'. lines 64-64: | ||
created: object(4,0) | ||
mutated: object(0,0) | ||
gas summary: computation_cost: 1000000, storage_cost: 2728400, storage_rebate: 978120, non_refundable_storage_fee: 9880 | ||
|
||
task 5 'run'. lines 66-66: | ||
created: object(5,0) | ||
mutated: object(0,0) | ||
gas summary: computation_cost: 1000000, storage_cost: 2728400, storage_rebate: 978120, non_refundable_storage_fee: 9880 | ||
|
||
task 6 'run'. lines 68-68: | ||
created: object(6,0) | ||
mutated: object(0,0) | ||
gas summary: computation_cost: 1000000, storage_cost: 2728400, storage_rebate: 978120, non_refundable_storage_fee: 9880 | ||
|
||
task 7 'run'. lines 70-70: | ||
created: object(7,0) | ||
mutated: object(0,0) | ||
gas summary: computation_cost: 1000000, storage_cost: 2728400, storage_rebate: 978120, non_refundable_storage_fee: 9880 | ||
|
||
task 8 'view-object'. lines 72-72: | ||
Owner: Account Address ( A ) | ||
Version: 5 | ||
Contents: A0::m::Canary {id: sui::object::UID {id: sui::object::ID {bytes: fake(4,0)}}, addr: vector[57u8, 98u8, 48u8, 52u8, 101u8, 52u8, 50u8, 57u8, 50u8, 54u8, 101u8, 55u8, 48u8, 54u8, 54u8, 56u8, 99u8, 101u8, 56u8, 50u8, 97u8, 52u8, 99u8, 50u8, 51u8, 56u8, 56u8, 98u8, 101u8, 52u8, 101u8, 50u8, 100u8, 52u8, 99u8, 53u8, 98u8, 54u8, 54u8, 49u8, 98u8, 101u8, 48u8, 50u8, 52u8, 98u8, 53u8, 56u8, 101u8, 49u8, 53u8, 49u8, 56u8, 101u8, 55u8, 49u8, 99u8, 55u8, 54u8, 56u8, 57u8, 50u8, 51u8, 54u8]} | ||
|
||
task 9 'view-object'. lines 74-74: | ||
Owner: Account Address ( A ) | ||
Version: 6 | ||
Contents: A0::m::Canary {id: sui::object::UID {id: sui::object::ID {bytes: fake(5,0)}}, addr: vector[57u8, 98u8, 48u8, 52u8, 101u8, 52u8, 50u8, 57u8, 50u8, 54u8, 101u8, 55u8, 48u8, 54u8, 54u8, 56u8, 99u8, 101u8, 56u8, 50u8, 97u8, 52u8, 99u8, 50u8, 51u8, 56u8, 56u8, 98u8, 101u8, 52u8, 101u8, 50u8, 100u8, 52u8, 99u8, 53u8, 98u8, 54u8, 54u8, 49u8, 98u8, 101u8, 48u8, 50u8, 52u8, 98u8, 53u8, 56u8, 101u8, 49u8, 53u8, 49u8, 56u8, 101u8, 55u8, 49u8, 99u8, 55u8, 54u8, 56u8, 57u8, 50u8, 51u8, 54u8]} | ||
|
||
task 10 'view-object'. lines 76-76: | ||
Owner: Account Address ( A ) | ||
Version: 7 | ||
Contents: A0::m::Canary {id: sui::object::UID {id: sui::object::ID {bytes: fake(6,0)}}, addr: vector[57u8, 98u8, 48u8, 52u8, 101u8, 52u8, 50u8, 57u8, 50u8, 54u8, 101u8, 55u8, 48u8, 54u8, 54u8, 56u8, 99u8, 101u8, 56u8, 50u8, 97u8, 52u8, 99u8, 50u8, 51u8, 56u8, 56u8, 98u8, 101u8, 52u8, 101u8, 50u8, 100u8, 52u8, 99u8, 53u8, 98u8, 54u8, 54u8, 49u8, 98u8, 101u8, 48u8, 50u8, 52u8, 98u8, 53u8, 56u8, 101u8, 49u8, 53u8, 49u8, 56u8, 101u8, 55u8, 49u8, 99u8, 55u8, 54u8, 56u8, 57u8, 50u8, 51u8, 54u8]} | ||
|
||
task 11 'view-object'. lines 78-78: | ||
Owner: Account Address ( A ) | ||
Version: 8 | ||
Contents: A0::m::Canary {id: sui::object::UID {id: sui::object::ID {bytes: fake(7,0)}}, addr: vector[98u8, 55u8, 50u8, 55u8, 55u8, 53u8, 48u8, 100u8, 98u8, 50u8, 54u8, 48u8, 49u8, 52u8, 101u8, 53u8, 54u8, 101u8, 99u8, 102u8, 57u8, 50u8, 99u8, 100u8, 51u8, 50u8, 101u8, 52u8, 100u8, 48u8, 54u8, 56u8, 50u8, 51u8, 56u8, 56u8, 50u8, 49u8, 54u8, 50u8, 51u8, 99u8, 48u8, 52u8, 54u8, 57u8, 56u8, 100u8, 57u8, 54u8, 50u8, 57u8, 48u8, 56u8, 100u8, 49u8, 50u8, 48u8, 97u8, 53u8, 49u8, 54u8, 100u8, 48u8]} | ||
78 changes: 78 additions & 0 deletions
78
crates/sui-adapter-transactional-tests/tests/upgrade/type_names.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//# init --addresses A0=0x0 A1=0x0 A2=0x0 --accounts A | ||
|
||
//# publish --upgradeable --sender A | ||
module A0::m { | ||
use sui::object::UID; | ||
|
||
struct Canary has key { | ||
id: UID, | ||
addr: vector<u8>, | ||
} | ||
|
||
struct A {} | ||
|
||
} | ||
|
||
//# upgrade --package A0 --upgrade-capability 1,1 --sender A | ||
module A1::m { | ||
use sui::object::UID; | ||
|
||
struct Canary has key { | ||
id: UID, | ||
addr: vector<u8>, | ||
} | ||
|
||
struct A {} | ||
struct B {} | ||
} | ||
|
||
//# upgrade --package A1 --upgrade-capability 1,1 --sender A | ||
module A2::m { | ||
use std::ascii; | ||
use std::type_name; | ||
use sui::object::{Self, UID}; | ||
use sui::transfer; | ||
use sui::tx_context::{Self, TxContext}; | ||
|
||
struct Canary has key { | ||
id: UID, | ||
addr: vector<u8>, | ||
} | ||
|
||
struct A {} | ||
struct B {} | ||
|
||
entry fun canary<T>(use_original: bool, ctx: &mut TxContext) { | ||
let type = if (use_original) { | ||
type_name::get_original<T>() | ||
} else { | ||
type_name::get<T>() | ||
}; | ||
|
||
let addr = ascii::into_bytes(type_name::get_address(&type)); | ||
|
||
transfer::transfer( | ||
Canary { id: object::new(ctx), addr }, | ||
tx_context::sender(ctx), | ||
) | ||
} | ||
} | ||
|
||
//# run A2::m::canary --type-args A0::m::A --args true --sender A | ||
|
||
//# run A2::m::canary --type-args A1::m::B --args true --sender A | ||
|
||
//# run A2::m::canary --type-args A0::m::A --args false --sender A | ||
|
||
//# run A2::m::canary --type-args A1::m::B --args false --sender A | ||
|
||
//# view-object 4,0 | ||
|
||
//# view-object 5,0 | ||
|
||
//# view-object 6,0 | ||
|
||
//# view-object 7,0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The output is a little hard to make sense of here -- the key thing is that the last one is different from all the rest.