Skip to content

Commit a73e93f

Browse files
authored
[sui-framework] Add party_transfer (not yet enabled) (#20947)
## Description - Adds public and private variants of party_transfer for Consensus V2 objects - Adds compiler support for private generics checks - Adds verifier support for private generics checks - Native function is disabled currently via protocol config ## Test plan - Added 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. - [ ] Protocol: - [ ] Nodes (Validators and Full nodes): - [ ] gRPC: - [ ] JSON-RPC: - [ ] GraphQL: - [ ] CLI: - [ ] Rust SDK:
1 parent e980dcb commit a73e93f

File tree

95 files changed

+1512
-142
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+1512
-142
lines changed

crates/sui-adapter-transactional-tests/tests/mvcc/receive_object_access_through_parent_df.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ Contents: tto::M1::Wrapper<tto::M1::A> {
238238

239239
task 11, line 98:
240240
//# run tto::M1::receive_b_parent --args object(2,4) receiving(2,7) --sender A
241-
Error: Transaction Effects Status: Move Runtime Abort. Location: sui::transfer::receive_impl (function index 12) at offset 0, Abort Code: 2
242-
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MoveAbort(MoveLocation { module: ModuleId { address: sui, name: Identifier("transfer") }, function: 12, instruction: 0, function_name: Some("receive_impl") }, 2), source: Some(VMError { major_status: ABORTED, sub_status: Some(2), message: None, exec_state: None, location: Module(ModuleId { address: sui, name: Identifier("transfer") }), indices: [], offsets: [(FunctionDefinitionIndex(12), 0)] }), command: Some(0) } }
241+
Error: Transaction Effects Status: Move Runtime Abort. Location: sui::transfer::receive_impl (function index 15) at offset 0, Abort Code: 2
242+
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MoveAbort(MoveLocation { module: ModuleId { address: sui, name: Identifier("transfer") }, function: 15, instruction: 0, function_name: Some("receive_impl") }, 2), source: Some(VMError { major_status: ABORTED, sub_status: Some(2), message: None, exec_state: None, location: Module(ModuleId { address: sui, name: Identifier("transfer") }), indices: [], offsets: [(FunctionDefinitionIndex(15), 0)] }), command: Some(0) } }
243243

244244
task 12, line 100:
245245
//# run tto::M1::receive_b_parent --args object(2,4) receiving(2,6) --sender A

crates/sui-adapter-transactional-tests/tests/mvcc/receive_object_access_through_parent_dof.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ Contents: tto::M1::Wrapper<tto::M1::A> {
256256

257257
task 13, line 102:
258258
//# run tto::M1::receive_b_parent --args object(2,8) receiving(2,9) --sender A
259-
Error: Transaction Effects Status: Move Runtime Abort. Location: sui::transfer::receive_impl (function index 12) at offset 0, Abort Code: 2
260-
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MoveAbort(MoveLocation { module: ModuleId { address: sui, name: Identifier("transfer") }, function: 12, instruction: 0, function_name: Some("receive_impl") }, 2), source: Some(VMError { major_status: ABORTED, sub_status: Some(2), message: None, exec_state: None, location: Module(ModuleId { address: sui, name: Identifier("transfer") }), indices: [], offsets: [(FunctionDefinitionIndex(12), 0)] }), command: Some(0) } }
259+
Error: Transaction Effects Status: Move Runtime Abort. Location: sui::transfer::receive_impl (function index 15) at offset 0, Abort Code: 2
260+
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MoveAbort(MoveLocation { module: ModuleId { address: sui, name: Identifier("transfer") }, function: 15, instruction: 0, function_name: Some("receive_impl") }, 2), source: Some(VMError { major_status: ABORTED, sub_status: Some(2), message: None, exec_state: None, location: Module(ModuleId { address: sui, name: Identifier("transfer") }), indices: [], offsets: [(FunctionDefinitionIndex(15), 0)] }), command: Some(0) } }
261261

