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

The CLI (cb-sol-cli admin withdraw) doesn't actually withdraw fees #758

Closed ws4charlie closed 2 years ago

ws4charlie commented 2 years ago

I am trying to bridge 2 Ethereum chains and came across below fee withdraw issue.

step-0: setup bridges properly on both home chain and destination chain. step-1: Set any amount of fee(2 tokens in below case) using below command

cb-sol-cli --url $SRC_GATEWAY --privateKey $SRC_PK --gasPrice 10000000000 admin set-fee \
    --bridge $SRC_BRIDGE \
    --fee 20000000000000000000

step-2: Trigger a deposit (e.g. 10 tokens) transaction on the SRC_BRIDGE contract and wait for transaction to finalize. step-3: We'll see the balance of bridge as 20 because the fee was set to 20. step-4: Try and withdraw collected fee from the bridge using below command

cb-sol-cli --url $SRC_GATEWAY --privateKey $SRC_ADMIN_PK --gasPrice 10000000000 admin withdraw \
    --bridge $SRC_BRIDGE \
    --handler $SRC_HANDLER \
    --tokenContract $SRC_TOKEN \
    --recipient $RECIPIENT_ADDRESS \
    --amountOrId 2000000000000000000

step-5: The withdraw will fail because it actually tried to withdraw 20 token from the HANDLER(having only 10 in its balance) instead of BRIDGE contract. The behaviour is different from the description of the CLI below. image

Expected Behavior

cb-sol-cli admin withdraw is supposed to withdraw the fee collected instead of from HANDLER contract. I'm curious if there is a way to withdraw the fee back? What's the correct command/parameter?

Versions

ChainBridge commit (or docker tag): v1.1.5 chainbridge-deploy: master chainbridge-solidity version: any chainbridge-substrate version: None Go version: go1.15.7

P1sar commented 2 years ago

Hey @ws4charlie, sorry for the long wait response! Definitely, there is a mistake in the description because adminWithdraw withdraws funds from Handlers (liquidity). In order to withdraw collected fees (that are collected on Bridge smart contract), you need to use https://github.com/ChainSafe/chainbridge-solidity/blob/v1.0.1/contracts/Bridge.sol#L425. Unfortunately, looks like, this method is not implemented in JS cli. Also, we are not going to support this version of chainbridge and JS CLI, right now we are focused on the new version https://github.com/ChainSafe/chainbridge-core that includes built-in CLI. But you are free to create PR with this method. Thank you for your question!