forked from MystenLabs/sui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sui-verifier] Added support for characteristic types (MystenLabs#3563)
* [sui-verifier] Added support for characteristic types * Fixed a problem related to another struct being defined * Adjusted tests and examples to work with the new verifier pass * Fixed another problem plus adjusted more test outputs * Another bug fix * Yet another fix * Addressed review comments * Addressed more review comments * Addressed even more review comments
- Loading branch information
Showing
39 changed files
with
638 additions
and
130 deletions.
There are no files selected for viewing
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
50 changes: 25 additions & 25 deletions
50
crates/sui-adapter-transactional-tests/tests/children/child_of_shared_object.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 |
---|---|---|
@@ -1,91 +1,91 @@ | ||
// Copyright (c) 2022, Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//# init --addresses T1=0x0 T2=0x0 T3=0x0 A=0x42 | ||
//# init --addresses t1=0x0 t2=0x0 t3=0x0 A=0x42 | ||
|
||
//# publish | ||
|
||
module T3::O3 { | ||
module t3::o3 { | ||
use sui::object::{Self, Info}; | ||
use sui::transfer; | ||
use sui::tx_context::{Self, TxContext}; | ||
|
||
struct O3 has key, store { | ||
struct Obj3 has key, store { | ||
info: Info, | ||
} | ||
|
||
public entry fun create(ctx: &mut TxContext) { | ||
let o = O3 { info: object::new(ctx) }; | ||
let o = Obj3 { info: object::new(ctx) }; | ||
transfer::transfer(o, tx_context::sender(ctx)) | ||
} | ||
} | ||
|
||
//# publish | ||
|
||
module T2::O2 { | ||
module t2::o2 { | ||
use sui::object::{Self, Info}; | ||
use sui::transfer; | ||
use sui::tx_context::{Self, TxContext}; | ||
use T3::O3::O3; | ||
use t3::o3::Obj3; | ||
|
||
struct O2 has key, store { | ||
struct Obj2 has key, store { | ||
info: Info, | ||
} | ||
|
||
public entry fun create_shared(child: O3, ctx: &mut TxContext) { | ||
public entry fun create_shared(child: Obj3, ctx: &mut TxContext) { | ||
transfer::share_object(new(child, ctx)) | ||
} | ||
|
||
public entry fun create_owned(child: O3, ctx: &mut TxContext) { | ||
public entry fun create_owned(child: Obj3, ctx: &mut TxContext) { | ||
transfer::transfer(new(child, ctx), tx_context::sender(ctx)) | ||
} | ||
|
||
public entry fun use_o2_o3(_o2: &mut O2, o3: O3, ctx: &mut TxContext) { | ||
public entry fun use_o2_o3(_o2: &mut Obj2, o3: Obj3, ctx: &mut TxContext) { | ||
transfer::transfer(o3, tx_context::sender(ctx)) | ||
} | ||
|
||
fun new(child: O3, ctx: &mut TxContext): O2 { | ||
fun new(child: Obj3, ctx: &mut TxContext): Obj2 { | ||
let info = object::new(ctx); | ||
transfer::transfer_to_object_id(child, &info); | ||
O2 { info } | ||
Obj2 { info } | ||
} | ||
} | ||
|
||
|
||
//# publish | ||
|
||
module T1::O1 { | ||
module t1::o1 { | ||
use sui::object::{Self, Info}; | ||
use sui::transfer; | ||
use sui::tx_context::{Self, TxContext}; | ||
use T2::O2::O2; | ||
use T3::O3::O3; | ||
use t2::o2::Obj2; | ||
use t3::o3::Obj3; | ||
|
||
struct O1 has key { | ||
struct Obj1 has key { | ||
info: Info, | ||
} | ||
|
||
public entry fun create_shared(child: O2, ctx: &mut TxContext) { | ||
public entry fun create_shared(child: Obj2, ctx: &mut TxContext) { | ||
transfer::share_object(new(child, ctx)) | ||
} | ||
|
||
// This function will be invalid if _o2 is a shared object and owns _o3. | ||
public entry fun use_o2_o3(_o2: &mut O2, o3: O3, ctx: &mut TxContext) { | ||
public entry fun use_o2_o3(_o2: &mut Obj2, o3: Obj3, ctx: &mut TxContext) { | ||
transfer::transfer(o3, tx_context::sender(ctx)) | ||
} | ||
|
||
fun new(child: O2, ctx: &mut TxContext): O1 { | ||
fun new(child: Obj2, ctx: &mut TxContext): Obj1 { | ||
let info = object::new(ctx); | ||
transfer::transfer_to_object_id(child, &info); | ||
O1 { info } | ||
Obj1 { info } | ||
} | ||
} | ||
|
||
//# run T3::O3::create | ||
//# run t3::o3::create | ||
|
||
//# run T2::O2::create_shared --args object(109) | ||
//# run t2::o2::create_shared --args object(109) | ||
|
||
// This run should error as O2/O3 were not defined in O1 | ||
//# run T1::O1::use_o2_o3 --args object(111) object(109) | ||
// This run should error as Obj2/Obj3 were not defined in o1 | ||
//# run t1::o1::use_o2_o3 --args object(111) object(109) | ||
|
||
//# run T2::O2::use_o2_o3 --args object(111) object(109) | ||
//# run t2::o2::use_o2_o3 --args object(111) object(109) |
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
5 changes: 5 additions & 0 deletions
5
crates/sui-verifier-transactional-tests/tests/char_type/bool_field.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,5 @@ | ||
processed 2 tasks | ||
|
||
task 1 'publish'. lines 8-15: | ||
created: object(103) | ||
written: object(102) |
15 changes: 15 additions & 0 deletions
15
crates/sui-verifier-transactional-tests/tests/char_type/bool_field.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,15 @@ | ||
// Copyright (c) 2022, Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// correct, bool field specified at source level | ||
|
||
//# init --addresses test=0x0 | ||
|
||
//# publish | ||
module test::m { | ||
|
||
struct M has drop { some_field: bool } | ||
|
||
fun init(_: M, _ctx: &mut sui::tx_context::TxContext) { | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
crates/sui-verifier-transactional-tests/tests/char_type/instantiate.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,5 @@ | ||
processed 2 tasks | ||
|
||
task 1 'publish'. lines 8-20: | ||
Error: Transaction Effects Status: Sui Move Bytecode Verification Error. Please run the Sui Move Verifier for more information. | ||
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: SuiMoveVerificationError, source: Some("characteristic type _::m::M is instantiated in the _::m::pack function and must never be") } } |
20 changes: 20 additions & 0 deletions
20
crates/sui-verifier-transactional-tests/tests/char_type/instantiate.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,20 @@ | ||
// Copyright (c) 2022, Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// invalid, struct type incorrectly instantiated | ||
|
||
//# init --addresses test=0x0 | ||
|
||
//# publish | ||
module test::m { | ||
|
||
struct M has drop { } | ||
|
||
fun init(_: M, _ctx: &mut sui::tx_context::TxContext) { | ||
} | ||
|
||
|
||
fun pack(): M { | ||
M {} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
crates/sui-verifier-transactional-tests/tests/char_type/more_abilities.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,5 @@ | ||
processed 2 tasks | ||
|
||
task 1 'publish'. lines 8-20: | ||
Error: Transaction Effects Status: Sui Move Bytecode Verification Error. Please run the Sui Move Verifier for more information. | ||
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: SuiMoveVerificationError, source: Some("characteristic type candidate _::m::M must have a single ability: drop") } } |
20 changes: 20 additions & 0 deletions
20
crates/sui-verifier-transactional-tests/tests/char_type/more_abilities.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,20 @@ | ||
// Copyright (c) 2022, Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// invalid, struct type has abilities beyond drop | ||
|
||
//# init --addresses test=0x0 | ||
|
||
//# publish | ||
module test::m { | ||
|
||
struct M has drop, copy { } | ||
|
||
fun init(_: M, _ctx: &mut sui::tx_context::TxContext) { | ||
} | ||
|
||
|
||
fun pack(): M { | ||
M {} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
crates/sui-verifier-transactional-tests/tests/char_type/no_drop.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,5 @@ | ||
processed 2 tasks | ||
|
||
task 1 'publish'. lines 8-16: | ||
Error: Transaction Effects Status: Sui Move Bytecode Verification Error. Please run the Sui Move Verifier for more information. | ||
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: SuiMoveVerificationError, source: Some("characteristic type candidate _::m::M must have a single ability: drop") } } |
16 changes: 16 additions & 0 deletions
16
crates/sui-verifier-transactional-tests/tests/char_type/no_drop.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,16 @@ | ||
// Copyright (c) 2022, Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// invalid, char type has no drop ability | ||
|
||
//# init --addresses test=0x0 | ||
|
||
//# publish | ||
module test::m { | ||
|
||
struct M { } | ||
|
||
fun init(t: M, _: &mut sui::tx_context::TxContext) { | ||
let M { } = t; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
crates/sui-verifier-transactional-tests/tests/char_type/no_field.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,5 @@ | ||
processed 2 tasks | ||
|
||
task 1 'publish'. lines 8-15: | ||
created: object(103) | ||
written: object(102) |
15 changes: 15 additions & 0 deletions
15
crates/sui-verifier-transactional-tests/tests/char_type/no_field.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,15 @@ | ||
// Copyright (c) 2022, Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// correct, no field specified at source level | ||
|
||
//# init --addresses test=0x0 | ||
|
||
//# publish | ||
module test::m { | ||
|
||
struct M has drop { } | ||
|
||
fun init(_: M, _ctx: &mut sui::tx_context::TxContext) { | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
crates/sui-verifier-transactional-tests/tests/char_type/no_init_arg.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,5 @@ | ||
processed 2 tasks | ||
|
||
task 1 'publish'. lines 8-15: | ||
Error: Transaction Effects Status: Sui Move Bytecode Verification Error. Please run the Sui Move Verifier for more information. | ||
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: SuiMoveVerificationError, source: Some("init function of a module containing characteristic type candidate must have _::m::M as the first parameter") } } |
15 changes: 15 additions & 0 deletions
15
crates/sui-verifier-transactional-tests/tests/char_type/no_init_arg.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,15 @@ | ||
// Copyright (c) 2022, Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// invalid, no char type parameter in init | ||
|
||
//# init --addresses test=0x0 | ||
|
||
//# publish | ||
module test::m { | ||
|
||
struct M has drop { value: bool } | ||
|
||
fun init(_: &mut sui::tx_context::TxContext) { | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
crates/sui-verifier-transactional-tests/tests/char_type/other_mod_def.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,9 @@ | ||
processed 3 tasks | ||
|
||
task 1 'publish'. lines 8-12: | ||
created: object(103) | ||
written: object(102) | ||
|
||
task 2 'publish'. lines 14-19: | ||
Error: Transaction Effects Status: Sui Move Bytecode Verification Error. Please run the Sui Move Verifier for more information. | ||
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: SuiMoveVerificationError, source: Some("Expected exactly one parameter for _::n::init of type &mut sui::tx_context::TxContext") } } |
Oops, something went wrong.