-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
1,317 additions
and
0 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
...es/sui-adapter-transactional-tests/tests/mvcc/receive_object_access_through_parent_df.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,70 @@ | ||
processed 14 tasks | ||
|
||
init: | ||
A: object(0,0) | ||
|
||
task 1 'publish'. lines 6-78: | ||
created: object(1,0) | ||
mutated: object(0,1) | ||
gas summary: computation_cost: 1000000, storage_cost: 12524800, storage_rebate: 0, non_refundable_storage_fee: 0 | ||
|
||
task 2 'run'. lines 80-80: | ||
created: object(2,0), object(2,1), object(2,2), object(2,3), object(2,4), object(2,5), object(2,6), object(2,7) | ||
mutated: object(0,0) | ||
gas summary: computation_cost: 1000000, storage_cost: 15298800, storage_rebate: 0, non_refundable_storage_fee: 0 | ||
|
||
task 3 'view-object'. lines 82-82: | ||
Owner: Object ID: ( _ ) | ||
Version: 2 | ||
Contents: sui::dynamic_field::Field<sui::dynamic_object_field::Wrapper<u64>, sui::object::ID> {id: sui::object::UID {id: sui::object::ID {bytes: fake(2,0)}}, name: sui::dynamic_object_field::Wrapper<u64> {name: 1u64}, value: sui::object::ID {bytes: fake(2,5)}} | ||
|
||
task 4 'view-object'. lines 84-84: | ||
Owner: Object ID: ( fake(2,6) ) | ||
Version: 2 | ||
Contents: sui::dynamic_field::Field<u64, tto::M1::A> {id: sui::object::UID {id: sui::object::ID {bytes: fake(2,1)}}, name: 0u64, value: tto::M1::A {id: sui::object::UID {id: sui::object::ID {bytes: _}}, value: vector[98u8, 95u8, 99u8, 104u8, 105u8, 108u8, 100u8]}} | ||
|
||
task 5 'view-object'. lines 86-86: | ||
Owner: Object ID: ( _ ) | ||
Version: 2 | ||
Contents: sui::dynamic_field::Field<u64, tto::M1::A> {id: sui::object::UID {id: sui::object::ID {bytes: fake(2,2)}}, name: 0u64, value: tto::M1::A {id: sui::object::UID {id: sui::object::ID {bytes: _}}, value: vector[98u8, 95u8, 99u8, 104u8, 105u8, 108u8, 100u8, 95u8, 99u8, 104u8, 105u8, 108u8, 100u8]}} | ||
|
||
task 6 'view-object'. lines 88-88: | ||
Owner: Object ID: ( _ ) | ||
Version: 2 | ||
Contents: sui::dynamic_field::Field<u64, tto::M1::A> {id: sui::object::UID {id: sui::object::ID {bytes: fake(2,3)}}, name: 0u64, value: tto::M1::A {id: sui::object::UID {id: sui::object::ID {bytes: _}}, value: vector[119u8, 114u8, 97u8, 112u8, 112u8, 101u8, 100u8, 95u8, 100u8, 111u8, 102u8]}} | ||
|
||
task 7 'view-object'. lines 90-90: | ||
Owner: Account Address ( A ) | ||
Version: 2 | ||
Contents: tto::M1::A {id: sui::object::UID {id: sui::object::ID {bytes: fake(2,4)}}, value: vector[97u8, 95u8, 112u8, 97u8, 114u8, 101u8, 110u8, 116u8]} | ||
|
||
task 8 'view-object'. lines 92-92: | ||
Owner: Object ID: ( fake(2,0) ) | ||
Version: 2 | ||
Contents: tto::M1::A {id: sui::object::UID {id: sui::object::ID {bytes: fake(2,5)}}, value: vector[98u8, 95u8, 99u8, 104u8, 105u8, 108u8, 100u8, 95u8, 99u8, 104u8, 105u8, 108u8, 100u8, 95u8, 100u8, 111u8, 102u8]} | ||
|
||
task 9 'view-object'. lines 94-94: | ||
Owner: Account Address ( fake(2,4) ) | ||
Version: 2 | ||
Contents: tto::M1::A {id: sui::object::UID {id: sui::object::ID {bytes: fake(2,6)}}, value: vector[98u8, 95u8, 112u8, 97u8, 114u8, 101u8, 110u8, 116u8]} | ||
|
||
task 10 'view-object'. lines 96-99: | ||
Owner: Account Address ( fake(2,4) ) | ||
Version: 2 | ||
Contents: tto::M1::Wrapper<tto::M1::A> {id: sui::object::UID {id: sui::object::ID {bytes: fake(2,7)}}, value: tto::M1::A {id: sui::object::UID {id: sui::object::ID {bytes: _}}, value: vector[119u8, 114u8, 97u8, 112u8, 112u8, 101u8, 100u8]}} | ||
|
||
task 11 'run'. lines 100-100: | ||
Error: Transaction Effects Status: Move Runtime Abort. Location: sui::transfer::receive_impl (function index 10) at offset 0, Abort Code: 2 | ||
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MoveAbort(MoveLocation { module: ModuleId { address: sui, name: Identifier("transfer") }, function: 10, 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(10), 0)] }), command: Some(0) } } | ||
|
||
task 12 'run'. lines 102-102: | ||
created: object(12,0) | ||
mutated: object(0,0), object(2,4) | ||
wrapped: object(2,6) | ||
gas summary: computation_cost: 1000000, storage_cost: 4278800, storage_rebate: 3521232, non_refundable_storage_fee: 35568 | ||
|
||
task 13 'run'. lines 104-104: | ||
created: object(13,0) | ||
mutated: object(0,0), object(2,4) | ||
wrapped: object(2,7) | ||
gas summary: computation_cost: 1000000, storage_cost: 4856400, storage_rebate: 4093056, non_refundable_storage_fee: 41344 |
104 changes: 104 additions & 0 deletions
104
...s/sui-adapter-transactional-tests/tests/mvcc/receive_object_access_through_parent_df.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,104 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//# init --addresses tto=0x0 --accounts A | ||
|
||
//# publish | ||
module tto::M1 { | ||
use sui::object::{Self, UID}; | ||
use sui::tx_context::{Self, TxContext}; | ||
use sui::transfer::{Self, Receiving}; | ||
use sui::dynamic_object_field as dof; | ||
use sui::dynamic_field as df; | ||
|
||
const KEY: u64 = 0; | ||
const BKEY: u64 = 1; | ||
|
||
struct A has key, store { | ||
id: UID, | ||
value: vector<u8>, | ||
} | ||
|
||
struct Wrapper<T: key + store> has key, store { | ||
id: UID, | ||
value: T, | ||
} | ||
|
||
public fun start(ctx: &mut TxContext) { | ||
let a_parent = A { id: object::new(ctx), value: b"a_parent" }; | ||
|
||
let b_parent = A { id: object::new(ctx), value: b"b_parent" }; | ||
let b_child = A { id: object::new(ctx), value: b"b_child" }; | ||
let b_child_child = A { id: object::new(ctx), value: b"b_child_child" }; | ||
let b_child_child_dof = A { id: object::new(ctx), value: b"b_child_child_dof" }; | ||
|
||
let wrapped_df = A { id: object::new(ctx), value: b"wrapped_dof" }; | ||
let to_wrap = A { id: object::new(ctx), value: b"wrapped" }; | ||
df::add(&mut to_wrap.id, KEY, wrapped_df); | ||
let wrapped = Wrapper { id: object::new(ctx), value: to_wrap }; | ||
|
||
df::add(&mut b_child.id, KEY, b_child_child); | ||
dof::add(&mut b_child.id, BKEY, b_child_child_dof); | ||
df::add(&mut b_parent.id, KEY, b_child); | ||
|
||
let a_address = object::id_address(&a_parent); | ||
transfer::public_transfer(a_parent, tx_context::sender(ctx)); | ||
transfer::public_transfer(b_parent, a_address); | ||
transfer::public_transfer(wrapped, a_address); | ||
} | ||
|
||
public entry fun receive_b_parent(a_parent: &mut A, x: Receiving<A>) { | ||
let b_parent = transfer::receive(&mut a_parent.id, x); | ||
df::add(&mut a_parent.id, KEY, b_parent); | ||
let b_parent: &A = df::borrow(&a_parent.id, KEY); | ||
let b_child: &A = df::borrow(&b_parent.id, KEY); | ||
let b_child_child: &A = df::borrow(&b_child.id, KEY); | ||
let b_child_child_dof: &A = dof::borrow(&b_child.id, BKEY); | ||
assert!(a_parent.value == b"a_parent", 0); | ||
assert!(b_child.value == b"b_child", 1); | ||
assert!(b_parent.value == b"b_parent", 2); | ||
assert!(b_child_child.value == b"b_child_child", 3); | ||
assert!(b_child_child_dof.value == b"b_child_child_dof", 4); | ||
} | ||
|
||
public entry fun receive_wrapped(a_parent: &mut A, x: Receiving<Wrapper<A>>) { | ||
let wrapped = transfer::receive(&mut a_parent.id, x); | ||
df::add(&mut a_parent.id, BKEY, wrapped); | ||
let wrapped: &Wrapper<A> = df::borrow(&a_parent.id, BKEY); | ||
let wrapped_dof: &A = df::borrow(&wrapped.value.id, KEY); | ||
assert!(wrapped.value.value == b"wrapped", 5); | ||
assert!(wrapped_dof.value == b"wrapped_dof", 6); | ||
} | ||
} | ||
|
||
// receive, add, and then access through parent. | ||
// * A dynamic field | ||
// * A dynamic field of a dynamic field | ||
// * A dynamic object field of a dynamic field | ||
// * A dynamic field of wrapped object that was received | ||
|
||
//# run tto::M1::start --sender A | ||
|
||
//# view-object 2,0 | ||
|
||
//# view-object 2,1 | ||
|
||
//# view-object 2,2 | ||
|
||
//# view-object 2,3 | ||
|
||
//# view-object 2,4 | ||
|
||
//# view-object 2,5 | ||
|
||
//# view-object 2,6 | ||
|
||
//# view-object 2,7 | ||
|
||
// E_OBJECT_TYPE_MISMATCH | ||
// Try to load an invalid type that will cause indexing to fail. | ||
//# run tto::M1::receive_b_parent --args object(2,4) receiving(2,7) --sender A | ||
|
||
//# run tto::M1::receive_b_parent --args object(2,4) receiving(2,6) --sender A | ||
|
||
//# run tto::M1::receive_wrapped --args object(2,4) receiving(2,7) --sender A |
78 changes: 78 additions & 0 deletions
78
...s/sui-adapter-transactional-tests/tests/mvcc/receive_object_access_through_parent_dof.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,78 @@ | ||
processed 16 tasks | ||
|
||
init: | ||
A: object(0,0) | ||
|
||
task 1 'publish'. lines 6-78: | ||
created: object(1,0) | ||
mutated: object(0,1) | ||
gas summary: computation_cost: 1000000, storage_cost: 12509600, storage_rebate: 0, non_refundable_storage_fee: 0 | ||
|
||
task 2 'run'. lines 80-80: | ||
created: object(2,0), object(2,1), object(2,2), object(2,3), object(2,4), object(2,5), object(2,6), object(2,7), object(2,8), object(2,9) | ||
mutated: object(0,0) | ||
gas summary: computation_cost: 1000000, storage_cost: 18749200, storage_rebate: 0, non_refundable_storage_fee: 0 | ||
|
||
task 3 'view-object'. lines 82-82: | ||
Owner: Object ID: ( fake(2,7) ) | ||
Version: 2 | ||
Contents: sui::dynamic_field::Field<sui::dynamic_object_field::Wrapper<u64>, sui::object::ID> {id: sui::object::UID {id: sui::object::ID {bytes: fake(2,0)}}, name: sui::dynamic_object_field::Wrapper<u64> {name: 0u64}, value: sui::object::ID {bytes: fake(2,4)}} | ||
|
||
task 4 'view-object'. lines 84-84: | ||
Owner: Object ID: ( _ ) | ||
Version: 2 | ||
Contents: sui::dynamic_field::Field<sui::dynamic_object_field::Wrapper<u64>, sui::object::ID> {id: sui::object::UID {id: sui::object::ID {bytes: fake(2,1)}}, name: sui::dynamic_object_field::Wrapper<u64> {name: 0u64}, value: sui::object::ID {bytes: fake(2,5)}} | ||
|
||
task 5 'view-object'. lines 86-86: | ||
Owner: Object ID: ( fake(2,6) ) | ||
Version: 2 | ||
Contents: sui::dynamic_field::Field<sui::dynamic_object_field::Wrapper<u64>, sui::object::ID> {id: sui::object::UID {id: sui::object::ID {bytes: fake(2,2)}}, name: sui::dynamic_object_field::Wrapper<u64> {name: 0u64}, value: sui::object::ID {bytes: fake(2,7)}} | ||
|
||
task 6 'view-object'. lines 88-88: | ||
Owner: Object ID: ( fake(2,7) ) | ||
Version: 2 | ||
Contents: sui::dynamic_field::Field<u64, tto::M1::A> {id: sui::object::UID {id: sui::object::ID {bytes: fake(2,3)}}, name: 1u64, value: tto::M1::A {id: sui::object::UID {id: sui::object::ID {bytes: _}}, value: vector[98u8, 95u8, 99u8, 104u8, 105u8, 108u8, 100u8, 95u8, 99u8, 104u8, 105u8, 108u8, 100u8, 95u8, 100u8, 102u8]}} | ||
|
||
task 7 'view-object'. lines 90-90: | ||
Owner: Object ID: ( fake(2,0) ) | ||
Version: 2 | ||
Contents: tto::M1::A {id: sui::object::UID {id: sui::object::ID {bytes: fake(2,4)}}, value: vector[98u8, 95u8, 99u8, 104u8, 105u8, 108u8, 100u8, 95u8, 99u8, 104u8, 105u8, 108u8, 100u8]} | ||
|
||
task 8 'view-object'. lines 92-92: | ||
Owner: Object ID: ( fake(2,1) ) | ||
Version: 2 | ||
Contents: tto::M1::A {id: sui::object::UID {id: sui::object::ID {bytes: fake(2,5)}}, value: vector[119u8, 114u8, 97u8, 112u8, 112u8, 101u8, 100u8, 95u8, 100u8, 102u8]} | ||
|
||
task 9 'view-object'. lines 94-94: | ||
Owner: Account Address ( fake(2,8) ) | ||
Version: 2 | ||
Contents: tto::M1::A {id: sui::object::UID {id: sui::object::ID {bytes: fake(2,6)}}, value: vector[98u8, 95u8, 112u8, 97u8, 114u8, 101u8, 110u8, 116u8]} | ||
|
||
task 10 'view-object'. lines 96-96: | ||
Owner: Object ID: ( fake(2,2) ) | ||
Version: 2 | ||
Contents: tto::M1::A {id: sui::object::UID {id: sui::object::ID {bytes: fake(2,7)}}, value: vector[98u8, 95u8, 99u8, 104u8, 105u8, 108u8, 100u8]} | ||
|
||
task 11 'view-object'. lines 98-98: | ||
Owner: Account Address ( A ) | ||
Version: 2 | ||
Contents: tto::M1::A {id: sui::object::UID {id: sui::object::ID {bytes: fake(2,8)}}, value: vector[97u8, 95u8, 112u8, 97u8, 114u8, 101u8, 110u8, 116u8]} | ||
|
||
task 12 'view-object'. lines 100-103: | ||
Owner: Account Address ( fake(2,8) ) | ||
Version: 2 | ||
Contents: tto::M1::Wrapper<tto::M1::A> {id: sui::object::UID {id: sui::object::ID {bytes: fake(2,9)}}, value: tto::M1::A {id: sui::object::UID {id: sui::object::ID {bytes: _}}, value: vector[119u8, 114u8, 97u8, 112u8, 112u8, 101u8, 100u8]}} | ||
|
||
task 13 'run'. lines 104-104: | ||
Error: Transaction Effects Status: Move Runtime Abort. Location: sui::transfer::receive_impl (function index 10) at offset 0, Abort Code: 2 | ||
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MoveAbort(MoveLocation { module: ModuleId { address: sui, name: Identifier("transfer") }, function: 10, 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(10), 0)] }), command: Some(0) } } | ||
|
||
task 14 'run'. lines 106-106: | ||
created: object(14,0) | ||
mutated: object(0,0), object(2,6), object(2,8) | ||
gas summary: computation_cost: 1000000, storage_cost: 6011600, storage_rebate: 3521232, non_refundable_storage_fee: 35568 | ||
|
||
task 15 'run'. lines 108-108: | ||
created: object(15,0) | ||
mutated: object(0,0), object(2,8), object(2,9) | ||
gas summary: computation_cost: 1000000, storage_cost: 6589200, storage_rebate: 4093056, non_refundable_storage_fee: 41344 |
108 changes: 108 additions & 0 deletions
108
.../sui-adapter-transactional-tests/tests/mvcc/receive_object_access_through_parent_dof.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,108 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//# init --addresses tto=0x0 --accounts A | ||
|
||
//# publish | ||
module tto::M1 { | ||
use sui::object::{Self, UID}; | ||
use sui::tx_context::{Self, TxContext}; | ||
use sui::transfer::{Self, Receiving}; | ||
use sui::dynamic_object_field as dof; | ||
use sui::dynamic_field as df; | ||
|
||
const KEY: u64 = 0; | ||
const BKEY: u64 = 1; | ||
|
||
struct A has key, store { | ||
id: UID, | ||
value: vector<u8>, | ||
} | ||
|
||
struct Wrapper<T: key + store> has key, store { | ||
id: UID, | ||
value: T, | ||
} | ||
|
||
public fun start(ctx: &mut TxContext) { | ||
let a_parent = A { id: object::new(ctx), value: b"a_parent" }; | ||
|
||
let b_parent = A { id: object::new(ctx), value: b"b_parent" }; | ||
let b_child = A { id: object::new(ctx), value: b"b_child" }; | ||
let b_child_child = A { id: object::new(ctx), value: b"b_child_child" }; | ||
let b_child_child_df = A { id: object::new(ctx), value: b"b_child_child_df" }; | ||
|
||
let wrapped_dof = A { id: object::new(ctx), value: b"wrapped_df" }; | ||
let to_wrap = A { id: object::new(ctx), value: b"wrapped" }; | ||
dof::add(&mut to_wrap.id, KEY, wrapped_dof); | ||
let wrapped = Wrapper { id: object::new(ctx), value: to_wrap }; | ||
|
||
dof::add(&mut b_child.id, KEY, b_child_child); | ||
df::add(&mut b_child.id, BKEY, b_child_child_df); | ||
dof::add(&mut b_parent.id, KEY, b_child); | ||
|
||
let a_address = object::id_address(&a_parent); | ||
transfer::public_transfer(a_parent, tx_context::sender(ctx)); | ||
transfer::public_transfer(b_parent, a_address); | ||
transfer::public_transfer(wrapped, a_address); | ||
} | ||
|
||
public entry fun receive_b_parent(a_parent: &mut A, x: Receiving<A>) { | ||
let b_parent = transfer::receive(&mut a_parent.id, x); | ||
dof::add(&mut a_parent.id, KEY, b_parent); | ||
let b_parent: &A = dof::borrow(&a_parent.id, KEY); | ||
let b_child: &A = dof::borrow(&b_parent.id, KEY); | ||
let b_child_child: &A = dof::borrow(&b_child.id, KEY); | ||
let b_child_child_df: &A = df::borrow(&b_child.id, BKEY); | ||
assert!(a_parent.value == b"a_parent", 0); | ||
assert!(b_child.value == b"b_child", 1); | ||
assert!(b_parent.value == b"b_parent", 2); | ||
assert!(b_child_child.value == b"b_child_child", 3); | ||
assert!(b_child_child_df.value == b"b_child_child_df", 4); | ||
} | ||
|
||
public entry fun receive_wrapped(a_parent: &mut A, x: Receiving<Wrapper<A>>) { | ||
let wrapped = transfer::receive(&mut a_parent.id, x); | ||
dof::add(&mut a_parent.id, BKEY, wrapped); | ||
let wrapped: &Wrapper<A> = dof::borrow(&a_parent.id, BKEY); | ||
let wrapped_df: &A = dof::borrow(&wrapped.value.id, KEY); | ||
assert!(wrapped.value.value == b"wrapped", 5); | ||
assert!(wrapped_df.value == b"wrapped_df", 6); | ||
} | ||
} | ||
|
||
// receive, add, and then access through parent. | ||
// * A dynamic object field | ||
// * A dynamic object field of a dynamic object field | ||
// * A dynamic field of a dynamic object field | ||
// * A dynamic object field of wrapped object that was received | ||
|
||
//# run tto::M1::start --sender A | ||
|
||
//# view-object 2,0 | ||
|
||
//# view-object 2,1 | ||
|
||
//# view-object 2,2 | ||
|
||
//# view-object 2,3 | ||
|
||
//# view-object 2,4 | ||
|
||
//# view-object 2,5 | ||
|
||
//# view-object 2,6 | ||
|
||
//# view-object 2,7 | ||
|
||
//# view-object 2,8 | ||
|
||
//# view-object 2,9 | ||
|
||
// E_OBJECT_TYPE_MISMATCH | ||
// Try to load an invalid type that will cause indexing to fail. | ||
//# run tto::M1::receive_b_parent --args object(2,8) receiving(2,9) --sender A | ||
|
||
//# run tto::M1::receive_b_parent --args object(2,8) receiving(2,6) --sender A | ||
|
||
//# run tto::M1::receive_wrapped --args object(2,8) receiving(2,9) --sender A |
Oops, something went wrong.