Skip to content

Commit

Permalink
Set the gas parameter in the native function. (#748)
Browse files Browse the repository at this point in the history
add license info

add missed license info

remove unused code

update the git version of the Move library

cargo fmt

update Cargo.lock
  • Loading branch information
stevenlaw123 authored Sep 4, 2023
1 parent 4fe7ae6 commit 91229a8
Show file tree
Hide file tree
Showing 38 changed files with 1,192 additions and 104 deletions.
76 changes: 38 additions & 38 deletions Cargo.lock

Large diffs are not rendered by default.

66 changes: 33 additions & 33 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -205,39 +205,39 @@ anstream = { version = "0.3" }

# Note: the BEGIN and END comments below are required for external tooling. Do not remove.
# BEGIN MOVE DEPENDENCIES
move-abigen = { git = "https://github.com/rooch-network/move", rev = "782ed81dbe10e406779ad4499259e2dbe9a04c6d" }
move-binary-format = { git = "https://github.com/rooch-network/move", rev = "782ed81dbe10e406779ad4499259e2dbe9a04c6d" }
move-bytecode-verifier = { git = "https://github.com/rooch-network/move", rev = "782ed81dbe10e406779ad4499259e2dbe9a04c6d" }
move-bytecode-utils = { git = "https://github.com/rooch-network/move", rev = "782ed81dbe10e406779ad4499259e2dbe9a04c6d" }
move-cli = { git = "https://github.com/rooch-network/move", rev = "782ed81dbe10e406779ad4499259e2dbe9a04c6d" }
move-command-line-common = { git = "https://github.com/rooch-network/move", rev = "782ed81dbe10e406779ad4499259e2dbe9a04c6d" }
move-compiler ={ git = "https://github.com/rooch-network/move", rev = "782ed81dbe10e406779ad4499259e2dbe9a04c6d" }
move-core-types = { git = "https://github.com/rooch-network/move", rev = "782ed81dbe10e406779ad4499259e2dbe9a04c6d", features = ["address32"] }
move-coverage = { git = "https://github.com/rooch-network/move", rev = "782ed81dbe10e406779ad4499259e2dbe9a04c6d" }
move-disassembler = { git = "https://github.com/rooch-network/move", rev = "782ed81dbe10e406779ad4499259e2dbe9a04c6d" }
move-docgen = { git = "https://github.com/rooch-network/move", rev = "782ed81dbe10e406779ad4499259e2dbe9a04c6d" }
move-errmapgen = { git = "https://github.com/rooch-network/move", rev = "782ed81dbe10e406779ad4499259e2dbe9a04c6d" }
move-ir-compiler = { git = "https://github.com/rooch-network/move", rev = "782ed81dbe10e406779ad4499259e2dbe9a04c6d" }
move-model = { git = "https://github.com/rooch-network/move", rev = "782ed81dbe10e406779ad4499259e2dbe9a04c6d" }
move-package = { git = "https://github.com/rooch-network/move", rev = "782ed81dbe10e406779ad4499259e2dbe9a04c6d" }
move-prover = { git = "https://github.com/rooch-network/move", rev = "782ed81dbe10e406779ad4499259e2dbe9a04c6d" }
move-prover-boogie-backend = { git = "https://github.com/rooch-network/move", rev = "782ed81dbe10e406779ad4499259e2dbe9a04c6d" }
move-stackless-bytecode = { git = "https://github.com/rooch-network/move", rev = "782ed81dbe10e406779ad4499259e2dbe9a04c6d" }
move-prover-test-utils = { git = "https://github.com/rooch-network/move", rev = "782ed81dbe10e406779ad4499259e2dbe9a04c6d" }
move-resource-viewer = { git = "https://github.com/rooch-network/move", rev = "782ed81dbe10e406779ad4499259e2dbe9a04c6d" }
move-stackless-bytecode-interpreter = { git = "https://github.com/rooch-network/move", rev = "782ed81dbe10e406779ad4499259e2dbe9a04c6d" }
move-stdlib = { git = "https://github.com/rooch-network/move", rev = "782ed81dbe10e406779ad4499259e2dbe9a04c6d", features = ["address32", "testing"] }
move-symbol-pool = { git = "https://github.com/rooch-network/move", rev = "782ed81dbe10e406779ad4499259e2dbe9a04c6d" }
#move-table-extension = { git = "https://github.com/rooch-network/move", rev = "782ed81dbe10e406779ad4499259e2dbe9a04c6d" }
move-transactional-test-runner = { git = "https://github.com/rooch-network/move", rev = "782ed81dbe10e406779ad4499259e2dbe9a04c6d" }
move-unit-test = { git = "https://github.com/rooch-network/move", rev = "782ed81dbe10e406779ad4499259e2dbe9a04c6d", features = ["table-extension"] }
move-vm-runtime = { git = "https://github.com/rooch-network/move", rev = "782ed81dbe10e406779ad4499259e2dbe9a04c6d", features = ["lazy_natives"] }
move-vm-test-utils = { git = "https://github.com/rooch-network/move", rev = "782ed81dbe10e406779ad4499259e2dbe9a04c6d", features = ["table-extension"] }
move-vm-types = { git = "https://github.com/rooch-network/move", rev = "782ed81dbe10e406779ad4499259e2dbe9a04c6d" }
read-write-set = { git = "https://github.com/rooch-network/move", rev = "782ed81dbe10e406779ad4499259e2dbe9a04c6d" }
read-write-set-dynamic = { git = "https://github.com/rooch-network/move", rev = "782ed81dbe10e406779ad4499259e2dbe9a04c6d" }
move-bytecode-source-map = { git = "https://github.com/rooch-network/move", rev = "782ed81dbe10e406779ad4499259e2dbe9a04c6d" }
move-ir-types = { git = "https://github.com/rooch-network/move", rev = "782ed81dbe10e406779ad4499259e2dbe9a04c6d" }# END MOVE DEPENDENCIES
move-abigen = { git = "https://github.com/rooch-network/move", rev = "e2caf0ac9c788e6e487a9d35d1530254c747650c" }
move-binary-format = { git = "https://github.com/rooch-network/move", rev = "e2caf0ac9c788e6e487a9d35d1530254c747650c" }
move-bytecode-verifier = { git = "https://github.com/rooch-network/move", rev = "e2caf0ac9c788e6e487a9d35d1530254c747650c" }
move-bytecode-utils = { git = "https://github.com/rooch-network/move", rev = "e2caf0ac9c788e6e487a9d35d1530254c747650c" }
move-cli = { git = "https://github.com/rooch-network/move", rev = "e2caf0ac9c788e6e487a9d35d1530254c747650c" }
move-command-line-common = { git = "https://github.com/rooch-network/move", rev = "e2caf0ac9c788e6e487a9d35d1530254c747650c" }
move-compiler ={ git = "https://github.com/rooch-network/move", rev = "e2caf0ac9c788e6e487a9d35d1530254c747650c" }
move-core-types = { git = "https://github.com/rooch-network/move", rev = "e2caf0ac9c788e6e487a9d35d1530254c747650c", features = ["address32"] }
move-coverage = { git = "https://github.com/rooch-network/move", rev = "e2caf0ac9c788e6e487a9d35d1530254c747650c" }
move-disassembler = { git = "https://github.com/rooch-network/move", rev = "e2caf0ac9c788e6e487a9d35d1530254c747650c" }
move-docgen = { git = "https://github.com/rooch-network/move", rev = "e2caf0ac9c788e6e487a9d35d1530254c747650c" }
move-errmapgen = { git = "https://github.com/rooch-network/move", rev = "e2caf0ac9c788e6e487a9d35d1530254c747650c" }
move-ir-compiler = { git = "https://github.com/rooch-network/move", rev = "e2caf0ac9c788e6e487a9d35d1530254c747650c" }
move-model = { git = "https://github.com/rooch-network/move", rev = "e2caf0ac9c788e6e487a9d35d1530254c747650c" }
move-package = { git = "https://github.com/rooch-network/move", rev = "e2caf0ac9c788e6e487a9d35d1530254c747650c" }
move-prover = { git = "https://github.com/rooch-network/move", rev = "e2caf0ac9c788e6e487a9d35d1530254c747650c" }
move-prover-boogie-backend = { git = "https://github.com/rooch-network/move", rev = "e2caf0ac9c788e6e487a9d35d1530254c747650c" }
move-stackless-bytecode = { git = "https://github.com/rooch-network/move", rev = "e2caf0ac9c788e6e487a9d35d1530254c747650c" }
move-prover-test-utils = { git = "https://github.com/rooch-network/move", rev = "e2caf0ac9c788e6e487a9d35d1530254c747650c" }
move-resource-viewer = { git = "https://github.com/rooch-network/move", rev = "e2caf0ac9c788e6e487a9d35d1530254c747650c" }
move-stackless-bytecode-interpreter = { git = "https://github.com/rooch-network/move", rev = "e2caf0ac9c788e6e487a9d35d1530254c747650c" }
move-stdlib = { git = "https://github.com/rooch-network/move", rev = "e2caf0ac9c788e6e487a9d35d1530254c747650c", features = ["address32", "testing"] }
move-symbol-pool = { git = "https://github.com/rooch-network/move", rev = "e2caf0ac9c788e6e487a9d35d1530254c747650c" }
#move-table-extension = { git = "https://github.com/rooch-network/move", rev = "e2caf0ac9c788e6e487a9d35d1530254c747650c" }
move-transactional-test-runner = { git = "https://github.com/rooch-network/move", rev = "e2caf0ac9c788e6e487a9d35d1530254c747650c" }
move-unit-test = { git = "https://github.com/rooch-network/move", rev = "e2caf0ac9c788e6e487a9d35d1530254c747650c", features = ["table-extension"] }
move-vm-runtime = { git = "https://github.com/rooch-network/move", rev = "e2caf0ac9c788e6e487a9d35d1530254c747650c", features = ["lazy_natives"] }
move-vm-test-utils = { git = "https://github.com/rooch-network/move", rev = "e2caf0ac9c788e6e487a9d35d1530254c747650c", features = ["table-extension"] }
move-vm-types = { git = "https://github.com/rooch-network/move", rev = "e2caf0ac9c788e6e487a9d35d1530254c747650c" }
read-write-set = { git = "https://github.com/rooch-network/move", rev = "e2caf0ac9c788e6e487a9d35d1530254c747650c" }
read-write-set-dynamic = { git = "https://github.com/rooch-network/move", rev = "e2caf0ac9c788e6e487a9d35d1530254c747650c" }
move-bytecode-source-map = { git = "https://github.com/rooch-network/move", rev = "e2caf0ac9c788e6e487a9d35d1530254c747650c" }
move-ir-types = { git = "https://github.com/rooch-network/move", rev = "e2caf0ac9c788e6e487a9d35d1530254c747650c" }# END MOVE DEPENDENCIES

# keep this for convenient debug Move in local repo
# [patch.'https://github.com/rooch-network/move']
Expand Down
9 changes: 9 additions & 0 deletions crates/rooch-framework/src/natives/gas_parameter/account.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright (c) RoochNetwork
// SPDX-License-Identifier: Apache-2.0

use crate::natives::gas_parameter::native::MUL;
use crate::natives::rooch_framework::account::GasParameters;

crate::natives::gas_parameter::native::define_gas_parameters_for_natives!(GasParameters, "account", [
[.create_signer.base, "create_signer.base", (5 + 1) * MUL],
]);
9 changes: 9 additions & 0 deletions crates/rooch-framework/src/natives/gas_parameter/bcd.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright (c) RoochNetwork
// SPDX-License-Identifier: Apache-2.0

use crate::natives::gas_parameter::native::MUL;
use moveos_stdlib::natives::moveos_stdlib::bcs::GasParameters;

crate::natives::gas_parameter::native::define_gas_parameters_for_natives!(GasParameters, "bcd", [
[.from_bytes.base, "from_bytes.base", (5 + 1) * MUL],
]);
10 changes: 10 additions & 0 deletions crates/rooch-framework/src/natives/gas_parameter/decoding.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) RoochNetwork
// SPDX-License-Identifier: Apache-2.0

