Eip 1884 v3 (#19743)
* core/vm, tests: implement EIP 1884, add support for feature-tests * core/vm: 1884-changes to extcodehash, move selfbalance opcode * tests: fix statetests * core/vm: move constants, address review concerns * core/vm: word formatting Co-Authored-By: Péter Szilágyi <peterke@gmail.com>
This commit is contained in:
committed by
Péter Szilágyi
parent
f3478f2899
commit
3e993ff64a
@ -21,6 +21,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
@ -109,6 +110,29 @@ type stTransactionMarshaling struct {
|
||||
PrivateKey hexutil.Bytes
|
||||
}
|
||||
|
||||
// getVMConfig takes a fork definition and returns a chain config.
|
||||
// The fork definition can be
|
||||
// - a plain forkname, e.g. `Byzantium`,
|
||||
// - a fork basename, and a list of EIPs to enable; e.g. `Byzantium+1884+1283`.
|
||||
func getVMConfig(forkString string) (baseConfig *params.ChainConfig, eips []int, err error) {
|
||||
var (
|
||||
splitForks = strings.Split(forkString, "+")
|
||||
ok bool
|
||||
baseName, eipsStrings = splitForks[0], splitForks[1:]
|
||||
)
|
||||
if baseConfig, ok = Forks[baseName]; !ok {
|
||||
return nil, nil, UnsupportedForkError{baseName}
|
||||
}
|
||||
for _, eip := range eipsStrings {
|
||||
if eipNum, err := strconv.Atoi(eip); err != nil {
|
||||
return nil, nil, fmt.Errorf("syntax error, invalid eip number %v", eipNum)
|
||||
} else {
|
||||
eips = append(eips, eipNum)
|
||||
}
|
||||
}
|
||||
return baseConfig, eips, nil
|
||||
}
|
||||
|
||||
// Subtests returns all valid subtests of the test.
|
||||
func (t *StateTest) Subtests() []StateSubtest {
|
||||
var sub []StateSubtest
|
||||
@ -122,10 +146,11 @@ func (t *StateTest) Subtests() []StateSubtest {
|
||||
|
||||
// Run executes a specific subtest.
|
||||
func (t *StateTest) Run(subtest StateSubtest, vmconfig vm.Config) (*state.StateDB, error) {
|
||||
config, ok := Forks[subtest.Fork]
|
||||
if !ok {
|
||||
config, eips, err := getVMConfig(subtest.Fork)
|
||||
if err != nil {
|
||||
return nil, UnsupportedForkError{subtest.Fork}
|
||||
}
|
||||
vmconfig.ExtraEips = eips
|
||||
block := t.genesis(config).ToBlock(nil)
|
||||
statedb := MakePreState(rawdb.NewMemoryDatabase(), t.json.Pre)
|
||||
|
||||
|
Reference in New Issue
Block a user