ganache
ganache copied to clipboard
fork from avax c-chain using ganache
something wrong happened when forking from avax c-chain
CodedError: cannot query unfinalized data at webpack://Ganache/../../chains/ethereum/ethereum/lib/src/forking/handlers/base-handler.js:174:23 at process.promise (node:internal/process/task_queues:96:5) at async HttpHandler.queueRequest (webpack://Ganache/../../chains/ethereum/ethereum/lib/src/forking/handlers/base-handler.js:178:36) at async HttpHandler.nonce [as request] (webpack://Ganache/../../chains/ethereum/ethereum/lib/src/forking/handlers/http-handler.js:176:9) at async nonce (webpack://Ganache/../../chains/ethereum/ethereum/lib/src/forking/fork.js:47:11) at async stateRoot (webpack://Ganache/../../chains/ethereum/ethereum/lib/src/forking/fork.js:135:23) at async Promise.all (index 1) at async Fork.cache (webpack://Ganache/../../chains/ethereum/ethereum/lib/src/forking/fork.js:102:58) at async Promise.all (index 0) at async Fork.initialize (webpack://Ganache/../../chains/ethereum/ethereum/lib/src/forking/fork.js:199:23) { code: -32000 }
can you provide reproduction steps?
Closing this. Please comment or open an issue if this is still a problem.
Same here. This is how to reproduce it (public RPC):
$ npx ganache --fork.url https://api.avax-test.network/ext/bc/C/rpc
ganache v7.5.0 (@ganache/cli: 0.6.0, @ganache/core: 0.6.0)
Starting RPC server
CodedError: cannot query unfinalized data
at /home/didi/src/sf/protocol-monorepo/node_modules/ganache/dist/node/1.js:2:113817
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async HttpHandler.queueRequest (/home/didi/src/sf/protocol-monorepo/node_modules/ganache/dist/node/1.js:2:113970)
at async HttpHandler.request (/home/didi/src/sf/protocol-monorepo/node_modules/ganache/dist/node/1.js:2:116137)
at async getBlockByNumber (/home/didi/src/sf/protocol-monorepo/node_modules/ganache/dist/node/1.js:2:122295)
at async PersistentCache.getBlock (/home/didi/src/sf/protocol-monorepo/node_modules/ganache/dist/node/1.js:2:127698)
at async /home/didi/src/sf/protocol-monorepo/node_modules/ganache/dist/node/1.js:2:127241
at async Promise.all (index 0)
at async PersistentCache.initialize (/home/didi/src/sf/protocol-monorepo/node_modules/ganache/dist/node/1.js:2:127003)
at async Fork.initCache (/home/didi/src/sf/protocol-monorepo/node_modules/ganache/dist/node/1.js:2:110319) {
code: -32000
}
What's surprising: this doesn't happen on the mainnet RPC:
$ npx ganache --fork.url https://api.avax.network/ext/bc/C/rpc
ganache v7.5.0 (@ganache/cli: 0.6.0, @ganache/core: 0.6.0)
Starting RPC server
Available Accounts
...
I get the same behaviour with self-hosted Avalanche RPCs.
FWIW I'm not able to reproduce this with Ganache v7.8.0
FWIW I'm not able to reproduce this with Ganache v7.8.0
that's weird.
$ npx ganache --fork.url https://api.avax-test.network/ext/bc/C/rpc
ganache v7.8.0 (@ganache/cli: 0.9.0, @ganache/core: 0.9.0)
Starting RPC server
CodedError: cannot query unfinalized data
at /home/didi/.nvm/versions/node/v18.15.0/lib/node_modules/ganache/dist/node/1.js:2:117004
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async HttpHandler.queueRequest (/home/didi/.nvm/versions/node/v18.15.0/lib/node_modules/ganache/dist/node/1.js:2:117157)
at async HttpHandler.request (/home/didi/.nvm/versions/node/v18.15.0/lib/node_modules/ganache/dist/node/1.js:2:119323)
at async getBlockByNumber (/home/didi/.nvm/versions/node/v18.15.0/lib/node_modules/ganache/dist/node/1.js:2:125477)
at async PersistentCache.getBlock (/home/didi/.nvm/versions/node/v18.15.0/lib/node_modules/ganache/dist/node/1.js:2:130886)
at async /home/didi/.nvm/versions/node/v18.15.0/lib/node_modules/ganache/dist/node/1.js:2:130429
at async Promise.all (index 0)
at async PersistentCache.initialize (/home/didi/.nvm/versions/node/v18.15.0/lib/node_modules/ganache/dist/node/1.js:2:130191)
at async Fork.initCache (/home/didi/.nvm/versions/node/v18.15.0/lib/node_modules/ganache/dist/node/1.js:2:113386) {
code: -32000
This is on Ubuntu 20.04
If you want it to work with a chain that isn't like Ethereum but pretends it is sometimes you'll sometimes have to figure out what this chain is doing that isn't Ethereum.
In this case it seems like the chain doesn't support querying the chain at recent blocks. You probably need to tell ganache to only query the chain at some n blocks before the latest block number. You can do this with the --fork.preLatestConfirmations
flag, something like ganache --fork.preLatestConfirmations 128 ...
where 128 is whatever number makes it work :-)
@davidmurdoch thx for that hint!