A full archive node has access to the historical state of the blockchain.
For example, if the node returns balance of an account (which has some eth) at block 1 then that node will be an archive node.
- Case of an archive node:
$ curl --data '{"method":"eth_getBalance","params":["0xe5Fb31A5CaEE6a96de393bdBF89FBe65fe125Bb3", "0x1"],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localh
ost:8545
{"jsonrpc":"2.0","result":"0x3635c9adc5dea00000","id":1}
In the above code snippet, we are querying balance of 0xe5Fb31A5CaEE6a96de393bdBF89FBe65fe125Bb3 an address which received 1k ETH during the genesis block.
Asserting the result of the above JSON-RPC call to be equal to 1K ETH will explicitly indicate if the node is an archive node.
- Case of a non archive node:
$ curl --data '{"method":"eth_getBalance","params":["0xe5Fb31A5CaEE6a96de393bdBF89FBe65fe125Bb3", "0x1"],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST https://cloudflare-eth.com/
{"jsonrpc":"2.0","id":1,"error":{"code":-32000,"message":"missing trie node d67e4d450343046425ae4271474353857ab860dbc0a1dde64b41b5cd3a532bf3 (path )"}}
A non archive node will not be able to return the balance at block 1 for the above address.
contract.methods.func(arg1, arg2).call(null, blockNumber)
, but I did not quite understand your explanation. – goodvibration Apr 21 '20 at 14:56if (!error.message.startsWith("Invalid JSON RPC response"))
, then you know that you are not using a full archive node. – goodvibration Apr 21 '20 at 14:57pure
function). – goodvibration Apr 21 '20 at 14:58assert
,require
,revert
, array access operations, division, modulo, external calls (to another contract), and probably a few more of those. For example a getter function of any one of your (non-array) public variables. – goodvibration Apr 21 '20 at 15:00.call()
? That error message you mentioned can be different depending on the underlying client (geth, parity, etc.), so that is not reliable. – Shane Fontaine Apr 21 '20 at 15:22