use crate::natives::gas_parameter::native::MUL;
use crate::natives::rooch_framework::crypto::decoding::GasParameters;

crate::natives::gas_parameter::native::define_gas_parameters_for_natives!(GasParameters, "decoding", [
[.base58.base, "base58.base", (5 + 1) * MUL],
[.base58check.base, "base58check.base", (5 + 1) * MUL],
]);
9 changes: 9 additions & 0 deletions crates/rooch-framework/src/natives/gas_parameter/ecdsa_k1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright (c) RoochNetwork
// SPDX-License-Identifier: Apache-2.0

use crate::natives::gas_parameter::native::MUL;
use crate::natives::rooch_framework::crypto::ecdsa_k1::GasParameters;

crate::natives::gas_parameter::native::define_gas_parameters_for_natives!(GasParameters, "ecdsa_k1", [
[.verify.base, "verify.base", (5 + 1) * MUL],
]);
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) RoochNetwork
// SPDX-License-Identifier: Apache-2.0

use crate::natives::gas_parameter::native::MUL;
use crate::natives::rooch_framework::crypto::ecdsa_k1_recoverable::GasParameters;

crate::natives::gas_parameter::native::define_gas_parameters_for_natives!(GasParameters, "ecdsa_k1_recoverable", [
[.verify.base, "verify.base", (5 + 1) * MUL],
[.ecrecover.base, "ecrecover.base", (5 + 1) * MUL],
[.decompress_pubkey.base, "decompress_pubkey.base", (5 + 1) * MUL],
]);
9 changes: 9 additions & 0 deletions crates/rooch-framework/src/natives/gas_parameter/ed25519.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright (c) RoochNetwork
// SPDX-License-Identifier: Apache-2.0

