From 7c4947a4c5c1e534a162116430f719fbacc16bca Mon Sep 17 00:00:00 2001 From: jsvisa Date: Fri, 28 Jul 2023 17:38:58 +0800 Subject: [PATCH 1/3] core: check excessBlobGas in front Signed-off-by: jsvisa --- core/state_transition.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/state_transition.go b/core/state_transition.go index 6cfe1d9c1a06d..b9ecfb3b94523 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -242,10 +242,6 @@ func (st *StateTransition) buyGas() error { } if st.evm.ChainConfig().IsCancun(st.evm.Context.BlockNumber, st.evm.Context.Time) { if blobGas := st.blobGasUsed(); blobGas > 0 { - if st.evm.Context.ExcessBlobGas == nil { - // programming error - panic("missing field excess data gas") - } // Check that the user has enough funds to cover blobGasUsed * tx.BlobGasFeeCap blobBalanceCheck := new(big.Int).SetUint64(blobGas) blobBalanceCheck.Mul(blobBalanceCheck, st.msg.BlobGasFeeCap) @@ -332,6 +328,10 @@ func (st *StateTransition) preCheck() error { if st.evm.ChainConfig().IsCancun(st.evm.Context.BlockNumber, st.evm.Context.Time) { if st.blobGasUsed() > 0 { + if st.evm.Context.ExcessBlobGas == nil { + // programming error + panic("missing field excess data gas") + } // Check that the user is paying at least the current blob fee blobFee := eip4844.CalcBlobFee(*st.evm.Context.ExcessBlobGas) if st.msg.BlobGasFeeCap.Cmp(blobFee) < 0 { From d3784e17c6081c63a19cfc517cbb79b50196ab39 Mon Sep 17 00:00:00 2001 From: jsvisa Date: Fri, 28 Jul 2023 22:26:28 +0800 Subject: [PATCH 2/3] core: no need to manual panic Signed-off-by: jsvisa --- core/state_transition.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/core/state_transition.go b/core/state_transition.go index b9ecfb3b94523..98a7c256a3746 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -328,11 +328,8 @@ func (st *StateTransition) preCheck() error { if st.evm.ChainConfig().IsCancun(st.evm.Context.BlockNumber, st.evm.Context.Time) { if st.blobGasUsed() > 0 { - if st.evm.Context.ExcessBlobGas == nil { - // programming error - panic("missing field excess data gas") - } // Check that the user is paying at least the current blob fee + // ExcessBlobGas must not be nil, which is checked in eip4844.VerifyEIP4844Header blobFee := eip4844.CalcBlobFee(*st.evm.Context.ExcessBlobGas) if st.msg.BlobGasFeeCap.Cmp(blobFee) < 0 { return fmt.Errorf("%w: address %v have %v want %v", ErrBlobFeeCapTooLow, st.msg.From.Hex(), st.msg.BlobGasFeeCap, blobFee) From 73f39af9968b2c45e48436f7ecbcd4426c794353 Mon Sep 17 00:00:00 2001 From: jsvisa Date: Mon, 31 Jul 2023 14:19:42 +0800 Subject: [PATCH 3/3] core: no comment Signed-off-by: jsvisa --- core/state_transition.go | 1 - 1 file changed, 1 deletion(-) diff --git a/core/state_transition.go b/core/state_transition.go index 98a7c256a3746..13f3f32321c9e 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -329,7 +329,6 @@ func (st *StateTransition) preCheck() error { if st.evm.ChainConfig().IsCancun(st.evm.Context.BlockNumber, st.evm.Context.Time) { if st.blobGasUsed() > 0 { // Check that the user is paying at least the current blob fee - // ExcessBlobGas must not be nil, which is checked in eip4844.VerifyEIP4844Header blobFee := eip4844.CalcBlobFee(*st.evm.Context.ExcessBlobGas) if st.msg.BlobGasFeeCap.Cmp(blobFee) < 0 { return fmt.Errorf("%w: address %v have %v want %v", ErrBlobFeeCapTooLow, st.msg.From.Hex(), st.msg.BlobGasFeeCap, blobFee)