262262
task 14, line 104:
263263
//# run tto::M1::receive_b_parent --args object(2,8) receiving(2,6) --sender A
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Copyright (c) Mysten Labs, Inc.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
//# init --addresses ex=0x0
5+
6+
//# publish
7+
module ex::m;
8+
9+
public struct Pub has key, store {
10+
id: UID,
11+
}
12+
13+
public struct Priv has key {
14+
id: UID,
15+
}
16+
17+
public fun mint(ctx: &mut TxContext) {
18+
let p = Pub { id: object::new(ctx) };
19+
let q = Priv { id: object::new(ctx) };
20+
transfer::public_transfer(p, ctx.sender());
21+
transfer::transfer(q, ctx.sender());
22+
}
23+
24+
public fun create_party(ctx: &mut TxContext) {
25+
let p = Pub { id: object::new(ctx) };
26+
transfer::public_party_transfer(p, sui::party::single_owner(@0))
27+
}
28+
29+
public fun pub_party(obj: Pub, p: sui::party::Party) {
30+
transfer::public_party_transfer(obj, p)
31+
}
32+
33+
public fun priv_party(obj: Priv, p: sui::party::Party) {
34+
transfer::party_transfer(obj, p)
35+
}
36+
37+
//# run ex::m::mint
38+
39+
// Aborts since party transfer is not enabled
40+
//# run ex::m::create_party
41+
42+
// Aborts since party transfer is not enabled
43+
//# programmable --inputs object(2,0) @0
44+
//> 0: sui::party::single_owner(Input(1));
45+
//> ex::m::priv_party(Input(0), Result(0))
46+
47+
48+
// Aborts since party transfer is not enabled
49+
//# programmable --inputs object(2,1) @0
50+
//> 0: sui::party::single_owner(Input(1));
51+
//> ex::m::pub_party(Input(0), Result(0))
52+
53+
// Aborts since party transfer is not enabled
54+
//# programmable --inputs object(2,1) @0
55+
//> 0: sui::party::single_owner(Input(1));
56+
//> sui::transfer::public_party_transfer<ex::m::Pub>(Input(0), Result(0))
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
source: external-crates/move/crates/move-transactional-test-runner/src/framework.rs
3+
---
4+
processed 7 tasks
5+
6+
task 1, lines 6-35:
7+
//# publish
8+
created: object(1,0)
9+
mutated: object(0,0)
10+
gas summary: computation_cost: 1000000, storage_cost: 7638000, storage_rebate: 0, non_refundable_storage_fee: 0
11+
12+
task 2, lines 37-39:
13+
//# run ex::m::mint
14+
created: object(2,0), object(2,1)
15+
mutated: object(0,0)
16+
gas summary: computation_cost: 1000000, storage_cost: 3442800, storage_rebate: 978120, non_refundable_storage_fee: 9880
17+
18+
task 3, lines 40-42:
19+
//# run ex::m::create_party
20+
Error: Transaction Effects Status: Move Runtime Abort. Location: sui::transfer::party_transfer_impl (function index 13) at offset 0, Abort Code: 5
21+
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MoveAbort(MoveLocation { module: ModuleId { address: sui, name: Identifier("transfer") }, function: 13, instruction: 0, function_name: Some("party_transfer_impl") }, 5), source: Some(VMError { major_status: ABORTED, sub_status: Some(5), message: None, exec_state: None, location: Module(ModuleId { address: sui, name: Identifier("transfer") }), indices: [], offsets: [(FunctionDefinitionIndex(13), 0)] }), command: Some(0) } }
22+
23+
task 4, lines 43-48:
24+
//# programmable --inputs object(2,0) @0
25+
//> 0: sui::party::single_owner(Input(1));
26+
//> ex::m::priv_party(Input(0), Result(0))
27+
// Aborts since party transfer is not enabled
28+
Error: Transaction Effects Status: Move Runtime Abort. Location: sui::transfer::party_transfer_impl (function index 13) at offset 0, Abort Code: 5
29+
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MoveAbort(MoveLocation { module: ModuleId { address: sui, name: Identifier("transfer") }, function: 13, instruction: 0, function_name: Some("party_transfer_impl") }, 5), source: Some(VMError { major_status: ABORTED, sub_status: Some(5), message: None, exec_state: None, location: Module(ModuleId { address: sui, name: Identifier("transfer") }), indices: [], offsets: [(FunctionDefinitionIndex(13), 0)] }), command: Some(1) } }
30+
31+
task 5, lines 49-53:
32+
//# programmable --inputs object(2,1) @0
33+
//> 0: sui::party::single_owner(Input(1));
34+
//> ex::m::pub_party(Input(0), Result(0))
35+
// Aborts since party transfer is not enabled
36+
Error: Transaction Effects Status: Move Runtime Abort. Location: sui::transfer::party_transfer_impl (function index 13) at offset 0, Abort Code: 5
37+
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MoveAbort(MoveLocation { module: ModuleId { address: sui, name: Identifier("transfer") }, function: 13, instruction: 0, function_name: Some("party_transfer_impl") }, 5), source: Some(VMError { major_status: ABORTED, sub_status: Some(5), message: None, exec_state: None, location: Module(ModuleId { address: sui, name: Identifier("transfer") }), indices: [], offsets: [(FunctionDefinitionIndex(13), 0)] }), command: Some(1) } }
38+
39+
task 6, lines 54-56:
40+
//# programmable --inputs object(2,1) @0
41+
//> 0: sui::party::single_owner(Input(1));
42+
//> sui::transfer::public_party_transfer<ex::m::Pub>(Input(0), Result(0))
43+
Error: Transaction Effects Status: Move Runtime Abort. Location: sui::transfer::party_transfer_impl (function index 13) at offset 0, Abort Code: 5
44+
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MoveAbort(MoveLocation { module: ModuleId { address: sui, name: Identifier("transfer") }, function: 13, instruction: 0, function_name: Some("party_transfer_impl") }, 5), source: Some(VMError { major_status: ABORTED, sub_status: Some(5), message: None, exec_state: None, location: Module(ModuleId { address: sui, name: Identifier("transfer") }), indices: [], offsets: [(FunctionDefinitionIndex(13), 0)] }), command: Some(1) } }
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright (c) Mysten Labs, Inc.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
//# init --addresses ex=0x0
5+
6+
//# publish
7+
module ex::m;
8+
9+
public struct Priv has key {
10+
id: UID,
11+
}
12+
13+
public fun mint(ctx: &mut TxContext) {
14+
let q = Priv { id: object::new(ctx) };
15+
transfer::transfer(q, ctx.sender());
16+
}
17+
18+
public fun priv(ctx: &mut TxContext): Priv {
19+
Priv { id: object::new(ctx) }
20+
}
21+
22+
//# run ex::m::mint
23+
24+
// Does not have store
25+
//# programmable --inputs object(2,0) @0
26+
//> 0: sui::party::single_owner(Input(1));
27+
//> sui::transfer::public_party_transfer<ex::m::Priv>(Input(0), Result(0))
28+
29+
// Does not have store
30+
//# programmable --inputs @0
31+
//> 0: ex::m::priv();
32+
//> 1: sui::party::single_owner(Input(0));
33+
//> sui::transfer::public_party_transfer<ex::m::Priv>(Result(0), Result(1))
34+
35+
// Private transfer
36+
//# programmable --inputs object(2,0) @0
37+
//> 0: sui::party::single_owner(Input(1));
38+
//> sui::transfer::party_transfer<ex::m::Priv>(Input(0), Result(0))
39+
40+
// Private transfer
41+
//# programmable --inputs @0
42+
//> 0: ex::m::priv();
43+
//> 1: sui::party::single_owner(Input(0));
44+
//> sui::transfer::party_transfer<ex::m::Priv>(Result(0), Result(1))
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
source: external-crates/move/crates/move-transactional-test-runner/src/framework.rs
3+
---
4+
processed 7 tasks
5+
6+
task 1, lines 6-20:
7+
//# publish
8+
created: object(1,0)
9+
mutated: object(0,0)
10+
gas summary: computation_cost: 1000000, storage_cost: 5198400, storage_rebate: 0, non_refundable_storage_fee: 0
11+
12+
task 2, lines 22-24:
13+
//# run ex::m::mint
14+
created: object(2,0)
15+
mutated: object(0,0)
16+
gas summary: computation_cost: 1000000, storage_cost: 2219200, storage_rebate: 978120, non_refundable_storage_fee: 9880
17+
18+
task 3, lines 25-29:
19+
//# programmable --inputs object(2,0) @0
20+
//> 0: sui::party::single_owner(Input(1));
21+
//> sui::transfer::public_party_transfer<ex::m::Priv>(Input(0), Result(0))
22+
// Does not have store
23+
Error: Transaction Effects Status: Move Bytecode Verification Error. Please run the Bytecode Verifier for more information.
24+
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: VMVerificationOrDeserializationError, source: Some(VMError { major_status: CONSTRAINT_NOT_SATISFIED, sub_status: None, message: None, exec_state: None, location: Module(ModuleId { address: sui, name: Identifier("transfer") }), indices: [], offsets: [] }), command: Some(1) } }
25+
26+
task 4, lines 30-35:
27+
//# programmable --inputs @0
28+
//> 0: ex::m::priv();
29+
//> 1: sui::party::single_owner(Input(0));
30+
//> sui::transfer::public_party_transfer<ex::m::Priv>(Result(0), Result(1))
31+
// Private transfer
32+
Error: Transaction Effects Status: Move Bytecode Verification Error. Please run the Bytecode Verifier for more information.
33+
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: VMVerificationOrDeserializationError, source: Some(VMError { major_status: CONSTRAINT_NOT_SATISFIED, sub_status: None, message: None, exec_state: None, location: Module(ModuleId { address: sui, name: Identifier("transfer") }), indices: [], offsets: [] }), command: Some(2) } }
34+
35+
task 5, lines 36-40:
36+
//# programmable --inputs object(2,0) @0
37+
//> 0: sui::party::single_owner(Input(1));
38+
//> sui::transfer::party_transfer<ex::m::Priv>(Input(0), Result(0))
39+
// Private transfer
40+
Error: Transaction Effects Status: Non Entry Function Invoked. Move Call must start with an entry function
41+
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: NonEntryFunctionInvoked, source: Some("Cannot directly call sui::transfer::party_transfer. Use the public variant instead, sui::transfer::public_party_transfer"), command: Some(1) } }
42+
43+
task 6, lines 41-44:
44+
//# programmable --inputs @0
45+
//> 0: ex::m::priv();
46+
//> 1: sui::party::single_owner(Input(0));
47+
//> sui::transfer::party_transfer<ex::m::Priv>(Result(0), Result(1))
48+
Error: Transaction Effects Status: Non Entry Function Invoked. Move Call must start with an entry function
49+
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: NonEntryFunctionInvoked, source: Some("Cannot directly call sui::transfer::party_transfer. Use the public variant instead, sui::transfer::public_party_transfer"), command: Some(2) } }