use crate::natives::gas_parameter::native::MUL;
use crate::natives::rooch_framework::crypto::ed25519::GasParameters;

crate::natives::gas_parameter::native::define_gas_parameters_for_natives!(GasParameters, "ed25519", [
[.verify.base, "verify.base", (5 + 1) * MUL],
]);
13 changes: 13 additions & 0 deletions crates/rooch-framework/src/natives/gas_parameter/encoding.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (c) RoochNetwork
// SPDX-License-Identifier: Apache-2.0

use crate::natives::gas_parameter::native::MUL;
use crate::natives::rooch_framework::crypto::encoding::GasParameters;

crate::natives::gas_parameter::native::define_gas_parameters_for_natives!(GasParameters, "encoding", [
[.base58.base, "base58.base", (5 + 1) * MUL],
[.base58check.base, "base58check.base", (5 + 1) * MUL],
[.bech32.base, "bech32.base", (5 + 1) * MUL],
[.p2pkh.base, "p2pkh.base", (5 + 1) * MUL],
[.p2sh.base, "p2sh.base", (5 + 1) * MUL],
]);
9 changes: 9 additions & 0 deletions crates/rooch-framework/src/natives/gas_parameter/events.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright (c) RoochNetwork
// SPDX-License-Identifier: Apache-2.0

