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

Non-standard empty response for eth_getStorageAt? #595

Open
lukaw3d opened this issue Jul 23, 2024 · 3 comments
Open

Non-standard empty response for eth_getStorageAt? #595

lukaw3d opened this issue Jul 23, 2024 · 3 comments

Comments

@lukaw3d
Copy link
Member

lukaw3d commented Jul 23, 2024

Copied from slack before it's lost

Luka:

do our JSON RPCs return nonstandard empty responses?
(I had to change detectUsingEIP1967LogicSlot in abi-playground oasisprotocol/abi-playground@e9646c5)

curl 'https://eth-mainnet.g.alchemy.com/v2/upUGXHgfmYdHJlxmsq5INODNexAwPVdD' \
  -H 'content-type: application/json' \
  --data-raw '{"jsonrpc":"2.0","id":4,"method":"eth_getStorageAt","params":["0x8Bc2B030b299964eEfb5e1e0b36991352E56D2D3","0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc","latest"]}'
# {"jsonrpc":"2.0","id":4,"result":"0x0000000000000000000000000000000000000000000000000000000000000000"}

# vs ours
curl 'https://sapphire.oasis.io/' \
  -H 'content-type: application/json' \
  --data-raw '{"jsonrpc":"2.0","id":1,"method":"eth_getStorageAt","params":["0x8Bc2B030b299964eEfb5e1e0b36991352E56D2D3","0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc","latest"]}'
# {"jsonrpc":"2.0","id":1,"result":"0x0"}

curl 'https://emerald.oasis.io/' \
  -H 'content-type: application/json' \
  --data-raw '{"jsonrpc":"2.0","id":1,"method":"eth_getStorageAt","params":["0x8Bc2B030b299964eEfb5e1e0b36991352E56D2D3","0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc","latest"]}'
# {"jsonrpc":"2.0","id":1,"result":"0x0"}

Peter:

should be an easy fix
But apparently some app in the past did not expect leading zeroes (

// Some apps expect no leading zeros, so output as big integer.
). But I have no idea what I tested this with at that time. Can change if it thats nonstandard

Luka:

