mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 22:26:42 +00:00
fix sanbox bugs: set mgval to zero (#52)
* set mgval to zero * readd value check * fix eip1559's gasprice
This commit is contained in:
parent
3f71d17360
commit
d62e7c1745
2 changed files with 7 additions and 4 deletions
|
|
@ -195,15 +195,18 @@ func (st *StateTransition) to() common.Address {
|
|||
func (st *StateTransition) buyGas() error {
|
||||
mgval := new(big.Int).SetUint64(st.msg.Gas())
|
||||
mgval = mgval.Mul(mgval, st.gasPrice)
|
||||
if st.evm.Config.PreExec {
|
||||
mgval = big.NewInt(0)
|
||||
}
|
||||
balanceCheck := mgval
|
||||
if st.gasFeeCap != nil {
|
||||
balanceCheck = new(big.Int).SetUint64(st.msg.Gas())
|
||||
balanceCheck = balanceCheck.Mul(balanceCheck, st.gasFeeCap)
|
||||
balanceCheck.Add(balanceCheck, st.value)
|
||||
}
|
||||
if st.evm.Config.PreExec {
|
||||
balanceCheck = big.NewInt(0)
|
||||
}
|
||||
balanceCheck.Add(balanceCheck, st.value)
|
||||
}
|
||||
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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -281,7 +281,7 @@ func (api *PreExecAPI) TraceMany(ctx context.Context, origins []PreArgs) ([]PreR
|
|||
Input: origin.Input,
|
||||
}
|
||||
// Get a new instance of the EVM.
|
||||
msg, err := txArgs.ToMessage(0, nil)
|
||||
msg, err := txArgs.ToMessage(api.e.APIBackend.RPCGasCap(), header.BaseFee)
|
||||
if err != nil {
|
||||
preResList = append(preResList, PreResult{
|
||||
Error: PreError{
|
||||
|
|
|
|||
Loading…
Reference in a new issue