use crate::natives::gas_parameter::native::MUL;
use moveos_stdlib::natives::moveos_stdlib::event::GasParameters;

crate::natives::gas_parameter::native::define_gas_parameters_for_natives!(GasParameters, "events", [
[.emit.base, "emit.base", (52 + 1) * MUL],
]);
26 changes: 26 additions & 0 deletions crates/rooch-framework/src/natives/gas_parameter/gas_member.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) RoochNetwork
// SPDX-License-Identifier: Apache-2.0

use std::collections::BTreeMap;

/// A trait for converting from a map representation of the on-chain gas schedule.
pub trait FromOnChainGasSchedule: Sized {
/// Constructs a value of this type from a map representation of the on-chain gas schedule.
/// `None` should be returned when the gas schedule is missing some required entries.
/// Unused entries should be safely ignored.
fn from_on_chain_gas_schedule(gas_schedule: &BTreeMap<String, u64>) -> Option<Self>;
}

/// A trait for converting to a list of entries of the on-chain gas schedule.
pub trait ToOnChainGasSchedule {
/// Converts `self` into a list of entries of the on-chain gas schedule.
/// Each entry is a key-value pair where the key is a string representing the name of the
/// parameter, where the value is the gas parameter itself.
fn to_on_chain_gas_schedule(&self) -> Vec<(String, u64)>;
}

/// A trait for defining an initial value to be used in the genesis.
pub trait InitialGasSchedule: Sized {
/// Returns the initial value of this type, which is used in the genesis.
fn initial() -> Self;
}
11 changes: 11 additions & 0 deletions crates/rooch-framework/src/natives/gas_parameter/hash.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) RoochNetwork
// SPDX-License-Identifier: Apache-2.0

use crate::natives::gas_parameter::native::MUL;
use crate::natives::rooch_framework::crypto::hash::GasParameters;

