Skip to content

Commit a42b8aa

Browse files
jwasingerstevemilk
authored andcommitted
all: remove TerminalTotalDifficultyPassed (ethereum#30609)
rebased ethereum#29766 . The downstream branch appears to have been deleted and I don't have perms to push to that fork. `TerminalTotalDifficultyPassed` is removed. `TerminalTotalDifficulty` must now be non-nil, and it is expected that networks are already merged: we can only import PoW/Clique chains, not produce blocks on them. --------- Co-authored-by: stevemilk <[email protected]>
1 parent 6ab76ce commit a42b8aa

File tree

35 files changed

+378
-442
lines changed

35 files changed

+378
-442
lines changed

cmd/devp2p/internal/ethtest/testdata/genesis.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"shanghaiTime": 780,
1919
"cancunTime": 840,
2020
"terminalTotalDifficulty": 9454784,
21-
"terminalTotalDifficultyPassed": true,
2221
"ethash": {}
2322
},
2423
"nonce": "0x0",

cmd/geth/genesis_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var customGenesisTests = []struct {
2929
query string
3030
result string
3131
}{
32-
// Genesis file with an empty chain configuration (ensure missing fields work)
32+
// Genesis file with a mostly-empty chain configuration (ensure missing fields work)
3333
{
3434
genesis: `{
3535
"alloc" : {},
@@ -41,8 +41,8 @@ var customGenesisTests = []struct {
4141
"mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
4242
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
4343
"timestamp" : "0x00",
44-
"config" : {
45-
"terminalTotalDifficultyPassed": true
44+
"config": {
45+
"terminalTotalDifficulty": 0
4646
}
4747
}`,
4848
query: "eth.getBlock(0).nonce",
@@ -64,7 +64,7 @@ var customGenesisTests = []struct {
6464
"homesteadBlock" : 42,
6565
"daoForkBlock" : 141,
6666
"daoForkSupport" : true,
67-
"terminalTotalDifficultyPassed" : true
67+
"terminalTotalDifficulty": 0
6868
}
6969
}`,
7070
query: "eth.getBlock(0).nonce",
@@ -114,8 +114,8 @@ func TestCustomBackend(t *testing.T) {
114114
"mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
115115
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
116116
"timestamp" : "0x00",
117-
"config" : {
118-
"terminalTotalDifficultyPassed": true
117+
"config": {
118+
"terminalTotalDifficulty": 0
119119
}
120120
}`
121121
type backendTest struct {

cmd/geth/testdata/clique.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"byzantiumBlock": 0,
99
"constantinopleBlock": 0,
1010
"petersburgBlock": 0,
11-
"terminalTotalDifficultyPassed": true,
11+
"terminalTotalDifficulty": 0,
1212
"clique": {
1313
"period": 5,
1414
"epoch": 30000
@@ -22,4 +22,4 @@
2222
"balance": "300000"
2323
}
2424
}
25-
}
25+
}

