-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into use-libevm
- Loading branch information
Showing
3 changed files
with
91 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// (c) 2019-2021, Ava Labs, Inc. | ||
// | ||
// This file is a derived work, based on the go-ethereum library whose original | ||
// notices appear below. | ||
// | ||
// It is distributed under a license compatible with the licensing terms of the | ||
// original code from which it is derived. | ||
// | ||
// Much love to the original authors for their work. | ||
// ********** | ||
// Copyright 2017 The go-ethereum Authors | ||
// This file is part of the go-ethereum library. | ||
// | ||
// The go-ethereum library is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// The go-ethereum library is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
package core | ||
|
||
import ( | ||
"math/big" | ||
"testing" | ||
"time" | ||
|
||
"github.com/ava-labs/coreth/core/rawdb" | ||
"github.com/ava-labs/coreth/core/types" | ||
"github.com/ava-labs/coreth/params" | ||
"github.com/ava-labs/coreth/triedb" | ||
"github.com/ava-labs/coreth/utils" | ||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestGenesisEthUpgrades(t *testing.T) { | ||
db := rawdb.NewMemoryDatabase() | ||
preEthUpgrades := ¶ms.ChainConfig{ | ||
ChainID: big.NewInt(43114), // Specifically refers to mainnet for this UT | ||
HomesteadBlock: big.NewInt(0), | ||
DAOForkBlock: nil, | ||
DAOForkSupport: false, | ||
EIP150Block: big.NewInt(0), | ||
EIP155Block: big.NewInt(0), | ||
EIP158Block: big.NewInt(0), | ||
ByzantiumBlock: big.NewInt(0), | ||
ConstantinopleBlock: big.NewInt(0), | ||
PetersburgBlock: big.NewInt(0), | ||
IstanbulBlock: big.NewInt(0), | ||
MuirGlacierBlock: big.NewInt(0), | ||
NetworkUpgrades: params.NetworkUpgrades{ | ||
Check failure on line 58 in core/genesis_extra_test.go GitHub Actions / Lint
Check failure on line 58 in core/genesis_extra_test.go GitHub Actions / Golang Unit Tests (macos-latest)
Check failure on line 58 in core/genesis_extra_test.go GitHub Actions / Golang Unit Tests (ubuntu-20.04)
Check failure on line 58 in core/genesis_extra_test.go GitHub Actions / Golang Unit Tests (ubuntu-latest)
|
||
ApricotPhase1BlockTimestamp: utils.NewUint64(0), | ||
ApricotPhase2BlockTimestamp: utils.NewUint64(0), | ||
}, | ||
} | ||
|
||
tdb := triedb.NewDatabase(db, triedb.HashDefaults) | ||
config := *preEthUpgrades | ||
// Set this up once, just to get the genesis hash | ||
_, genHash, err := SetupGenesisBlock(db, tdb, &Genesis{Config: &config}, common.Hash{}, false) | ||
require.NoError(t, err) | ||
|
||
// Write the configuration back to the db as it would be in prior versions | ||
rawdb.WriteChainConfig(db, genHash, preEthUpgrades) | ||
|
||
// Make some other block | ||
block := types.NewBlock( | ||
&types.Header{ | ||
Number: big.NewInt(1640340), // Berlin activation on mainnet | ||
Difficulty: big.NewInt(1), | ||
ParentHash: genHash, | ||
Time: uint64(time.Now().Unix()), | ||
}, | ||
nil, nil, nil, nil, | ||
) | ||
rawdb.WriteBlock(db, block) | ||
|
||
// We should still be able to re-initialize | ||
config = *preEthUpgrades | ||
config.SetEthUpgrades() // New versions will set additional fields eg, LondonBlock | ||
Check failure on line 87 in core/genesis_extra_test.go GitHub Actions / Lint
Check failure on line 87 in core/genesis_extra_test.go GitHub Actions / Golang Unit Tests (macos-latest)
Check failure on line 87 in core/genesis_extra_test.go GitHub Actions / Golang Unit Tests (ubuntu-20.04)
Check failure on line 87 in core/genesis_extra_test.go GitHub Actions / Golang Unit Tests (ubuntu-latest)
|
||
_, _, err = SetupGenesisBlock(db, tdb, &Genesis{Config: &config}, block.Hash(), false) | ||
require.NoError(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters