Skip to content

Commit 6cd8742

Browse files
authored
runtime: undeprecate ens_name_by_hash (#4751)
1 parent 40aba26 commit 6cd8742

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

graph/src/runtime/gas/costs.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ pub const BIG_MATH_GAS_OP: GasOp = GasOp {
5353
// Allow up to 100,000 data sources to be created
5454
pub const CREATE_DATA_SOURCE: Gas = Gas(CONST_MAX_GAS_PER_HANDLER / 100_000);
5555

56+
pub const ENS_NAME_BY_HASH: Gas = Gas(DEFAULT_BASE_COST);
57+
5658
pub const LOG_OP: GasOp = GasOp {
5759
// Allow up to 100,000 logs
5860
base_cost: CONST_MAX_GAS_PER_HANDLER / 100_000,

runtime/wasm/src/host_exports.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,12 @@ impl<C: Blockchain> HostExports<C> {
737737
Ok(())
738738
}
739739

740-
pub(crate) fn ens_name_by_hash(&self, hash: &str) -> Result<Option<String>, anyhow::Error> {
740+
pub(crate) fn ens_name_by_hash(
741+
&self,
742+
hash: &str,
743+
gas: &GasCounter,
744+
) -> Result<Option<String>, anyhow::Error> {
745+
gas.consume_host_fn(gas::ENS_NAME_BY_HASH)?;
741746
Ok(self.ens_lookup.find_name(hash)?)
742747
}
743748

runtime/wasm/src/module/mod.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1852,16 +1852,8 @@ impl<C: Blockchain> WasmInstanceContext<C> {
18521852
gas: &GasCounter,
18531853
hash_ptr: AscPtr<AscString>,
18541854
) -> Result<AscPtr<AscString>, HostExportError> {
1855-
// Not enabled on the network, no gas consumed.
1856-
// This is unrelated to IPFS, but piggyback on the config to disallow it on the network.
1857-
if !self.experimental_features.allow_non_deterministic_ipfs {
1858-
return Err(HostExportError::Deterministic(anyhow!(
1859-
"`ens_name_by_hash` is deprecated"
1860-
)));
1861-
}
1862-
18631855
let hash: String = asc_get(self, hash_ptr, gas)?;
1864-
let name = self.ctx.host_exports.ens_name_by_hash(&hash)?;
1856+
let name = self.ctx.host_exports.ens_name_by_hash(&hash, gas)?;
18651857
if name.is_none() && self.ctx.host_exports.is_ens_data_empty()? {
18661858
return Err(anyhow!(
18671859
"Missing ENS data: see https://github.com/graphprotocol/ens-rainbow"

0 commit comments

Comments
 (0)