core, all: split vm.Context into BlockContext and TxContext (#21672)
* all: core: split vm.Config into BlockConfig and TxConfig * core: core/vm: reset EVM between tx in block instead of creating new * core/vm: added docs
This commit is contained in:
committed by
GitHub
parent
6f4cccf8d2
commit
2045a2bba3
@ -182,9 +182,10 @@ func (t *StateTest) RunNoVerify(subtest StateSubtest, vmconfig vm.Config, snapsh
|
||||
if err != nil {
|
||||
return nil, nil, common.Hash{}, err
|
||||
}
|
||||
context := core.NewEVMContext(msg, block.Header(), nil, &t.json.Env.Coinbase)
|
||||
txContext := core.NewEVMTxContext(msg)
|
||||
context := core.NewEVMBlockContext(block.Header(), nil, &t.json.Env.Coinbase)
|
||||
context.GetHash = vmTestBlockHash
|
||||
evm := vm.NewEVM(context, statedb, config, vmconfig)
|
||||
evm := vm.NewEVM(context, txContext, statedb, config, vmconfig)
|
||||
|
||||
if config.IsYoloV2(context.BlockNumber) {
|
||||
statedb.AddAddressToAccessList(msg.From())
|
||||
|
@ -138,20 +138,22 @@ func (t *VMTest) newEVM(statedb *state.StateDB, vmconfig vm.Config) *vm.EVM {
|
||||
return core.CanTransfer(db, address, amount)
|
||||
}
|
||||
transfer := func(db vm.StateDB, sender, recipient common.Address, amount *big.Int) {}
|
||||
context := vm.Context{
|
||||
txContext := vm.TxContext{
|
||||
Origin: t.json.Exec.Origin,
|
||||
GasPrice: t.json.Exec.GasPrice,
|
||||
}
|
||||
context := vm.BlockContext{
|
||||
CanTransfer: canTransfer,
|
||||
Transfer: transfer,
|
||||
GetHash: vmTestBlockHash,
|
||||
Origin: t.json.Exec.Origin,
|
||||
Coinbase: t.json.Env.Coinbase,
|
||||
BlockNumber: new(big.Int).SetUint64(t.json.Env.Number),
|
||||
Time: new(big.Int).SetUint64(t.json.Env.Timestamp),
|
||||
GasLimit: t.json.Env.GasLimit,
|
||||
Difficulty: t.json.Env.Difficulty,
|
||||
GasPrice: t.json.Exec.GasPrice,
|
||||
}
|
||||
vmconfig.NoRecursion = true
|
||||
return vm.NewEVM(context, statedb, params.MainnetChainConfig, vmconfig)
|
||||
return vm.NewEVM(context, txContext, statedb, params.MainnetChainConfig, vmconfig)
|
||||
}
|
||||
|
||||
func vmTestBlockHash(n uint64) common.Hash {
|
||||
|
Reference in New Issue
Block a user