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.
[verifier] Fix verifier parameter rules. [adapter] Fix visibility che…
…ck (MystenLabs#2051) * [verifier] Fix verifier parameter rules - Fixed rules to statically reject entry functions whose signatures are *always* invalid
- Loading branch information
Showing
20 changed files
with
318 additions
and
74 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
crates/sui-adapter-transactional-tests/tests/entry_points/wrong_visibility.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,14 @@ | ||
processed 5 tasks | ||
|
||
task 1 'publish'. lines 8-24: | ||
created: object(103) | ||
written: object(102) | ||
|
||
task 2 'run'. lines 26-26: | ||
Error: Function visibility is invalid for an entry point to execution: "Can only call functions with 'public(script)' visibility". | ||
|
||
task 3 'run'. lines 28-28: | ||
Error: Function visibility is invalid for an entry point to execution: "Can only call functions with 'public(script)' visibility". | ||
|
||
task 4 'run'. lines 30-30: | ||
Error: Function visibility is invalid for an entry point to execution: "Can only call functions with 'public(script)' visibility". |
30 changes: 30 additions & 0 deletions
30
crates/sui-adapter-transactional-tests/tests/entry_points/wrong_visibility.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,30 @@ | ||
// Copyright (c) 2022, Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// invalid, the adapter should yell that the invoked functions have the wrong visibility | ||
|
||
//# init --addresses Test=0x0 | ||
|
||
//# publish | ||
module Test::M { | ||
use Sui::TxContext::TxContext; | ||
|
||
public fun t1(_: &mut TxContext) { | ||
abort 0 | ||
} | ||
|
||
public(friend) fun t2(_: &mut TxContext) { | ||
abort 0 | ||
} | ||
|
||
fun t3(_: &mut TxContext) { | ||
abort 0 | ||
} | ||
|
||
} | ||
|
||
//# run Test::M::t1 | ||
|
||
//# run Test::M::t2 | ||
|
||
//# run Test::M::t3 |
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
4 changes: 4 additions & 0 deletions
4
crates/sui-verifier-transactional-tests/tests/entry_points/non_key_struct.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,4 @@ | ||
processed 1 task | ||
|
||
task 0 'publish'. lines 6-17: | ||
Error: Failed to verify the Move module, reason: "Invalid entry point parameter type. Expected primitive or object type. Got: _::M::S". |
17 changes: 17 additions & 0 deletions
17
crates/sui-verifier-transactional-tests/tests/entry_points/non_key_struct.mvir
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,17 @@ | ||
// Copyright (c) 2022, Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// invalid, non key structs are not supported | ||
|
||
//# publish | ||
module 0x0.M { | ||
import 0x2.TxContext; | ||
|
||
struct S has copy, drop, store { value: u64 } | ||
|
||
public(script) no(s: Self.S, ctx: &mut TxContext.TxContext) { | ||
label l0: | ||
abort 0; | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
crates/sui-verifier-transactional-tests/tests/entry_points/non_key_struct_generic.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,7 @@ | ||
processed 2 tasks | ||
|
||
task 0 'publish'. lines 6-21: | ||
Error: Failed to verify the Move module, reason: "Invalid entry point parameter type. Expected primitive or object type. Got: _::M::Obj<_::M::NoStore>". | ||
|
||
task 1 'publish'. lines 23-35: | ||
Error: Failed to verify the Move module, reason: "Invalid entry point parameter type. Expected primitive or object type. Got: _::M::Obj<T0>". |
35 changes: 35 additions & 0 deletions
35
crates/sui-verifier-transactional-tests/tests/entry_points/non_key_struct_generic.mvir
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,35 @@ | ||
// Copyright (c) 2022, Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// invalid as NoStore doesn't have store, so Obj doesn't have key | ||
|
||
//# publish | ||
module 0x0.M { | ||
import 0x2.TxContext; | ||
import 0x2.ID; | ||
|
||
struct Obj<T> has key { id: ID.VersionedID } | ||
struct NoStore has copy, drop { value: u64 } | ||
|
||
public(script) no(s: Self.Obj<Self.NoStore>, ctx: &mut TxContext.TxContext) { | ||
label l0: | ||
abort 0; | ||
} | ||
|
||
} | ||
|
||
// valid, while T doesn't have store, and might it later, we require it to be annotated | ||
|
||
//# publish | ||
module 0x0.M { | ||
import 0x2.TxContext; | ||
import 0x2.ID; | ||
|
||
struct Obj<T> has key { id: ID.VersionedID } | ||
|
||
public(script) no<T>(s: Self.Obj<T>, ctx: &mut TxContext.TxContext) { | ||
label l0: | ||
abort 0; | ||
} | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
crates/sui-verifier-transactional-tests/tests/entry_points/non_key_struct_generic_valid.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 1 task | ||
|
||
task 0 'publish'. lines 6-18: | ||
created: object(103) | ||
written: object(102) |
18 changes: 18 additions & 0 deletions
18
crates/sui-verifier-transactional-tests/tests/entry_points/non_key_struct_generic_valid.mvir
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,18 @@ | ||
// Copyright (c) 2022, Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// valid, T has store, thus Obj has key | ||
|
||
//# publish | ||
module 0x0.M { | ||
import 0x2.TxContext; | ||
import 0x2.ID; | ||
|
||
struct Obj<T> has key { id: ID.VersionedID } | ||
|
||
public(script) no<T: store>(s: Self.Obj<T>, ctx: &mut TxContext.TxContext) { | ||
label l0: | ||
abort 0; | ||
} | ||
|
||
} |
4 changes: 4 additions & 0 deletions
4
crates/sui-verifier-transactional-tests/tests/entry_points/non_key_struct_vector.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,4 @@ | ||
processed 1 task | ||
|
||
task 0 'publish'. lines 6-17: | ||
Error: Failed to verify the Move module, reason: "Invalid entry point parameter type. Expected primitive or object type. Got: vector<_::M::S>". |
17 changes: 17 additions & 0 deletions
17
crates/sui-verifier-transactional-tests/tests/entry_points/non_key_struct_vector.mvir
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,17 @@ | ||
// Copyright (c) 2022, Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// invalid, non key structs are not supported, even in vectors | ||
|
||
//# publish | ||
module 0x0.M { | ||
import 0x2.TxContext; | ||
|
||
struct S has copy, drop, store { value: u64 } | ||
|
||
public(script) no(s: vector<Self.S>, ctx: &mut TxContext.TxContext) { | ||
label l0: | ||
abort 0; | ||
} | ||
|
||
} |
4 changes: 4 additions & 0 deletions
4
crates/sui-verifier-transactional-tests/tests/entry_points/option.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,4 @@ | ||
processed 1 task | ||
|
||
task 0 'publish'. lines 6-16: | ||
Error: Failed to verify the Move module, reason: "Invalid entry point parameter type. Expected primitive or object type. Got: Std::Option::Option<u64>". |
16 changes: 16 additions & 0 deletions
16
crates/sui-verifier-transactional-tests/tests/entry_points/option.mvir
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, non key structs are not supported | ||
|
||
//# publish | ||
module 0x0.M { | ||
import 0x2.TxContext; | ||
import 0x1.Option; | ||
|
||
public(script) no(s: Option.Option<u64>, ctx: &mut TxContext.TxContext) { | ||
label l0: | ||
abort 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
Oops, something went wrong.