cmd/utils/flags.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,9 +1867,6 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
18671867
if err != nil {
18681868
Fatalf("Could not read genesis from database: %v", err)
18691869
}
1870-
if !genesis.Config.TerminalTotalDifficultyPassed {
1871-
Fatalf("Bad developer-mode genesis configuration: terminalTotalDifficultyPassed must be true")
1872-
}
18731870
if genesis.Config.TerminalTotalDifficulty == nil {
18741871
Fatalf("Bad developer-mode genesis configuration: terminalTotalDifficulty must be specified")
18751872
} else if genesis.Config.TerminalTotalDifficulty.Cmp(big.NewInt(0)) != 0 {

consensus/beacon/consensus.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,6 @@ func errOut(n int, err error) chan error {
116116
func (beacon *Beacon) splitHeaders(chain consensus.ChainHeaderReader, headers []*types.Header) ([]*types.Header, []*types.Header, error) {
117117
// TTD is not defined yet, all headers should be in legacy format.
118118
ttd := chain.Config().TerminalTotalDifficulty
119-
if ttd == nil {
120-
return headers, nil, nil
121-
}
122119
ptd := chain.GetTd(headers[0].ParentHash, headers[0].Number.Uint64()-1)
123120
if ptd == nil {
124121
return nil, nil, consensus.ErrUnknownAncestor
@@ -495,9 +492,6 @@ func (beacon *Beacon) SetThreads(threads int) {
495492
// It depends on the parentHash already being stored in the database.
496493
// If the parentHash is not stored in the database a UnknownAncestor error is returned.
497494
func IsTTDReached(chain consensus.ChainHeaderReader, parentHash common.Hash, parentNumber uint64) (bool, error) {
498-
if chain.Config().TerminalTotalDifficulty == nil {
499-
return false, nil
500-
}
501495
td := chain.GetTd(parentHash, parentNumber)
502496
if td == nil {
503497
return false, consensus.ErrUnknownAncestor

core/block_validator_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,12 @@ func testHeaderVerificationForMerging(t *testing.T, isClique bool) {
113113
}
114114
copy(gspec.ExtraData[32:], addr[:])
115115

116+
// chain_maker has no blockchain to retrieve the TTD from, setting to nil
117+
// is a hack to signal it to generate pre-merge blocks
118+
gspec.Config.TerminalTotalDifficulty = nil
116119
td := 0
117120
genDb, blocks, _ := GenerateChainWithGenesis(gspec, engine, 8, nil)
121+
118122
for i, block := range blocks {
119123
header := block.Header()
120124
if i > 0 {
@@ -145,7 +149,6 @@ func testHeaderVerificationForMerging(t *testing.T, isClique bool) {
145149
}
146150
preBlocks = blocks
147151
gspec.Config.TerminalTotalDifficulty = big.NewInt(int64(td))
148-
t.Logf("Set ttd to %v\n", gspec.Config.TerminalTotalDifficulty)
149152
postBlocks, _ = GenerateChain(gspec.Config, preBlocks[len(preBlocks)-1], engine, genDb, 8, func(i int, gen *BlockGen) {
150153
gen.SetPoS()
151154
})

core/blockchain_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4092,7 +4092,6 @@ func TestEIP3651(t *testing.T) {
40924092
gspec.Config.BerlinBlock = common.Big0
40934093
gspec.Config.LondonBlock = common.Big0
40944094
gspec.Config.TerminalTotalDifficulty = common.Big0
4095-
gspec.Config.TerminalTotalDifficultyPassed = true
40964095
gspec.Config.ShanghaiTime = u64(0)
40974096
signer := types.LatestSigner(gspec.Config)
40984097

core/chain_makers_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ func TestGeneratePOSChain(t *testing.T) {
5757
db = rawdb.NewMemoryDatabase()
5858
)
5959

60-
config.TerminalTotalDifficultyPassed = true
6160
config.TerminalTotalDifficulty = common.Big0
6261
config.ShanghaiTime = u64(0)
6362
config.CancunTime = u64(0)

core/forkid/forkid_test.go

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -378,26 +378,25 @@ func TestTimeBasedForkInGenesis(t *testing.T) {
378378
forkidHash = checksumToBytes(crc32.ChecksumIEEE(genesis.Hash().Bytes()))
379379
config = func(shanghai, cancun uint64) *params.ChainConfig {
380380
return &params.ChainConfig{
381-
ChainID: big.NewInt(1337),
382-
HomesteadBlock: big.NewInt(0),
383-
DAOForkBlock: nil,
384-
DAOForkSupport: true,
385-
EIP150Block: big.NewInt(0),
386-
EIP155Block: big.NewInt(0),
387-
EIP158Block: big.NewInt(0),
388-
ByzantiumBlock: big.NewInt(0),
389-
ConstantinopleBlock: big.NewInt(0),
390-
PetersburgBlock: big.NewInt(0),
391-
IstanbulBlock: big.NewInt(0),
392-
MuirGlacierBlock: big.NewInt(0),
393-
BerlinBlock: big.NewInt(0),
394-
LondonBlock: big.NewInt(0),
395-
TerminalTotalDifficulty: big.NewInt(0),
396-
TerminalTotalDifficultyPassed: true,
397-
MergeNetsplitBlock: big.NewInt(0),
398-
ShanghaiTime: &shanghai,
399-
CancunTime: &cancun,
400-
Ethash: new(params.EthashConfig),
381+
ChainID: big.NewInt(1337),
382+
HomesteadBlock: big.NewInt(0),
383+
DAOForkBlock: nil,
384+
DAOForkSupport: true,
385+
EIP150Block: big.NewInt(0),
386+
EIP155Block: big.NewInt(0),
387+
EIP158Block: big.NewInt(0),
388+
ByzantiumBlock: big.NewInt(0),
389+
ConstantinopleBlock: big.NewInt(0),
390+
PetersburgBlock: big.NewInt(0),
391+
IstanbulBlock: big.NewInt(0),
392+
MuirGlacierBlock: big.NewInt(0),
393+
BerlinBlock: big.NewInt(0),
394+
LondonBlock: big.NewInt(0),
395+
TerminalTotalDifficulty: big.NewInt(0),
396+
MergeNetsplitBlock: big.NewInt(0),
397+
ShanghaiTime: &shanghai,
398+
CancunTime: &cancun,
399+
Ethash: new(params.EthashConfig),
401400
}
402401
}
403402
)

core/genesis_test.go

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -257,31 +257,30 @@ func newDbConfig(scheme string) *triedb.Config {
257257
func TestVerkleGenesisCommit(t *testing.T) {
258258
var verkleTime uint64 = 0
259259
verkleConfig := &params.ChainConfig{
260-
ChainID: big.NewInt(1),
261-
HomesteadBlock: big.NewInt(0),
262-
DAOForkBlock: nil,
263-
DAOForkSupport: false,
264-
EIP150Block: big.NewInt(0),
265-
EIP155Block: big.NewInt(0),
266-
EIP158Block: big.NewInt(0),
267-
ByzantiumBlock: big.NewInt(0),
268-
ConstantinopleBlock: big.NewInt(0),
269-
PetersburgBlock: big.NewInt(0),
270-
IstanbulBlock: big.NewInt(0),
271-
MuirGlacierBlock: big.NewInt(0),
272-
BerlinBlock: big.NewInt(0),
273-
LondonBlock: big.NewInt(0),
274-
ArrowGlacierBlock: big.NewInt(0),
275-
GrayGlacierBlock: big.NewInt(0),
276-
MergeNetsplitBlock: nil,
277-
ShanghaiTime: &verkleTime,
278-
CancunTime: &verkleTime,
279-
PragueTime: &verkleTime,
280-
VerkleTime: &verkleTime,
281-
TerminalTotalDifficulty: big.NewInt(0),
282-
TerminalTotalDifficultyPassed: true,
283-
Ethash: nil,
284-
Clique: nil,
260+
ChainID: big.NewInt(1),
261+
HomesteadBlock: big.NewInt(0),
262+
DAOForkBlock: nil,
263+
DAOForkSupport: false,
264+
EIP150Block: big.NewInt(0),
265+
EIP155Block: big.NewInt(0),
266+
EIP158Block: big.NewInt(0),
267+
ByzantiumBlock: big.NewInt(0),
268+
ConstantinopleBlock: big.NewInt(0),
269+
PetersburgBlock: big.NewInt(0),
270+
IstanbulBlock: big.NewInt(0),
271+
MuirGlacierBlock: big.NewInt(0),
272+
BerlinBlock: big.NewInt(0),
273+
LondonBlock: big.NewInt(0),
274+
ArrowGlacierBlock: big.NewInt(0),
275+
GrayGlacierBlock: big.NewInt(0),
276+
MergeNetsplitBlock: nil,
277+
ShanghaiTime: &verkleTime,
278+
CancunTime: &verkleTime,
279+
PragueTime: &verkleTime,
280+
VerkleTime: &verkleTime,
281+
TerminalTotalDifficulty: big.NewInt(0),
282+
Ethash: nil,
283+
Clique: nil,
285284
}
286285

287286
genesis := &Genesis{

0 commit comments

Comments
 (0)