mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
fix: Add l1fee to the balanceCheck (#229)
Add l1fee to the balanceCheck Co-authored-by: HAOYUatHZ <haoyu@protonmail.com>
This commit is contained in:
parent
96642f5be6
commit
3c5f532ef3
1 changed files with 6 additions and 0 deletions
|
|
@ -26,6 +26,7 @@ import (
|
|||
"github.com/scroll-tech/go-ethereum/core/types"
|
||||
"github.com/scroll-tech/go-ethereum/core/vm"
|
||||
"github.com/scroll-tech/go-ethereum/crypto/codehash"
|
||||
"github.com/scroll-tech/go-ethereum/log"
|
||||
"github.com/scroll-tech/go-ethereum/params"
|
||||
"github.com/scroll-tech/go-ethereum/rollup/fees"
|
||||
)
|
||||
|
|
@ -207,6 +208,7 @@ func (st *StateTransition) buyGas() error {
|
|||
|
||||
if st.evm.ChainConfig().UsingScroll {
|
||||
// always add l1fee, because all tx are L2-to-L1 ATM
|
||||
log.Debug("Adding L1 fee", "l1_fee", st.l1Fee)
|
||||
mgval = mgval.Add(mgval, st.l1Fee)
|
||||
}
|
||||
|
||||
|
|
@ -215,6 +217,10 @@ func (st *StateTransition) buyGas() error {
|
|||
balanceCheck = new(big.Int).SetUint64(st.msg.Gas())
|
||||
balanceCheck = balanceCheck.Mul(balanceCheck, st.gasFeeCap)
|
||||
balanceCheck.Add(balanceCheck, st.value)
|
||||
if st.evm.ChainConfig().UsingScroll {
|
||||
// always add l1fee, because all tx are L2-to-L1 ATM
|
||||
balanceCheck.Add(balanceCheck, st.l1Fee)
|
||||
}
|
||||
}
|
||||
if have, want := st.state.GetBalance(st.msg.From()), balanceCheck; have.Cmp(want) < 0 {
|
||||
return fmt.Errorf("%w: address %v have %v want %v", ErrInsufficientFunds, st.msg.From().Hex(), have, want)
|
||||
|
|
|
|||
Loading…
Reference in a new issue