Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions runtime/test/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1844,10 +1844,10 @@ async fn test_yaml_parsing(api_version: Version, gas_used: u64) {

#[graph::test]
async fn yaml_parsing_v0_0_4() {
test_yaml_parsing(API_VERSION_0_0_4, 1053927678771).await;
test_yaml_parsing(API_VERSION_0_0_4, 1066812580659).await;
}

#[graph::test]
async fn yaml_parsing_v0_0_5() {
test_yaml_parsing(API_VERSION_0_0_5, 1053946160531).await;
test_yaml_parsing(API_VERSION_0_0_5, 1066831062419).await;
}
2 changes: 1 addition & 1 deletion runtime/wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ anyhow = { workspace = true }
never = "0.1"

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

# AssemblyScript uses sign extensions
parity-wasm = { version = "0.45", features = ["std", "sign_ext"] }
Expand Down
4 changes: 4 additions & 0 deletions runtime/wasm/src/gas_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,8 @@ impl Rules for GasRules {

MemoryGrowCost::Linear(gas_per_page)
}

fn call_per_local_cost(&self) -> u32 {
0
}
}
6 changes: 4 additions & 2 deletions runtime/wasm/src/mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,10 @@ impl ValidModule {

name
});
let parity_module = wasm_instrument::gas_metering::inject(parity_module, &GasRules, "gas")
.map_err(|_| anyhow!("Failed to inject gas counter"))?;
let backend = wasm_instrument::gas_metering::host_function::Injector::new("gas", "gas");
let parity_module =
wasm_instrument::gas_metering::inject(parity_module, backend, &GasRules)
.map_err(|_| anyhow!("Failed to inject gas counter"))?;
let raw_module = parity_module.into_bytes()?;

// We use Cranelift as a compilation engine. Cranelift is an optimizing compiler, but that
Expand Down
6 changes: 3 additions & 3 deletions runtime/wasm/src/module/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use graph::data_source::{MappingTrigger, TriggerWithHandler};
use graph::prelude::*;
use graph::runtime::{
HostExportError, asc_new,
gas::{Gas, GasCounter, SaturatingInto},
gas::{Gas, GasCounter},
};
use graph::{components::subgraph::MappingError, runtime::AscPtr};

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