crates/sui-adapter-transactional-tests/tests/receive_object/basic_receive.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,5 @@ Contents: tto::M1::B {
7070

7171
task 8, line 46:
7272
//# run tto::M1::receiver --args object(2,0) receiving(2,1)@3
73-
Error: Transaction Effects Status: Move Runtime Abort. Location: sui::transfer::receive_impl (function index 12) at offset 0, Abort Code: 3
74-
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MoveAbort(MoveLocation { module: ModuleId { address: sui, name: Identifier("transfer") }, function: 12, instruction: 0, function_name: Some("receive_impl") }, 3), source: Some(VMError { major_status: ABORTED, sub_status: Some(3), message: None, exec_state: None, location: Module(ModuleId { address: sui, name: Identifier("transfer") }), indices: [], offsets: [(FunctionDefinitionIndex(12), 0)] }), command: Some(0) } }
73+
Error: Transaction Effects Status: Move Runtime Abort. Location: sui::transfer::receive_impl (function index 15) at offset 0, Abort Code: 3
74+
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MoveAbort(MoveLocation { module: ModuleId { address: sui, name: Identifier("transfer") }, function: 15, instruction: 0, function_name: Some("receive_impl") }, 3), source: Some(VMError { major_status: ABORTED, sub_status: Some(3), message: None, exec_state: None, location: Module(ModuleId { address: sui, name: Identifier("transfer") }), indices: [], offsets: [(FunctionDefinitionIndex(15), 0)] }), command: Some(0) } }

