From 6cd874242efbe86fcf27d4bd10ab646232f958a0 Mon Sep 17 00:00:00 2001 From: Leonardo Yvens Date: Wed, 12 Jul 2023 15:56:18 +0100 Subject: [PATCH] runtime: undeprecate ens_name_by_hash (#4751) --- graph/src/runtime/gas/costs.rs | 2 ++ runtime/wasm/src/host_exports.rs | 7 ++++++- runtime/wasm/src/module/mod.rs | 10 +--------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/graph/src/runtime/gas/costs.rs b/graph/src/runtime/gas/costs.rs index 951532aeaab..6436fc2102d 100644 --- a/graph/src/runtime/gas/costs.rs +++ b/graph/src/runtime/gas/costs.rs @@ -53,6 +53,8 @@ pub const BIG_MATH_GAS_OP: GasOp = GasOp { // Allow up to 100,000 data sources to be created pub const CREATE_DATA_SOURCE: Gas = Gas(CONST_MAX_GAS_PER_HANDLER / 100_000); +pub const ENS_NAME_BY_HASH: Gas = Gas(DEFAULT_BASE_COST); + pub const LOG_OP: GasOp = GasOp { // Allow up to 100,000 logs base_cost: CONST_MAX_GAS_PER_HANDLER / 100_000, diff --git a/runtime/wasm/src/host_exports.rs b/runtime/wasm/src/host_exports.rs index 5032462043f..2ef1e819c55 100644 --- a/runtime/wasm/src/host_exports.rs +++ b/runtime/wasm/src/host_exports.rs @@ -737,7 +737,12 @@ impl HostExports { Ok(()) } - pub(crate) fn ens_name_by_hash(&self, hash: &str) -> Result, anyhow::Error> { + pub(crate) fn ens_name_by_hash( + &self, + hash: &str, + gas: &GasCounter, + ) -> Result, anyhow::Error> { + gas.consume_host_fn(gas::ENS_NAME_BY_HASH)?; Ok(self.ens_lookup.find_name(hash)?) } diff --git a/runtime/wasm/src/module/mod.rs b/runtime/wasm/src/module/mod.rs index fe05cf923be..85aa8c151aa 100644 --- a/runtime/wasm/src/module/mod.rs +++ b/runtime/wasm/src/module/mod.rs @@ -1852,16 +1852,8 @@ impl WasmInstanceContext { gas: &GasCounter, hash_ptr: AscPtr, ) -> Result, HostExportError> { - // Not enabled on the network, no gas consumed. - // This is unrelated to IPFS, but piggyback on the config to disallow it on the network. - if !self.experimental_features.allow_non_deterministic_ipfs { - return Err(HostExportError::Deterministic(anyhow!( - "`ens_name_by_hash` is deprecated" - ))); - } - let hash: String = asc_get(self, hash_ptr, gas)?; - let name = self.ctx.host_exports.ens_name_by_hash(&hash)?; + let name = self.ctx.host_exports.ens_name_by_hash(&hash, gas)?; if name.is_none() && self.ctx.host_exports.is_ens_data_empty()? { return Err(anyhow!( "Missing ENS data: see https://github.com/graphprotocol/ens-rainbow"