diff --git a/Cargo.lock b/Cargo.lock index 41a9a1ec8d..22c31753de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9927,6 +9927,33 @@ dependencies = [ "walkdir", ] +[[package]] +name = "starcoin-frameworks" +version = "2.0.1" +dependencies = [ + "arrayref", + "hex", + "libsecp256k1", + "log 0.4.17", + "move-binary-format", + "move-command-line-common", + "move-core-types", + "move-docgen", + "move-errmapgen", + "move-prover", + "move-stdlib", + "move-vm-runtime", + "move-vm-types", + "num_enum", + "rand 0.8.5", + "ripemd160", + "smallvec 1.10.0", + "starcoin-crypto", + "starcoin-uint", + "tiny-keccak", + "walkdir", +] + [[package]] name = "starcoin-gas-algebra-ext" version = "2.0.1" @@ -9939,7 +9966,6 @@ dependencies = [ "move-vm-test-utils", "move-vm-types", "serde", - "starcoin-natives", ] [[package]] @@ -9952,9 +9978,9 @@ dependencies = [ "move-stdlib", "move-table-extension", "move-vm-types", + "starcoin-frameworks", "starcoin-gas-algebra-ext", "starcoin-logger", - "starcoin-natives", ] [[package]] @@ -10289,33 +10315,6 @@ dependencies = [ "starcoin-vm-types", ] -[[package]] -name = "starcoin-natives" -version = "2.0.1" -dependencies = [ - "arrayref", - "hex", - "libsecp256k1", - "log 0.4.17", - "move-binary-format", - "move-command-line-common", - "move-core-types", - "move-docgen", - "move-errmapgen", - "move-prover", - "move-stdlib", - "move-vm-runtime", - "move-vm-types", - "num_enum", - "rand 0.8.5", - "ripemd160", - "smallvec 1.10.0", - "starcoin-crypto", - "starcoin-uint", - "tiny-keccak", - "walkdir", -] - [[package]] name = "starcoin-network" version = "2.0.1" @@ -11304,11 +11303,11 @@ dependencies = [ "serde", "starcoin-config", "starcoin-crypto", + "starcoin-frameworks", "starcoin-gas-algebra-ext", "starcoin-gas-meter", "starcoin-logger", "starcoin-metrics", - "starcoin-natives", "starcoin-parallel-executor", "starcoin-types", "starcoin-vm-types", diff --git a/Cargo.toml b/Cargo.toml index 58f78584a9..9b3374f05d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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", @@ -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", @@ -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" } diff --git a/vm/natives/Cargo.toml b/vm/frameworks/Cargo.toml similarity index 97% rename from vm/natives/Cargo.toml rename to vm/frameworks/Cargo.toml index 82300403ae..8850efdd58 100644 --- a/vm/natives/Cargo.toml +++ b/vm/frameworks/Cargo.toml @@ -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 } diff --git a/vm/frameworks/src/lib.rs b/vm/frameworks/src/lib.rs new file mode 100644 index 0000000000..b4ac9f045f --- /dev/null +++ b/vm/frameworks/src/lib.rs @@ -0,0 +1,2 @@ +// ref aptos-core/aptos-move/framework/src/lib.rs +pub mod natives; diff --git a/vm/natives/src/account.rs b/vm/frameworks/src/natives/account.rs similarity index 98% rename from vm/natives/src/account.rs rename to vm/frameworks/src/natives/account.rs index fd328053bd..6246355575 100644 --- a/vm/natives/src/account.rs +++ b/vm/frameworks/src/natives/account.rs @@ -98,5 +98,5 @@ pub fn make_all(gas_params: GasParameters) -> impl Iterator impl Iterator impl Iterator = 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 = FromHex::from_hex("4e03657aea45a94fc7d47ba826c8d667c0d1e6e33a64a036ec44f58fa12d6c45") .unwrap(); diff --git a/vm/natives/src/helpers.rs b/vm/frameworks/src/natives/helpers.rs similarity index 100% rename from vm/natives/src/helpers.rs rename to vm/frameworks/src/natives/helpers.rs diff --git a/vm/natives/src/lib.rs b/vm/frameworks/src/natives/mod.rs similarity index 100% rename from vm/natives/src/lib.rs rename to vm/frameworks/src/natives/mod.rs diff --git a/vm/natives/src/secp256k1.rs b/vm/frameworks/src/natives/secp256k1.rs similarity index 97% rename from vm/natives/src/secp256k1.rs rename to vm/frameworks/src/natives/secp256k1.rs index 1c45c9f576..0ebc8542de 100644 --- a/vm/natives/src/secp256k1.rs +++ b/vm/frameworks/src/natives/secp256k1.rs @@ -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}; @@ -102,5 +102,5 @@ pub fn make_all(gas_params: GasParameters) -> impl Iterator impl Iterator impl Iterator { 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] diff --git a/vm/natives/src/u256.rs b/vm/frameworks/src/natives/u256.rs similarity index 98% rename from vm/natives/src/u256.rs rename to vm/frameworks/src/natives/u256.rs index 824f943eae..288261b8e9 100644 --- a/vm/natives/src/u256.rs +++ b/vm/frameworks/src/natives/u256.rs @@ -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; @@ -215,5 +215,5 @@ pub fn make_all(gas_params: GasParameters) -> impl Iterator for GasSchedule diff --git a/vm/starcoin-gas-meter/Cargo.toml b/vm/starcoin-gas-meter/Cargo.toml index f7ba089262..1537c37264 100644 --- a/vm/starcoin-gas-meter/Cargo.toml +++ b/vm/starcoin-gas-meter/Cargo.toml @@ -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] diff --git a/vm/vm-runtime/Cargo.toml b/vm/vm-runtime/Cargo.toml index 839a4aebe3..8a7099d636 100644 --- a/vm/vm-runtime/Cargo.toml +++ b/vm/vm-runtime/Cargo.toml @@ -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 } @@ -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 = [] diff --git a/vm/vm-runtime/src/natives.rs b/vm/vm-runtime/src/natives.rs index 70157627c5..2b4d50b41a 100644 --- a/vm/vm-runtime/src/natives.rs +++ b/vm/vm-runtime/src/natives.rs @@ -29,7 +29,7 @@ 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", @@ -37,11 +37,11 @@ pub fn starcoin_natives(gas_params: NativeGasParameters) -> NativeFunctionTable ); 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", @@ -53,7 +53,7 @@ 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", @@ -61,11 +61,11 @@ pub fn starcoin_natives(gas_params: NativeGasParameters) -> NativeFunctionTable ); 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!( @@ -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);