The goal was to setup a bridge between a local Polygon-Edge node and a Substrate node (chainbridge-substrate-chain). Transferring an ERC721 from the Polygon node to Substrate works as expected; the ERC721 is burned from the Polygon side and minted into the desired account on Substrate. However, transferring an ERC721 from Substrate to Polygon causes an "insufficient funds" error, followed by a ChainBridge panic and shutdown.
The Polygon-Edge node premines a large balance to the admin account, and the relayer account.
Expected behavior is that an ERC721 would be successfully transferred from Substrate to the Polygon-Edge node.
Substrate will burn the asset, start cross-chain transfer, bridge handles this transfer and initiates asset minting on the Polygon node.
If the relayer does not have enough funds, it seems that a panic should not happen.
Current Behavior
Transferring ERC721 from Substrate to Polygon causes the following error in the relayer:
WARN[06-22|14:55:37] Voting failed chain=polygon-edge source=1 dest=70 depositNonce=8 gasLimit=8000000 gasPrice=2514619659 err="insufficient funds for gas * price + value"
WARN[06-22|14:55:39] Voting failed chain=polygon-edge source=1 dest=70 depositNonce=8 gasLimit=8000000 gasPrice=2514619659 err="insufficient funds for gas * price + value"
...
EROR[06-22|14:55:57] Submission of Vote transaction failed chain=polygon-edge source=1 dest=70 depositNonce=8
EROR[06-22|14:55:57] FATAL ERROR. Shutting down. system=core err="submission of transaction failed"
Possible Solution
At first, I believed this was due to my configurations being incorrect. So, I increased the premine amount to the admin and relayer account. I also increased the gasLimit and maxGasPrice in the ChainBridge config.json, as well as the block-gas-limit for the Polygon node.
where 0x0D39a7185771653E1e01d25975551bFa9462a677 is the admin account (and validator), and 0x1E5CbE897FA43B49bc772125cb1d2EcB2674Da2E is the relayer account.
The block-gas-limit was also increased to 1000000000.
After following the guide, and generating the genesis config, the node is started. The genesis config is as follows:
The privateKey is of the admin account: 0x0D39a7185771653E1e01d25975551bFa9462a677 (just a local test account, so it does not matter if privateKey is public). The url is of the polygon-edge node. And the chainId is (arbitrarily) set to 70.
Register resource for ERC721 (using deployed contract addresses)
Substrate
On https://polkadot.js.org/apps, on the sudo page, Alice was added a relayer account.
The resource was registered using the following parameters:
The bridge is then started with the following command:
./chainbridge --config config.json --testkey alice --latest
Minting and transferring from Substrate to Polygon
On the Polkadot UI, in the sudo page, using the erc721.mint extrinsic, an ERC721 is minted into Alice's account with the id of 1 (as an example), and metadata of "".
On the Extrinisics page, with Alice as the caller, using example.transferErc721 specified with the following parameters:
ChainBridge commit (or docker tag): built from source: 8cee3ff157224d18ccc214002548aa5bd75f52ef
chainbridge-solidity version: included with chainbridge-deploy
chainbridge-substrate version: built from source, sha: c89d5afea87f502e349aafad4e404f1e4a03b9bb
Go version: go1.17.6 darwin/amd64
The goal was to setup a bridge between a local Polygon-Edge node and a Substrate node (chainbridge-substrate-chain). Transferring an ERC721 from the Polygon node to Substrate works as expected; the ERC721 is burned from the Polygon side and minted into the desired account on Substrate. However, transferring an ERC721 from Substrate to Polygon causes an "insufficient funds" error, followed by a ChainBridge panic and shutdown.
The Polygon-Edge node premines a large balance to the admin account, and the relayer account.
The following guides were followed / referenced:
Expected Behavior
Expected behavior is that an ERC721 would be successfully transferred from Substrate to the Polygon-Edge node. Substrate will burn the asset, start cross-chain transfer, bridge handles this transfer and initiates asset minting on the Polygon node.
If the relayer does not have enough funds, it seems that a panic should not happen.
Current Behavior
Transferring ERC721 from Substrate to Polygon causes the following error in the relayer:
Possible Solution
At first, I believed this was due to my configurations being incorrect. So, I increased the premine amount to the admin and relayer account. I also increased the
gasLimit
andmaxGasPrice
in the ChainBridgeconfig.json
, as well as theblock-gas-limit
for the Polygon node.Steps to Reproduce (for bugs)
Prebuilt release v0.4.1 was used for darwin_amd64 architecture.
When generating the genesis config, premine amounts were specified for the admin account and the relayer account, as shown here:
where
0x0D39a7185771653E1e01d25975551bFa9462a677
is the admin account (and validator), and0x1E5CbE897FA43B49bc772125cb1d2EcB2674Da2E
is the relayer account. The block-gas-limit was also increased to1000000000
.After following the guide, and generating the genesis config, the node is started. The genesis config is as follows:
build
run
Deploy contracts on Polygon-Edge node, and specify relayer account
The privateKey is of the admin account:
0x0D39a7185771653E1e01d25975551bFa9462a677
(just a local test account, so it does not matter if privateKey is public). The url is of the polygon-edge node. And the chainId is (arbitrarily) set to 70.Register resource for ERC721 (using deployed contract addresses)
Polygon
Substrate On https://polkadot.js.org/apps, on the sudo page,
Alice
was added a relayer account. The resource was registered using the following parameters:And lastly, the polygon chain was whitelisted using the chainId of 70.
cb-sol-cli erc721 add-minter \ --url http://localhost:10002 \ --privateKey 0x2a264f9056ed138affcee2b0e6c50dab906c1eeb22bff7975bfdd1719c648823 \ --erc721Address "0xD4Fe45ff74fb4C03E4232791e9e62Be640DB8B8E" \ --minter "0x6D0e1d3238c831A2dc815fB01869EC7e21379DCc"
chainbridge accounts import --privateKey 0x6b5df9abc6a93671769dc45490ed430b70423cfa5e414b452dd278f4959eaae7
The bridge is then started with the following command:
erc721.mint
extrinsic, an ERC721 is minted into Alice's account with the id of1
(as an example), and metadata of""
.On the
Extrinisics
page, with Alice as the caller, usingexample.transferErc721
specified with the following parameters:recipient:
0x0D39a7185771653E1e01d25975551bFa9462a677 // polygon-validator & admin account
tokenId:1
destId:70
The asset is burned from Substrate, and a
chainBridge.NonFungibleTransfer
event is emitted.The bridge terminal output then shows:
Versions
ChainBridge commit (or docker tag): built from source: 8cee3ff157224d18ccc214002548aa5bd75f52ef chainbridge-solidity version: included with chainbridge-deploy chainbridge-substrate version: built from source, sha: c89d5afea87f502e349aafad4e404f1e4a03b9bb Go version: go1.17.6 darwin/amd64