cmd,core,eth,params,tests: define yolov3 + enable EIP-2565 (#22213)
Removes the yolov2 definition, adds yolov3, including EIP-2565. This PR also disables some of the erroneously generated blockchain and statetests, and adds the new genesis hash + alloc for yolov3. This PR disables the CLI switches for yolo, since it's not complete until we merge support for 2930.
This commit is contained in:
@ -78,18 +78,23 @@ var PrecompiledContractsIstanbul = map[common.Address]PrecompiledContract{
|
||||
common.BytesToAddress([]byte{9}): &blake2F{},
|
||||
}
|
||||
|
||||
// PrecompiledContractsYoloV2 contains the default set of pre-compiled Ethereum
|
||||
// contracts used in the Yolo v2 test release.
|
||||
var PrecompiledContractsYoloV2 = map[common.Address]PrecompiledContract{
|
||||
common.BytesToAddress([]byte{1}): &ecrecover{},
|
||||
common.BytesToAddress([]byte{2}): &sha256hash{},
|
||||
common.BytesToAddress([]byte{3}): &ripemd160hash{},
|
||||
common.BytesToAddress([]byte{4}): &dataCopy{},
|
||||
common.BytesToAddress([]byte{5}): &bigModExp{eip2565: false},
|
||||
common.BytesToAddress([]byte{6}): &bn256AddIstanbul{},
|
||||
common.BytesToAddress([]byte{7}): &bn256ScalarMulIstanbul{},
|
||||
common.BytesToAddress([]byte{8}): &bn256PairingIstanbul{},
|
||||
common.BytesToAddress([]byte{9}): &blake2F{},
|
||||
// PrecompiledContractsYoloV3 contains the default set of pre-compiled Ethereum
|
||||
// contracts used in the Yolo v3 test release.
|
||||
var PrecompiledContractsYoloV3 = map[common.Address]PrecompiledContract{
|
||||
common.BytesToAddress([]byte{1}): &ecrecover{},
|
||||
common.BytesToAddress([]byte{2}): &sha256hash{},
|
||||
common.BytesToAddress([]byte{3}): &ripemd160hash{},
|
||||
common.BytesToAddress([]byte{4}): &dataCopy{},
|
||||
common.BytesToAddress([]byte{5}): &bigModExp{eip2565: true},
|
||||
common.BytesToAddress([]byte{6}): &bn256AddIstanbul{},
|
||||
common.BytesToAddress([]byte{7}): &bn256ScalarMulIstanbul{},
|
||||
common.BytesToAddress([]byte{8}): &bn256PairingIstanbul{},
|
||||
common.BytesToAddress([]byte{9}): &blake2F{},
|
||||
}
|
||||
|
||||
// PrecompiledContractsBLS contains the set of pre-compiled Ethereum
|
||||
// contracts specified in EIP-2537. These are exported for testing purposes.
|
||||
var PrecompiledContractsBLS = map[common.Address]PrecompiledContract{
|
||||
common.BytesToAddress([]byte{10}): &bls12381G1Add{},
|
||||
common.BytesToAddress([]byte{11}): &bls12381G1Mul{},
|
||||
common.BytesToAddress([]byte{12}): &bls12381G1MultiExp{},
|
||||
@ -102,7 +107,7 @@ var PrecompiledContractsYoloV2 = map[common.Address]PrecompiledContract{
|
||||
}
|
||||
|
||||
var (
|
||||
PrecompiledAddressesYoloV2 []common.Address
|
||||
PrecompiledAddressesYoloV3 []common.Address
|
||||
PrecompiledAddressesIstanbul []common.Address
|
||||
PrecompiledAddressesByzantium []common.Address
|
||||
PrecompiledAddressesHomestead []common.Address
|
||||
@ -118,8 +123,8 @@ func init() {
|
||||
for k := range PrecompiledContractsIstanbul {
|
||||
PrecompiledAddressesIstanbul = append(PrecompiledAddressesIstanbul, k)
|
||||
}
|
||||
for k := range PrecompiledContractsYoloV2 {
|
||||
PrecompiledAddressesYoloV2 = append(PrecompiledAddressesYoloV2, k)
|
||||
for k := range PrecompiledContractsYoloV3 {
|
||||
PrecompiledAddressesYoloV3 = append(PrecompiledAddressesYoloV3, k)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,8 +46,8 @@ type (
|
||||
// configuration
|
||||
func (evm *EVM) ActivePrecompiles() []common.Address {
|
||||
switch {
|
||||
case evm.chainRules.IsYoloV2:
|
||||
return PrecompiledAddressesYoloV2
|
||||
case evm.chainRules.IsYoloV3:
|
||||
return PrecompiledAddressesYoloV3
|
||||
case evm.chainRules.IsIstanbul:
|
||||
return PrecompiledAddressesIstanbul
|
||||
case evm.chainRules.IsByzantium:
|
||||
@ -60,8 +60,8 @@ func (evm *EVM) ActivePrecompiles() []common.Address {
|
||||
func (evm *EVM) precompile(addr common.Address) (PrecompiledContract, bool) {
|
||||
var precompiles map[common.Address]PrecompiledContract
|
||||
switch {
|
||||
case evm.chainRules.IsYoloV2:
|
||||
precompiles = PrecompiledContractsYoloV2
|
||||
case evm.chainRules.IsYoloV3:
|
||||
precompiles = PrecompiledContractsYoloV3
|
||||
case evm.chainRules.IsIstanbul:
|
||||
precompiles = PrecompiledContractsIstanbul
|
||||
case evm.chainRules.IsByzantium:
|
||||
@ -446,7 +446,7 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64,
|
||||
evm.StateDB.SetNonce(caller.Address(), nonce+1)
|
||||
// We add this to the access list _before_ taking a snapshot. Even if the creation fails,
|
||||
// the access-list change should not be rolled back
|
||||
if evm.chainRules.IsYoloV2 {
|
||||
if evm.chainRules.IsYoloV3 {
|
||||
evm.StateDB.AddAddressToAccessList(address)
|
||||
}
|
||||
// Ensure there's no existing contract already at the designated address
|
||||
|
@ -99,8 +99,8 @@ func NewEVMInterpreter(evm *EVM, cfg Config) *EVMInterpreter {
|
||||
if cfg.JumpTable[STOP] == nil {
|
||||
var jt JumpTable
|
||||
switch {
|
||||
case evm.chainRules.IsYoloV2:
|
||||
jt = yoloV2InstructionSet
|
||||
case evm.chainRules.IsYoloV3:
|
||||
jt = yoloV3InstructionSet
|
||||
case evm.chainRules.IsIstanbul:
|
||||
jt = istanbulInstructionSet
|
||||
case evm.chainRules.IsConstantinople:
|
||||
|
@ -56,16 +56,16 @@ var (
|
||||
byzantiumInstructionSet = newByzantiumInstructionSet()
|
||||
constantinopleInstructionSet = newConstantinopleInstructionSet()
|
||||
istanbulInstructionSet = newIstanbulInstructionSet()
|
||||
yoloV2InstructionSet = newYoloV2InstructionSet()
|
||||
yoloV3InstructionSet = newYoloV3InstructionSet()
|
||||
)
|
||||
|
||||
// JumpTable contains the EVM opcodes supported at a given fork.
|
||||
type JumpTable [256]*operation
|
||||
|
||||
// newYoloV2InstructionSet creates an instructionset containing
|
||||
// newYoloV3InstructionSet creates an instructionset containing
|
||||
// - "EIP-2315: Simple Subroutines"
|
||||
// - "EIP-2929: Gas cost increases for state access opcodes"
|
||||
func newYoloV2InstructionSet() JumpTable {
|
||||
func newYoloV3InstructionSet() JumpTable {
|
||||
instructionSet := newIstanbulInstructionSet()
|
||||
enable2315(&instructionSet) // Subroutines - https://eips.ethereum.org/EIPS/eip-2315
|
||||
enable2929(&instructionSet) // Access lists for trie accesses https://eips.ethereum.org/EIPS/eip-2929
|
||||
|
@ -65,7 +65,7 @@ func setDefaults(cfg *Config) {
|
||||
PetersburgBlock: new(big.Int),
|
||||
IstanbulBlock: new(big.Int),
|
||||
MuirGlacierBlock: new(big.Int),
|
||||
YoloV2Block: nil,
|
||||
YoloV3Block: nil,
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,7 +113,7 @@ func Execute(code, input []byte, cfg *Config) ([]byte, *state.StateDB, error) {
|
||||
vmenv = NewEnv(cfg)
|
||||
sender = vm.AccountRef(cfg.Origin)
|
||||
)
|
||||
if cfg.ChainConfig.IsYoloV2(vmenv.Context.BlockNumber) {
|
||||
if cfg.ChainConfig.IsYoloV3(vmenv.Context.BlockNumber) {
|
||||
cfg.State.AddAddressToAccessList(cfg.Origin)
|
||||
cfg.State.AddAddressToAccessList(address)
|
||||
for _, addr := range vmenv.ActivePrecompiles() {
|
||||
@ -149,7 +149,7 @@ func Create(input []byte, cfg *Config) ([]byte, common.Address, uint64, error) {
|
||||
vmenv = NewEnv(cfg)
|
||||
sender = vm.AccountRef(cfg.Origin)
|
||||
)
|
||||
if cfg.ChainConfig.IsYoloV2(vmenv.Context.BlockNumber) {
|
||||
if cfg.ChainConfig.IsYoloV3(vmenv.Context.BlockNumber) {
|
||||
cfg.State.AddAddressToAccessList(cfg.Origin)
|
||||
for _, addr := range vmenv.ActivePrecompiles() {
|
||||
cfg.State.AddAddressToAccessList(addr)
|
||||
@ -177,7 +177,7 @@ func Call(address common.Address, input []byte, cfg *Config) ([]byte, uint64, er
|
||||
vmenv := NewEnv(cfg)
|
||||
|
||||
sender := cfg.State.GetOrNewStateObject(cfg.Origin)
|
||||
if cfg.ChainConfig.IsYoloV2(vmenv.Context.BlockNumber) {
|
||||
if cfg.ChainConfig.IsYoloV3(vmenv.Context.BlockNumber) {
|
||||
cfg.State.AddAddressToAccessList(cfg.Origin)
|
||||
cfg.State.AddAddressToAccessList(address)
|
||||
for _, addr := range vmenv.ActivePrecompiles() {
|
||||
|
Reference in New Issue
Block a user