-
Notifications
You must be signed in to change notification settings - Fork 711
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add missing default gas cost for some abis (#4761)
* Add missing default gas cost for some abis * Add xtask check gas cost definitions * Update massa-sc-runtime in Cargo.lock * Update massa-sc-runtime in Cargo.lock - round 2 * Add eclude list in xtask check_gas_cost_definitions * Cargo fmt pass
- Loading branch information
Showing
7 changed files
with
94 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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::<HashSet<String>>(); | ||
|
||
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::<HashSet<String>>(); | ||
|
||
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(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters