Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Put try/catch guard around ENS forward resolution in decoder/debugger #6083

Merged
merged 1 commit into from Jun 13, 2023

Conversation

haltman-at
Copy link
Contributor

PR description

This PR fixes an issue noticed by @gnidan. Turns out that ENSJS will throw an error if you try to resolve an ENS name which contains certain characters not permitted in URLs[0], such as 馃 (but apparently 馃崙 is fine). This despite the fact that it has no problem with them on reverse resolution, and apparently it was possible to register these names in the first place (presumably by just not using ENSJS).

Since I don't really want to go tearing out ENSJS right now, I'm fixing this the crudest way possible, with a blunt try/catch. I could check for the particular error message, but that's probably too brittle.

(Notionally I could use a library (ideally one we're already implicitly using) to check for the particular illegal characters, but that seems a bit too much work for something like this.)

[0] I'm a little unclear at this point, honestly. Suffice it to say that there is apparently at least one convention under which they are illegal, and ENSJS is applying this convention.

Testing instructions

Nick found this issue by attempting to use the decoder to decode the state variables (as of block 17445497) of the mainnet contract at address 0xa39739ef8b0231dbfa0dcda07d7e29faabcf4bb2, having obtained its source via fetch-and-compile. The particular variable that causes the error is called "TroveOwners". Try executing the following commands in node --experimental-repl-await: (or run this outside the repl I guess :P )

const { fetchAndCompile } = require("@truffle/fetch-and-compile")
Decoder = require("@truffle/decoder")
address = "0xa39739ef8b0231dbfa0dcda07d7e29faabcf4bb2"
networkId = 1
let { compileResult } = await fetchAndCompile(address, { network: { networkId } })
let projectInfo = { commonCompilations: compileResult.compilations }
let Web3 = require("web3")
let web3 = new Web3(<your preferred way of connecting to mainnet>)
let projectDecoder = await Decoder.forProject({ provider: web3.currentProvider, projectInfo })
let decoder = await projectDecoder.forAddress(address)
block = 17445497
await decoder.variable("TroveOwners", block)

That last line should not error. (Without this fix, it does.)

@haltman-at haltman-at merged commit b5c10ae into develop Jun 13, 2023
10 checks passed
@haltman-at haltman-at deleted the peach-yes-houseplant-no branch June 13, 2023 21:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants