gitee.com/liu-zhao234568/cntest@v1.0.0/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  	"gitee.com/liu-zhao234568/cntest/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  	"Berlin": {
   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  		BerlinBlock:         big.NewInt(0),
   155  	},
   156  	"BerlinToLondonAt5": {
   157  		ChainID:             big.NewInt(1),
   158  		HomesteadBlock:      big.NewInt(0),
   159  		EIP150Block:         big.NewInt(0),
   160  		EIP155Block:         big.NewInt(0),
   161  		EIP158Block:         big.NewInt(0),
   162  		ByzantiumBlock:      big.NewInt(0),
   163  		ConstantinopleBlock: big.NewInt(0),
   164  		PetersburgBlock:     big.NewInt(0),
   165  		IstanbulBlock:       big.NewInt(0),
   166  		BerlinBlock:         big.NewInt(0),
   167  		LondonBlock:         big.NewInt(5),
   168  	},
   169  	"London": {
   170  		ChainID:             big.NewInt(1),
   171  		HomesteadBlock:      big.NewInt(0),
   172  		EIP150Block:         big.NewInt(0),
   173  		EIP155Block:         big.NewInt(0),
   174  		EIP158Block:         big.NewInt(0),
   175  		ByzantiumBlock:      big.NewInt(0),
   176  		ConstantinopleBlock: big.NewInt(0),
   177  		PetersburgBlock:     big.NewInt(0),
   178  		IstanbulBlock:       big.NewInt(0),
   179  		BerlinBlock:         big.NewInt(0),
   180  		LondonBlock:         big.NewInt(0),
   181  	},
   182  	"Aleut": {
   183  		ChainID:             big.NewInt(1),
   184  		HomesteadBlock:      big.NewInt(0),
   185  		EIP150Block:         big.NewInt(0),
   186  		EIP155Block:         big.NewInt(0),
   187  		EIP158Block:         big.NewInt(0),
   188  		ByzantiumBlock:      big.NewInt(0),
   189  		ConstantinopleBlock: big.NewInt(0),
   190  		PetersburgBlock:     big.NewInt(0),
   191  		IstanbulBlock:       big.NewInt(0),
   192  		BerlinBlock:         big.NewInt(0),
   193  		LondonBlock:         big.NewInt(0),
   194  	},
   195  }
   196  
   197  // Returns the set of defined fork names
   198  func AvailableForks() []string {
   199  	var availableForks []string
   200  	for k := range Forks {
   201  		availableForks = append(availableForks, k)
   202  	}
   203  	sort.Strings(availableForks)
   204  	return availableForks
   205  }
   206  
   207  // UnsupportedForkError is returned when a test requests a fork that isn't implemented.
   208  type UnsupportedForkError struct {
   209  	Name string
   210  }
   211  
   212  func (e UnsupportedForkError) Error() string {
   213  	return fmt.Sprintf("unsupported fork %q", e.Name)
   214  }