ChainSafe / ChainBridge

🌉 Modular Multi-Directional Blockchain Bridge to interact with Multiple Networks; Ethereum, Ethereum Classic, Substrate, based chains. Stay tuned for ChainBridge Hub!
GNU Lesser General Public License v3.0
475 stars 300 forks source link

ERC 721 tokens not deposited/released in destination chain #762

Closed vineetaparodkar closed 2 years ago

vineetaparodkar commented 2 years ago

ERC721 deposit failing with chainbridge

Description

Chainbridge sample ERC721 token is transferred between Polygon POS chain and local network setup with polygon edge. ERC 721 token is deposited and proposal is executed at relayer but tokens are not released in Polygon edge network.

Your environment

Steps to reproduce

Description

Chainbridge sample ERC721 token is transferred between Polygon POS chain and local network setup with polygon edge. ERC 721 token is deposited and proposal is executed at relayer but tokens are not released in Polygon edge network.

Your environment

Steps to reproduce

  1. Deployed chainbridge contracts on Polygon POS chain

cb-sol-cli deploy --all --chainId 99 \ --url <RPCURL> \ --privateKey <PRIVATE_KEY> \ --relayers 0xbE6401aaBFd8B019747205787E6FaeA82BA46C60 \ --relayerThreshold 1 \ --gasPrice 24854016445 \

  1. Deploy chainbridge contracts on polygon edge chain

cb-sol-cli deploy --all --chainId 100 \ --url http://localhost:8002 \ --privateKey <PRIVATE_KEY> \ --relayers 0xbE6401aaBFd8B019747205787E6FaeA82BA46C60 \ --relayerThreshold 1 \

  1. Register resource on pos chain and polygon edge chain

cb-sol-cli bridge register-resource \ --url http://localhost:8002 \ --privateKey <PRIVATE_KEY> \ --resourceId "0x000000000000000000000000000000e389d61c11e5fe32ec1735b3cd38c69501" \ --bridge "0x545f55f6cC8D95307C712e68eaCcfE848bfb10d6" \ --handler "0xA5630f58dc7422CF9B4EE763F156e771D8C8Dda4" \ --targetContract "0xa1F5DFbd3CeAC105b173481CcCcee3D32Da877c5" \

cb-sol-cli bridge register-resource \ --url <RPCURL> \ --privateKey <PRIVATE_KEY> \ --resourceId "0x000000000000000000000000000000e389d61c11e5fe32ec1735b3cd38c69501" \ --bridge "0x545f55f6cC8D95307C712e68eaCcfE848bfb10d6" \ --handler "0xA5630f58dc7422CF9B4EE763F156e771D8C8Dda4" \ --targetContract "0xa1F5DFbd3CeAC105b173481CcCcee3D32Da877c5" \ --gasPrice 48678101393 \

  1. Mint erc721 token on Polygon POS chain

cb-sol-cli erc721 mint --url <RPCURL> --privateKey <PRIVATE_KEY> --erc721Address "0xa1F5DFbd3CeAC105b173481CcCcee3D32Da877c5" --id 0x90 --gasPrice 43850705630

  1. Approve token to be spent by handler contract on POS chain

cb-sol-cli erc721 approve \ --url <RPCURL> \ --privateKey <PRIVATE_KEY> \ --erc721Address "0xa1F5DFbd3CeAC105b173481CcCcee3D32Da877c5" \ --recipient "0xA5630f58dc7422CF9B4EE763F156e771D8C8Dda4" \ --id 0x90 \ --gasPrice 31606193298 \

  1. Create a deposit transaction

cb-sol-cli erc721 deposit \ --url <RPCURL> \ --privateKey <PRIVATE_KEY> \ --bridge "0x545f55f6cC8D95307C712e68eaCcfE848bfb10d6" \ --resourceId "0x000000000000000000000000000000e389d61c11e5fe32ec1735b3cd38c69501" \ --id 0x90 \ --dest 100 \ --recipient "0x5142C452a671AcbD369Fbf99307e707719C118B3" \ --gasPrice 18670932665 \

  1. check erc721 token on polygon edge chain

cb-sol-cli erc721 owner \ --url http://localhost:8005 \ --privateKey <PRIVATE_KEY> \ --erc721Address "0xa1F5DFbd3CeAC105b173481CcCcee3D32Da877c5" \ --id 0x90

Expected behaviour

Tokens should be released in polygon edge network and below command should return owner address cb-sol-cli erc721 owner \ --url http://localhost:8005 \ --privateKey <PRIVATE_KEY> \ --erc721Address "0x79fd328b623157c4cf9Db77EF7645B7840A75E71" \ --id 0x90

