Skip to content

Commit

Permalink
fix: reset GasFeeCap and GasPremium when replacing message (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
strahe authored Jun 4, 2024
1 parent cd60a36 commit 4452fef
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
6 changes: 3 additions & 3 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ POST /requests/{:id}/speedup
#### 请求参数
| 参数名 || 是否必须 | 说明 |
|-----------|------|------|---------------------------------|
| fee_limit | 1FIL || 允许最大消耗的GAS费用,不传系统自动预估,值越大上链时间越快 |
| 参数名 || 是否必须 | 说明 |
|-----------|------|------|-----------------------|
| fee_limit | 1FIL || 允许最大消耗的GAS费用,不传系统自动预估 |
#### 请求示例
```json
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ POST /requests/{:id}/speedup
> This does not guarantee the message will be on-chain. Check the request status again after a while and try multiple times if needed.
#### Request parameters
| Parameter | Value | Required | Description |
|-----------|-------|----------|----------------------------------------------------------------------------------------------------------------------|
| fee_limit | 1FIL | No | Maximum allowable gas fee; if not provided, the system estimates; the higher the value, the faster the on-chain time |
| Parameter | Value | Required | Description |
|-----------|-------|----------|-------------------------------------------------------------------|
| fee_limit | 1FIL | No | Maximum allowable gas fee; if not provided, the system estimates; |
#### Request Example
```json
Expand Down
6 changes: 4 additions & 2 deletions service.go
Original file line number Diff line number Diff line change
Expand Up @@ -864,14 +864,16 @@ func (s *Service) replaceMessage(ctx context.Context, id uint, mss *api.MessageS

defaultRBF := messagepool.ComputeRBF(msg.GasPremium, cfg.ReplaceByFeeRatio)

msg.GasLimit = 0 // clear gas limit
//msg.GasLimit = 0 // clear gas limit
msg.GasFeeCap = abi.NewTokenAmount(0)
msg.GasPremium = abi.NewTokenAmount(0)
ret, err := s.api.GasEstimateMessageGas(ctx, &msg, mss, types.EmptyTSK)
if err != nil {
return fmt.Errorf("failed to estimate gas values: %w", err)
}
msg.GasPremium = big.Max(ret.GasPremium, defaultRBF)
msg.GasFeeCap = big.Max(ret.GasFeeCap, msg.GasPremium)
msg.GasLimit = ret.GasLimit // set new gas limit
//msg.GasLimit = ret.GasLimit // set new gas limit

mff := func() (abi.TokenAmount, error) {
return abi.TokenAmount(config.DefaultDefaultMaxFee), nil
Expand Down

0 comments on commit 4452fef

Please sign in to comment.