crate::natives::gas_parameter::native::define_gas_parameters_for_natives!(GasParameters, "hash", [
[.keccak256.base, "keccak256.base", (5 + 1) * MUL],
[.blake2b256.base, "blake2b256.base", (5 + 1) * MUL],
[.ripemd160.base, "ripemd160.base", (5 + 1) * MUL],
]);
22 changes: 22 additions & 0 deletions crates/rooch-framework/src/natives/gas_parameter/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) RoochNetwork
// SPDX-License-Identifier: Apache-2.0
mod account;
mod bcd;
mod decoding;
mod ecdsa_k1;
mod ecdsa_k1_recoverable;
mod ed25519;
mod encoding;
mod events;
pub mod gas_member;
mod hash;
mod move_module;
pub mod move_std;
pub mod native;
pub mod nursery;
mod rlp;
mod schnorr;
mod signer;
mod table_extension;
mod test_helper;
mod type_info;
16 changes: 16 additions & 0 deletions crates/rooch-framework/src/natives/gas_parameter/move_module.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) RoochNetwork
// SPDX-License-Identifier: Apache-2.0

use crate::natives::gas_parameter::native::MUL;
use moveos_stdlib::natives::moveos_stdlib::move_module::GasParameters;

crate::natives::gas_parameter::native::define_gas_parameters_for_natives!(GasParameters, "move_module", [
[.module_name_inner.base, "module_name_inner.base", (5 + 1) * MUL],
[.module_name_inner.per_byte_in_str, "module_name_inner.per_byte_in_str", (5 + 1) * MUL],
[.verify_modules_inner.base, "verify_modules_inner.base", (5 + 1) * MUL],
[.verify_modules_inner.per_byte, "verify_modules_inner.per_byte", (5 + 1) * MUL],
[.request_init_functions.base, "request_init_functions.base", (5 + 1) * MUL],
[.request_init_functions.per_byte, "request_init_functions.per_byte", (5 + 1) * MUL],
[.check_compatibililty_inner.base, "check_compatibililty_inner.base", (5 + 1) * MUL],
[.check_compatibililty_inner.per_byte, "check_compatibililty_inner.per_byte", (5 + 1) * MUL],
]);
32 changes: 32 additions & 0 deletions crates/rooch-framework/src/natives/gas_parameter/move_std.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) RoochNetwork
// SPDX-License-Identifier: Apache-2.0

use crate::natives::gas_parameter::native::MUL;
use move_stdlib::natives::GasParameters;

// modify should with impl From<VMConfig> for GasSchedule
crate::natives::gas_parameter::native::define_gas_parameters_for_natives!(GasParameters, "move_stdlib", [
[.bcs.to_bytes.per_byte_serialized, "bcs.to_bytes.per_byte_serialized", (181 + 1) * MUL],
[.bcs.to_bytes.failure, "bcs.to_bytes.failure", (181 + 1) * MUL],
[.bcs.to_bytes.legacy_min_output_size, "bcs.to_bytes.legacy_min_output_size", MUL],

[.hash.sha2_256.per_byte, "hash.sha2_256.per_byte", (21 + 1) * MUL],
[.hash.sha2_256.legacy_min_input_len, "hash.sha2_256.legacy_min_input_len", MUL],
[.hash.sha3_256.per_byte, "hash.sha3_256.per_byte", (64 + 1) * MUL],
[.hash.sha3_256.legacy_min_input_len, "hash.sha3_256.legacy_min_input_len", MUL],

[.signer.borrow_address.base, "signer.borrow_address.base", (353 + 1) * MUL],

[.string.check_utf8.per_byte, optional "string.check_utf8.per_byte", (4 + 1) * MUL],
[.string.is_char_boundary.base, optional "string.is_char_boundary.base", (4 + 1) * MUL],
[.string.sub_string.per_byte, optional "string.sub_string.per_byte", (4 + 1) * MUL],
[.string.index_of.per_byte_searched, optional "string.index_of.per_byte_searched", (4 + 1) * MUL],

[.vector.length.base, "vector.length.base", (98 + 1) * MUL],
[.vector.empty.base, "vector.empty.base", (84 + 1) * MUL],
[.vector.borrow.base, "vector.borrow.base", (1334 + 1) * MUL],
[.vector.push_back.legacy_per_abstract_memory_unit, "vector.push_back.legacy_per_abstract_memory_unit", (53 + 1) * MUL],
[.vector.pop_back.base, "vector.pop_back.base", (227 + 1) * MUL],
[.vector.destroy_empty.base, "vector.destroy_empty.base", (572 + 1) * MUL],
[.vector.swap.base, "vector.swap.base", (1436 + 1) * MUL],
], allow_unmapped = 2);
Loading

0 comments on commit 91229a8

Please sign in to comment.