crates/sui-adapter-transactional-tests/tests/receive_object/move_vec_receiving_types.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ task 11, lines 93-97:
104104
//> 0: MakeMoveVec<sui::transfer::Receiving<tto::M1::B>>([Input(1), Input(2), Input(3), Input(4)]);
105105
//> 1: tto::M1::receive_all(Input(0), Result(0));
106106
// Try to spoof a receiving object
107-
Error: Transaction Effects Status: Move Runtime Abort. Location: sui::transfer::receive_impl (function index 12) at offset 0, Abort Code: 2
108-
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MoveAbort(MoveLocation { module: ModuleId { address: sui, name: Identifier("transfer") }, function: 12, instruction: 0, function_name: Some("receive_impl") }, 2), source: Some(VMError { major_status: ABORTED, sub_status: Some(2), message: None, exec_state: None, location: Module(ModuleId { address: sui, name: Identifier("transfer") }), indices: [], offsets: [(FunctionDefinitionIndex(12), 0)] }), command: Some(1) } }
107+
Error: Transaction Effects Status: Move Runtime Abort. Location: sui::transfer::receive_impl (function index 15) at offset 0, Abort Code: 2
108+
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MoveAbort(MoveLocation { module: ModuleId { address: sui, name: Identifier("transfer") }, function: 15, instruction: 0, function_name: Some("receive_impl") }, 2), source: Some(VMError { major_status: ABORTED, sub_status: Some(2), message: None, exec_state: None, location: Module(ModuleId { address: sui, name: Identifier("transfer") }), indices: [], offsets: [(FunctionDefinitionIndex(15), 0)] }), command: Some(1) } }
109109

