diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 708eca3eb17..5eac7cc1003 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -116,6 +116,24 @@ jobs: submodules: "recursive" - uses: crate-ci/typos@master + misc: + if: github.ref != 'refs/heads/staging' + needs: sanity + runs-on: ubuntu-latest + continue-on-error: true + steps: + - uses: actions/checkout@v4 + with: + submodules: "recursive" + - uses: dtolnay/rust-toolchain@master + with: + toolchain: 1.81.0 + - uses: Swatinem/rust-cache@v2 + with: + shared-key: "clippy" + save-if: ${{ github.ref_name == 'main' }} + - run: cargo xtask check_gas_cost_definitions + # Full cross-platform tests required to merge on main branch full: name: full diff --git a/Cargo.lock b/Cargo.lock index a607752d5a9..71e71a5838b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2796,7 +2796,7 @@ dependencies = [ [[package]] name = "massa-sc-runtime" version = "0.10.0" -source = "git+https://github.com/massalabs/massa-sc-runtime?branch=next_breaking_update#2081855e026cbb8e19ced6b0e2aae67b0de379f1" +source = "git+https://github.com/massalabs/massa-sc-runtime?branch=feature/inconsistent_gas_entries#0555ff2ae5a88c96100b4f9caf55ba15bb6839a2" dependencies = [ "anyhow", "as-ffi-bindings", @@ -3645,6 +3645,7 @@ dependencies = [ name = "massa_xtask" version = "2.3.0" dependencies = [ + "massa-sc-runtime", "massa_models", "toml_edit 0.21.0", "walkdir", @@ -4464,8 +4465,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c1318b19085f08681016926435853bbf7858f9c082d0999b80550ff5d9abe15" dependencies = [ "bytes", - "heck 0.4.1", - "itertools 0.12.0", + "heck 0.5.0", + "itertools 0.10.5", "log", "multimap", "once_cell", @@ -4485,7 +4486,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5" dependencies = [ "anyhow", - "itertools 0.12.0", + "itertools 0.10.5", "proc-macro2 1.0.86", "quote 1.0.37", "syn 2.0.75", diff --git a/Cargo.toml b/Cargo.toml index 4178921d123..50a5f48bc74 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -107,7 +107,7 @@ massa_wallet = { path = "./massa-wallet" } # Massa projects dependencies massa-proto-rs = { git = "https://github.com/massalabs/massa-proto-rs", branch = "mainnet_2_3" } -massa-sc-runtime = { git = "https://github.com/massalabs/massa-sc-runtime", "branch" = "next_breaking_update" } +massa-sc-runtime = { git = "https://github.com/massalabs/massa-sc-runtime", "branch" = "feature/inconsistent_gas_entries" } peernet = { git = "https://github.com/massalabs/PeerNet", "rev" = "04b05ddd320fbe76cc858115af7b5fc28bdb8310" } # Dev only - use local dependencies # massa-proto-rs = { path = "../massa-proto-rs" } diff --git a/massa-node/base_config/gas_costs/abi_gas_costs.json b/massa-node/base_config/gas_costs/abi_gas_costs.json index 66ad4901324..3d35aa5cfdb 100644 --- a/massa-node/base_config/gas_costs/abi_gas_costs.json +++ b/massa-node/base_config/gas_costs/abi_gas_costs.json @@ -125,5 +125,11 @@ "abi_unsafe_random": 402, "abi_verify_signature": 1192, "abi_chain_id": 301, - "launch_wasmv1": 18641 + "launch_wasmv1": 18641, + "assembly_script_console_log": 171, + "assembly_script_console_info": 171, + "assembly_script_console_debug": 171, + "assembly_script_console_warn": 171, + "assembly_script_console_error": 171, + "assembly_script_trace": 171 } \ No newline at end of file diff --git a/massa-xtask/Cargo.toml b/massa-xtask/Cargo.toml index 7e268a344cd..a5f3c178506 100644 --- a/massa-xtask/Cargo.toml +++ b/massa-xtask/Cargo.toml @@ -4,6 +4,9 @@ version = "2.3.0" edition = "2021" [dependencies] +# update_package_versions dependencies massa_models = {workspace = true} toml_edit = {workspace = true} # BOM UPGRADE Revert to "0.19.8" if problem walkdir = {workspace = true} +# check_gas_costs dependencies +massa-sc-runtime = {workspace = true, features = ["gas_calibration"]} diff --git a/massa-xtask/src/check_gas_cost_definitions.rs b/massa-xtask/src/check_gas_cost_definitions.rs new file mode 100644 index 00000000000..a754238c8ec --- /dev/null +++ b/massa-xtask/src/check_gas_cost_definitions.rs @@ -0,0 +1,56 @@ +use massa_sc_runtime::GasCosts; +use std::collections::HashSet; + +pub(crate) fn check_gas_cost_definitions() -> Result<(), String> { + // Check gas cost definition between: + // massa-node/base_config/gas_costs/abi_gas_costs.json + // massa-sc-runtime GasCosts::default() + + let gas_costs = GasCosts::default(); + let gas_costs_abi_defined = gas_costs + .get_abi_costs() + .keys() + .cloned() + .collect::>(); + + let massa_node_gas_costs = GasCosts::new( + // SETTINGS.execution.abi_gas_costs_file.clone(), + // SETTINGS.execution.wasm_gas_costs_file.clone(), + "massa-node/base_config/gas_costs/abi_gas_costs.json".into(), + "massa-node/base_config/gas_costs/wasm_gas_costs.json".into(), + ) + .expect("Failed to load gas costs"); + + let massa_node_gas_costs_abi_defined = massa_node_gas_costs + .get_abi_costs() + .keys() + .cloned() + .collect::>(); + + let mut found_diff = false; + let diff_1 = gas_costs_abi_defined.difference(&massa_node_gas_costs_abi_defined); + for x1 in diff_1 { + println!("Found in default() but not in json: {x1}"); + found_diff = true; + } + + let diff_2 = massa_node_gas_costs_abi_defined.difference(&gas_costs_abi_defined); + let exclude_list = HashSet::from([ + "cl_compilation", + "launch", + "sp_compilation", + "launch_wasmv1", + "max_instance", + ]); + for x2 in diff_2 { + if !exclude_list.contains(x2.as_str()) { + println!("Found in json but not in default(): {x2}"); + } + } + + if found_diff { + Err("Found gas costs definition differences".to_string()) + } else { + Ok(()) + } +} diff --git a/massa-xtask/src/main.rs b/massa-xtask/src/main.rs index a962ef40764..df8aacee12e 100644 --- a/massa-xtask/src/main.rs +++ b/massa-xtask/src/main.rs @@ -1,4 +1,7 @@ +mod check_gas_cost_definitions; mod update_package_versions; + +use crate::check_gas_cost_definitions::check_gas_cost_definitions; use crate::update_package_versions::update_package_versions; use std::env; @@ -10,6 +13,7 @@ fn main() { match task.as_deref() { // We can add more tasks here Some("update_package_versions") => update_package_versions(), + Some("check_gas_cost_definitions") => check_gas_cost_definitions().unwrap(), _ => panic!("Unknown task"), } }