Closed tkporter closed 2 months ago
The change should probably go into JsonRpcProvider
for going over the JSON-RPC wire protocol, since I don't want to change the behaviour of the the class BaseProvider which has other sub-classes.
Thanks! I'll fix this today. :)
(Note: in v6, the formatter has a storageSlot
method, which is used to safely transform this value based on the network)
Thanks so much! Makes sense to me :)
This should be fixed in 5.6.7. Try it out and let me know if you still have any problems.
Thanks! :)
Sorry for the inconvenience guys. Fixing this was a tough call, as we accidentally deviated from the "standard" previously.
No worries; I'm a huge fan of things being standards compliant. :)
I've already made changes in v6 that are aligned with this too.
just tried this and am seeing the same error
Did you update to the latest version? 5.6.8?
i did! went there first actually. trying 5.6.7 now
5.6.7 should work too. I’ll re-open and look at it tomorrow.
i am seeing this most readily when i do a uniswap v3 swap then try to trace the transaction using hardhat-tracer
if that is of any help
both 5.6.7 and 5.6.8 are not working now.
> await ethers.provider.getStorageAt("0xaE80289290853f78219f2AfD3C69e0A3105fF96C", "0x0000000000000000000000000000000000000000000000000000000000000000");
Uncaught:
ProviderError: Errors encountered in param 1: Storage slot argument must have a length of 66 ("0x" + 32 bytes), but '0x0' has a length of 3
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at GanacheGasMultiplierProvider.request (/Users/sgnoo/Workspace/xociety-monorepo/packages/contracts/node_modules/hardhat/src/internal/core/providers/gas-providers.ts:312:34)
at HttpProvider.request (/Users/sgnoo/Workspace/xociety-monorepo/packages/contracts/node_modules/hardhat/src/internal/core/providers/http.ts:78:19)
Can you once try removing lock files and reinstalling on your end if it solves the problem?
@3commascapital @0xdagarn Have you tried @zemse suggestion of removing any lock files and re-installing? Can you make sure the version of the @ethersproject/providers
package in the node_modules/@ethersproject/providers/package.json
is 5.6.8?
I've just tried to reproduce this against the latest version and it still works for me.
Same error when I use 6.0.8
, but if I use 5.6.8
, it works well.
Closing older issues. But if this is still happening in v6, please re-open or start a new issue.
Thanks! :)
Ethers Version
@ethersproject/providers
5.6.5
Search Terms
BaseProvider,getStorageAt
Describe the Problem
I came across this while trying to use
provider.getStorageAt(someAddress, 0);
against a fresh install of Hardhat. The fresh install evidently used Hardhat v2.9.5 that includes a change to make Hardhat network'seth_getStorageAt
spec compliant (Hardhat PR here, references spec found here). Apparently the spec requires the storage position passed intoeth_getStorageAt
to be a 32 byte hex string, which BaseProvider doesn't do.Calling
getStorageAt
would give this Hardhat error:InvalidArgumentsError: Errors encountered in param 1: Storage slot argument must have a length of 66 ("0x" + 32 bytes), but '0x0' has a length of 3
. Eventually I tracked it down to this line: https://github.com/ethers-io/ethers.js/blob/master/packages/providers/src.ts/base-provider.ts#L1482I was able to fix it locally by changing the
hexValue(p)
tohexZeroPad(p, 32)
. I'm happy to open a PR but I'm not sure if that's the best place to make the change / if it totally preserves backward compatibility for other use cases.For any passerby, downgrading Hardhat version to <= v2.9.4 seems to be a sufficient workaround for now
Code Snippet
Contract ABI
No response
Errors
No response
Environment
node.js (v12 or newer), Hardhat
Environment (Other)
No response