mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-17 18:30:45 +00:00
core/vm/runtime: cap regular gas budget at MaxTxGas for Amsterdam (#35301)
This commit is contained in:
parent
6c80ee6c50
commit
896a4ab7c6
1 changed files with 15 additions and 3 deletions
|
|
@ -143,12 +143,16 @@ func Execute(code, input []byte, cfg *Config) ([]byte, *state.StateDB, error) {
|
||||||
cfg.State.CreateAccount(address)
|
cfg.State.CreateAccount(address)
|
||||||
// set the receiver's (the executing contract) code for execution.
|
// set the receiver's (the executing contract) code for execution.
|
||||||
cfg.State.SetCode(address, code, tracing.CodeChangeUnspecified)
|
cfg.State.SetCode(address, code, tracing.CodeChangeUnspecified)
|
||||||
|
limit := cfg.GasLimit
|
||||||
|
if rules.IsAmsterdam {
|
||||||
|
limit = min(cfg.GasLimit, params.MaxTxGas)
|
||||||
|
}
|
||||||
// Call the code with the given configuration.
|
// Call the code with the given configuration.
|
||||||
ret, result, err := vmenv.Call(
|
ret, result, err := vmenv.Call(
|
||||||
cfg.Origin,
|
cfg.Origin,
|
||||||
common.BytesToAddress([]byte("contract")),
|
common.BytesToAddress([]byte("contract")),
|
||||||
input,
|
input,
|
||||||
vm.NewGasBudget(cfg.GasLimit, 0),
|
vm.NewGasBudget(limit, cfg.GasLimit-limit),
|
||||||
uint256.MustFromBig(cfg.Value),
|
uint256.MustFromBig(cfg.Value),
|
||||||
)
|
)
|
||||||
if cfg.EVMConfig.Tracer != nil && cfg.EVMConfig.Tracer.OnTxEnd != nil {
|
if cfg.EVMConfig.Tracer != nil && cfg.EVMConfig.Tracer.OnTxEnd != nil {
|
||||||
|
|
@ -178,11 +182,15 @@ func Create(input []byte, cfg *Config) ([]byte, common.Address, uint64, error) {
|
||||||
// - prepare accessList(post-berlin)
|
// - prepare accessList(post-berlin)
|
||||||
// - reset transient storage(eip 1153)
|
// - reset transient storage(eip 1153)
|
||||||
cfg.State.Prepare(rules, cfg.Origin, cfg.Coinbase, nil, vm.ActivePrecompiles(rules), nil)
|
cfg.State.Prepare(rules, cfg.Origin, cfg.Coinbase, nil, vm.ActivePrecompiles(rules), nil)
|
||||||
|
limit := cfg.GasLimit
|
||||||
|
if rules.IsAmsterdam {
|
||||||
|
limit = min(cfg.GasLimit, params.MaxTxGas)
|
||||||
|
}
|
||||||
// Call the code with the given configuration.
|
// Call the code with the given configuration.
|
||||||
code, address, result, _, err := vmenv.Create(
|
code, address, result, _, err := vmenv.Create(
|
||||||
cfg.Origin,
|
cfg.Origin,
|
||||||
input,
|
input,
|
||||||
vm.NewGasBudget(cfg.GasLimit, 0),
|
vm.NewGasBudget(limit, cfg.GasLimit-limit),
|
||||||
uint256.MustFromBig(cfg.Value),
|
uint256.MustFromBig(cfg.Value),
|
||||||
)
|
)
|
||||||
if cfg.EVMConfig.Tracer != nil && cfg.EVMConfig.Tracer.OnTxEnd != nil {
|
if cfg.EVMConfig.Tracer != nil && cfg.EVMConfig.Tracer.OnTxEnd != nil {
|
||||||
|
|
@ -212,12 +220,16 @@ func Call(address common.Address, input []byte, cfg *Config) ([]byte, uint64, er
|
||||||
// - reset transient storage(eip 1153)
|
// - reset transient storage(eip 1153)
|
||||||
statedb.Prepare(rules, cfg.Origin, cfg.Coinbase, &address, vm.ActivePrecompiles(rules), nil)
|
statedb.Prepare(rules, cfg.Origin, cfg.Coinbase, &address, vm.ActivePrecompiles(rules), nil)
|
||||||
|
|
||||||
|
limit := cfg.GasLimit
|
||||||
|
if rules.IsAmsterdam {
|
||||||
|
limit = min(cfg.GasLimit, params.MaxTxGas)
|
||||||
|
}
|
||||||
// Call the code with the given configuration.
|
// Call the code with the given configuration.
|
||||||
ret, result, err := vmenv.Call(
|
ret, result, err := vmenv.Call(
|
||||||
cfg.Origin,
|
cfg.Origin,
|
||||||
address,
|
address,
|
||||||
input,
|
input,
|
||||||
vm.NewGasBudget(cfg.GasLimit, 0),
|
vm.NewGasBudget(limit, cfg.GasLimit-limit),
|
||||||
uint256.MustFromBig(cfg.Value),
|
uint256.MustFromBig(cfg.Value),
|
||||||
)
|
)
|
||||||
if cfg.EVMConfig.Tracer != nil && cfg.EVMConfig.Tracer.OnTxEnd != nil {
|
if cfg.EVMConfig.Tracer != nil && cfg.EVMConfig.Tracer.OnTxEnd != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue