Skip to content

Commit 61cafaa

Browse files
dependabot[bot]lutter
authored andcommitted
build(deps): bump wasm-instrument from 0.2.0 to 0.4.0
Bumps [wasm-instrument](https://github.com/paritytech/wasm-instrument) from 0.2.0 to 0.4.0. - [Changelog](https://github.com/paritytech/wasm-instrument/blob/master/CHANGELOG.md) - [Commits](paritytech/wasm-instrument@0.2.0...v0.4.0) --- updated-dependencies: - dependency-name: wasm-instrument dependency-version: 0.4.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
1 parent 3fba7f9 commit 61cafaa

5 files changed

Lines changed: 14 additions & 8 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

runtime/wasm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ anyhow = { workspace = true }
1414
never = "0.1"
1515

1616
wasmtime.workspace = true
17-
wasm-instrument = { version = "0.2.0", features = ["std", "sign_ext"] }
17+
wasm-instrument = { version = "0.4.0", features = ["std", "sign_ext"] }
1818

1919
# AssemblyScript uses sign extensions
2020
parity-wasm = { version = "0.45", features = ["std", "sign_ext"] }

runtime/wasm/src/gas_rules.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,4 +165,8 @@ impl Rules for GasRules {
165165

166166
MemoryGrowCost::Linear(gas_per_page)
167167
}
168+
169+
fn call_per_local_cost(&self) -> u32 {
170+
0
171+
}
168172
}

runtime/wasm/src/mapping.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,10 @@ impl ValidModule {
302302

303303
name
304304
});
305-
let parity_module = wasm_instrument::gas_metering::inject(parity_module, &GasRules, "gas")
306-
.map_err(|_| anyhow!("Failed to inject gas counter"))?;
305+
let backend = wasm_instrument::gas_metering::host_function::Injector::new("gas", "gas");
306+
let parity_module =
307+
wasm_instrument::gas_metering::inject(parity_module, backend, &GasRules)
308+
.map_err(|_| anyhow!("Failed to inject gas counter"))?;
307309
let raw_module = parity_module.into_bytes()?;
308310

309311
// We use Cranelift as a compilation engine. Cranelift is an optimizing compiler, but that

runtime/wasm/src/module/instance.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use graph::data_source::{MappingTrigger, TriggerWithHandler};
1616
use graph::prelude::*;
1717
use graph::runtime::{
1818
HostExportError, asc_new,
19-
gas::{Gas, GasCounter, SaturatingInto},
19+
gas::{Gas, GasCounter},
2020
};
2121
use graph::{components::subgraph::MappingError, runtime::AscPtr};
2222

@@ -576,15 +576,15 @@ pub(crate) fn build_linker(
576576
linker.func_wrap(
577577
"gas",
578578
"gas",
579-
|mut caller: wasmtime::Caller<'_, WasmInstanceData>, gas_used: u32| -> anyhow::Result<()> {
579+
|mut caller: wasmtime::Caller<'_, WasmInstanceData>, gas_used: u64| -> anyhow::Result<()> {
580580
// Gas metering has a relevant execution cost cost, being called tens of thousands
581581
// of times per handler, but it's not worth having a stopwatch section here because
582582
// the cost of measuring would be greater than the cost of `consume_host_fn`. Last
583583
// time this was benchmarked it took < 100ns to run.
584584
if let Err(e) = caller
585585
.data()
586586
.gas
587-
.consume_host_fn_with_metrics(gas_used.saturating_into(), "gas")
587+
.consume_host_fn_with_metrics(Gas::new(gas_used), "gas")
588588
{
589589
caller.data_mut().deterministic_host_trap = true;
590590
return Err(e.into());

0 commit comments

Comments
 (0)