common: fix gas fee mismatch before TIPTRC21Fee, close XFN-51 (#1636)

This commit is contained in:
Daniel Liu 2025-11-03 18:54:14 +08:00 committed by benjamin202410
parent d8785b2f45
commit 3aa20f1537
2 changed files with 8 additions and 0 deletions

View file

@ -13,6 +13,8 @@ func GetGasFee(blockNumber, gas uint64) *big.Int {
fee = fee.Mul(fee, GasPrice50x) fee = fee.Mul(fee, GasPrice50x)
} else if blockNumber > TIPTRC21Fee.Uint64() { } else if blockNumber > TIPTRC21Fee.Uint64() {
fee = fee.Mul(fee, TRC21GasPrice) fee = fee.Mul(fee, TRC21GasPrice)
} else {
fee = fee.Mul(fee, TRC21GasPriceBefore)
} }
return fee return fee

View file

@ -30,6 +30,12 @@ var (
) )
func TestFeeTxWithTRC21Token(t *testing.T) { func TestFeeTxWithTRC21Token(t *testing.T) {
oldTRC21GasPriceBefore := new(big.Int).Set(common.TIPTRC21Fee)
defer func() {
common.TIPTRC21Fee = oldTRC21GasPriceBefore
}()
common.TRC21GasPriceBefore = big.NewInt(1)
// init genesis // init genesis
contractBackend := backends.NewXDCSimulatedBackend( contractBackend := backends.NewXDCSimulatedBackend(
types.GenesisAlloc{ types.GenesisAlloc{