From 3b9eb638a27bff0ce92a69095f0a19fa9492d1bd Mon Sep 17 00:00:00 2001 From: Gary Rong Date: Mon, 11 May 2026 21:37:40 +0800 Subject: [PATCH] core: rename error message --- core/state_processor_test.go | 2 +- core/state_transition.go | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/core/state_processor_test.go b/core/state_processor_test.go index c3d9d64160..2700aed505 100644 --- a/core/state_processor_test.go +++ b/core/state_processor_test.go @@ -229,7 +229,7 @@ func TestStateProcessorErrors(t *testing.T) { txs: []*types.Transaction{ mkDynamicTx(0, common.Address{}, params.TxGas, bigNumber, bigNumber), }, - want: "could not apply tx 0 [0xd82a0c2519acfeac9a948258c47e784acd20651d9d80f9a1c67b4137651c3a24]: gas cost exceeds 256 bits", + want: "could not apply tx 0 [0xd82a0c2519acfeac9a948258c47e784acd20651d9d80f9a1c67b4137651c3a24]: insufficient funds for gas * price + value: address 0x71562b71999873DB5b286dF957af199Ec94617F7 required balance exceeds 256 bits", }, { // ErrMaxInitCodeSizeExceeded txs: []*types.Transaction{ diff --git a/core/state_transition.go b/core/state_transition.go index 8e7903c166..fcd483eeb7 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -18,7 +18,6 @@ package core import ( "bytes" - "errors" "fmt" "math" "math/big" @@ -369,7 +368,7 @@ func (st *stateTransition) buyGas() error { mgval := new(uint256.Int).SetUint64(st.msg.GasLimit) _, overflow := mgval.MulOverflow(mgval, st.msg.GasPrice) if overflow { - return errors.New("gas cost exceeds 256 bits") + return fmt.Errorf("%w: address %v required balance exceeds 256 bits", ErrInsufficientFunds, st.msg.From.Hex()) } balanceCheck := new(uint256.Int).Set(mgval) if st.msg.GasFeeCap != nil { @@ -406,11 +405,11 @@ func (st *stateTransition) buyGas() error { // an excessively large blob base fee and bypass the blob base fee validation. _, overflow = blobFee.MulOverflow(blobFee, blobBaseFee) if overflow { - return errors.New("blobFee exceeds 256 bits") + return fmt.Errorf("%w: address %v required balance exceeds 256 bits", ErrInsufficientFunds, st.msg.From.Hex()) } _, overflow = mgval.AddOverflow(mgval, blobFee) if overflow { - return errors.New("gas cost exceeds 256 bits") + return fmt.Errorf("%w: address %v required balance exceeds 256 bits", ErrInsufficientFunds, st.msg.From.Hex()) } } }