110110
task 12, lines 98-100:
111111
//# programmable --inputs object(2,0) receiving(2,1) receiving(2,2) receiving(2,3) receiving(2,4)

crates/sui-adapter-transactional-tests/tests/receive_object/receive_and_deleted.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,5 @@ No object at id 2,1
6363

6464
task 8, line 46:
6565
//# run tto::M1::deleter --args object(2,0) receiving(2,1)@3
66-
Error: Transaction Effects Status: Move Runtime Abort. Location: sui::transfer::receive_impl (function index 12) at offset 0, Abort Code: 3
67-
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MoveAbort(MoveLocation { module: ModuleId { address: sui, name: Identifier("transfer") }, function: 12, instruction: 0, function_name: Some("receive_impl") }, 3), source: Some(VMError { major_status: ABORTED, sub_status: Some(3), message: None, exec_state: None, location: Module(ModuleId { address: sui, name: Identifier("transfer") }), indices: [], offsets: [(FunctionDefinitionIndex(12), 0)] }), command: Some(0) } }
66+
Error: Transaction Effects Status: Move Runtime Abort. Location: sui::transfer::receive_impl (function index 15) at offset 0, Abort Code: 3
67+
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MoveAbort(MoveLocation { module: ModuleId { address: sui, name: Identifier("transfer") }, function: 15, instruction: 0, function_name: Some("receive_impl") }, 3), source: Some(VMError { major_status: ABORTED, sub_status: Some(3), message: None, exec_state: None, location: Module(ModuleId { address: sui, name: Identifier("transfer") }), indices: [], offsets: [(FunctionDefinitionIndex(15), 0)] }), command: Some(0) } }

crates/sui-adapter-transactional-tests/tests/receive_object/receive_and_send_back.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,5 @@ Contents: tto::M1::B {
7070

7171
task 8, line 47:
7272
//# run tto::M1::send_back --args object(2,0) receiving(2,1)@3
73-
Error: Transaction Effects Status: Move Runtime Abort. Location: sui::transfer::receive_impl (function index 12) at offset 0, Abort Code: 3
74-
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MoveAbort(MoveLocation { module: ModuleId { address: sui, name: Identifier("transfer") }, function: 12, instruction: 0, function_name: Some("receive_impl") }, 3), source: Some(VMError { major_status: ABORTED, sub_status: Some(3), message: None, exec_state: None, location: Module(ModuleId { address: sui, name: Identifier("transfer") }), indices: [], offsets: [(FunctionDefinitionIndex(12), 0)] }), command: Some(0) } }
73+
Error: Transaction Effects Status: Move Runtime Abort. Location: sui::transfer::receive_impl (function index 15) at offset 0, Abort Code: 3
74+
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MoveAbort(MoveLocation { module: ModuleId { address: sui, name: Identifier("transfer") }, function: 15, instruction: 0, function_name: Some("receive_impl") }, 3), source: Some(VMError { major_status: ABORTED, sub_status: Some(3), message: None, exec_state: None, location: Module(ModuleId { address: sui, name: Identifier("transfer") }), indices: [], offsets: [(FunctionDefinitionIndex(15), 0)] }), command: Some(0) } }

0 commit comments

Comments
 (0)