Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undeprecate ens_name_by_hash #4751

Merged
merged 1 commit into from
Jul 12, 2023
Merged
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
2 changes: 2 additions & 0 deletions graph/src/runtime/gas/costs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion runtime/wasm/src/host_exports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,12 @@ impl<C: Blockchain> HostExports<C> {
Ok(())
}

pub(crate) fn ens_name_by_hash(&self, hash: &str) -> Result<Option<String>, anyhow::Error> {
pub(crate) fn ens_name_by_hash(
&self,
hash: &str,
gas: &GasCounter,
) -> Result<Option<String>, anyhow::Error> {
gas.consume_host_fn(gas::ENS_NAME_BY_HASH)?;
Ok(self.ens_lookup.find_name(hash)?)
}

Expand Down
10 changes: 1 addition & 9 deletions runtime/wasm/src/module/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1852,16 +1852,8 @@ impl<C: Blockchain> WasmInstanceContext<C> {
gas: &GasCounter,
hash_ptr: AscPtr<AscString>,
) -> Result<AscPtr<AscString>, 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"
Expand Down