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

fork should allow to specify a network name instead of url #1164

Open
wighawag opened this issue Jan 7, 2021 · 5 comments
Open

fork should allow to specify a network name instead of url #1164

wighawag opened this issue Jan 7, 2021 · 5 comments
Labels
status:ready This issue is ready to be worked on type:feature Feature request

Comments

@wighawag
Copy link
Contributor

wighawag commented Jan 7, 2021

The forking feature requires you to specify a url and while it works it prevent plugin that add context to a network (like named accounts and deployments in hardhat-deploy) when fork is enabled.
Indeed when fork is running there is no information about the network

If the fork config would have a network field (instead of url). that field would be used by hardhat to get the url from the corresponding network.

Then hardhat could expose a runtime environemnet like hre.forkedNetwork that plugin could read to reconstruct the context for that particular network

Without this plugin like hardhat require the user to specify the network the fork is from. duplicating an information that could be easily available

@fvictorio
Copy link
Member

Not sure I understand this. You want a way to check in runtime if the current network is a fork?

@wighawag
Copy link
Contributor Author

Basically instead of

{
...
 networks: {
    hardhat: {
      forking: {
            url: "<mainnet_url>"
          }
    },
    mainnet {
      url: "<mainnet_url>",
    }
 }
}

it would simply be

{
...
 networks: {
    hardhat: {
      forking: {
            network: "mainnet"
          }
    },
    mainnet {
      url: "<mainnet_url>",
    }
 }
}

This remove the need to duplicate url, but more importantly it allows plugin (and hardhat) to consider the network config that could be specific or any other context added. For hardhat-deploy this include named accounts, but also deployments, etc....
These are specific to a network. not an url.

@fvictorio
Copy link
Member

Oh, I see now, thanks for the explanation!

@fvictorio fvictorio added the type:feature Feature request label Jan 26, 2021
@wighawag
Copy link
Contributor Author

wighawag commented May 6, 2021

Any update on this ? This is really a shame that when things are executed on a fork, there is no information of the network it is forked from. it is always hardhat. There is often things you want to have configured differently based on the network.

The workaround for now is to add extra info via env variable (see https://github.com/wighawag/template-ethereum-contracts/blob/9ff1bccd2e2badc2deed0eca25877ada2cd52ee5/hardhat.config.ts), but it would be logical for hardhat to keep track of what network it is being forked from an use what is already there for that, the named network

@fvictorio
Copy link
Member

Hey @wighawag, we are kind of overwhelmed with things to do right now. I still think this makes sense, even if there are workarounds (like using an env var to set the fork, and checking that env var in runtime), and it's probably not hard to implement, but the hardest part is to think about the best way to do this at a product/config level, and I'm not sure when we'll have time to do that 🙁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready This issue is ready to be worked on type:feature Feature request
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

2 participants