diff --git a/cmd/geth/genesis_test.go b/cmd/geth/genesis_test.go index 7adc9d2658..2766be2deb 100644 --- a/cmd/geth/genesis_test.go +++ b/cmd/geth/genesis_test.go @@ -29,7 +29,7 @@ var customGenesisTests = []struct { query string result string }{ - // Genesis file with an empty chain configuration (ensure missing fields work) + // Genesis file with a mostly-empty chain configuration (ensure missing fields work) { genesis: `{ "alloc" : {}, @@ -41,7 +41,9 @@ var customGenesisTests = []struct { "mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "timestamp" : "0x00", - "config": {} + "config": { + "terminalTotalDifficulty": "0xffffffffffffffff" + } }`, query: "eth.getBlock(0).nonce", result: "0x0000000000001338", @@ -61,7 +63,8 @@ var customGenesisTests = []struct { "config" : { "homesteadBlock" : 42, "daoForkBlock" : 141, - "daoForkSupport" : true + "daoForkSupport" : true, + "terminalTotalDifficulty": "0xffffffffffffffff" } }`, query: "eth.getBlock(0).nonce", @@ -111,7 +114,9 @@ func TestCustomBackend(t *testing.T) { "mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "timestamp" : "0x00", - "config": {} + "config": { + "terminalTotalDifficulty": "0xffffffffffffffff" + } }` type backendTest struct { initArgs []string diff --git a/cmd/geth/testdata/clique.json b/cmd/geth/testdata/clique.json index b54b4a7d3b..d318f4c166 100644 --- a/cmd/geth/testdata/clique.json +++ b/cmd/geth/testdata/clique.json @@ -8,6 +8,7 @@ "byzantiumBlock": 0, "constantinopleBlock": 0, "petersburgBlock": 0, + "terminalTotalDifficulty": 0, "clique": { "period": 5, "epoch": 30000 @@ -21,4 +22,4 @@ "balance": "300000" } } -} \ No newline at end of file +} diff --git a/consensus/beacon/consensus.go b/consensus/beacon/consensus.go index ae4c9f29a1..cbeb5e88d6 100644 --- a/consensus/beacon/consensus.go +++ b/consensus/beacon/consensus.go @@ -19,8 +19,6 @@ package beacon import ( "errors" "fmt" - "math/big" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/consensus" "github.com/ethereum/go-ethereum/consensus/misc/eip1559" @@ -32,6 +30,7 @@ import ( "github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/trie" "github.com/holiman/uint256" + "math/big" ) // Proof-of-stake protocol constants. @@ -115,9 +114,6 @@ func errOut(n int, err error) chan error { func (beacon *Beacon) splitHeaders(chain consensus.ChainHeaderReader, headers []*types.Header) ([]*types.Header, []*types.Header, error) { // TTD is not defined yet, all headers should be in legacy format. ttd := chain.Config().TerminalTotalDifficulty - if ttd == nil { - return headers, nil, nil - } ptd := chain.GetTd(headers[0].ParentHash, headers[0].Number.Uint64()-1) if ptd == nil { return nil, nil, consensus.ErrUnknownAncestor @@ -494,9 +490,6 @@ func (beacon *Beacon) SetThreads(threads int) { // It depends on the parentHash already being stored in the database. // If the parentHash is not stored in the database a UnknownAncestor error is returned. func IsTTDReached(chain consensus.ChainHeaderReader, parentHash common.Hash, parentNumber uint64) (bool, error) { - if chain.Config().TerminalTotalDifficulty == nil { - return false, nil - } td := chain.GetTd(parentHash, parentNumber) if td == nil { return false, consensus.ErrUnknownAncestor diff --git a/core/block_validator_test.go b/core/block_validator_test.go index 80e6820661..03e2079b10 100644 --- a/core/block_validator_test.go +++ b/core/block_validator_test.go @@ -115,6 +115,8 @@ func testHeaderVerificationForMerging(t *testing.T, isClique bool) { td := 0 genDb, blocks, _ := GenerateChainWithGenesis(gspec, engine, 8, nil) + gspec.Config.TerminalTotalDifficulty = big.NewInt(1000) + for i, block := range blocks { header := block.Header() if i > 0 {