Conversation
dai1975
commented
Jan 30, 2025
- fix price bump bug to set opts.Nonce before GasFeeCalculator#Apply
- check latest(replacing) transaction's gas fee is already high enough
- make IETHClient interface and use it in gas.go and txpool.go for testing
Signed-off-by: Daisuke Kanda <daisuke.kanda@datachain.jp>
Signed-off-by: Daisuke Kanda <daisuke.kanda@datachain.jp>
| gasFeeCap := targetTx.GasFeeCap.ToInt() | ||
| gasTipCap := targetTx.GasTipCap.ToInt() | ||
| gasFeeCap := new(big.Int).Set(targetTx.GasFeeCap.ToInt()) | ||
| gasTipCap := new(big.Int).Set(targetTx.GasTipCap.ToInt()) |
There was a problem hiding this comment.
hexuti.Big.ToInt() returns same pointer of receiver instance and following inclByPercent() overwrite it. This make problems when targetTx object is stored and reused such as testing mock.
Signed-off-by: Daisuke Kanda <daisuke.kanda@datachain.jp>
|
@dai1975 You have replaced the |
|
@dai1975 To easily mock all the functions of the Specifically, |
Signed-off-by: Daisuke Kanda <daisuke.kanda@datachain.jp>
Signed-off-by: Daisuke Kanda <daisuke.kanda@datachain.jp>
Signed-off-by: Daisuke Kanda <daisuke.kanda@datachain.jp>
Signed-off-by: Daisuke Kanda <daisuke.kanda@datachain.jp>
| if err := NewGasFeeCalculator(chain.client, &chain.config).Apply(ctx, txOpts); err != nil { | ||
| return nil, err | ||
| } | ||
|
|
There was a problem hiding this comment.
statement move to fix bug
|
@siburu moved interface definition to ethereum package. |
Signed-off-by: Daisuke Kanda <daisuke.kanda@datachain.jp>
Signed-off-by: Daisuke Kanda <daisuke.kanda@datachain.jp>
pkg/relay/ethereum/gas.go
Outdated
|
|
||
| if oldTx != nil && oldTx.GasFeeCap != nil && oldTx.GasTipCap != nil { | ||
| if oldTx.GasFeeCap.ToInt().Cmp(gasFeeCap) >= 0 && oldTx.GasTipCap.ToInt().Cmp(gasTipCap) >= 0 { | ||
| return fmt.Errorf("old tx's gasFeeCap(%v) and gasTipCap(%v) are higher than suggestion(%v, %v)", oldTx.GasFeeCap.ToInt(), oldTx.GasTipCap.ToInt(), gasFeeCap, gasTipCap) |
There was a problem hiding this comment.
Please fix the error message by replacing higher than with greater than or equal to.
pkg/relay/ethereum/gas_test.go
Outdated
| cli.MockHistoryGasTipCap.SetUint64(99) // lower than 100 | ||
| cli.MockHistoryGasFeeCap.SetUint64(299 - 99) //lower than 300 |
There was a problem hiding this comment.
You should replace 99 and 299 - 99 with 100 and 300 - 100 to test the corner case.
Signed-off-by: Daisuke Kanda <daisuke.kanda@datachain.jp>