Skip to content

Commit

Permalink
Add tracing to dynamic field operations (#15135)
Browse files Browse the repository at this point in the history
  • Loading branch information
mystenmark authored Dec 1, 2023
1 parent 6523f42 commit 07902ad
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions sui-execution/latest/sui-move-natives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ move-vm-runtime = { path = "../../../external-crates/move/crates/move-vm-runtime
sui-protocol-config.workspace = true
sui-types.workspace = true
workspace-hack.workspace = true
tracing.workspace = true
7 changes: 7 additions & 0 deletions sui-execution/latest/sui-move-natives/src/dynamic_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use move_vm_types::{
use smallvec::smallvec;
use std::collections::VecDeque;
use sui_types::{base_types::MoveObjectType, dynamic_field::derive_dynamic_field_id};
use tracing::instrument;

const E_KEY_DOES_NOT_EXIST: u64 = 1;
const E_FIELD_TYPE_MISMATCH: u64 = 2;
Expand Down Expand Up @@ -78,6 +79,7 @@ pub struct DynamicFieldHashTypeAndKeyCostParams {
* + dynamic_field_hash_type_and_key_value_cost_per_byte * size_of(k) | covers cost of operating on the value `k`
* + dynamic_field_hash_type_and_key_type_tag_cost_per_byte * size_of(type_tag(k)) | covers cost of operating on the type tag of `K`
**************************************************************************************************/
#[instrument(level = "trace", skip_all, err)]
pub fn hash_type_and_key(
context: &mut NativeContext,
mut ty_args: Vec<Type>,
Expand Down Expand Up @@ -158,6 +160,7 @@ pub struct DynamicFieldAddChildObjectCostParams {
* + dynamic_field_add_child_object_value_cost_per_byte * size_of(child) | covers cost of operating on the value `child`
* + dynamic_field_add_child_object_struct_tag_cost_per_byte * size_of(struct)tag(Child)) | covers cost of operating on the struct tag of `Child`
**************************************************************************************************/
#[instrument(level = "trace", skip_all, err)]
pub fn add_child_object(
context: &mut NativeContext,
mut ty_args: Vec<Type>,
Expand Down Expand Up @@ -260,6 +263,7 @@ pub struct DynamicFieldBorrowChildObjectCostParams {
* + dynamic_field_borrow_child_object_child_ref_cost_per_byte * size_of(&Child) | covers cost of fetching and returning `&Child`
* + dynamic_field_borrow_child_object_type_cost_per_byte * size_of(Child) | covers cost of operating on type `Child`
**************************************************************************************************/
#[instrument(level = "trace", skip_all, err)]
pub fn borrow_child_object(
context: &mut NativeContext,
mut ty_args: Vec<Type>,
Expand Down Expand Up @@ -336,6 +340,7 @@ pub struct DynamicFieldRemoveChildObjectCostParams {
* + dynamic_field_remove_child_object_type_cost_per_byte * size_of(Child) | covers cost of operating on type `Child`
* + dynamic_field_remove_child_object_child_cost_per_byte * size_of(child) | covers cost of fetching and returning value of type `Child`
**************************************************************************************************/
#[instrument(level = "trace", skip_all, err)]
pub fn remove_child_object(
context: &mut NativeContext,
mut ty_args: Vec<Type>,
Expand Down Expand Up @@ -399,6 +404,7 @@ pub struct DynamicFieldHasChildObjectCostParams {
* Implementation of the Move native function `has_child_object(parent: address, id: address): bool`
* gas cost: dynamic_field_has_child_object_cost_base | covers various fixed costs in the oper
**************************************************************************************************/
#[instrument(level = "trace", skip_all, err)]
pub fn has_child_object(
context: &mut NativeContext,
ty_args: Vec<Type>,
Expand Down Expand Up @@ -440,6 +446,7 @@ pub struct DynamicFieldHasChildObjectWithTyCostParams {
* + dynamic_field_has_child_object_with_ty_type_cost_per_byte * size_of(Child) | covers cost of operating on type `Child`
* + dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte * size_of(Child) | covers cost of fetching and returning value of type tag for `Child`
**************************************************************************************************/
#[instrument(level = "trace", skip_all, err)]
pub fn has_child_object_with_ty(
context: &mut NativeContext,
mut ty_args: Vec<Type>,
Expand Down
1 change: 1 addition & 0 deletions sui-execution/next-vm/sui-move-natives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ move-vm-runtime = { path = "../../../external-crates/move/move-execution/next-vm
sui-protocol-config.workspace = true
sui-types.workspace = true
workspace-hack.workspace = true
tracing.workspace = true
7 changes: 7 additions & 0 deletions sui-execution/next-vm/sui-move-natives/src/dynamic_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use move_vm_types::{
use smallvec::smallvec;
use std::collections::VecDeque;
use sui_types::{base_types::MoveObjectType, dynamic_field::derive_dynamic_field_id};
use tracing::instrument;

const E_KEY_DOES_NOT_EXIST: u64 = 1;
const E_FIELD_TYPE_MISMATCH: u64 = 2;
Expand Down Expand Up @@ -78,6 +79,7 @@ pub struct DynamicFieldHashTypeAndKeyCostParams {
* + dynamic_field_hash_type_and_key_value_cost_per_byte * size_of(k) | covers cost of operating on the value `k`
* + dynamic_field_hash_type_and_key_type_tag_cost_per_byte * size_of(type_tag(k)) | covers cost of operating on the type tag of `K`
**************************************************************************************************/
#[instrument(level = "trace", skip_all, err)]
pub fn hash_type_and_key(
context: &mut NativeContext,
mut ty_args: Vec<Type>,
Expand Down Expand Up @@ -158,6 +160,7 @@ pub struct DynamicFieldAddChildObjectCostParams {
* + dynamic_field_add_child_object_value_cost_per_byte * size_of(child) | covers cost of operating on the value `child`
* + dynamic_field_add_child_object_struct_tag_cost_per_byte * size_of(struct)tag(Child)) | covers cost of operating on the struct tag of `Child`
**************************************************************************************************/
#[instrument(level = "trace", skip_all, err)]
pub fn add_child_object(
context: &mut NativeContext,
mut ty_args: Vec<Type>,
Expand Down Expand Up @@ -260,6 +263,7 @@ pub struct DynamicFieldBorrowChildObjectCostParams {
* + dynamic_field_borrow_child_object_child_ref_cost_per_byte * size_of(&Child) | covers cost of fetching and returning `&Child`
* + dynamic_field_borrow_child_object_type_cost_per_byte * size_of(Child) | covers cost of operating on type `Child`
**************************************************************************************************/
#[instrument(level = "trace", skip_all, err)]
pub fn borrow_child_object(
context: &mut NativeContext,
mut ty_args: Vec<Type>,
Expand Down Expand Up @@ -336,6 +340,7 @@ pub struct DynamicFieldRemoveChildObjectCostParams {
* + dynamic_field_remove_child_object_type_cost_per_byte * size_of(Child) | covers cost of operating on type `Child`
* + dynamic_field_remove_child_object_child_cost_per_byte * size_of(child) | covers cost of fetching and returning value of type `Child`
**************************************************************************************************/
#[instrument(level = "trace", skip_all, err)]
pub fn remove_child_object(
context: &mut NativeContext,
mut ty_args: Vec<Type>,
Expand Down Expand Up @@ -399,6 +404,7 @@ pub struct DynamicFieldHasChildObjectCostParams {
* Implementation of the Move native function `has_child_object(parent: address, id: address): bool`
* gas cost: dynamic_field_has_child_object_cost_base | covers various fixed costs in the oper
**************************************************************************************************/
#[instrument(level = "trace", skip_all, err)]
pub fn has_child_object(
context: &mut NativeContext,
ty_args: Vec<Type>,
Expand Down Expand Up @@ -440,6 +446,7 @@ pub struct DynamicFieldHasChildObjectWithTyCostParams {
* + dynamic_field_has_child_object_with_ty_type_cost_per_byte * size_of(Child) | covers cost of operating on type `Child`
* + dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte * size_of(Child) | covers cost of fetching and returning value of type tag for `Child`
**************************************************************************************************/
#[instrument(level = "trace", skip_all, err)]
pub fn has_child_object_with_ty(
context: &mut NativeContext,
mut ty_args: Vec<Type>,
Expand Down
1 change: 1 addition & 0 deletions sui-execution/v0/sui-move-natives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ move-vm-runtime = { path = "../../../external-crates/move/move-execution/v0/move
sui-protocol-config.workspace = true
sui-types.workspace = true
workspace-hack.workspace = true
tracing.workspace = true
7 changes: 7 additions & 0 deletions sui-execution/v0/sui-move-natives/src/dynamic_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use move_vm_types::{
use smallvec::smallvec;
use std::collections::VecDeque;
use sui_types::{base_types::MoveObjectType, dynamic_field::derive_dynamic_field_id};
use tracing::instrument;

const E_KEY_DOES_NOT_EXIST: u64 = 1;
const E_FIELD_TYPE_MISMATCH: u64 = 2;
Expand Down Expand Up @@ -78,6 +79,7 @@ pub struct DynamicFieldHashTypeAndKeyCostParams {
* + dynamic_field_hash_type_and_key_value_cost_per_byte * size_of(k) | covers cost of operating on the value `k`
* + dynamic_field_hash_type_and_key_type_tag_cost_per_byte * size_of(type_tag(k)) | covers cost of operating on the type tag of `K`
**************************************************************************************************/
#[instrument(level = "trace", skip_all, err)]
pub fn hash_type_and_key(
context: &mut NativeContext,
mut ty_args: Vec<Type>,
Expand Down Expand Up @@ -158,6 +160,7 @@ pub struct DynamicFieldAddChildObjectCostParams {
* + dynamic_field_add_child_object_value_cost_per_byte * size_of(child) | covers cost of operating on the value `child`
* + dynamic_field_add_child_object_struct_tag_cost_per_byte * size_of(struct)tag(Child)) | covers cost of operating on the struct tag of `Child`
**************************************************************************************************/
#[instrument(level = "trace", skip_all, err)]
pub fn add_child_object(
context: &mut NativeContext,
mut ty_args: Vec<Type>,
Expand Down Expand Up @@ -253,6 +256,7 @@ pub struct DynamicFieldBorrowChildObjectCostParams {
* + dynamic_field_borrow_child_object_child_ref_cost_per_byte * size_of(&Child) | covers cost of fetching and returning `&Child`
* + dynamic_field_borrow_child_object_type_cost_per_byte * size_of(Child) | covers cost of operating on type `Child`
**************************************************************************************************/
#[instrument(level = "trace", skip_all, err)]
pub fn borrow_child_object(
context: &mut NativeContext,
mut ty_args: Vec<Type>,
Expand Down Expand Up @@ -329,6 +333,7 @@ pub struct DynamicFieldRemoveChildObjectCostParams {
* + dynamic_field_remove_child_object_type_cost_per_byte * size_of(Child) | covers cost of operating on type `Child`
* + dynamic_field_remove_child_object_child_cost_per_byte * size_of(child) | covers cost of fetching and returning value of type `Child`
**************************************************************************************************/
#[instrument(level = "trace", skip_all, err)]
pub fn remove_child_object(
context: &mut NativeContext,
mut ty_args: Vec<Type>,
Expand Down Expand Up @@ -392,6 +397,7 @@ pub struct DynamicFieldHasChildObjectCostParams {
* Implementation of the Move native function `has_child_object(parent: address, id: address): bool`
* gas cost: dynamic_field_has_child_object_cost_base | covers various fixed costs in the oper
**************************************************************************************************/
#[instrument(level = "trace", skip_all, err)]
pub fn has_child_object(
context: &mut NativeContext,
ty_args: Vec<Type>,
Expand Down Expand Up @@ -433,6 +439,7 @@ pub struct DynamicFieldHasChildObjectWithTyCostParams {
* + dynamic_field_has_child_object_with_ty_type_cost_per_byte * size_of(Child) | covers cost of operating on type `Child`
* + dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte * size_of(Child) | covers cost of fetching and returning value of type tag for `Child`
**************************************************************************************************/
#[instrument(level = "trace", skip_all, err)]
pub fn has_child_object_with_ty(
context: &mut NativeContext,
mut ty_args: Vec<Type>,
Expand Down
1 change: 1 addition & 0 deletions sui-execution/v1/sui-move-natives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ move-vm-runtime = { path = "../../../external-crates/move/move-execution/v1/crat
sui-protocol-config.workspace = true
sui-types.workspace = true
workspace-hack.workspace = true
tracing.workspace = true
7 changes: 7 additions & 0 deletions sui-execution/v1/sui-move-natives/src/dynamic_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use move_vm_types::{
use smallvec::smallvec;
use std::collections::VecDeque;
use sui_types::{base_types::MoveObjectType, dynamic_field::derive_dynamic_field_id};
use tracing::instrument;

const E_KEY_DOES_NOT_EXIST: u64 = 1;
const E_FIELD_TYPE_MISMATCH: u64 = 2;
Expand Down Expand Up @@ -78,6 +79,7 @@ pub struct DynamicFieldHashTypeAndKeyCostParams {
* + dynamic_field_hash_type_and_key_value_cost_per_byte * size_of(k) | covers cost of operating on the value `k`
* + dynamic_field_hash_type_and_key_type_tag_cost_per_byte * size_of(type_tag(k)) | covers cost of operating on the type tag of `K`
**************************************************************************************************/
#[instrument(level = "trace", skip_all, err)]
pub fn hash_type_and_key(
context: &mut NativeContext,
mut ty_args: Vec<Type>,
Expand Down Expand Up @@ -158,6 +160,7 @@ pub struct DynamicFieldAddChildObjectCostParams {
* + dynamic_field_add_child_object_value_cost_per_byte * size_of(child) | covers cost of operating on the value `child`
* + dynamic_field_add_child_object_struct_tag_cost_per_byte * size_of(struct)tag(Child)) | covers cost of operating on the struct tag of `Child`
**************************************************************************************************/
#[instrument(level = "trace", skip_all, err)]
pub fn add_child_object(
context: &mut NativeContext,
mut ty_args: Vec<Type>,
Expand Down Expand Up @@ -260,6 +263,7 @@ pub struct DynamicFieldBorrowChildObjectCostParams {
* + dynamic_field_borrow_child_object_child_ref_cost_per_byte * size_of(&Child) | covers cost of fetching and returning `&Child`
* + dynamic_field_borrow_child_object_type_cost_per_byte * size_of(Child) | covers cost of operating on type `Child`
**************************************************************************************************/
#[instrument(level = "trace", skip_all, err)]
pub fn borrow_child_object(
context: &mut NativeContext,
mut ty_args: Vec<Type>,
Expand Down Expand Up @@ -336,6 +340,7 @@ pub struct DynamicFieldRemoveChildObjectCostParams {
* + dynamic_field_remove_child_object_type_cost_per_byte * size_of(Child) | covers cost of operating on type `Child`
* + dynamic_field_remove_child_object_child_cost_per_byte * size_of(child) | covers cost of fetching and returning value of type `Child`
**************************************************************************************************/
#[instrument(level = "trace", skip_all, err)]
pub fn remove_child_object(
context: &mut NativeContext,
mut ty_args: Vec<Type>,
Expand Down Expand Up @@ -399,6 +404,7 @@ pub struct DynamicFieldHasChildObjectCostParams {
* Implementation of the Move native function `has_child_object(parent: address, id: address): bool`
* gas cost: dynamic_field_has_child_object_cost_base | covers various fixed costs in the oper
**************************************************************************************************/
#[instrument(level = "trace", skip_all, err)]
pub fn has_child_object(
context: &mut NativeContext,
ty_args: Vec<Type>,
Expand Down Expand Up @@ -440,6 +446,7 @@ pub struct DynamicFieldHasChildObjectWithTyCostParams {
* + dynamic_field_has_child_object_with_ty_type_cost_per_byte * size_of(Child) | covers cost of operating on type `Child`
* + dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte * size_of(Child) | covers cost of fetching and returning value of type tag for `Child`
**************************************************************************************************/
#[instrument(level = "trace", skip_all, err)]
pub fn has_child_object_with_ty(
context: &mut NativeContext,
mut ty_args: Vec<Type>,
Expand Down

2 comments on commit 07902ad

@vercel
Copy link

@vercel vercel bot commented on 07902ad Dec 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 07902ad Dec 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.