Skip to content

Commit

Permalink
[transfer-to-object] Allow calling some additional functions (MystenL…
Browse files Browse the repository at this point in the history
…abs#15531)

## Description 

Adds the ability to call a function to determine the object ID to be
received

## Test Plan 

Added additional tests for this.

---
If your changes are not user-facing and not a breaking change, you can
skip the following section. Otherwise, please indicate what changed, and
then add to the Release Notes section as highlighted during the release
process.

### Type of Change (Check all that apply)

- [X] protocol change
- [ ] user-visible impact
- [ ] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration

### Release notes

Added additional functionality to determine the object ID of a receiving
object.
  • Loading branch information
tzakian authored Jan 3, 2024
1 parent 005784f commit 6418ced
Show file tree
Hide file tree
Showing 54 changed files with 1,518 additions and 669 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
processed 10 tasks

task 1 'publish'. lines 6-31:
created: object(1,0)
mutated: object(0,0)
gas summary: computation_cost: 1000000, storage_cost: 6650000, storage_rebate: 0, non_refundable_storage_fee: 0

task 2 'run'. lines 33-33:
created: object(2,0), object(2,1)
mutated: object(0,0)
gas summary: computation_cost: 1000000, storage_cost: 3420000, storage_rebate: 978120, non_refundable_storage_fee: 9880

task 3 'view-object'. lines 35-35:
Owner: Account Address ( _ )
Version: 3
Contents: tto::M1::A {id: sui::object::UID {id: sui::object::ID {bytes: fake(2,0)}}}

task 4 'view-object'. lines 37-37:
Owner: Account Address ( fake(2,0) )
Version: 3
Contents: tto::M1::B {id: sui::object::UID {id: sui::object::ID {bytes: fake(2,1)}}}

task 5 'run'. lines 39-39:
mutated: object(0,0)
gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880

task 6 'programmable'. lines 41-42:
mutated: object(0,0)
gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880

task 7 'programmable'. lines 44-45:
mutated: object(0,0)
gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880

task 8 'view-object'. lines 47-47:
Owner: Account Address ( _ )
Version: 3
Contents: tto::M1::A {id: sui::object::UID {id: sui::object::ID {bytes: fake(2,0)}}}

task 9 'view-object'. lines 49-49:
Owner: Account Address ( fake(2,0) )
Version: 3
Contents: tto::M1::B {id: sui::object::UID {id: sui::object::ID {bytes: fake(2,1)}}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

//# init --addresses tto=0x0

//# publish
module tto::M1 {
use sui::object::{Self, UID};
use sui::tx_context::{Self, TxContext};
use sui::transfer::{Self, Receiving};

struct A has key, store {
id: UID,
}

struct B has key, store {
id: UID,
}

public fun start(ctx: &mut TxContext) {
let a = A { id: object::new(ctx) };
let a_address = object::id_address(&a);
let b = B { id: object::new(ctx) };
transfer::public_transfer(a, tx_context::sender(ctx));
transfer::public_transfer(b, a_address);
}

public entry fun receiver(x: Receiving<B>) {
transfer::receiving_object_id(&x);
}
}

//# run tto::M1::start

//# view-object 2,0

//# view-object 2,1

//# run tto::M1::receiver --args receiving(2,1)

//# programmable --inputs receiving(2,1)
//> sui::transfer::receiving_object_id<tto::M1::B>(Input(0))

//# programmable --inputs receiving(2,1)
//> tto::M1::receiver(Input(0))

//# view-object 2,0

//# view-object 2,1
4 changes: 2 additions & 2 deletions crates/sui-framework-tests/src/metered_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
use move_bytecode_verifier::meter::Scope;
use prometheus::Registry;
use std::{path::PathBuf, sync::Arc, time::Instant};
use sui_adapter::adapter::{default_verifier_config, run_metered_move_bytecode_verifier};
use sui_adapter::adapter::run_metered_move_bytecode_verifier;
use sui_framework::BuiltInFramework;
use sui_move_build::{CompiledPackage, SuiPackageHooks};
use sui_protocol_config::ProtocolConfig;
use sui_types::{
error::{SuiError, SuiResult},
metrics::BytecodeVerifierMetrics,
};
use sui_verifier::meter::SuiVerifierMeter;
use sui_verifier::{default_verifier_config, meter::SuiVerifierMeter};

fn build(path: PathBuf) -> SuiResult<CompiledPackage> {
let mut config = sui_move_build::BuildConfig::new_for_testing();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ Response: {
"data": {
"availableRange": {
"first": {
"digest": "J1HE76Y2wW8ewvY4mkMLoakkFQJwoRn4SmYiEf4A17oC",
"digest": "AiBjCdxSobDeDLbaYu3BpujPePncHL7QXtDPTFmirSkL",
"sequenceNumber": 0
},
"last": {
"digest": "J1HE76Y2wW8ewvY4mkMLoakkFQJwoRn4SmYiEf4A17oC",
"digest": "AiBjCdxSobDeDLbaYu3BpujPePncHL7QXtDPTFmirSkL",
"sequenceNumber": 0
}
},
"first": {
"digest": "J1HE76Y2wW8ewvY4mkMLoakkFQJwoRn4SmYiEf4A17oC",
"digest": "AiBjCdxSobDeDLbaYu3BpujPePncHL7QXtDPTFmirSkL",
"sequenceNumber": 0
},
"last": {
"digest": "J1HE76Y2wW8ewvY4mkMLoakkFQJwoRn4SmYiEf4A17oC",
"digest": "AiBjCdxSobDeDLbaYu3BpujPePncHL7QXtDPTFmirSkL",
"sequenceNumber": 0
}
}
Expand All @@ -35,20 +35,20 @@ Response: {
"data": {
"availableRange": {
"first": {
"digest": "J1HE76Y2wW8ewvY4mkMLoakkFQJwoRn4SmYiEf4A17oC",
"digest": "AiBjCdxSobDeDLbaYu3BpujPePncHL7QXtDPTFmirSkL",
"sequenceNumber": 0
},
"last": {
"digest": "BthNPt8o8jotqVkCJknVF6vCBrGwp6VABAYuzyPJVzvv",
"digest": "374bD5qhZg6ro1ZktSdnzRJ88CrRSiZnj4WVk3fsd5hx",
"sequenceNumber": 2
}
},
"first": {
"digest": "J1HE76Y2wW8ewvY4mkMLoakkFQJwoRn4SmYiEf4A17oC",
"digest": "AiBjCdxSobDeDLbaYu3BpujPePncHL7QXtDPTFmirSkL",
"sequenceNumber": 0
},
"last": {
"digest": "BthNPt8o8jotqVkCJknVF6vCBrGwp6VABAYuzyPJVzvv",
"digest": "374bD5qhZg6ro1ZktSdnzRJ88CrRSiZnj4WVk3fsd5hx",
"sequenceNumber": 2
}
}
Expand Down
56 changes: 28 additions & 28 deletions crates/sui-graphql-e2e-tests/tests/call/dynamic_fields.exp
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ Response: {
{
"name": {
"type": {
"repr": "u64"
"repr": "bool"
},
"data": {
"Number": "0"
"Bool": false
},
"bcs": "AAAAAAAAAAA="
"bcs": "AA=="
},
"value": {
"__typename": "MoveValue"
Expand All @@ -49,24 +49,24 @@ Response: {
{
"name": {
"type": {
"repr": "vector<u8>"
"repr": "u64"
},
"data": {
"Vector": []
"Number": "0"
},
"bcs": "AA=="
"bcs": "AAAAAAAAAAA="
},
"value": {
"__typename": "MoveValue"
"__typename": "MoveObject"
}
},
{
"name": {
"type": {
"repr": "bool"
"repr": "vector<u8>"
},
"data": {
"Bool": false
"Vector": []
},
"bcs": "AA=="
},
Expand All @@ -85,7 +85,7 @@ Response: {
"bcs": "AAAAAAAAAAA="
},
"value": {
"__typename": "MoveObject"
"__typename": "MoveValue"
}
}
]
Expand Down Expand Up @@ -119,53 +119,49 @@ Response: {
{
"name": {
"type": {
"repr": "u64"
"repr": "bool"
},
"data": {
"Number": "0"
"Bool": false
},
"bcs": "AAAAAAAAAAA="
"bcs": "AA=="
},
"value": {
"bcs": "AAAAAAAAAAA=",
"bcs": "AgAAAAAAAAA=",
"data": {
"Number": "0"
"Number": "2"
},
"__typename": "MoveValue"
}
},
{
"name": {
"type": {
"repr": "vector<u8>"
"repr": "u64"
},
"data": {
"Vector": []
"Number": "0"
},
"bcs": "AA=="
"bcs": "AAAAAAAAAAA="
},
"value": {
"bcs": "AQAAAAAAAAA=",
"data": {
"Number": "1"
},
"__typename": "MoveValue"
"__typename": "MoveObject"
}
},
{
"name": {
"type": {
"repr": "bool"
"repr": "vector<u8>"
},
"data": {
"Bool": false
"Vector": []
},
"bcs": "AA=="
},
"value": {
"bcs": "AgAAAAAAAAA=",
"bcs": "AQAAAAAAAAA=",
"data": {
"Number": "2"
"Number": "1"
},
"__typename": "MoveValue"
}
Expand All @@ -181,7 +177,11 @@ Response: {
"bcs": "AAAAAAAAAAA="
},
"value": {
"__typename": "MoveObject"
"bcs": "AAAAAAAAAAA=",
"data": {
"Number": "0"
},
"__typename": "MoveValue"
}
}
]
Expand Down
Loading

0 comments on commit 6418ced

Please sign in to comment.