From 47604587322de24255451899f1fd2dd2d49c1a9b Mon Sep 17 00:00:00 2001 From: Gheis Mohammadi Date: Sat, 1 Apr 2023 01:28:44 +0800 Subject: [PATCH] update all ethereum rawdb pointers to use harmony rawdb (#4395) --- cmd/harmony/dumpdb.go | 5 ++--- core/epochchain_test.go | 2 +- core/evm_test.go | 2 +- core/rawdb/accessors_chain_test.go | 18 ++++++++---------- core/rawdb/accessors_indexes_test.go | 6 ++---- core/rawdb/accessors_snapdb_test.go | 3 +-- core/staking_verifier_test.go | 2 +- core/state/managed_state_test.go | 2 +- core/tx_pool_test.go | 2 +- core/vm/contracts_write_test.go | 2 +- core/vm/gas_table_test.go | 2 +- core/vm/runtime/runtime.go | 2 +- core/vm/runtime/runtime_test.go | 2 +- hmy/bloombits.go | 3 +-- internal/chain/engine_test.go | 2 +- internal/shardchain/dbfactory_tikv.go | 2 +- node/worker/worker_test.go | 2 +- staking/slash/double-sign_test.go | 2 +- test/chain/main.go | 2 +- test/chain/reward/main.go | 2 +- 20 files changed, 29 insertions(+), 36 deletions(-) diff --git a/cmd/harmony/dumpdb.go b/cmd/harmony/dumpdb.go index 72e9de030..5803359e5 100644 --- a/cmd/harmony/dumpdb.go +++ b/cmd/harmony/dumpdb.go @@ -12,7 +12,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" - ethRawDB "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" @@ -367,12 +366,12 @@ func (db *KakashiDB) stateDataDump(block *types.Block) { func dumpMain(srcDBDir, destDBDir string, batchLimit int) { fmt.Println("===dumpMain===") - srcDB, err := ethRawDB.NewLevelDBDatabase(srcDBDir, LEVELDB_CACHE_SIZE, LEVELDB_HANDLES, "", false) + srcDB, err := rawdb.NewLevelDBDatabase(srcDBDir, LEVELDB_CACHE_SIZE, LEVELDB_HANDLES, "", false) if err != nil { fmt.Println("open src db error:", err) os.Exit(-1) } - destDB, err := ethRawDB.NewLevelDBDatabase(destDBDir, LEVELDB_CACHE_SIZE, LEVELDB_HANDLES, "", false) + destDB, err := rawdb.NewLevelDBDatabase(destDBDir, LEVELDB_CACHE_SIZE, LEVELDB_HANDLES, "", false) if err != nil { fmt.Println("open dest db error:", err) os.Exit(-1) diff --git a/core/epochchain_test.go b/core/epochchain_test.go index eec7bd628..32f0dd530 100644 --- a/core/epochchain_test.go +++ b/core/epochchain_test.go @@ -3,8 +3,8 @@ package core_test import ( "testing" - "github.com/ethereum/go-ethereum/core/rawdb" "github.com/harmony-one/harmony/core" + "github.com/harmony-one/harmony/core/rawdb" "github.com/harmony-one/harmony/core/vm" nodeconfig "github.com/harmony-one/harmony/internal/configs/node" "github.com/stretchr/testify/require" diff --git a/core/evm_test.go b/core/evm_test.go index 962dedd30..cab3f712c 100644 --- a/core/evm_test.go +++ b/core/evm_test.go @@ -9,13 +9,13 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethdb" bls_core "github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/harmony/block" blockfactory "github.com/harmony-one/harmony/block/factory" "github.com/harmony-one/harmony/common/denominations" + "github.com/harmony-one/harmony/core/rawdb" "github.com/harmony-one/harmony/core/state" "github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/core/vm" diff --git a/core/rawdb/accessors_chain_test.go b/core/rawdb/accessors_chain_test.go index e9dea0882..6edf9f9ec 100644 --- a/core/rawdb/accessors_chain_test.go +++ b/core/rawdb/accessors_chain_test.go @@ -21,8 +21,6 @@ import ( "math/big" "testing" - "github.com/ethereum/go-ethereum/core/rawdb" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/rlp" "github.com/harmony-one/harmony/block" @@ -34,7 +32,7 @@ import ( // Tests block header storage and retrieval operations. func TestHeaderStorage(t *testing.T) { - db := rawdb.NewMemoryDatabase() + db := NewMemoryDatabase() // Create a test header to move around the database and make sure it's really new header := blockfactory.NewTestHeader().With().Number(big.NewInt(42)).Extra([]byte("test header")).Header() @@ -67,7 +65,7 @@ func TestHeaderStorage(t *testing.T) { // Tests block body storage and retrieval operations. func TestBodyStorage(t *testing.T) { - db := rawdb.NewMemoryDatabase() + db := NewMemoryDatabase() // Create a test body to move around the database and make sure it's really new body := types.NewTestBody().With().Uncles([]*block.Header{blockfactory.NewTestHeader().With().Extra([]byte("test header")).Header()}).Body() @@ -105,7 +103,7 @@ func TestBodyStorage(t *testing.T) { // Tests block storage and retrieval operations. func TestBlockStorage(t *testing.T) { - db := rawdb.NewMemoryDatabase() + db := NewMemoryDatabase() // Create a test block to move around the database and make sure it's really new block := types.NewBlockWithHeader(blockfactory.NewTestHeader().With(). @@ -167,7 +165,7 @@ func TestBlockStorage(t *testing.T) { // Tests that partial block contents don't get reassembled into full blocks. func TestPartialBlockStorage(t *testing.T) { - db := rawdb.NewMemoryDatabase() + db := NewMemoryDatabase() block := types.NewBlockWithHeader(blockfactory.NewTestHeader().With(). Extra([]byte("test block")). TxHash(types.EmptyRootHash). @@ -200,7 +198,7 @@ func TestPartialBlockStorage(t *testing.T) { // Tests block total difficulty storage and retrieval operations. func TestTdStorage(t *testing.T) { - db := rawdb.NewMemoryDatabase() + db := NewMemoryDatabase() // Create a test TD to move around the database and make sure it's really new hash, td := common.Hash{}, big.NewInt(314) @@ -223,7 +221,7 @@ func TestTdStorage(t *testing.T) { // Tests that canonical numbers can be mapped to hashes and retrieved. func TestCanonicalMappingStorage(t *testing.T) { - db := rawdb.NewMemoryDatabase() + db := NewMemoryDatabase() // Create a test canonical number and assinged hash to move around hash, number := common.Hash{0: 0xff}, uint64(314) @@ -246,7 +244,7 @@ func TestCanonicalMappingStorage(t *testing.T) { // Tests that head headers and head blocks can be assigned, individually. func TestHeadStorage(t *testing.T) { - db := rawdb.NewMemoryDatabase() + db := NewMemoryDatabase() blockHead := types.NewBlockWithHeader(blockfactory.NewTestHeader().With().Extra([]byte("test block header")).Header()) blockFull := types.NewBlockWithHeader(blockfactory.NewTestHeader().With().Extra([]byte("test block full")).Header()) @@ -281,7 +279,7 @@ func TestHeadStorage(t *testing.T) { // Tests that receipts associated with a single block can be stored and retrieved. func TestBlockReceiptStorage(t *testing.T) { - db := rawdb.NewMemoryDatabase() + db := NewMemoryDatabase() receipt1 := &types.Receipt{ Status: types.ReceiptStatusFailed, diff --git a/core/rawdb/accessors_indexes_test.go b/core/rawdb/accessors_indexes_test.go index 77a66f63e..41f54ac98 100644 --- a/core/rawdb/accessors_indexes_test.go +++ b/core/rawdb/accessors_indexes_test.go @@ -20,8 +20,6 @@ import ( "math/big" "testing" - "github.com/ethereum/go-ethereum/core/rawdb" - "github.com/harmony-one/harmony/crypto/bls" "github.com/ethereum/go-ethereum/common" @@ -42,7 +40,7 @@ var ( // Tests that positional lookup metadata can be stored and retrieved. func TestLookupStorage(t *testing.T) { - db := rawdb.NewMemoryDatabase() + db := NewMemoryDatabase() tx1 := types.NewTransaction(1, common.BytesToAddress([]byte{0x11}), 0, big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11}) tx2 := types.NewTransaction(2, common.BytesToAddress([]byte{0x22}), 0, big.NewInt(222), 2222, big.NewInt(22222), []byte{0x22, 0x22, 0x22}) @@ -123,7 +121,7 @@ func TestLookupStorage(t *testing.T) { // Test that staking tx hash does not find a plain tx hash (and visa versa) within the same block func TestMixedLookupStorage(t *testing.T) { - db := rawdb.NewMemoryDatabase() + db := NewMemoryDatabase() tx := types.NewTransaction(1, common.BytesToAddress([]byte{0x11}), 0, big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11}) stx := sampleCreateValidatorStakingTxn() diff --git a/core/rawdb/accessors_snapdb_test.go b/core/rawdb/accessors_snapdb_test.go index e81a856b2..915a28e8c 100644 --- a/core/rawdb/accessors_snapdb_test.go +++ b/core/rawdb/accessors_snapdb_test.go @@ -5,7 +5,6 @@ import ( "testing" "github.com/ethereum/go-ethereum/common/hexutil" - ethRawDB "github.com/ethereum/go-ethereum/core/rawdb" blockfactory "github.com/harmony-one/harmony/block/factory" nodeconfig "github.com/harmony-one/harmony/internal/configs/node" ) @@ -22,7 +21,7 @@ func TestSnapdbInfo(t *testing.T) { LastAccountKey: hexutil.MustDecode("0x1339383fd90ed804e28464763a13fafad66dd0f88434b8e5d8b410eb75a10331"), LastAccountStateKey: hexutil.MustDecode("0xa940a0bb9eca4f9d5eee3f4059f458bd4a05bb1d680c5f7c781b06bc43c20df6"), } - db := ethRawDB.NewMemoryDatabase() + db := NewMemoryDatabase() if err := WriteSnapdbInfo(db, src); err != nil { t.Fatal(err) } diff --git a/core/staking_verifier_test.go b/core/staking_verifier_test.go index eeb372889..01d24cc8d 100644 --- a/core/staking_verifier_test.go +++ b/core/staking_verifier_test.go @@ -9,7 +9,7 @@ import ( "github.com/harmony-one/harmony/internal/params" - "github.com/ethereum/go-ethereum/core/rawdb" + "github.com/harmony-one/harmony/core/rawdb" "github.com/harmony-one/harmony/crypto/bls" diff --git a/core/state/managed_state_test.go b/core/state/managed_state_test.go index d1fbb906d..81d316c3a 100644 --- a/core/state/managed_state_test.go +++ b/core/state/managed_state_test.go @@ -19,7 +19,7 @@ package state import ( "testing" - "github.com/ethereum/go-ethereum/core/rawdb" + "github.com/harmony-one/harmony/core/rawdb" "github.com/ethereum/go-ethereum/common" ) diff --git a/core/tx_pool_test.go b/core/tx_pool_test.go index 5d11b50e9..9e1bba296 100644 --- a/core/tx_pool_test.go +++ b/core/tx_pool_test.go @@ -27,7 +27,7 @@ import ( "testing" "time" - "github.com/ethereum/go-ethereum/core/rawdb" + "github.com/harmony-one/harmony/core/rawdb" "github.com/harmony-one/harmony/crypto/bls" diff --git a/core/vm/contracts_write_test.go b/core/vm/contracts_write_test.go index c7269e6ff..479bf420f 100644 --- a/core/vm/contracts_write_test.go +++ b/core/vm/contracts_write_test.go @@ -7,8 +7,8 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/ethdb" + "github.com/harmony-one/harmony/core/rawdb" "github.com/harmony-one/harmony/core/state" "github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/internal/params" diff --git a/core/vm/gas_table_test.go b/core/vm/gas_table_test.go index 4619ccd02..08e265c74 100644 --- a/core/vm/gas_table_test.go +++ b/core/vm/gas_table_test.go @@ -26,7 +26,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/core/rawdb" + "github.com/harmony-one/harmony/core/rawdb" "github.com/harmony-one/harmony/core/state" ) diff --git a/core/vm/runtime/runtime.go b/core/vm/runtime/runtime.go index 69275fc58..5595866da 100644 --- a/core/vm/runtime/runtime.go +++ b/core/vm/runtime/runtime.go @@ -22,8 +22,8 @@ import ( "time" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/crypto" + "github.com/harmony-one/harmony/core/rawdb" "github.com/harmony-one/harmony/core/state" "github.com/harmony-one/harmony/core/vm" "github.com/harmony-one/harmony/internal/params" diff --git a/core/vm/runtime/runtime_test.go b/core/vm/runtime/runtime_test.go index 09f2b6fc4..a4f86ed8b 100644 --- a/core/vm/runtime/runtime_test.go +++ b/core/vm/runtime/runtime_test.go @@ -21,7 +21,7 @@ import ( "strings" "testing" - "github.com/ethereum/go-ethereum/core/rawdb" + "github.com/harmony-one/harmony/core/rawdb" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" diff --git a/hmy/bloombits.go b/hmy/bloombits.go index aaef781ca..461372de2 100644 --- a/hmy/bloombits.go +++ b/hmy/bloombits.go @@ -23,7 +23,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/bitutil" "github.com/ethereum/go-ethereum/core/bloombits" - ethRawDB "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/ethdb" "github.com/harmony-one/harmony/block" "github.com/harmony-one/harmony/core" @@ -72,7 +71,7 @@ func NewBloomIndexer(db core.Chain, size, confirms uint64) *core.ChainIndexer { db: db.ChainDb(), size: size, } - table := ethRawDB.NewTable(db.ChainDb(), string(rawdb.BloomBitsIndexPrefix)) + table := rawdb.NewTable(db.ChainDb(), string(rawdb.BloomBitsIndexPrefix)) return core.NewChainIndexer(db, table, backend, size, confirms, bloomThrottling, "bloombits") } diff --git a/internal/chain/engine_test.go b/internal/chain/engine_test.go index 07810d83f..5a842088c 100644 --- a/internal/chain/engine_test.go +++ b/internal/chain/engine_test.go @@ -19,7 +19,7 @@ import ( types2 "github.com/harmony-one/harmony/staking/types" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/rawdb" + "github.com/harmony-one/harmony/core/rawdb" "github.com/harmony-one/harmony/core/state" "github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/internal/params" diff --git a/internal/shardchain/dbfactory_tikv.go b/internal/shardchain/dbfactory_tikv.go index 6651cd5c3..80b0117ed 100644 --- a/internal/shardchain/dbfactory_tikv.go +++ b/internal/shardchain/dbfactory_tikv.go @@ -5,7 +5,7 @@ import ( "io" "sync" - "github.com/ethereum/go-ethereum/core/rawdb" + "github.com/harmony-one/harmony/core/rawdb" "github.com/harmony-one/harmony/internal/tikv" tikvCommon "github.com/harmony-one/harmony/internal/tikv/common" "github.com/harmony-one/harmony/internal/tikv/prefix" diff --git a/node/worker/worker_test.go b/node/worker/worker_test.go index e6ffdfdda..37d61816c 100644 --- a/node/worker/worker_test.go +++ b/node/worker/worker_test.go @@ -7,7 +7,7 @@ import ( "github.com/harmony-one/harmony/core/state" - "github.com/ethereum/go-ethereum/core/rawdb" + "github.com/harmony-one/harmony/core/rawdb" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" diff --git a/staking/slash/double-sign_test.go b/staking/slash/double-sign_test.go index 670a99d7c..470a8ae1d 100644 --- a/staking/slash/double-sign_test.go +++ b/staking/slash/double-sign_test.go @@ -8,7 +8,7 @@ import ( "strings" "testing" - "github.com/ethereum/go-ethereum/core/rawdb" + "github.com/harmony-one/harmony/core/rawdb" "github.com/harmony-one/harmony/crypto/bls" diff --git a/test/chain/main.go b/test/chain/main.go index e78b51935..fd1a74e73 100644 --- a/test/chain/main.go +++ b/test/chain/main.go @@ -6,7 +6,7 @@ import ( "log" "math/big" - "github.com/ethereum/go-ethereum/core/rawdb" + "github.com/harmony-one/harmony/core/rawdb" chain2 "github.com/harmony-one/harmony/test/chain/chain" "github.com/ethereum/go-ethereum/common" diff --git a/test/chain/reward/main.go b/test/chain/reward/main.go index 2f79378e3..5cfe9425a 100644 --- a/test/chain/reward/main.go +++ b/test/chain/reward/main.go @@ -6,7 +6,7 @@ import ( "math/rand" "time" - "github.com/ethereum/go-ethereum/core/rawdb" + "github.com/harmony-one/harmony/core/rawdb" msg_pb "github.com/harmony-one/harmony/api/proto/message" "github.com/harmony-one/harmony/crypto/bls"