github.com/ethereum/go-ethereum@v1.14.3/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  func u64(val uint64) *uint64 { return &val }
    28  
    29  // Forks table defines supported forks and their chain config.
    30  var Forks = map[string]*params.ChainConfig{
    31  	"Frontier": {
    32  		ChainID: big.NewInt(1),
    33  	},
    34  	"Homestead": {
    35  		ChainID:        big.NewInt(1),
    36  		HomesteadBlock: big.NewInt(0),
    37  	},
    38  	"EIP150": {
    39  		ChainID:        big.NewInt(1),
    40  		HomesteadBlock: big.NewInt(0),
    41  		EIP150Block:    big.NewInt(0),
    42  	},
    43  	"EIP158": {
    44  		ChainID:        big.NewInt(1),
    45  		HomesteadBlock: big.NewInt(0),
    46  		EIP150Block:    big.NewInt(0),
    47  		EIP155Block:    big.NewInt(0),
    48  		EIP158Block:    big.NewInt(0),
    49  	},
    50  	"Byzantium": {
    51  		ChainID:        big.NewInt(1),
    52  		HomesteadBlock: big.NewInt(0),
    53  		EIP150Block:    big.NewInt(0),
    54  		EIP155Block:    big.NewInt(0),
    55  		EIP158Block:    big.NewInt(0),
    56  		DAOForkBlock:   big.NewInt(0),
    57  		ByzantiumBlock: big.NewInt(0),
    58  	},
    59  	"Constantinople": {
    60  		ChainID:             big.NewInt(1),
    61  		HomesteadBlock:      big.NewInt(0),
    62  		EIP150Block:         big.NewInt(0),
    63  		EIP155Block:         big.NewInt(0),
    64  		EIP158Block:         big.NewInt(0),
    65  		DAOForkBlock:        big.NewInt(0),
    66  		ByzantiumBlock:      big.NewInt(0),
    67  		ConstantinopleBlock: big.NewInt(0),
    68  		PetersburgBlock:     big.NewInt(10000000),
    69  	},
    70  	"ConstantinopleFix": {
    71  		ChainID:             big.NewInt(1),
    72  		HomesteadBlock:      big.NewInt(0),
    73  		EIP150Block:         big.NewInt(0),
    74  		EIP155Block:         big.NewInt(0),
    75  		EIP158Block:         big.NewInt(0),
    76  		DAOForkBlock:        big.NewInt(0),
    77  		ByzantiumBlock:      big.NewInt(0),
    78  		ConstantinopleBlock: big.NewInt(0),
    79  		PetersburgBlock:     big.NewInt(0),
    80  	},
    81  	"Istanbul": {
    82  		ChainID:             big.NewInt(1),
    83  		HomesteadBlock:      big.NewInt(0),
    84  		EIP150Block:         big.NewInt(0),
    85  		EIP155Block:         big.NewInt(0),
    86  		EIP158Block:         big.NewInt(0),
    87  		DAOForkBlock:        big.NewInt(0),
    88  		ByzantiumBlock:      big.NewInt(0),
    89  		ConstantinopleBlock: big.NewInt(0),
    90  		PetersburgBlock:     big.NewInt(0),
    91  		IstanbulBlock:       big.NewInt(0),
    92  	},
    93  	"MuirGlacier": {
    94  		ChainID:             big.NewInt(1),
    95  		HomesteadBlock:      big.NewInt(0),
    96  		EIP150Block:         big.NewInt(0),
    97  		EIP155Block:         big.NewInt(0),
    98  		EIP158Block:         big.NewInt(0),
    99  		DAOForkBlock:        big.NewInt(0),
   100  		ByzantiumBlock:      big.NewInt(0),
   101  		ConstantinopleBlock: big.NewInt(0),
   102  		PetersburgBlock:     big.NewInt(0),
   103  		IstanbulBlock:       big.NewInt(0),
   104  		MuirGlacierBlock:    big.NewInt(0),
   105  	},
   106  	"FrontierToHomesteadAt5": {
   107  		ChainID:        big.NewInt(1),
   108  		HomesteadBlock: big.NewInt(5),
   109  	},
   110  	"HomesteadToEIP150At5": {
   111  		ChainID:        big.NewInt(1),
   112  		HomesteadBlock: big.NewInt(0),
   113  		EIP150Block:    big.NewInt(5),
   114  	},
   115  	"HomesteadToDaoAt5": {
   116  		ChainID:        big.NewInt(1),
   117  		HomesteadBlock: big.NewInt(0),
   118  		DAOForkBlock:   big.NewInt(5),
   119  		DAOForkSupport: true,
   120  	},
   121  	"EIP158ToByzantiumAt5": {
   122  		ChainID:        big.NewInt(1),
   123  		HomesteadBlock: big.NewInt(0),
   124  		EIP150Block:    big.NewInt(0),
   125  		EIP155Block:    big.NewInt(0),
   126  		EIP158Block:    big.NewInt(0),
   127  		ByzantiumBlock: big.NewInt(5),
   128  	},
   129  	"ByzantiumToConstantinopleAt5": {
   130  		ChainID:             big.NewInt(1),
   131  		HomesteadBlock:      big.NewInt(0),
   132  		EIP150Block:         big.NewInt(0),
   133  		EIP155Block:         big.NewInt(0),
   134  		EIP158Block:         big.NewInt(0),
   135  		ByzantiumBlock:      big.NewInt(0),
   136  		ConstantinopleBlock: big.NewInt(5),
   137  	},
   138  	"ByzantiumToConstantinopleFixAt5": {
   139  		ChainID:             big.NewInt(1),
   140  		HomesteadBlock:      big.NewInt(0),
   141  		EIP150Block:         big.NewInt(0),
   142  		EIP155Block:         big.NewInt(0),
   143  		EIP158Block:         big.NewInt(0),
   144  		ByzantiumBlock:      big.NewInt(0),
   145  		ConstantinopleBlock: big.NewInt(5),
   146  		PetersburgBlock:     big.NewInt(5),
   147  	},
   148  	"ConstantinopleFixToIstanbulAt5": {
   149  		ChainID:             big.NewInt(1),
   150  		HomesteadBlock:      big.NewInt(0),
   151  		EIP150Block:         big.NewInt(0),
   152  		EIP155Block:         big.NewInt(0),
   153  		EIP158Block:         big.NewInt(0),
   154  		ByzantiumBlock:      big.NewInt(0),
   155  		ConstantinopleBlock: big.NewInt(0),
   156  		PetersburgBlock:     big.NewInt(0),
   157  		IstanbulBlock:       big.NewInt(5),
   158  	},
   159  	"Berlin": {
   160  		ChainID:             big.NewInt(1),
   161  		HomesteadBlock:      big.NewInt(0),
   162  		EIP150Block:         big.NewInt(0),
   163  		EIP155Block:         big.NewInt(0),
   164  		EIP158Block:         big.NewInt(0),
   165  		ByzantiumBlock:      big.NewInt(0),
   166  		ConstantinopleBlock: big.NewInt(0),
   167  		PetersburgBlock:     big.NewInt(0),
   168  		IstanbulBlock:       big.NewInt(0),
   169  		MuirGlacierBlock:    big.NewInt(0),
   170  		BerlinBlock:         big.NewInt(0),
   171  	},
   172  	"BerlinToLondonAt5": {
   173  		ChainID:             big.NewInt(1),
   174  		HomesteadBlock:      big.NewInt(0),
   175  		EIP150Block:         big.NewInt(0),
   176  		EIP155Block:         big.NewInt(0),
   177  		EIP158Block:         big.NewInt(0),
   178  		ByzantiumBlock:      big.NewInt(0),
   179  		ConstantinopleBlock: big.NewInt(0),
   180  		PetersburgBlock:     big.NewInt(0),
   181  		IstanbulBlock:       big.NewInt(0),
   182  		MuirGlacierBlock:    big.NewInt(0),
   183  		BerlinBlock:         big.NewInt(0),
   184  		LondonBlock:         big.NewInt(5),
   185  	},
   186  	"London": {
   187  		ChainID:             big.NewInt(1),
   188  		HomesteadBlock:      big.NewInt(0),
   189  		EIP150Block:         big.NewInt(0),
   190  		EIP155Block:         big.NewInt(0),
   191  		EIP158Block:         big.NewInt(0),
   192  		ByzantiumBlock:      big.NewInt(0),
   193  		ConstantinopleBlock: big.NewInt(0),
   194  		PetersburgBlock:     big.NewInt(0),
   195  		IstanbulBlock:       big.NewInt(0),
   196  		MuirGlacierBlock:    big.NewInt(0),
   197  		BerlinBlock:         big.NewInt(0),
   198  		LondonBlock:         big.NewInt(0),
   199  	},
   200  	"ArrowGlacier": {
   201  		ChainID:             big.NewInt(1),
   202  		HomesteadBlock:      big.NewInt(0),
   203  		EIP150Block:         big.NewInt(0),
   204  		EIP155Block:         big.NewInt(0),
   205  		EIP158Block:         big.NewInt(0),
   206  		ByzantiumBlock:      big.NewInt(0),
   207  		ConstantinopleBlock: big.NewInt(0),
   208  		PetersburgBlock:     big.NewInt(0),
   209  		IstanbulBlock:       big.NewInt(0),
   210  		MuirGlacierBlock:    big.NewInt(0),
   211  		BerlinBlock:         big.NewInt(0),
   212  		LondonBlock:         big.NewInt(0),
   213  		ArrowGlacierBlock:   big.NewInt(0),
   214  	},
   215  	"ArrowGlacierToMergeAtDiffC0000": {
   216  		ChainID:                 big.NewInt(1),
   217  		HomesteadBlock:          big.NewInt(0),
   218  		EIP150Block:             big.NewInt(0),
   219  		EIP155Block:             big.NewInt(0),
   220  		EIP158Block:             big.NewInt(0),
   221  		ByzantiumBlock:          big.NewInt(0),
   222  		ConstantinopleBlock:     big.NewInt(0),
   223  		PetersburgBlock:         big.NewInt(0),
   224  		IstanbulBlock:           big.NewInt(0),
   225  		MuirGlacierBlock:        big.NewInt(0),
   226  		BerlinBlock:             big.NewInt(0),
   227  		LondonBlock:             big.NewInt(0),
   228  		ArrowGlacierBlock:       big.NewInt(0),
   229  		GrayGlacierBlock:        big.NewInt(0),
   230  		MergeNetsplitBlock:      big.NewInt(0),
   231  		TerminalTotalDifficulty: big.NewInt(0xC0000),
   232  	},
   233  	"GrayGlacier": {
   234  		ChainID:             big.NewInt(1),
   235  		HomesteadBlock:      big.NewInt(0),
   236  		EIP150Block:         big.NewInt(0),
   237  		EIP155Block:         big.NewInt(0),
   238  		EIP158Block:         big.NewInt(0),
   239  		ByzantiumBlock:      big.NewInt(0),
   240  		ConstantinopleBlock: big.NewInt(0),
   241  		PetersburgBlock:     big.NewInt(0),
   242  		IstanbulBlock:       big.NewInt(0),
   243  		MuirGlacierBlock:    big.NewInt(0),
   244  		BerlinBlock:         big.NewInt(0),
   245  		LondonBlock:         big.NewInt(0),
   246  		ArrowGlacierBlock:   big.NewInt(0),
   247  		GrayGlacierBlock:    big.NewInt(0),
   248  	},
   249  	"Merge": {
   250  		ChainID:                 big.NewInt(1),
   251  		HomesteadBlock:          big.NewInt(0),
   252  		EIP150Block:             big.NewInt(0),
   253  		EIP155Block:             big.NewInt(0),
   254  		EIP158Block:             big.NewInt(0),
   255  		ByzantiumBlock:          big.NewInt(0),
   256  		ConstantinopleBlock:     big.NewInt(0),
   257  		PetersburgBlock:         big.NewInt(0),
   258  		IstanbulBlock:           big.NewInt(0),
   259  		MuirGlacierBlock:        big.NewInt(0),
   260  		BerlinBlock:             big.NewInt(0),
   261  		LondonBlock:             big.NewInt(0),
   262  		ArrowGlacierBlock:       big.NewInt(0),
   263  		MergeNetsplitBlock:      big.NewInt(0),
   264  		TerminalTotalDifficulty: big.NewInt(0),
   265  	},
   266  	"Shanghai": {
   267  		ChainID:                 big.NewInt(1),
   268  		HomesteadBlock:          big.NewInt(0),
   269  		EIP150Block:             big.NewInt(0),
   270  		EIP155Block:             big.NewInt(0),
   271  		EIP158Block:             big.NewInt(0),
   272  		ByzantiumBlock:          big.NewInt(0),
   273  		ConstantinopleBlock:     big.NewInt(0),
   274  		PetersburgBlock:         big.NewInt(0),
   275  		IstanbulBlock:           big.NewInt(0),
   276  		MuirGlacierBlock:        big.NewInt(0),
   277  		BerlinBlock:             big.NewInt(0),
   278  		LondonBlock:             big.NewInt(0),
   279  		ArrowGlacierBlock:       big.NewInt(0),
   280  		MergeNetsplitBlock:      big.NewInt(0),
   281  		TerminalTotalDifficulty: big.NewInt(0),
   282  		ShanghaiTime:            u64(0),
   283  	},
   284  	"MergeToShanghaiAtTime15k": {
   285  		ChainID:                 big.NewInt(1),
   286  		HomesteadBlock:          big.NewInt(0),
   287  		EIP150Block:             big.NewInt(0),
   288  		EIP155Block:             big.NewInt(0),
   289  		EIP158Block:             big.NewInt(0),
   290  		ByzantiumBlock:          big.NewInt(0),
   291  		ConstantinopleBlock:     big.NewInt(0),
   292  		PetersburgBlock:         big.NewInt(0),
   293  		IstanbulBlock:           big.NewInt(0),
   294  		MuirGlacierBlock:        big.NewInt(0),
   295  		BerlinBlock:             big.NewInt(0),
   296  		LondonBlock:             big.NewInt(0),
   297  		ArrowGlacierBlock:       big.NewInt(0),
   298  		MergeNetsplitBlock:      big.NewInt(0),
   299  		TerminalTotalDifficulty: big.NewInt(0),
   300  		ShanghaiTime:            u64(15_000),
   301  	},
   302  	"Cancun": {
   303  		ChainID:                 big.NewInt(1),
   304  		HomesteadBlock:          big.NewInt(0),
   305  		EIP150Block:             big.NewInt(0),
   306  		EIP155Block:             big.NewInt(0),
   307  		EIP158Block:             big.NewInt(0),
   308  		ByzantiumBlock:          big.NewInt(0),
   309  		ConstantinopleBlock:     big.NewInt(0),
   310  		PetersburgBlock:         big.NewInt(0),
   311  		IstanbulBlock:           big.NewInt(0),
   312  		MuirGlacierBlock:        big.NewInt(0),
   313  		BerlinBlock:             big.NewInt(0),
   314  		LondonBlock:             big.NewInt(0),
   315  		ArrowGlacierBlock:       big.NewInt(0),
   316  		MergeNetsplitBlock:      big.NewInt(0),
   317  		TerminalTotalDifficulty: big.NewInt(0),
   318  		ShanghaiTime:            u64(0),
   319  		CancunTime:              u64(0),
   320  	},
   321  	"ShanghaiToCancunAtTime15k": {
   322  		ChainID:                 big.NewInt(1),
   323  		HomesteadBlock:          big.NewInt(0),
   324  		EIP150Block:             big.NewInt(0),
   325  		EIP155Block:             big.NewInt(0),
   326  		EIP158Block:             big.NewInt(0),
   327  		ByzantiumBlock:          big.NewInt(0),
   328  		ConstantinopleBlock:     big.NewInt(0),
   329  		PetersburgBlock:         big.NewInt(0),
   330  		IstanbulBlock:           big.NewInt(0),
   331  		MuirGlacierBlock:        big.NewInt(0),
   332  		BerlinBlock:             big.NewInt(0),
   333  		LondonBlock:             big.NewInt(0),
   334  		ArrowGlacierBlock:       big.NewInt(0),
   335  		MergeNetsplitBlock:      big.NewInt(0),
   336  		TerminalTotalDifficulty: big.NewInt(0),
   337  		ShanghaiTime:            u64(0),
   338  		CancunTime:              u64(15_000),
   339  	},
   340  	"Prague": {
   341  		ChainID:                 big.NewInt(1),
   342  		HomesteadBlock:          big.NewInt(0),
   343  		EIP150Block:             big.NewInt(0),
   344  		EIP155Block:             big.NewInt(0),
   345  		EIP158Block:             big.NewInt(0),
   346  		ByzantiumBlock:          big.NewInt(0),
   347  		ConstantinopleBlock:     big.NewInt(0),
   348  		PetersburgBlock:         big.NewInt(0),
   349  		IstanbulBlock:           big.NewInt(0),
   350  		MuirGlacierBlock:        big.NewInt(0),
   351  		BerlinBlock:             big.NewInt(0),
   352  		LondonBlock:             big.NewInt(0),
   353  		ArrowGlacierBlock:       big.NewInt(0),
   354  		MergeNetsplitBlock:      big.NewInt(0),
   355  		TerminalTotalDifficulty: big.NewInt(0),
   356  		ShanghaiTime:            u64(0),
   357  		CancunTime:              u64(0),
   358  		PragueTime:              u64(0),
   359  	},
   360  	"CancunToPragueAtTime15k": {
   361  		ChainID:                 big.NewInt(1),
   362  		HomesteadBlock:          big.NewInt(0),
   363  		EIP150Block:             big.NewInt(0),
   364  		EIP155Block:             big.NewInt(0),
   365  		EIP158Block:             big.NewInt(0),
   366  		ByzantiumBlock:          big.NewInt(0),
   367  		ConstantinopleBlock:     big.NewInt(0),
   368  		PetersburgBlock:         big.NewInt(0),
   369  		IstanbulBlock:           big.NewInt(0),
   370  		MuirGlacierBlock:        big.NewInt(0),
   371  		BerlinBlock:             big.NewInt(0),
   372  		LondonBlock:             big.NewInt(0),
   373  		ArrowGlacierBlock:       big.NewInt(0),
   374  		MergeNetsplitBlock:      big.NewInt(0),
   375  		TerminalTotalDifficulty: big.NewInt(0),
   376  		ShanghaiTime:            u64(0),
   377  		CancunTime:              u64(0),
   378  		PragueTime:              u64(15_000),
   379  	},
   380  }
   381  
   382  // AvailableForks returns the set of defined fork names
   383  func AvailableForks() []string {
   384  	var availableForks []string
   385  	for k := range Forks {
   386  		availableForks = append(availableForks, k)
   387  	}
   388  	sort.Strings(availableForks)
   389  	return availableForks
   390  }
   391  
   392  // UnsupportedForkError is returned when a test requests a fork that isn't implemented.
   393  type UnsupportedForkError struct {
   394  	Name string
   395  }
   396  
   397  func (e UnsupportedForkError) Error() string {
   398  	return fmt.Sprintf("unsupported fork %q", e.Name)
   399  }