github.com/haliliceylan/bsc@v1.1.10-0.20220501224556-eb78d644ebcb/tests/init.go (about)

     1  // Copyright 2015 The go-ethereum Authors
     2  // This file is part of the go-ethereum library.
     3  //
     4  // The go-ethereum library is free software: you can redistribute it and/or modify
     5  // it under the terms of the GNU Lesser General Public License as published by
     6  // the Free Software Foundation, either version 3 of the License, or
     7  // (at your option) any later version.
     8  //
     9  // The go-ethereum library is distributed in the hope that it will be useful,
    10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  // GNU Lesser General Public License for more details.
    13  //
    14  // You should have received a copy of the GNU Lesser General Public License
    15  // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
    16  
    17  package tests
    18  
    19  import (
    20  	"fmt"
    21  	"math/big"
    22  	"sort"
    23  
    24  	"github.com/ethereum/go-ethereum/params"
    25  )
    26  
    27  // Forks table defines supported forks and their chain config.
    28  var Forks = map[string]*params.ChainConfig{
    29  	"Frontier": {
    30  		ChainID: big.NewInt(1),
    31  	},
    32  	"Homestead": {
    33  		ChainID:        big.NewInt(1),
    34  		HomesteadBlock: big.NewInt(0),
    35  	},
    36  	"EIP150": {
    37  		ChainID:        big.NewInt(1),
    38  		HomesteadBlock: big.NewInt(0),
    39  		EIP150Block:    big.NewInt(0),
    40  	},
    41  	"EIP158": {
    42  		ChainID:        big.NewInt(1),
    43  		HomesteadBlock: big.NewInt(0),
    44  		EIP150Block:    big.NewInt(0),
    45  		EIP155Block:    big.NewInt(0),
    46  		EIP158Block:    big.NewInt(0),
    47  	},
    48  	"Byzantium": {
    49  		ChainID:        big.NewInt(1),
    50  		HomesteadBlock: big.NewInt(0),
    51  		EIP150Block:    big.NewInt(0),
    52  		EIP155Block:    big.NewInt(0),
    53  		EIP158Block:    big.NewInt(0),
    54  		DAOForkBlock:   big.NewInt(0),
    55  		ByzantiumBlock: big.NewInt(0),
    56  	},
    57  	"Constantinople": {
    58  		ChainID:             big.NewInt(1),
    59  		HomesteadBlock:      big.NewInt(0),
    60  		EIP150Block:         big.NewInt(0),
    61  		EIP155Block:         big.NewInt(0),
    62  		EIP158Block:         big.NewInt(0),
    63  		DAOForkBlock:        big.NewInt(0),
    64  		ByzantiumBlock:      big.NewInt(0),
    65  		ConstantinopleBlock: big.NewInt(0),
    66  		PetersburgBlock:     big.NewInt(10000000),
    67  	},
    68  	"ConstantinopleFix": {
    69  		ChainID:             big.NewInt(1),
    70  		HomesteadBlock:      big.NewInt(0),
    71  		EIP150Block:         big.NewInt(0),
    72  		EIP155Block:         big.NewInt(0),
    73  		EIP158Block:         big.NewInt(0),
    74  		DAOForkBlock:        big.NewInt(0),
    75  		ByzantiumBlock:      big.NewInt(0),
    76  		ConstantinopleBlock: big.NewInt(0),
    77  		PetersburgBlock:     big.NewInt(0),
    78  	},
    79  	"Istanbul": {
    80  		ChainID:             big.NewInt(1),
    81  		HomesteadBlock:      big.NewInt(0),
    82  		EIP150Block:         big.NewInt(0),
    83  		EIP155Block:         big.NewInt(0),
    84  		EIP158Block:         big.NewInt(0),
    85  		DAOForkBlock:        big.NewInt(0),
    86  		ByzantiumBlock:      big.NewInt(0),
    87  		ConstantinopleBlock: big.NewInt(0),
    88  		PetersburgBlock:     big.NewInt(0),
    89  		IstanbulBlock:       big.NewInt(0),
    90  	},
    91  	"FrontierToHomesteadAt5": {
    92  		ChainID:        big.NewInt(1),
    93  		HomesteadBlock: big.NewInt(5),
    94  	},
    95  	"HomesteadToEIP150At5": {
    96  		ChainID:        big.NewInt(1),
    97  		HomesteadBlock: big.NewInt(0),
    98  		EIP150Block:    big.NewInt(5),
    99  	},
   100  	"HomesteadToDaoAt5": {
   101  		ChainID:        big.NewInt(1),
   102  		HomesteadBlock: big.NewInt(0),
   103  		DAOForkBlock:   big.NewInt(5),
   104  		DAOForkSupport: true,
   105  	},
   106  	"EIP158ToByzantiumAt5": {
   107  		ChainID:        big.NewInt(1),
   108  		HomesteadBlock: big.NewInt(0),
   109  		EIP150Block:    big.NewInt(0),
   110  		EIP155Block:    big.NewInt(0),
   111  		EIP158Block:    big.NewInt(0),
   112  		ByzantiumBlock: big.NewInt(5),
   113  	},
   114  	"ByzantiumToConstantinopleAt5": {
   115  		ChainID:             big.NewInt(1),
   116  		HomesteadBlock:      big.NewInt(0),
   117  		EIP150Block:         big.NewInt(0),
   118  		EIP155Block:         big.NewInt(0),
   119  		EIP158Block:         big.NewInt(0),
   120  		ByzantiumBlock:      big.NewInt(0),
   121  		ConstantinopleBlock: big.NewInt(5),
   122  	},
   123  	"ByzantiumToConstantinopleFixAt5": {
   124  		ChainID:             big.NewInt(1),
   125  		HomesteadBlock:      big.NewInt(0),
   126  		EIP150Block:         big.NewInt(0),
   127  		EIP155Block:         big.NewInt(0),
   128  		EIP158Block:         big.NewInt(0),
   129  		ByzantiumBlock:      big.NewInt(0),
   130  		ConstantinopleBlock: big.NewInt(5),
   131  		PetersburgBlock:     big.NewInt(5),
   132  	},
   133  	"ConstantinopleFixToIstanbulAt5": {
   134  		ChainID:             big.NewInt(1),
   135  		HomesteadBlock:      big.NewInt(0),
   136  		EIP150Block:         big.NewInt(0),
   137  		EIP155Block:         big.NewInt(0),
   138  		EIP158Block:         big.NewInt(0),
   139  		ByzantiumBlock:      big.NewInt(0),
   140  		ConstantinopleBlock: big.NewInt(0),
   141  		PetersburgBlock:     big.NewInt(0),
   142  		IstanbulBlock:       big.NewInt(5),
   143  	},
   144  	"YOLOv3": {
   145  		ChainID:             big.NewInt(1),
   146  		HomesteadBlock:      big.NewInt(0),
   147  		EIP150Block:         big.NewInt(0),
   148  		EIP155Block:         big.NewInt(0),
   149  		EIP158Block:         big.NewInt(0),
   150  		ByzantiumBlock:      big.NewInt(0),
   151  		ConstantinopleBlock: big.NewInt(0),
   152  		PetersburgBlock:     big.NewInt(0),
   153  		IstanbulBlock:       big.NewInt(0),
   154  		YoloV3Block:         big.NewInt(0),
   155  	},
   156  	// This specification is subject to change, but is for now identical to YOLOv3
   157  	// for cross-client testing purposes
   158  	"Berlin": {
   159  		ChainID:             big.NewInt(1),
   160  		HomesteadBlock:      big.NewInt(0),
   161  		EIP150Block:         big.NewInt(0),
   162  		EIP155Block:         big.NewInt(0),
   163  		EIP158Block:         big.NewInt(0),
   164  		ByzantiumBlock:      big.NewInt(0),
   165  		ConstantinopleBlock: big.NewInt(0),
   166  		PetersburgBlock:     big.NewInt(0),
   167  		IstanbulBlock:       big.NewInt(0),
   168  		BerlinBlock:         big.NewInt(0),
   169  	},
   170  }
   171  
   172  // Returns the set of defined fork names
   173  func AvailableForks() []string {
   174  	var availableForks []string
   175  	for k := range Forks {
   176  		availableForks = append(availableForks, k)
   177  	}
   178  	sort.Strings(availableForks)
   179  	return availableForks
   180  }
   181  
   182  // UnsupportedForkError is returned when a test requests a fork that isn't implemented.
   183  type UnsupportedForkError struct {
   184  	Name string
   185  }
   186  
   187  func (e UnsupportedForkError) Error() string {
   188  	return fmt.Sprintf("unsupported fork %q", e.Name)
   189  }