zeta-chain / localnet

ZetaChain's local dev environment with connected EVM chains.
https://www.zetachain.com/docs/developers/tutorials/localnet/
MIT License
6 stars 2 forks source link

fix: calling a universal contract using depositAndCall #13

Closed fadeev closed 2 months ago

fadeev commented 2 months ago

The only change aside from formatting is using protocolContracts.zrc20Eth.target inside protocolContracts.gatewayEVM.on("Deposited"...

fadeev commented 2 months ago

With this fix a test universal contract can be successfully called using depositAndCall. However, when a universal contract reverts, a contract on EVM is not getting called. I'm getting the following error:

Tx reverted, calling executeRevert on GatewayEVM...
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getTransactionCount
eth_chainId
eth_chainId
eth_chainId
eth_getBlockByNumber
eth_gasPrice
eth_maxPriorityFeePerGas
eth_chainId
eth_sendRawTransaction
eth_chainId
Call onRevert failed: Error: nonce has already been used (transaction="0x02f90195827a690d8502540be4008502540be400836691b7949fe46736679d2d9a65f0992f2272de9f3c7fa6e080b90124f7ad60db0000000000000000000000009a676e781a523b5d0c0e43731313a708cb60750800000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000149a676e781a523b5d0c0e43731313a708cb607508000000000000000000000000c080a0bf79d3fdc53ab374fa26fefc3c6acd25f757300223d7d8d5967963481d49aafea051706a5ed51079ef36be18bda60476edb16538b33ec6213f385fd3cceb34abf6", info={ "error": { "code": -32003, "message": "nonce too low" } }, code=NONCE_EXPIRED, version=6.13.2)
    at makeError (/Users/fadeev/github.com/zeta-chain/localnet/node_modules/ethers/src.ts/utils/errors.ts:694:21)
    at JsonRpcProvider.getRpcError (/Users/fadeev/github.com/zeta-chain/localnet/node_modules/ethers/src.ts/providers/provider-jsonrpc.ts:1031:33)
    at /Users/fadeev/github.com/zeta-chain/localnet/node_modules/ethers/src.ts/providers/provider-jsonrpc.ts:563:45
    at processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: 'NONCE_EXPIRED',
  transaction: '0x02f90195827a690d8502540be4008502540be400836691b7949fe46736679d2d9a65f0992f2272de9f3c7fa6e080b90124f7ad60db0000000000000000000000009a676e781a523b5d0c0e43731313a708cb60750800000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000149a676e781a523b5d0c0e43731313a708cb607508000000000000000000000000c080a0bf79d3fdc53ab374fa26fefc3c6acd25f757300223d7d8d5967963481d49aafea051706a5ed51079ef36be18bda60476edb16538b33ec6213f385fd3cceb34abf6',
  info: { error: { code: -32003, message: 'nonce too low' } },
  shortMessage: 'nonce has already been used'
}

@skosito

skosito commented 2 months ago

Tx reverted, calling executeRevert on GatewayEVM

will check more, but maybe this could help before tx is called:

 (deployer as NonceManager).reset();

this basically forces nonce manager to fetch last pending nonce from chain rather than using internal in memory state

fadeev commented 2 months ago
 (deployer as NonceManager).reset();

This worked! Thanks! 🙌