feat(gre): desambiguate chainIds using secondary network name #714
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
GRE uses
chainId
to get details about networks defined inhardhat.config.ts
. It's possible that there are multiple networks using the samechainId
so previously we used hardhat's main network name to disambiguate (i.e:hardhat
,mainnet
,localhost
).This works as long as the chain id being disambiguated is the main one (specified by the
--network
flag), however it won't work if the secondary network is the one affected.For example, for this
hardhat.config.ts
:Running a hardhat command using
--network localnitrol1
will work as it will uselocalnitrol1
network name to disambiguate, selectinglocalnitrol1
as the L1 andlocalnitrol2
as the L2.However running a hardhat command using
--network localnitrol2
won't work as it doesn't know which L1 network to choose. It will selectlocalnitrol2
as the L2 but the L1 will be uninitialized.Changes
This PR changes the GRE network selection so that it obtains the secondary network name from the main network name, and uses that to help disambiguating the networks.
So in the example above it will get the L1 network name
localnitrol2 --> localnitrol1
, and will then uselocalnitrol1
to find the correct L1 network.Signed-off-by: Tomás Migone [email protected]