You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a problem when using CI or a multi-container environment, for example Hardhat with the sapphire-dev where both are in containers on the same Docker network, where both containers have separate 172.16.x IP addresses.
The fetchRuntimePublicKey function isn't using the configured upstream JSON-RPC provider to request the call data public key. This means it's trying to access 127.0.0.1:8545 which won't work - because the sapphire-dev container is on another 172.x IP.
This is causing hardhat test to fail, but it works when running the tests locally, or when running the tests on the CI host rather than inside a container.
While this is annoying for CI, the more general problem is the provider detection code in fetchRuntimePublicKey doesn't seem to be functioning 100%.
One of the problems is there's duplicated logic to find the correct .send method inside fetchRuntimePublicKey because it's being called prior to wrapping the provider.
If it's moved until after the provider has been wrapped, then it can use the consistent EIP-1193 .request method.
Some notes on .send, if the provider isn't EIP-1193 compatible which has a standardized .request method. It will fall back to having to use .send which is wildly inconsistent across implementations.
publicsend(payload: JSONRPCRequestPayload,// @ts-ignore we patch this method so it doesn't conform to typecallback: (error: null|Error,response: JSONRPCResponsePayload)=>void): void
CedarMist
changed the title
When using Hardhat, fetchRuntimePublicKey falls through to fetchRuntimePublicKeyByChainId
client/js: When using Hardhat, fetchRuntimePublicKey falls through to fetchRuntimePublicKeyByChainIdJul 5, 2023
There is a problem when using CI or a multi-container environment, for example Hardhat with the
sapphire-dev
where both are in containers on the same Docker network, where both containers have separate 172.16.x IP addresses.The
fetchRuntimePublicKey
function isn't using the configured upstream JSON-RPC provider to request the call data public key. This means it's trying to access 127.0.0.1:8545 which won't work - because the sapphire-dev container is on another 172.x IP.This is causing
hardhat test
to fail, but it works when running the tests locally, or when running the tests on the CI host rather than inside a container.While this is annoying for CI, the more general problem is the provider detection code in
fetchRuntimePublicKey
doesn't seem to be functioning 100%.One of the problems is there's duplicated logic to find the correct
.send
method insidefetchRuntimePublicKey
because it's being called prior to wrapping the provider.If it's moved until after the provider has been wrapped, then it can use the consistent EIP-1193
.request
method.sapphire-paratime/clients/js/src/compat.ts
Line 628 in 54ca5fc
is called from
sapphire-paratime/clients/js/src/compat.ts
Line 265 in 54ca5fc
which is called from the top of the
wrap
function at:sapphire-paratime/clients/js/src/compat.ts
Line 131 in 54ca5fc
and
sapphire-paratime/clients/js/src/compat.ts
Line 142 in 54ca5fc
Some notes on
.send
, if the provider isn't EIP-1193 compatible which has a standardized.request
method. It will fall back to having to use.send
which is wildly inconsistent across implementations.With
.request
it can be simplified as:Truffle HDWallet-provider: https://github.com/trufflesuite/truffle/blob/a6fb238ef954d3ad4c6fd4181b78ee3dc047c8bf/packages/hdwallet-provider/src/index.ts#L364-L368
EIP-1193: https://eips.ethereum.org/EIPS/eip-1193#appendix-i-consumer-facing-api-documentation
Ethers JSON-RPC provider: https://github.com/ethers-io/ethers.js/blob/9197f9f938b5f3b5f97c043f2dab06854656c932/src.ts/providers/provider-jsonrpc.ts#L1139
Web3 provider
.send
: https://docs.web3js.org/api/web3-providers-http/class/HttpProvider#send which notes the interface is deprecated and to use.request
instead.The big problem seems to be that neither Truffle nor Ethers support
.request
...The
isEthersSend
function tries to determine between them:sapphire-paratime/clients/js/src/compat.ts
Lines 248 to 263 in 54ca5fc
And I used a bad hack to detect Truffle HDWallet provider:
sapphire-paratime/clients/js/src/compat.ts
Lines 648 to 655 in 54ca5fc
But this needs cleaning up to make sure it's compatible with:
The text was updated successfully, but these errors were encountered: