Skip to content

Commit

Permalink
chore(wasm-builder): add constants module for CodeValidator (#4485)
Browse files Browse the repository at this point in the history
  • Loading branch information
ecol-master authored Jan 31, 2025
1 parent caf74e7 commit 8003f88
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions utils/wasm-builder/src/code_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use anyhow::{anyhow, bail};
use gear_core::{
code::{Code, CodeError, ExportError, ImportError, TryNewCodeConfig},
gas_metering::CustomConstantCostRules,
gas_metering::{CustomConstantCostRules, Schedule},
};
use gear_wasm_instrument::SyscallName;
use pwasm_utils::parity_wasm::{
Expand Down Expand Up @@ -328,13 +328,14 @@ impl CodeValidator {
/// Validates wasm code in the same way as
/// `pallet_gear::pallet::Pallet::upload_program(...)`.
pub fn validate_program(self) -> anyhow::Result<()> {
let schedule = Schedule::default();
match Code::try_new(
self.code,
1,
|_| CustomConstantCostRules::default(),
None,
None,
None,
schedule.instruction_weights.version,
|module| schedule.rules(module),
schedule.limits.stack_height,
schedule.limits.data_segments_amount.into(),
schedule.limits.table_number.into(),
) {
Err(code_error) => Err(CodeErrorWithContext::from((self.module, code_error)))?,
_ => Ok(()),
Expand Down

0 comments on commit 8003f88

Please sign in to comment.