From 00903d155d558a4ec08c9e050a1def8979c909c5 Mon Sep 17 00:00:00 2001 From: sydhds Date: Mon, 11 Dec 2023 16:16:16 +0100 Subject: [PATCH 1/4] Add chain id abi calls --- Cargo.lock | 5 ++--- Cargo.toml | 3 ++- src/as_execution/abi.rs | 8 ++++++++ src/as_execution/context.rs | 1 + src/types.rs | 6 ++++++ src/wasmv1_execution/abi/abis.rs | 23 ++++++++++++++++++++++- 6 files changed, 41 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 32fec765..aaa762d3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -938,7 +938,6 @@ dependencies = [ [[package]] name = "massa-proto-rs" version = "0.1.0" -source = "git+https://github.com/massalabs/massa-proto-rs.git?rev=30b91d705b704287662b0e42457ece442005fa46#30b91d705b704287662b0e42457ece442005fa46" dependencies = [ "glob", "prost", @@ -2332,9 +2331,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.26" +version = "0.5.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b67b5f0a4e7a27a64c651977932b9dc5667ca7fc31ac44b03ed37a0cf42fdfff" +checksum = "6c830786f7720c2fd27a1a0e27a709dbd3c4d009b56d098fc742d4f4eab91fe2" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index 8224d991..46c720c2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,8 @@ chrono = { version = "=0.4", features = ["clock"], default-features = false } displaydoc = "0.2" function_name = "0.3" loupe = "0.1" -massa-proto-rs = { git = "https://github.com/massalabs/massa-proto-rs.git", rev = "30b91d705b704287662b0e42457ece442005fa46" } +# massa-proto-rs = { git = "https://github.com/massalabs/massa-proto-rs.git", rev = "effc0418977cd64402172b7eb749a2fc7537771a", features = ["tonic"] } +massa-proto-rs = { path = "../massa-proto-rs_2" } more-asserts = "0.3" num_enum = "0.7" parking_lot = "0.12" diff --git a/src/as_execution/abi.rs b/src/as_execution/abi.rs index 9a4b5633..7e0cd146 100644 --- a/src/as_execution/abi.rs +++ b/src/as_execution/abi.rs @@ -1051,6 +1051,14 @@ pub fn assembly_script_function_exists( Ok(function_exists(&mut ctx, address, function)? as i32) } +/// Return current chain id +#[named] +pub fn assembly_script_chain_id(mut ctx: FunctionEnvMut) -> ABIResult { + let env = get_env(&ctx)?; + sub_remaining_gas_abi(&env, &mut ctx, function_name!())?; + Ok(env.get_interface().chain_id()? as i32) +} + /// Assembly script builtin `abort` function. /// /// It prints the origin filename, an error messag, the line and column. diff --git a/src/as_execution/context.rs b/src/as_execution/context.rs index b990ba60..4b244eb4 100644 --- a/src/as_execution/context.rs +++ b/src/as_execution/context.rs @@ -277,6 +277,7 @@ impl ASContext { "assembly_script_local_execution" => Function::new_typed_with_env(store, &fenv, assembly_script_local_execution), "assembly_script_caller_has_write_access" => Function::new_typed_with_env(store, &fenv, assembly_script_caller_has_write_access), "assembly_script_function_exists" => Function::new_typed_with_env(store, &fenv, assembly_script_function_exists), + "assembly_script_chain_id" => Function::new_typed_with_env(store, &fenv, assembly_script_chain_id), }, }; diff --git a/src/types.rs b/src/types.rs index 7245b91f..8e503950 100644 --- a/src/types.rs +++ b/src/types.rs @@ -434,6 +434,9 @@ pub trait Interface: Send + Sync + InterfaceClone { // Keccak256 hash bytes fn hash_keccak256(&self, bytes: &[u8]) -> Result<[u8; 32]>; + // Return the current chain id + fn chain_id(&self) -> Result; + fn native_amount_from_str_wasmv1(&self, amount: &str) -> Result; fn native_amount_to_string_wasmv1(&self, amount: &NativeAmount) -> Result; @@ -529,6 +532,9 @@ pub trait Interface: Send + Sync + InterfaceClone { ) -> Result; fn compare_pub_key_wasmv1(&self, left: &str, right: &str) -> Result; + + // Return the current chain id + fn chain_id_wasmv1(&self) -> Result; } impl dyn Interface { diff --git a/src/wasmv1_execution/abi/abis.rs b/src/wasmv1_execution/abi/abis.rs index 3d8cae31..2368f5a1 100644 --- a/src/wasmv1_execution/abi/abis.rs +++ b/src/wasmv1_execution/abi/abis.rs @@ -114,7 +114,8 @@ pub fn register_abis(store: &mut impl AsStoreMut, shared_abi_env: ABIEnv) -> Imp "abi_evm_verify_signature" => abi_evm_verify_signature, "abi_evm_get_address_from_pubkey" => abi_evm_get_address_from_pubkey, "abi_evm_get_pubkey_from_signature" => abi_evm_get_pubkey_from_signature, - "abi_is_address_eoa" => abi_is_address_eoa + "abi_is_address_eoa" => abi_is_address_eoa, + "abi_chain_id" => abi_chain_id ) } @@ -1660,3 +1661,23 @@ pub fn abi_verify_signature( }, ) } + +#[named] +pub fn abi_chain_id( + store_env: FunctionEnvMut, + arg_offset: i32, +) -> Result { + handle_abi( + function_name!(), + store_env, + arg_offset, + |handler, _req: ChainIdRequest| -> Result { + match handler.interface.chain_id() { + Ok(chain_id) => { + resp_ok!(ChainIdResult, { id: chain_id }) + } + Err(e) => resp_err!(e), + } + }, + ) +} From fff2d1fd48369f3ec988ce681ba0422d0b94989f Mon Sep 17 00:00:00 2001 From: sydhds Date: Tue, 12 Dec 2023 16:46:34 +0100 Subject: [PATCH 2/4] Fix chain id export --- src/as_execution/abi.rs | 4 ++-- src/types.rs | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/as_execution/abi.rs b/src/as_execution/abi.rs index 7e0cd146..f44866ea 100644 --- a/src/as_execution/abi.rs +++ b/src/as_execution/abi.rs @@ -1053,10 +1053,10 @@ pub fn assembly_script_function_exists( /// Return current chain id #[named] -pub fn assembly_script_chain_id(mut ctx: FunctionEnvMut) -> ABIResult { +pub(crate) fn assembly_script_chain_id(mut ctx: FunctionEnvMut) -> ABIResult { let env = get_env(&ctx)?; sub_remaining_gas_abi(&env, &mut ctx, function_name!())?; - Ok(env.get_interface().chain_id()? as i32) + Ok(env.get_interface().chain_id()? as i64) } /// Assembly script builtin `abort` function. diff --git a/src/types.rs b/src/types.rs index 8e503950..3da770f0 100644 --- a/src/types.rs +++ b/src/types.rs @@ -145,6 +145,7 @@ impl Default for GasCosts { abi_costs.insert(String::from("assembly_script_console_warn"), 36); abi_costs.insert(String::from("assembly_script_console_error"), 36); abi_costs.insert(String::from("assembly_script_trace"), 36); + abi_costs.insert(String::from("assembly_script_chain_id"), 9); Self { abi_costs, operator_cost: 1, @@ -532,9 +533,6 @@ pub trait Interface: Send + Sync + InterfaceClone { ) -> Result; fn compare_pub_key_wasmv1(&self, left: &str, right: &str) -> Result; - - // Return the current chain id - fn chain_id_wasmv1(&self) -> Result; } impl dyn Interface { From 1ac054803762775d6679a1473f1534774933c25a Mon Sep 17 00:00:00 2001 From: sydhds Date: Tue, 12 Dec 2023 17:15:24 +0100 Subject: [PATCH 3/4] Update massa-proto-rs dependency + mock abi chain id call --- Cargo.lock | 362 +++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 3 +- src/tests/mod.rs | 4 + 3 files changed, 367 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aaa762d3..a436b057 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -73,12 +73,90 @@ dependencies = [ "wasmer", ] +[[package]] +name = "async-stream" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "async-trait" +version = "0.1.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + [[package]] name = "autocfg" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "axum" +version = "0.6.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" +dependencies = [ + "async-trait", + "axum-core", + "bitflags 1.3.2", + "bytes", + "futures-util", + "http", + "http-body", + "hyper", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "sync_wrapper", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http", + "http-body", + "mime", + "rustversion", + "tower-layer", + "tower-service", +] + [[package]] name = "backtrace" version = "0.3.69" @@ -735,6 +813,25 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +[[package]] +name = "h2" +version = "0.3.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d6250322ef6e60f93f9a2162799302cd6f68f79f6e5d85c8c16f14d1d958178" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap 2.1.0", + "slab", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "hashbrown" version = "0.11.2" @@ -774,6 +871,76 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "http" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "0.14.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2 0.4.10", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-timeout" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" +dependencies = [ + "hyper", + "pin-project-lite", + "tokio", + "tokio-io-timeout", +] + [[package]] name = "iana-time-zone" version = "0.1.58" @@ -938,11 +1105,13 @@ dependencies = [ [[package]] name = "massa-proto-rs" version = "0.1.0" +source = "git+https://github.com/massalabs/massa-proto-rs.git?rev=84678fb77cf6d06d85d55e2c20502908ff292e61#84678fb77cf6d06d85d55e2c20502908ff292e61" dependencies = [ "glob", "prost", "prost-build", "prost-types", + "tonic", "tonic-build", ] @@ -981,6 +1150,12 @@ dependencies = [ "which 5.0.0", ] +[[package]] +name = "matchit" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" + [[package]] name = "memchr" version = "2.6.4" @@ -1014,6 +1189,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + [[package]] name = "miniz_oxide" version = "0.7.1" @@ -1023,6 +1204,17 @@ dependencies = [ "adler", ] +[[package]] +name = "mio" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.48.0", +] + [[package]] name = "more-asserts" version = "0.2.2" @@ -1137,6 +1329,26 @@ dependencies = [ "indexmap 2.1.0", ] +[[package]] +name = "pin-project" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + [[package]] name = "pin-project-lite" version = "0.2.13" @@ -1621,6 +1833,26 @@ version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" +[[package]] +name = "socket2" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "socket2" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" +dependencies = [ + "libc", + "windows-sys 0.48.0", +] + [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -1649,6 +1881,12 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + [[package]] name = "tap" version = "1.0.1" @@ -1709,6 +1947,56 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" +[[package]] +name = "tokio" +version = "1.35.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d45b238a16291a4e1584e61820b8ae57d696cc5015c459c229ccc6990cc1c" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "pin-project-lite", + "socket2 0.5.5", + "windows-sys 0.48.0", +] + +[[package]] +name = "tokio-io-timeout" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf" +dependencies = [ + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-stream" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + [[package]] name = "toml_datetime" version = "0.6.3" @@ -1726,6 +2014,33 @@ dependencies = [ "winnow", ] +[[package]] +name = "tonic" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d560933a0de61cf715926b9cac824d4c883c2c43142f787595e48280c40a1d0e" +dependencies = [ + "async-stream", + "async-trait", + "axum", + "base64", + "bytes", + "h2", + "http", + "http-body", + "hyper", + "hyper-timeout", + "percent-encoding", + "pin-project", + "prost", + "tokio", + "tokio-stream", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + [[package]] name = "tonic-build" version = "0.10.2" @@ -1739,6 +2054,38 @@ dependencies = [ "syn 2.0.40", ] +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "indexmap 1.9.3", + "pin-project", + "pin-project-lite", + "rand", + "slab", + "tokio", + "tokio-util", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-layer" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + [[package]] name = "tracing" version = "0.1.40" @@ -1770,6 +2117,12 @@ dependencies = [ "once_cell", ] +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + [[package]] name = "typenum" version = "1.17.0" @@ -1826,6 +2179,15 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" diff --git a/Cargo.toml b/Cargo.toml index 46c720c2..079d9f13 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,8 +11,7 @@ chrono = { version = "=0.4", features = ["clock"], default-features = false } displaydoc = "0.2" function_name = "0.3" loupe = "0.1" -# massa-proto-rs = { git = "https://github.com/massalabs/massa-proto-rs.git", rev = "effc0418977cd64402172b7eb749a2fc7537771a", features = ["tonic"] } -massa-proto-rs = { path = "../massa-proto-rs_2" } +massa-proto-rs = { git = "https://github.com/massalabs/massa-proto-rs.git", rev = "84678fb77cf6d06d85d55e2c20502908ff292e61", features = ["tonic"] } more-asserts = "0.3" num_enum = "0.7" parking_lot = "0.12" diff --git a/src/tests/mod.rs b/src/tests/mod.rs index 3f34bf56..1d4a8325 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -801,6 +801,10 @@ impl Interface for TestInterface { println!("get_origin_operation_id"); Ok(Some(String::new())) } + + fn chain_id(&self) -> Result { + Ok(7) + } } #[cfg(feature = "gas_calibration")] From f2561655a4e1c38455c2f6c86e22013142dbf076 Mon Sep 17 00:00:00 2001 From: sydhds Date: Wed, 13 Dec 2023 14:40:35 +0100 Subject: [PATCH 4/4] Fix to return u64 and not i64 --- Cargo.lock | 361 ---------------------------------------- Cargo.toml | 2 +- src/as_execution/abi.rs | 4 +- 3 files changed, 3 insertions(+), 364 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a436b057..7a96c87e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -73,90 +73,12 @@ dependencies = [ "wasmer", ] -[[package]] -name = "async-stream" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" -dependencies = [ - "async-stream-impl", - "futures-core", - "pin-project-lite", -] - -[[package]] -name = "async-stream-impl" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - -[[package]] -name = "async-trait" -version = "0.1.74" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - [[package]] name = "autocfg" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" -[[package]] -name = "axum" -version = "0.6.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" -dependencies = [ - "async-trait", - "axum-core", - "bitflags 1.3.2", - "bytes", - "futures-util", - "http", - "http-body", - "hyper", - "itoa", - "matchit", - "memchr", - "mime", - "percent-encoding", - "pin-project-lite", - "rustversion", - "serde", - "sync_wrapper", - "tower", - "tower-layer", - "tower-service", -] - -[[package]] -name = "axum-core" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" -dependencies = [ - "async-trait", - "bytes", - "futures-util", - "http", - "http-body", - "mime", - "rustversion", - "tower-layer", - "tower-service", -] - [[package]] name = "backtrace" version = "0.3.69" @@ -813,25 +735,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" -[[package]] -name = "h2" -version = "0.3.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d6250322ef6e60f93f9a2162799302cd6f68f79f6e5d85c8c16f14d1d958178" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http", - "indexmap 2.1.0", - "slab", - "tokio", - "tokio-util", - "tracing", -] - [[package]] name = "hashbrown" version = "0.11.2" @@ -871,76 +774,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "http" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" -dependencies = [ - "bytes", - "fnv", - "itoa", -] - -[[package]] -name = "http-body" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" -dependencies = [ - "bytes", - "http", - "pin-project-lite", -] - -[[package]] -name = "httparse" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" - -[[package]] -name = "httpdate" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" - -[[package]] -name = "hyper" -version = "0.14.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" -dependencies = [ - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "httparse", - "httpdate", - "itoa", - "pin-project-lite", - "socket2 0.4.10", - "tokio", - "tower-service", - "tracing", - "want", -] - -[[package]] -name = "hyper-timeout" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" -dependencies = [ - "hyper", - "pin-project-lite", - "tokio", - "tokio-io-timeout", -] - [[package]] name = "iana-time-zone" version = "0.1.58" @@ -1111,7 +944,6 @@ dependencies = [ "prost", "prost-build", "prost-types", - "tonic", "tonic-build", ] @@ -1150,12 +982,6 @@ dependencies = [ "which 5.0.0", ] -[[package]] -name = "matchit" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" - [[package]] name = "memchr" version = "2.6.4" @@ -1189,12 +1015,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "mime" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" - [[package]] name = "miniz_oxide" version = "0.7.1" @@ -1204,17 +1024,6 @@ dependencies = [ "adler", ] -[[package]] -name = "mio" -version = "0.8.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" -dependencies = [ - "libc", - "wasi", - "windows-sys 0.48.0", -] - [[package]] name = "more-asserts" version = "0.2.2" @@ -1329,26 +1138,6 @@ dependencies = [ "indexmap 2.1.0", ] -[[package]] -name = "pin-project" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" -dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - [[package]] name = "pin-project-lite" version = "0.2.13" @@ -1833,26 +1622,6 @@ version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" -[[package]] -name = "socket2" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "socket2" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" -dependencies = [ - "libc", - "windows-sys 0.48.0", -] - [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -1881,12 +1650,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "sync_wrapper" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" - [[package]] name = "tap" version = "1.0.1" @@ -1947,56 +1710,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" -[[package]] -name = "tokio" -version = "1.35.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841d45b238a16291a4e1584e61820b8ae57d696cc5015c459c229ccc6990cc1c" -dependencies = [ - "backtrace", - "bytes", - "libc", - "mio", - "pin-project-lite", - "socket2 0.5.5", - "windows-sys 0.48.0", -] - -[[package]] -name = "tokio-io-timeout" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf" -dependencies = [ - "pin-project-lite", - "tokio", -] - -[[package]] -name = "tokio-stream" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" -dependencies = [ - "futures-core", - "pin-project-lite", - "tokio", -] - -[[package]] -name = "tokio-util" -version = "0.7.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" -dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "pin-project-lite", - "tokio", - "tracing", -] - [[package]] name = "toml_datetime" version = "0.6.3" @@ -2014,33 +1727,6 @@ dependencies = [ "winnow", ] -[[package]] -name = "tonic" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d560933a0de61cf715926b9cac824d4c883c2c43142f787595e48280c40a1d0e" -dependencies = [ - "async-stream", - "async-trait", - "axum", - "base64", - "bytes", - "h2", - "http", - "http-body", - "hyper", - "hyper-timeout", - "percent-encoding", - "pin-project", - "prost", - "tokio", - "tokio-stream", - "tower", - "tower-layer", - "tower-service", - "tracing", -] - [[package]] name = "tonic-build" version = "0.10.2" @@ -2054,38 +1740,6 @@ dependencies = [ "syn 2.0.40", ] -[[package]] -name = "tower" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" -dependencies = [ - "futures-core", - "futures-util", - "indexmap 1.9.3", - "pin-project", - "pin-project-lite", - "rand", - "slab", - "tokio", - "tokio-util", - "tower-layer", - "tower-service", - "tracing", -] - -[[package]] -name = "tower-layer" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" - -[[package]] -name = "tower-service" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" - [[package]] name = "tracing" version = "0.1.40" @@ -2117,12 +1771,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "try-lock" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" - [[package]] name = "typenum" version = "1.17.0" @@ -2179,15 +1827,6 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" -[[package]] -name = "want" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" -dependencies = [ - "try-lock", -] - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" diff --git a/Cargo.toml b/Cargo.toml index 079d9f13..5033ec8a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ chrono = { version = "=0.4", features = ["clock"], default-features = false } displaydoc = "0.2" function_name = "0.3" loupe = "0.1" -massa-proto-rs = { git = "https://github.com/massalabs/massa-proto-rs.git", rev = "84678fb77cf6d06d85d55e2c20502908ff292e61", features = ["tonic"] } +massa-proto-rs = { git = "https://github.com/massalabs/massa-proto-rs.git", rev = "84678fb77cf6d06d85d55e2c20502908ff292e61"} more-asserts = "0.3" num_enum = "0.7" parking_lot = "0.12" diff --git a/src/as_execution/abi.rs b/src/as_execution/abi.rs index f44866ea..ca95e446 100644 --- a/src/as_execution/abi.rs +++ b/src/as_execution/abi.rs @@ -1053,10 +1053,10 @@ pub fn assembly_script_function_exists( /// Return current chain id #[named] -pub(crate) fn assembly_script_chain_id(mut ctx: FunctionEnvMut) -> ABIResult { +pub(crate) fn assembly_script_chain_id(mut ctx: FunctionEnvMut) -> ABIResult { let env = get_env(&ctx)?; sub_remaining_gas_abi(&env, &mut ctx, function_name!())?; - Ok(env.get_interface().chain_id()? as i64) + Ok(env.get_interface().chain_id()? as u64) } /// Assembly script builtin `abort` function.