icon-project / icon-bridge

The centralized bridge of ICON
Apache License 2.0
21 stars 15 forks source link

gas limit times price should not exceed 1 ether #452

Open manishbista28 opened 2 years ago

manishbista28 commented 2 years ago

Overview

Relay sets a high gas limit (e.g 24000000 for transactions on BSC chain) to invoke handleRelayMessage on a batch of messages. For BSC chain, there is a cap to the maximum value that product of gas price and gas limit can have for a transaction and the cap is 1 ether. So for the current gas limit, maximum gas price that can be set becomes 1e18/24000000 => 41666666666.666664. If relay uses a gas price higher than this, transaction will not succeed. Since relay keeps retrying this same values and cannot succeed, the relay becomes stuck

Transaction with 54 Gwei as Gas Price https://testnet.bscscan.com/tx/0x893e5deb0beef82aa0741e6927b1fafb5cc53a5f108112baa33e2bcb3cfcd8b7

Median Gas price on the block is 54 Gwei

> eth.getBlockByNumber(22703378).transactions.map(t => eth.getTransaction(t).gasPrice)
[54000000001, 54000000001, 54000000001, 53000000001, 0]

BMR Logs

I|06:03:36.423669|0x50|bsc|i2b|tx_sender.go:207 GetMedianGasPriceForBlock(22703378) price: 54000000001 
D|06:03:36.697580|0x50|bsc|i2b|tx_sender.go:266 handleRelayMessage: send tx prev=btp://0x2.icon/cx3fbcd7c25be9aac63bd944a0b8d40becdaa35425
D|06:03:36.697580|hx98|bsc|b2i|rx_receiver.go:272 poll height latest=22703368 next=22703367
D|06:03:37.240604|0x50|bsc|i2b|tx_sender.go:287 handleRelayMessage: send tx error=tx fee (1.30 ether) exceeds the configured cap (1.00 ether)
D|06:03:37.739592|hx98|bsc|b2i|rx_receiver.go:463 block notification height=22703366
D|06:03:37.741698|0x50|relay|i2b|relay.go:215 tx.Send: retry=1 error=tx fee (1.30 ether) exceeds the configured cap (1.00 ether)
D|06:03:37.741778|0x50|bsc|i2b|tx_sender.go:266 handleRelayMessage: send tx prev=btp://0x2.icon/cx3fbcd7c25be9aac63bd944a0b8d40becdaa35425
D|06:03:37.801612|0x50|icon|i2b|rx_receiver.go:367 block notification height=12328073
D|06:03:38.336130|0x50|bsc|i2b|tx_sender.go:287 handleRelayMessage: send tx error=tx fee (1.30 ether) exceeds the configured cap (1.00 ether)
D|06:03:38.725879|hx98|relay|b2i|relay.go:113 relaySignal

Steps to Reproduce

Steps to reproduce the behavior:

  1. Get Median Gas Price from Block 22703378 on bsc testnet
  2. Use this gas price to do transaction while setting the above mentioned gas limit

Expected Behavior

Relay operation should not get stuck.

Additional Context

The issue was seen on privately deployed testnet.

CyrusVorwald commented 2 years ago

Please add the associated sprints, estimate, epics, and releases.