Skip to content

Commit

Permalink
rename starcoin-natives to starcoin-frameworks (#4189)
Browse files Browse the repository at this point in the history
  • Loading branch information
nkysg committed Sep 2, 2024
1 parent 52b9836 commit ae0970c
Show file tree
Hide file tree
Showing 20 changed files with 59 additions and 62 deletions.
59 changes: 29 additions & 30 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ members = [
"vm/types",
"vm/vm-runtime-types",
"vm/vm-runtime",
"vm/natives",
"vm/frameworks",
"vm/starcoin-native-interface",
"vm/stdlib",
"vm/compiler",
Expand Down Expand Up @@ -186,7 +186,7 @@ default-members = [
"vm/types",
"vm/vm-runtime-types",
"vm/vm-runtime",
"vm/natives",
"vm/frameworks",
"vm/starcoin-native-interface",
"vm/stdlib",
"vm/compiler",
Expand Down Expand Up @@ -471,7 +471,7 @@ starcoin-move-compiler = { path = "vm/compiler" }
starcoin-move-explain = { path = "vm/move-explain" }
starcoin-gas-algebra-ext = { path = "vm/gas-algebra-ext" }
starcoin-gas-meter = { path = "vm/starcoin-gas-meter" }
starcoin-natives = { path = "vm/natives" }
starcoin-frameworks = { path = "vm/frameworks" }
starcoin-native-interface = { path = "vm/starcoin-native-interface" }
starcoin-network = { path = "network" }
starcoin-network-rpc = { path = "network-rpc" }
Expand Down
2 changes: 1 addition & 1 deletion vm/natives/Cargo.toml → vm/frameworks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ testing = ["move-stdlib/testing"]
[package]
authors = { workspace = true }
edition = { workspace = true }
name = "starcoin-natives"
name = "starcoin-frameworks"
version = "2.0.1"
homepage = { workspace = true }
license = { workspace = true }
Expand Down
2 changes: 2 additions & 0 deletions vm/frameworks/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// ref aptos-core/aptos-move/framework/src/lib.rs
pub mod natives;
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,5 @@ pub fn make_all(gas_params: GasParameters) -> impl Iterator<Item = (String, Nati
),
];

crate::helpers::make_module_natives(natives)
crate::natives::helpers::make_module_natives(natives)
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2.0

use crate::util::make_native_from_func;
use crate::natives::util::make_native_from_func;
use move_binary_format::errors::PartialVMResult;
use move_core_types::gas_algebra::{InternalGas, InternalGasPerByte};
use move_vm_runtime::native_functions::{NativeContext, NativeFunction};
Expand Down Expand Up @@ -76,5 +76,5 @@ pub fn make_all(gas_params: GasParameters) -> impl Iterator<Item = (String, Nati
"from_bytes",
make_native_from_func(gas_params, native_from_bytes),
)];
crate::helpers::make_module_natives(natives)
crate::natives::helpers::make_module_natives(natives)
}
8 changes: 4 additions & 4 deletions vm/natives/src/hash.rs → vm/frameworks/src/natives/hash.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2.0

use crate::util::make_native_from_func;
use crate::natives::util::make_native_from_func;
use move_binary_format::errors::PartialVMResult;
use move_core_types::gas_algebra::{InternalGas, InternalGasPerByte, NumBytes};
use move_vm_runtime::native_functions::{NativeContext, NativeFunction};
Expand Down Expand Up @@ -38,7 +38,7 @@ pub fn native_keccak_256(

let cost = gas_params.base + gas_params.per_byte * NumBytes::new(input_arg.len() as u64);

let output = crate::ecrecover::keccak(input_arg.as_slice());
let output = crate::natives::ecrecover::keccak(input_arg.as_slice());

Ok(NativeResult::ok(cost, smallvec![Value::vector_u8(output)]))
}
Expand Down Expand Up @@ -100,7 +100,7 @@ pub fn make_all(gas_params: GasParameters) -> impl Iterator<Item = (String, Nati
),
];

crate::helpers::make_module_natives(natives)
crate::natives::helpers::make_module_natives(natives)
}

#[cfg(test)]
Expand All @@ -111,7 +111,7 @@ mod test {
#[test]
fn test_keccak() {
let input: Vec<u8> = FromHex::from_hex("616263").unwrap();
let output = crate::ecrecover::keccak(input.as_slice());
let output = crate::natives::ecrecover::keccak(input.as_slice());
let expect_output: Vec<u8> =
FromHex::from_hex("4e03657aea45a94fc7d47ba826c8d667c0d1e6e33a64a036ec44f58fa12d6c45")
.unwrap();
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*
**************************************************************************************************/

use crate::util::make_native_from_func;
use crate::natives::util::make_native_from_func;
use move_binary_format::errors::PartialVMResult;
use move_core_types::gas_algebra::{InternalGas, InternalGasPerArg, NumArgs};
use move_vm_runtime::native_functions::{NativeContext, NativeFunction};
Expand Down Expand Up @@ -102,5 +102,5 @@ pub fn make_all(gas_params: GasParameters) -> impl Iterator<Item = (String, Nati
make_native_from_func(gas_params, native_ecdsa_recover),
)];

crate::helpers::make_module_natives(natives)
crate::natives::helpers::make_module_natives(natives)
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0

use crate::ecrecover::{make_native_ecrecover, EcrecoverGasParameters};
use crate::natives::ecrecover::{make_native_ecrecover, EcrecoverGasParameters};
use move_binary_format::errors::PartialVMResult;
use move_core_types::gas_algebra::{InternalGas, InternalGasPerByte, NumBytes};
use move_vm_runtime::native_functions::{NativeContext, NativeFunction};
Expand Down Expand Up @@ -131,5 +131,5 @@ pub fn make_all(gas_params: GasParameters) -> impl Iterator<Item = (String, Nati
),
];

crate::helpers::make_module_natives(natives)
crate::natives::helpers::make_module_natives(natives)
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub struct GasParameters {
pub fn make_all(gas_params: GasParameters) -> impl Iterator<Item = (String, NativeFunction)> {
let natives = [("name_of", make_native_token_name_of(gas_params.name_of))];

crate::helpers::make_module_natives(natives)
crate::natives::helpers::make_module_natives(natives)
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions vm/natives/src/u256.rs → vm/frameworks/src/natives/u256.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::util::make_native_from_func;
use crate::natives::util::make_native_from_func;
use move_binary_format::errors::{PartialVMError, PartialVMResult};
use move_core_types::gas_algebra::{InternalGas, InternalGasPerByte, NumBytes};
use move_core_types::vm_status::StatusCode;
Expand Down Expand Up @@ -215,5 +215,5 @@ pub fn make_all(gas_params: GasParameters) -> impl Iterator<Item = (String, Nati
),
];

crate::helpers::make_module_natives(natives)
crate::natives::helpers::make_module_natives(natives)
}
File renamed without changes.
1 change: 0 additions & 1 deletion vm/gas-algebra-ext/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ move-stdlib = { workspace = true }
move-table-extension = { workspace = true }
move-vm-types = { workspace = true }
move-vm-test-utils = { workspace = true }
starcoin-natives = { workspace = true }
serde = { workspace = true }


Expand Down
3 changes: 0 additions & 3 deletions vm/gas-algebra-ext/src/starcoin_framework.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

use crate::traits::EXECUTION_GAS_MULTIPLIER as MUL;

use move_core_types::gas_algebra::{InternalGasPerByte, InternalGas};


// see starcoin/vm/types/src/on_chain_config/genesis_gas_schedule.rs
// 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
Expand Down
2 changes: 1 addition & 1 deletion vm/starcoin-gas-meter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ move-core-types = { workspace = true }
move-stdlib = { workspace = true }
move-table-extension = { workspace = true }
move-vm-types = { workspace = true }
starcoin-natives = { workspace = true }
starcoin-frameworks = { workspace = true }
starcoin-logger = { workspace = true }

[package]
Expand Down
4 changes: 2 additions & 2 deletions vm/vm-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ num_enum = { workspace = true }
rand = { workspace = true }
rand_core = { default-features = false, workspace = true }
starcoin-logger = { workspace = true }
starcoin-natives = { workspace = true }
starcoin-frameworks = { workspace = true }
starcoin-types = { workspace = true }
starcoin-vm-types = { workspace = true }
move-stdlib = { workspace = true }
Expand All @@ -44,5 +44,5 @@ stdlib = { workspace = true }
[features]
default = ["metrics"]
metrics = ["starcoin-metrics"]
testing = ["move-stdlib/testing", "starcoin-natives/testing"]
testing = ["move-stdlib/testing", "starcoin-frameworks/testing"]
force-deploy = []
14 changes: 7 additions & 7 deletions vm/vm-runtime/src/natives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ pub fn starcoin_natives(gas_params: NativeGasParameters) -> NativeFunctionTable
);
add_natives_from_module!(
"Hash",
starcoin_natives::hash::make_all(gas_params.starcoin_natives.hash)
starcoin_frameworks::natives::hash::make_all(gas_params.starcoin_natives.hash)
);
add_natives_from_module!(
"BCS",
move_stdlib::natives::bcs::make_all(gas_params.move_stdlib.bcs)
);
add_natives_from_module!(
"FromBCS",
starcoin_natives::from_bcs::make_all(gas_params.starcoin_natives.from_bcs)
starcoin_frameworks::natives::from_bcs::make_all(gas_params.starcoin_natives.from_bcs)
);
add_natives_from_module!(
"Signature",
starcoin_natives::signature::make_all(gas_params.starcoin_natives.signature)
starcoin_frameworks::natives::signature::make_all(gas_params.starcoin_natives.signature)
);
add_natives_from_module!(
"Vector",
Expand All @@ -53,19 +53,19 @@ pub fn starcoin_natives(gas_params: NativeGasParameters) -> NativeFunctionTable
);
add_natives_from_module!(
"Account",
starcoin_natives::account::make_all(gas_params.starcoin_natives.account)
starcoin_frameworks::natives::account::make_all(gas_params.starcoin_natives.account)
);
add_natives_from_module!(
"Signer",
move_stdlib::natives::signer::make_all(gas_params.move_stdlib.signer)
);
add_natives_from_module!(
"Token",
starcoin_natives::token::make_all(gas_params.starcoin_natives.token)
starcoin_frameworks::natives::token::make_all(gas_params.starcoin_natives.token)
);
add_natives_from_module!(
"U256",
starcoin_natives::u256::make_all(gas_params.starcoin_natives.u256)
starcoin_frameworks::natives::u256::make_all(gas_params.starcoin_natives.u256)
);
#[cfg(feature = "testing")]
add_natives_from_module!(
Expand All @@ -82,7 +82,7 @@ pub fn starcoin_natives(gas_params: NativeGasParameters) -> NativeFunctionTable
);
add_natives_from_module!(
"Secp256k1",
starcoin_natives::secp256k1::make_all(gas_params.starcoin_natives.secp256k1)
starcoin_frameworks::natives::secp256k1::make_all(gas_params.starcoin_natives.secp256k1)
);

let natives = make_table_from_iter(CORE_CODE_ADDRESS, natives);
Expand Down

0 comments on commit ae0970c

Please sign in to comment.