Skip to content

Commit

Permalink
[compiler-v2 native] fixed table native functions
Browse files Browse the repository at this point in the history
  • Loading branch information
welbon committed Sep 27, 2024
1 parent 55cfc60 commit a9a8fab
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 16 deletions.
1 change: 1 addition & 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 vm/framework/table-natives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ rust-version = { workspace = true }
[dependencies]
# starcoin-gas-algebra-ext = { workspace = true }
starcoin-native-interface = { workspace = true }
starcoin-gas-schedule = { workspace = true }
better_any = { workspace = true }
bytes = { workspace = true }
sha3 = { workspace = true }
Expand Down
48 changes: 32 additions & 16 deletions vm/gas-schedule/src/gas_schedule/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,36 @@ use move_core_types::gas_algebra::{InternalGas, InternalGasPerByte};
// same order as from https://github.com/starcoinorg/starcoin-framework/blob/main/sources/VMConfig.move#native_schedule
// modify should with impl From<VMConfig> for GasSchedule
// XXX FIXME YSG, need to modified
crate::gas_schedule::macros::define_gas_parameters!(TableGasParameters, "table", NativeGasParameters => .table,
crate::gas_schedule::macros::define_gas_parameters!(
TableGasParameters,
"table",
NativeGasParameters => .table,
[
[new_table_handle_base: InternalGas, "new_table_handle.base", (4 + 1) * MUL],

[add_box_per_byte_serialized: InternalGasPerByte, "add_box.per_byte_serialized", (4 + 1) * MUL],

[borrow_box_per_byte_serialized: InternalGasPerByte, "borrow_box.per_byte_serialized", (10 + 1) * MUL],

[remove_box_per_byte_serialized: InternalGasPerByte, "remove_box.per_byte_serialized", (8 + 1) * MUL],

[contains_box_per_byte_serialized: InternalGasPerByte, "contains_box.per_byte_serialized", (40 + 1) * MUL],


[destroy_empty_box_base:InternalGas , "destroy_empty_box.base", (20 + 1) * MUL],

[drop_unchecked_box_base: InternalGas, "drop_unchecked_box.base", (73 + 1) * MUL],
]);
[new_table_handle_base: InternalGas, "new_table_handle.base", (4 + 1) * MUL],
[add_box_per_byte_serialized: InternalGasPerByte, "add_box.per_byte_serialized", (4 + 1) * MUL],
[borrow_box_per_byte_serialized: InternalGasPerByte, "borrow_box.per_byte_serialized", (10 + 1) * MUL],
[remove_box_per_byte_serialized: InternalGasPerByte, "remove_box.per_byte_serialized", (8 + 1) * MUL],
[contains_box_per_byte_serialized: InternalGasPerByte, "contains_box.per_byte_serialized", (40 + 1) * MUL],
[destroy_empty_box_base:InternalGas , "destroy_empty_box.base", (20 + 1) * MUL],
[drop_unchecked_box_base: InternalGas, "drop_unchecked_box.base", (73 + 1) * MUL],

[common_load_base_legacy: InternalGas, "common.load.base", 302385],
[common_load_base_new: InternalGas, { 7.. => "common.load.base_new" }, 302385],
[common_load_per_byte: InternalGasPerByte, "common.load.per_byte", 151],
[common_load_failure: InternalGas, "common.load.failure", 0],

//[new_table_handle_base: InternalGas, "new_table_handle.base", 3676],

[add_box_base: InternalGas, "add_box.base", 4411],
//[add_box_per_byte_serialized: InternalGasPerByte, "add_box.per_byte_serialized", 36],
[borrow_box_base: InternalGas, "borrow_box.base", 4411],
//[borrow_box_per_byte_serialized: InternalGasPerByte, "borrow_box.per_byte_serialized", 36],
[contains_box_base: InternalGas, "contains_box.base", 4411],
//[contains_box_per_byte_serialized: InternalGasPerByte, "contains_box.per_byte_serialized", 36],

[remove_box_base: InternalGas, "remove_box.base", 4411],
//[remove_box_per_byte_serialized: InternalGasPerByte, "remove_box.per_byte_serialized", 36],
//[destroy_empty_box_base: InternalGas, "destroy_empty_box.base", 4411],
//[drop_unchecked_box_base: InternalGas, "drop_unchecked_box.base", 367],
]
);

0 comments on commit a9a8fab

Please sign in to comment.