From 1a1c1a471804a5fe11d0b895b6278e4f419b6f2a Mon Sep 17 00:00:00 2001 From: rrhlrmrr Date: Tue, 22 Apr 2025 23:43:18 +0900 Subject: [PATCH] Reflect PR comments --- core/types/transaction.go | 18 +++++------------- core/types/transaction_test.go | 4 ++-- eth/tracers/js/goja.go | 3 ++- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/core/types/transaction.go b/core/types/transaction.go index dbed3751d5..05ff14ff31 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -356,11 +356,11 @@ func (tx *Transaction) GasTipCapIntCmp(other *big.Int) int { // the actual negative value, _and_ ErrGasFeeCapTooLow func (tx *Transaction) EffectiveGasTip(baseFee *big.Int) (*big.Int, error) { dst := new(big.Int) - err := tx.EffectiveGasTipInto(dst, baseFee) + err := tx.effectiveGasTipInto(dst, baseFee) return dst, err } -func (tx *Transaction) EffectiveGasTipInto(dst *big.Int, baseFee *big.Int) error { +func (tx *Transaction) effectiveGasTipInto(dst *big.Int, baseFee *big.Int) error { if baseFee == nil { dst.Set(tx.inner.gasTipCap()) return nil @@ -380,14 +380,6 @@ func (tx *Transaction) EffectiveGasTipInto(dst *big.Int, baseFee *big.Int) error return err } -// EffectiveGasTipValue is identical to EffectiveGasTip, but does not return an -// error in case the effective gasTipCap is negative -func (tx *Transaction) EffectiveGasTipValue(baseFee *big.Int) *big.Int { - dst := new(big.Int) - tx.EffectiveGasTipInto(dst, baseFee) - return dst -} - // EffectiveGasTipCmp compares the effective gasTipCap of two transactions assuming the given base fee. func (tx *Transaction) EffectiveGasTipCmp(other *Transaction, baseFee *big.Int) int { if baseFee == nil { @@ -395,8 +387,8 @@ func (tx *Transaction) EffectiveGasTipCmp(other *Transaction, baseFee *big.Int) } txTip := new(big.Int) otherTip := new(big.Int) - tx.EffectiveGasTipInto(txTip, baseFee) - other.EffectiveGasTipInto(otherTip, baseFee) + tx.effectiveGasTipInto(txTip, baseFee) + other.effectiveGasTipInto(otherTip, baseFee) return txTip.Cmp(otherTip) } @@ -406,7 +398,7 @@ func (tx *Transaction) EffectiveGasTipIntCmp(other *big.Int, baseFee *big.Int) i return tx.GasTipCapIntCmp(other) } txTip := new(big.Int) - tx.EffectiveGasTipInto(txTip, baseFee) + tx.effectiveGasTipInto(txTip, baseFee) return txTip.Cmp(other) } diff --git a/core/types/transaction_test.go b/core/types/transaction_test.go index 249e18eb72..79100ad535 100644 --- a/core/types/transaction_test.go +++ b/core/types/transaction_test.go @@ -625,7 +625,7 @@ func BenchmarkEffectiveGasTip(b *testing.B) { b.ReportAllocs() dst := new(big.Int) for i := 0; i < b.N; i++ { - err := tx.EffectiveGasTipInto(dst, baseFee) + err := tx.effectiveGasTipInto(dst, baseFee) if err != nil { b.Fatal(err) } @@ -675,7 +675,7 @@ func TestEffectiveGasTipInto(t *testing.T) { // Get result from new method dst := new(big.Int) - newErr := tx.EffectiveGasTipInto(dst, baseFee) + newErr := tx.effectiveGasTipInto(dst, baseFee) // Compare results if (origErr != nil) != (newErr != nil) { diff --git a/eth/tracers/js/goja.go b/eth/tracers/js/goja.go index 227ea57226..d1e65bf7f4 100644 --- a/eth/tracers/js/goja.go +++ b/eth/tracers/js/goja.go @@ -260,7 +260,8 @@ func (t *jsTracer) OnTxStart(env *tracing.VMContext, tx *types.Transaction, from t.activePrecompiles = vm.ActivePrecompiles(rules) t.ctx["block"] = t.vm.ToValue(t.env.BlockNumber.Uint64()) t.ctx["gas"] = t.vm.ToValue(tx.Gas()) - gasPriceBig, err := t.toBig(t.vm, tx.EffectiveGasTipValue(env.BaseFee).String()) + gasTip, _ := tx.EffectiveGasTip(env.BaseFee) + gasPriceBig, err := t.toBig(t.vm, gasTip.String()) if err != nil { t.err = err return