(btw I don't know if there is a standard for it, or how tools other than abi.ninja check it)
This might be the closest to defining the API https://github.com/ethereum/execution-apis/blob/main/tests/eth_getStorageAt/get-storage-unknown-account.io
blockscout is forgiving https://github.com/oasisprotocol/emerald-blockscout/blob/oasis-v4.1.2-beta/apps/explorer/lib/explorer/chain.ex#L6800
when empty_address in ["0x", "0x0", "0x0000000000000000000000000000000000000000000000000000000000000000"]
these all return 0x0000000000000000000000000000000000000000000000000000000000000000:

curl 'https://opt-mainnet.g.alchemy.com/v2/upUGXHgfmYdHJlxmsq5INODNexAwPVdD' -H 'content-type: application/json' --data-raw '{"jsonrpc":"2.0","id":4,"method":"eth_getStorageAt","params":["0x8Bc2B030b299964eEfb5e1e0b36991352E56D2D3","0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc","latest"]}'
curl 'https://arb-mainnet.g.alchemy.com/v2/upUGXHgfmYdHJlxmsq5INODNexAwPVdD' -H 'content-type: application/json' --data-raw '{"jsonrpc":"2.0","id":4,"method":"eth_getStorageAt","params":["0x8Bc2B030b299964eEfb5e1e0b36991352E56D2D3","0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc","latest"]}'
curl 'https://polygon-mainnet.g.alchemy.com/v2/upUGXHgfmYdHJlxmsq5INODNexAwPVdD' -H 'content-type: application/json' --data-raw '{"jsonrpc":"2.0","id":4,"method":"eth_getStorageAt","params":["0x8Bc2B030b299964eEfb5e1e0b36991352E56D2D3","0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc","latest"]}'
curl 'https://polygonzkevm-mainnet.g.alchemy.com/v2/upUGXHgfmYdHJlxmsq5INODNexAwPVdD' -H 'content-type: application/json' --data-raw '{"jsonrpc":"2.0","id":4,"method":"eth_getStorageAt","params":["0x8Bc2B030b299964eEfb5e1e0b36991352E56D2D3","0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc","latest"]}'
curl 'https://astar-mainnet.g.alchemy.com/v2/upUGXHgfmYdHJlxmsq5INODNexAwPVdD' -H 'content-type: application/json' --data-raw '{"jsonrpc":"2.0","id":4,"method":"eth_getStorageAt","params":["0x8Bc2B030b299964eEfb5e1e0b36991352E56D2D3","0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc","latest"]}'
curl 'https://starknet-mainnet.g.alchemy.com/v2/upUGXHgfmYdHJlxmsq5INODNexAwPVdD' -H 'content-type: application/json' --data-raw '{"jsonrpc":"2.0","id":4,"method":"eth_getStorageAt","params":["0x8Bc2B030b299964eEfb5e1e0b36991352E56D2D3","0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc","latest"]}'
curl 'https://eth-sepolia.g.alchemy.com/v2/upUGXHgfmYdHJlxmsq5INODNexAwPVdD' -H 'content-type: application/json' --data-raw '{"jsonrpc":"2.0","id":4,"method":"eth_getStorageAt","params":["0x8Bc2B030b299964eEfb5e1e0b36991352E56D2D3","0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc","latest"]}'
curl 'https://base-sepolia.g.alchemy.com/v2/upUGXHgfmYdHJlxmsq5INODNexAwPVdD' -H 'content-type: application/json' --data-raw '{"jsonrpc":"2.0","id":4,"method":"eth_getStorageAt","params":["0x8Bc2B030b299964eEfb5e1e0b36991352E56D2D3","0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc","latest"]}'
curl 'https://bsc-dataseed1.defibit.io/' -H 'content-type: application/json' --data-raw '{"jsonrpc":"2.0","id":4,"method":"eth_getStorageAt","params":["0x8Bc2B030b299964eEfb5e1e0b36991352E56D2D3","0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc","latest"]}'
curl 'https://avalanche.public-rpc.com/' -H 'content-type: application/json' --data-raw '{"jsonrpc":"2.0","id":4,"method":"eth_getStorageAt","params":["0x8Bc2B030b299964eEfb5e1e0b36991352E56D2D3","0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc","latest"]}'
curl 'https://nova.arbitrum.io/rpc' -H 'content-type: application/json' --data-raw '{"jsonrpc":"2.0","id":4,"method":"eth_getStorageAt","params":["0x8Bc2B030b299964eEfb5e1e0b36991352E56D2D3","0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc","latest"]}'
@lukaw3d
Copy link
Member Author

lukaw3d commented Aug 9, 2024

From discord: ethers v5 provider.getStorageAt throws

Error: bad result from backend (
  method="getStorageAt",
  params={"address":"0x52Dcf311dc34Ac9373a4A4cfF37A3292487F273D","blockTag":"latest","position":"0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103"},
  result="0x0",
  error={"reason":"hex data is odd-length","code":"INVALID_ARGUMENT","argument":"value","value":"0x0"},
  code=SERVER_ERROR,
  version=providers/5.7.2
)
<script type="module">
import { ethers } from "https://cdnjs.cloudflare.com/ajax/libs/ethers/5.7.2/ethers.esm.js";
const provider = new ethers.providers.Web3Provider(window.ethereum)
console.log(await provider.getStorageAt(
  "0x52Dcf311dc34Ac9373a4A4cfF37A3292487F273D",
  "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103",
  "latest",
))
</script>

https://github.com/ethers-io/ethers.js/blob/d7e8ad1da5ae554739ba93bc4980c3ec25c43c91/packages/providers/src.ts/base-provider.ts#L1505-L1510

https://github.com/ethers-io/ethers.js/blob/d7e8ad1da5ae554739ba93bc4980c3ec25c43c91/packages/bytes/src.ts/index.ts#L237

@lukaw3d
Copy link
Member Author

lukaw3d commented Aug 9, 2024

Ethers v6 throws

TypeError: invalid BytesLike value (
  argument="value",
  value="0x0",
  code=INVALID_ARGUMENT,
  version=6.13.2
)
<script type="module">
import { ethers } from "https://cdnjs.cloudflare.com/ajax/libs/ethers/6.13.2/ethers.js";
const provider6 = new ethers.BrowserProvider(window.ethereum)
console.log(await provider6.getStorage(
  "0x52Dcf311dc34Ac9373a4A4cfF37A3292487F273D",
  "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103",
  "latest",
))
</script>

https://github.com/ethers-io/ethers.js/blob/72c2182d01afa855d131e82635dca3da063cfb31/src.ts/utils/data.ts#L44

@lukaw3d
Copy link
Member Author

lukaw3d commented Aug 9, 2024

Related ethers-io/ethers.js#1132

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant