From 3546df65c1462f50493f7da507e8cda2fac3da03 Mon Sep 17 00:00:00 2001 From: Gary Rong Date: Thu, 23 Jan 2025 13:53:34 +0800 Subject: [PATCH] core/rawdb: bump db version --- core/blockchain.go | 5 ++++- core/blockchain_test.go | 2 +- core/rawdb/accessors_chain.go | 8 -------- core/rawdb/ancient_scheme.go | 12 ++++-------- core/rawdb/chain_freezer.go | 8 -------- 5 files changed, 9 insertions(+), 26 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index b7738c6349..ab88f4b68e 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -127,7 +127,10 @@ const ( // - Version 8 // The following incompatible database changes were added: // * New scheme for contract code in order to separate the codes and trie nodes - BlockChainVersion uint64 = 8 + // - Version 9 + // Total difficulty has been removed from both the key-value store and the + // ancient store, the td freezer table has been deprecated since that. + BlockChainVersion uint64 = 9 ) // CacheConfig contains the configuration values for the trie database diff --git a/core/blockchain_test.go b/core/blockchain_test.go index 3063d6cf05..04dfa87b8b 100644 --- a/core/blockchain_test.go +++ b/core/blockchain_test.go @@ -4181,7 +4181,7 @@ func TestEIP7702(t *testing.T) { var ( config = *params.MergedTestChainConfig signer = types.LatestSigner(&config) - engine = beacon.NewFaker() + engine = beacon.New(ethash.NewFaker()) key1, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") key2, _ = crypto.HexToECDSA("8a1f9a8f95be41cd7ccb6168179afb4504aefe388d1e14474d32c45c72ce7b7a") addr1 = crypto.PubkeyToAddress(key1.PublicKey) diff --git a/core/rawdb/accessors_chain.go b/core/rawdb/accessors_chain.go index 1896986611..a586046d5f 100644 --- a/core/rawdb/accessors_chain.go +++ b/core/rawdb/accessors_chain.go @@ -726,14 +726,6 @@ func writeAncientBlock(op ethdb.AncientWriteOp, block *types.Block, header *type if err := op.Append(ChainFreezerReceiptTable, num, receipts); err != nil { return fmt.Errorf("can't append block %d receipts: %v", num, err) } - // TODO (rjl493456442) TD has been deprecated and write garbage data for - // backward compatibility. See https://github.com/ethereum/go-ethereum/pull/30744/. - // - // The TD freezer table is retained for backward compatibility within this - // major version (1.14.x) and will be discarded in the next major version. - if err := op.Append(ChainFreezerDifficultyTable, num, common.Big0); err != nil { - return fmt.Errorf("can't append block %d total difficulty: %v", num, err) - } return nil } diff --git a/core/rawdb/ancient_scheme.go b/core/rawdb/ancient_scheme.go index 371fd384ad..54a3be391f 100644 --- a/core/rawdb/ancient_scheme.go +++ b/core/rawdb/ancient_scheme.go @@ -35,19 +35,15 @@ const ( // ChainFreezerReceiptTable indicates the name of the freezer receipts table. ChainFreezerReceiptTable = "receipts" - - // ChainFreezerDifficultyTable indicates the name of the freezer total difficulty table. - ChainFreezerDifficultyTable = "diffs" ) // chainFreezerNoSnappy configures whether compression is disabled for the ancient-tables. // Hashes and difficulties don't compress well. var chainFreezerNoSnappy = map[string]bool{ - ChainFreezerHeaderTable: false, - ChainFreezerHashTable: true, - ChainFreezerBodiesTable: false, - ChainFreezerReceiptTable: false, - ChainFreezerDifficultyTable: true, + ChainFreezerHeaderTable: false, + ChainFreezerHashTable: true, + ChainFreezerBodiesTable: false, + ChainFreezerReceiptTable: false, } const ( diff --git a/core/rawdb/chain_freezer.go b/core/rawdb/chain_freezer.go index 7b5df7eb86..0627aca34c 100644 --- a/core/rawdb/chain_freezer.go +++ b/core/rawdb/chain_freezer.go @@ -328,14 +328,6 @@ func (f *chainFreezer) freezeRange(nfdb *nofreezedb, number, limit uint64) (hash if err := op.AppendRaw(ChainFreezerReceiptTable, number, receipts); err != nil { return fmt.Errorf("can't write receipts to Freezer: %v", err) } - // TODO (rjl493456442) TD has been deprecated and write garbage data for - // backward compatibility. See https://github.com/ethereum/go-ethereum/pull/30744/. - // - // The TD freezer table is retained for backward compatibility within this - // major version (1.14.x) and will be discarded in the next major version. - if err := op.Append(ChainFreezerDifficultyTable, number, common.Big0); err != nil { - return fmt.Errorf("can't write td to Freezer: %v", err) - } hashes = append(hashes, hash) } return nil