Actual behaviour

Tokens were not released in polygon edge network and cb-sol-cli erc721 owner command returned below error

cb-sol-cli erc721 owner \ --url http://localhost:8005 \ --privateKey <PRIVATE_KEY> \ --erc721Address "0xa1F5DFbd3CeAC105b173481CcCcee3D32Da877c5" \ --id 0x90

WARNING: Multiple definitions for safeTransferFrom { e: Error: unable to execute call: execution was reverted at getResult (/home/ubuntu/polygon-edge/chainbridge-nft/chainbridge-deploy/cb-sol-cli/node_modules/ethers/providers/json-rpc-provider.js:40:21) at exports.XMLHttpRequest.request.onreadystatechange (/home/ubuntu/polygon-edge/chainbridge-nft/chainbridge-deploy/cb-sol-cli/node_modules/ethers/utils/web.js:111:30) at exports.XMLHttpRequest.dispatchEvent (/home/ubuntu/polygon-edge/chainbridge-nft/chainbridge-deploy/cb-sol-cli/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:591:25) at setState (/home/ubuntu/polygon-edge/chainbridge-nft/chainbridge-deploy/cb-sol-cli/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:610:14) at IncomingMessage. (/home/ubuntu/polygon-edge/chainbridge-nft/chainbridge-deploy/cb-sol-cli/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:447:13) at IncomingMessage.emit (node:events:402:35) at endReadableNT (node:internal/streams/readable:1343:12) at processTicksAndRejections (node:internal/process/task_queues:83:21) { code: -32600, data: undefined, url: 'http://localhost:8005', body: '{"method":"eth_call","params":[{"from":"0xbE6401aaBFd8B019747205787E6FaeA82BA46C60","to":"0xa1F5DFbd3CeAC105b173481CcCcee3D32Da877c5","data":"0x6352211e0000000000000000000000000000000000000000000000000000000000000090"},"latest"],"id":44,"jsonrpc":"2.0"}', responseText: '{"jsonrpc":"2.0","id":44,"error":{"code":-32600,"message":"unable to execute call: execution was reverted"}}' } }

Logs

Relayer Logs:

INFO[04-05|16:41:44] Connecting to ethereum chain... chain=polygon-edge url=http://localhost:8005 INFO[04-05|16:41:44] Started mumbai chain system=core INFO[04-05|16:41:44] Started polygon-edge chain system=core INFO[04-05|16:41:44] Polling Blocks... chain=polygon-edge block=912 INFO[04-05|16:41:44] Polling Blocks... chain=mumbai block=25811416 INFO[04-05|16:43:06] Handling nonfungible deposit event chain=mumbai INFO[04-05|16:43:06] Attempting to resolve message chain=polygon-edge type=NonFungibleTransfer src=99 dst=100 nonce=1 rId=000000000000000000000000000000e389d61c11e5fe32ec1735b3cd38c69501 INFO[04-05|16:43:06] Creating erc721 proposal chain=polygon-edge src=99 nonce=1 INFO[04-05|16:43:06] Watching for finalization event chain=polygon-edge src=99 nonce=1 INFO[04-05|16:43:06] Submitted proposal vote chain=polygon-edge tx=0x1c1ccca390f3c63be660fc575884889be67baf3ba6bcffaa05a35b3396708778 src=99 depositNonce=1 gasPrice=15475 INFO[04-05|16:43:11] Submitted proposal execution chain=polygon-edge tx=0xb8f4faa90658f3fa5609f4a88228e6ca4f1dd2d12e0157d84591f7ea38c41df1 src=99 dst=100 nonce=1 gasPrice=15646

cb-sol-cli deposit Logs;

[erc721/deposit] Constructed deposit: [erc721/deposit] Resource Id: 0x000000000000000000000000000000e389d61c11e5fe32ec1735b3cd38c69501 [erc721/deposit] Token Id: 0x90 [erc721/deposit] len(recipient): 20 [erc721/deposit] Recipient: 0x5142C452a671AcbD369Fbf99307e707719C118B3 [erc721/deposit] Raw: 0x000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000145142C452a671AcbD369Fbf99307e707719C118B3 [erc721/deposit] Creating deposit to initiate transfer! Waiting for tx: 0xe937aff4c5c950ec1043ef0ffc3bbff0c457f84d022d3b27f455ff949dc194e1...

vineetaparodkar commented 2 years ago

Fixed with suggestions given in this issue, https://github.com/0xPolygon/polygon-edge/issues/492