bnb-chain / opbnb

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

depositERC20 infinite standby state

LamKwon opened this issue · comments

I built a local private network based on the tutorial below.
https://docs.bnbchain.org/opbnb-docs/docs/tutorials/running-a-local-development-environment
After that, erc20 deposit was performed, but it was stuck in infinite wait.
Below is the code I wrote and the terminal result window.

**depositERC20 : **

const depositERC20 = async () => {
console.log("Deposit ERC20")
const start = new Date()
console.log(erc20Addrs L1:${erc20Addrs.l1Addr} erc20Addrs L2:${erc20Addrs.l2Addr})
// Need the l2 address to know which bridge is responsible
const allowanceResponse = await crossChainMessenger.approveERC20(
erc20Addrs.l1Addr,
erc20Addrs.l2Addr,
centieth
);
await allowanceResponse.wait()
console.log(Allowance given by tx ${allowanceResponse.hash})
console.log(\tMore info: https://goerli.etherscan.io/tx/${allowanceResponse.hash})
console.log(Time so far ${(new Date() - start) / 1000} seconds)

const response = await crossChainMessenger.depositERC20(
erc20Addrs.l1Addr, erc20Addrs.l2Addr, centieth)
console.log(Deposit transaction hash (on L1): ${response.hash})
console.log(\tMore info: https://goerli.etherscan.io/tx/${response.hash})
await response.wait()
console.log("Waiting for status to change to RELAYED")
console.log(Time so far ${(new Date() - start) / 1000} seconds)
await crossChainMessenger.waitForMessageStatus(response.hash,
optimismSDK.MessageStatus.RELAYED)

await reportERC20Balances()
console.log(depositERC20 took ${(new Date() - start) / 1000} seconds\n\n)
}

**terminal result : **

OUTb on L1:1234 OUTb on L2:
Deposit ERC20
erc20Addrs L1:0x5653E7f599eF8937a7295D727D57a3479F3eaC16 erc20Addrs L2:0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82
Allowance given by tx 0x98a74de56296781156edb9351de8179d987e63c284abe61c649bc91447cfd3ab
More info: https://goerli.etherscan.io/tx/0x98a74de56296781156edb9351de8179d987e63c284abe61c649bc91447cfd3ab
Time so far 4.381 seconds
Deposit transaction hash (on L1): 0xc3d399cc9bbbe716df5f071af41a5ca27dba399e9ef855b47e35aee060cebed9
More info: https://goerli.etherscan.io/tx/0xc3d399cc9bbbe716df5f071af41a5ca27dba399e9ef855b47e35aee060cebed9
Waiting for status to change to RELAYED
Time so far 8.836 seconds

The hash seems to be calculated incorrectly in the code below.
In this part of the code, the normal hash value cannot be calculated, so an infinite wait state is in progress.

fileName :

  • cross-chain-messenger.js

Code :

  • async getMessageReceipt(message) {
    const resolved = await this.toCrossChainMessage(message);
    const messageHash = (0, core_utils_1.hashCrossDomainMessage)(resolved.messageNonce, resolved.sender, resolved.target, resolved.value, resolved.minGasLimit, resolved.message);

resolved Content :

  • {
    direction: 0,
    target: "0x4200000000000000000000000000000000000010",
    sender: "0xA343B1FC2897b8C49A72A9A0B2675cB9c7664e8c",
    message: "0x0166a07a0000000000000000000000000dcd1bf9a1b36ce34237eeafef220932846bcd820000000000000000000000005653e7f599ef8937a7295d727d57a3479f3eac160000000000000000000000000549823b9f738aea5cda099f985c564c20857f470000000000000000000000000549823b9f738aea5cda099f985c564c20857f470000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000",
    messageNonce: {
    _hex: "0x01000000000000000000000000000000000000000000000000000000000002",
    _isBigNumber: true,
    },
    value: {
    _hex: "0x00",
    _isBigNumber: true,
    },
    minGasLimit: {
    _hex: "0x030d40",
    _isBigNumber: true,
    },
    logIndex: 5,
    blockNumber: 291411,
    transactionHash: "0xf257791347e5dd81c381a815c5ee1d12157b7d04845688d2fb964f3343f5f878",
    }

messageHash :

  • "0x0619201d383436cefdcac9150af7f385c749cb69d5e0e1d4e556cff253144f01"

eth :

  • eth.getTransaction("0x0619201d383436cefdcac9150af7f385c749cb69d5e0e1d4e556cff253144f01")
  • null
commented

The waitForMessageStatus function in the SDK heavily relies on the usage of the getLogs API. However, please note that for BSC Testnet and Mainnet, the block range of this API is limited to 5000. Please confirm whether this is the case.

Based on the provided logs, it appears that the deposit transaction on L1 was successful, but the waiting process for the deposit transaction on L1 never completed. There could be several possibilities causing this issue, such as a mismatch in the L1/L2 chain configuration, problems with the op-node or op-geth, and so on.

Since this is your own private network, I am unable to investigate further. I recommend examining the cross-chain mechanism and identifying the exact step at which it halts.

References: