From 90c82a017a7ee5dddc4ccd9d32db0395010cd5a8 Mon Sep 17 00:00:00 2001 From: Minh Doan Date: Mon, 31 Dec 2018 17:25:24 -0800 Subject: [PATCH 1/3] move db into internal --- benchmark.go | 2 +- core/blockchain.go | 2 +- core/chain_makers.go | 2 +- core/genesis.go | 2 +- core/headerchain.go | 2 +- core/state/database.go | 2 +- core/state/managed_state_test.go | 2 +- core/state/state_test.go | 2 +- core/state/statedb_test.go | 2 +- core/tx_pool_test.go | 2 +- core/vm/runtime/runtime.go | 2 +- core/vm/runtime/runtime_test.go | 2 +- harmony/main.go | 5 +++-- {db => internal/db}/db.go | 0 {db => internal/db}/db_test.go | 0 {db => internal/db}/interface.go | 0 {db => internal/db}/memory_db.go | 0 node/node.go | 5 +++-- services/explorer/storage.go | 2 +- trie/database.go | 2 +- trie/iterator_test.go | 2 +- trie/proof.go | 2 +- trie/secure_trie_test.go | 2 +- trie/sync_test.go | 2 +- trie/trie_test.go | 2 +- 25 files changed, 25 insertions(+), 23 deletions(-) rename {db => internal/db}/db.go (100%) rename {db => internal/db}/db_test.go (100%) rename {db => internal/db}/interface.go (100%) rename {db => internal/db}/memory_db.go (100%) diff --git a/benchmark.go b/benchmark.go index 6ba46de0c..b53315d4e 100644 --- a/benchmark.go +++ b/benchmark.go @@ -12,8 +12,8 @@ import ( "github.com/harmony-one/harmony/p2p/p2pimpl" "github.com/harmony-one/harmony/consensus" - "github.com/harmony-one/harmony/db" "github.com/harmony-one/harmony/internal/attack" + "github.com/harmony-one/harmony/internal/db" "github.com/harmony-one/harmony/log" pkg_newnode "github.com/harmony-one/harmony/newnode" "github.com/harmony-one/harmony/node" diff --git a/core/blockchain.go b/core/blockchain.go index e1da21ff3..05a719487 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -27,7 +27,7 @@ import ( "sync/atomic" "time" - hdb "github.com/harmony-one/harmony/db" + hdb "github.com/harmony-one/harmony/internal/db" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/mclock" diff --git a/core/chain_makers.go b/core/chain_makers.go index 4c8b4b920..c135d9106 100644 --- a/core/chain_makers.go +++ b/core/chain_makers.go @@ -20,7 +20,7 @@ import ( "fmt" "math/big" - hdb "github.com/harmony-one/harmony/db" + hdb "github.com/harmony-one/harmony/internal/db" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/params" diff --git a/core/genesis.go b/core/genesis.go index c1e8b0f6e..ffd94ca00 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -32,7 +32,7 @@ import ( "github.com/harmony-one/harmony/core/rawdb" "github.com/harmony-one/harmony/core/state" "github.com/harmony-one/harmony/core/types" - hdb "github.com/harmony-one/harmony/db" + hdb "github.com/harmony-one/harmony/internal/db" ) //go:generate gencodec -type Genesis -field-override genesisSpecMarshaling -out gen_genesis.go diff --git a/core/headerchain.go b/core/headerchain.go index f9c5fcc7f..6f27fc5ee 100644 --- a/core/headerchain.go +++ b/core/headerchain.go @@ -32,7 +32,7 @@ import ( "github.com/harmony-one/harmony/consensus" "github.com/harmony-one/harmony/core/rawdb" "github.com/harmony-one/harmony/core/types" - "github.com/harmony-one/harmony/db" + "github.com/harmony-one/harmony/internal/db" "github.com/hashicorp/golang-lru" ) diff --git a/core/state/database.go b/core/state/database.go index a2ebd6786..2c38a2360 100644 --- a/core/state/database.go +++ b/core/state/database.go @@ -21,7 +21,7 @@ import ( "sync" "github.com/ethereum/go-ethereum/common" - "github.com/harmony-one/harmony/db" + "github.com/harmony-one/harmony/internal/db" "github.com/harmony-one/harmony/trie" lru "github.com/hashicorp/golang-lru" ) diff --git a/core/state/managed_state_test.go b/core/state/managed_state_test.go index 9b7a49402..4061be66f 100644 --- a/core/state/managed_state_test.go +++ b/core/state/managed_state_test.go @@ -20,7 +20,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" - "github.com/harmony-one/harmony/db" + "github.com/harmony-one/harmony/internal/db" ) var addr = common.BytesToAddress([]byte("test")) diff --git a/core/state/state_test.go b/core/state/state_test.go index 167a9bbda..50cd14966 100644 --- a/core/state/state_test.go +++ b/core/state/state_test.go @@ -21,7 +21,7 @@ import ( "math/big" "testing" - "github.com/harmony-one/harmony/db" + "github.com/harmony-one/harmony/internal/db" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" diff --git a/core/state/statedb_test.go b/core/state/statedb_test.go index d3b3a3ca1..4c7ad6813 100644 --- a/core/state/statedb_test.go +++ b/core/state/statedb_test.go @@ -32,7 +32,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/harmony-one/harmony/core/types" - "github.com/harmony-one/harmony/db" + "github.com/harmony-one/harmony/internal/db" ) // Tests that updating a state trie does not leak any database writes prior to diff --git a/core/tx_pool_test.go b/core/tx_pool_test.go index 5889f498f..ceecd0584 100644 --- a/core/tx_pool_test.go +++ b/core/tx_pool_test.go @@ -32,7 +32,7 @@ import ( "github.com/ethereum/go-ethereum/params" "github.com/harmony-one/harmony/core/state" "github.com/harmony-one/harmony/core/types" - "github.com/harmony-one/harmony/db" + "github.com/harmony-one/harmony/internal/db" ) // testTxPoolConfig is a transaction pool configuration without stateful disk diff --git a/core/vm/runtime/runtime.go b/core/vm/runtime/runtime.go index 9eb8affe5..31daf5600 100644 --- a/core/vm/runtime/runtime.go +++ b/core/vm/runtime/runtime.go @@ -26,7 +26,7 @@ import ( "github.com/ethereum/go-ethereum/params" "github.com/harmony-one/harmony/core/state" "github.com/harmony-one/harmony/core/vm" - "github.com/harmony-one/harmony/db" + "github.com/harmony-one/harmony/internal/db" ) // Config is a basic type specifying certain configuration flags for running diff --git a/core/vm/runtime/runtime_test.go b/core/vm/runtime/runtime_test.go index b21a87659..38f9ad868 100644 --- a/core/vm/runtime/runtime_test.go +++ b/core/vm/runtime/runtime_test.go @@ -26,7 +26,7 @@ import ( "github.com/ethereum/go-ethereum/params" "github.com/harmony-one/harmony/core/state" "github.com/harmony-one/harmony/core/vm" - "github.com/harmony-one/harmony/db" + "github.com/harmony-one/harmony/internal/db" ) func TestDefaults(t *testing.T) { diff --git a/harmony/main.go b/harmony/main.go index c0fce8f9c..be9c0dfc2 100644 --- a/harmony/main.go +++ b/harmony/main.go @@ -3,17 +3,18 @@ package main import ( "encoding/hex" "fmt" - "github.com/ethereum/go-ethereum/common" "log" "math/big" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" "github.com/harmony-one/harmony/consensus" "github.com/harmony-one/harmony/core" "github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/core/vm" - "github.com/harmony-one/harmony/db" + "github.com/harmony-one/harmony/internal/db" "github.com/harmony-one/harmony/node/worker" ) diff --git a/db/db.go b/internal/db/db.go similarity index 100% rename from db/db.go rename to internal/db/db.go diff --git a/db/db_test.go b/internal/db/db_test.go similarity index 100% rename from db/db_test.go rename to internal/db/db_test.go diff --git a/db/interface.go b/internal/db/interface.go similarity index 100% rename from db/interface.go rename to internal/db/interface.go diff --git a/db/memory_db.go b/internal/db/memory_db.go similarity index 100% rename from db/memory_db.go rename to internal/db/memory_db.go diff --git a/node/node.go b/node/node.go index a00e648c6..fbf13fa0f 100644 --- a/node/node.go +++ b/node/node.go @@ -6,7 +6,6 @@ import ( "encoding/gob" "encoding/hex" "fmt" - "github.com/ethereum/go-ethereum/rlp" "math/big" "os" "strconv" @@ -15,6 +14,8 @@ import ( "sync/atomic" "time" + "github.com/ethereum/go-ethereum/rlp" + "github.com/harmony-one/harmony/services/explorer" "github.com/harmony-one/harmony/client" @@ -28,7 +29,7 @@ import ( "github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/core/vm" "github.com/harmony-one/harmony/crypto/pki" - hdb "github.com/harmony-one/harmony/db" + hdb "github.com/harmony-one/harmony/internal/db" "github.com/harmony-one/harmony/log" "github.com/harmony-one/harmony/node/worker" "github.com/harmony-one/harmony/p2p" diff --git a/services/explorer/storage.go b/services/explorer/storage.go index 4e3d4277a..60f3efcd0 100644 --- a/services/explorer/storage.go +++ b/services/explorer/storage.go @@ -8,7 +8,7 @@ import ( "github.com/ethereum/go-ethereum/rlp" "github.com/harmony-one/harmony/core/types" - "github.com/harmony-one/harmony/db" + "github.com/harmony-one/harmony/internal/db" "github.com/harmony-one/harmony/log" ) diff --git a/trie/database.go b/trie/database.go index b1718c933..499282421 100644 --- a/trie/database.go +++ b/trie/database.go @@ -26,7 +26,7 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/rlp" - hdb "github.com/harmony-one/harmony/db" + hdb "github.com/harmony-one/harmony/internal/db" ) var ( diff --git a/trie/iterator_test.go b/trie/iterator_test.go index 48b8151c6..f54127efd 100644 --- a/trie/iterator_test.go +++ b/trie/iterator_test.go @@ -23,7 +23,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" - hdb "github.com/harmony-one/harmony/db" + hdb "github.com/harmony-one/harmony/internal/db" ) func TestIterator(t *testing.T) { diff --git a/trie/proof.go b/trie/proof.go index 83ba1bd30..bf342b14e 100644 --- a/trie/proof.go +++ b/trie/proof.go @@ -20,7 +20,7 @@ import ( "bytes" "fmt" - "github.com/harmony-one/harmony/db" + "github.com/harmony-one/harmony/internal/db" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" diff --git a/trie/secure_trie_test.go b/trie/secure_trie_test.go index cbb38f761..5df369f15 100644 --- a/trie/secure_trie_test.go +++ b/trie/secure_trie_test.go @@ -24,7 +24,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" - "github.com/harmony-one/harmony/db" + "github.com/harmony-one/harmony/internal/db" ) func newEmptySecure() *SecureTrie { diff --git a/trie/sync_test.go b/trie/sync_test.go index 4105244c2..ae73d21fa 100644 --- a/trie/sync_test.go +++ b/trie/sync_test.go @@ -20,7 +20,7 @@ import ( "bytes" "testing" - "github.com/harmony-one/harmony/db" + "github.com/harmony-one/harmony/internal/db" "github.com/ethereum/go-ethereum/common" ) diff --git a/trie/trie_test.go b/trie/trie_test.go index 238f14b59..cff9a4c86 100644 --- a/trie/trie_test.go +++ b/trie/trie_test.go @@ -33,7 +33,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/rlp" - "github.com/harmony-one/harmony/db" + "github.com/harmony-one/harmony/internal/db" ) func init() { From 182a519949883ce760d4300b91b0ccccd73aa461 Mon Sep 17 00:00:00 2001 From: Minh Doan Date: Mon, 31 Dec 2018 17:32:32 -0800 Subject: [PATCH 2/3] fix import order --- benchmark.go | 3 +-- core/blockchain.go | 3 +-- core/chain_makers.go | 3 +-- core/state/state_test.go | 3 +-- harmony/main.go | 1 - node/node.go | 11 ++++------- trie/proof.go | 3 +-- trie/sync_test.go | 3 +-- 8 files changed, 10 insertions(+), 20 deletions(-) diff --git a/benchmark.go b/benchmark.go index b53315d4e..a444eab16 100644 --- a/benchmark.go +++ b/benchmark.go @@ -9,8 +9,6 @@ import ( "runtime" "time" - "github.com/harmony-one/harmony/p2p/p2pimpl" - "github.com/harmony-one/harmony/consensus" "github.com/harmony-one/harmony/internal/attack" "github.com/harmony-one/harmony/internal/db" @@ -18,6 +16,7 @@ import ( pkg_newnode "github.com/harmony-one/harmony/newnode" "github.com/harmony-one/harmony/node" "github.com/harmony-one/harmony/p2p" + "github.com/harmony-one/harmony/p2p/p2pimpl" "github.com/harmony-one/harmony/profiler" ) diff --git a/core/blockchain.go b/core/blockchain.go index 05a719487..04adef182 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -27,8 +27,6 @@ import ( "sync/atomic" "time" - hdb "github.com/harmony-one/harmony/internal/db" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/mclock" "github.com/ethereum/go-ethereum/common/prque" @@ -43,6 +41,7 @@ import ( "github.com/harmony-one/harmony/core/state" "github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/core/vm" + hdb "github.com/harmony-one/harmony/internal/db" "github.com/harmony-one/harmony/trie" "github.com/hashicorp/golang-lru" ) diff --git a/core/chain_makers.go b/core/chain_makers.go index c135d9106..f20f7fa6b 100644 --- a/core/chain_makers.go +++ b/core/chain_makers.go @@ -20,14 +20,13 @@ import ( "fmt" "math/big" - hdb "github.com/harmony-one/harmony/internal/db" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/params" "github.com/harmony-one/harmony/consensus" "github.com/harmony-one/harmony/core/state" "github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/core/vm" + hdb "github.com/harmony-one/harmony/internal/db" ) // BlockGen creates blocks for testing. diff --git a/core/state/state_test.go b/core/state/state_test.go index 50cd14966..153c50136 100644 --- a/core/state/state_test.go +++ b/core/state/state_test.go @@ -21,10 +21,9 @@ import ( "math/big" "testing" - "github.com/harmony-one/harmony/internal/db" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/harmony-one/harmony/internal/db" checker "gopkg.in/check.v1" ) diff --git a/harmony/main.go b/harmony/main.go index be9c0dfc2..c5916e7ee 100644 --- a/harmony/main.go +++ b/harmony/main.go @@ -7,7 +7,6 @@ import ( "math/big" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" "github.com/harmony-one/harmony/consensus" diff --git a/node/node.go b/node/node.go index fbf13fa0f..fb61d903a 100644 --- a/node/node.go +++ b/node/node.go @@ -14,16 +14,12 @@ import ( "sync/atomic" "time" - "github.com/ethereum/go-ethereum/rlp" - - "github.com/harmony-one/harmony/services/explorer" - - "github.com/harmony-one/harmony/client" - clientService "github.com/harmony-one/harmony/client/service" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" + "github.com/ethereum/go-ethereum/rlp" + "github.com/harmony-one/harmony/client" + clientService "github.com/harmony-one/harmony/client/service" bft "github.com/harmony-one/harmony/consensus" "github.com/harmony-one/harmony/core" "github.com/harmony-one/harmony/core/types" @@ -35,6 +31,7 @@ import ( "github.com/harmony-one/harmony/p2p" "github.com/harmony-one/harmony/p2p/host" proto_node "github.com/harmony-one/harmony/proto/node" + "github.com/harmony-one/harmony/services/explorer" "github.com/harmony-one/harmony/services/syncing" "github.com/harmony-one/harmony/services/syncing/downloader" downloader_pb "github.com/harmony-one/harmony/services/syncing/downloader/proto" diff --git a/trie/proof.go b/trie/proof.go index bf342b14e..af405eb8b 100644 --- a/trie/proof.go +++ b/trie/proof.go @@ -20,12 +20,11 @@ import ( "bytes" "fmt" - "github.com/harmony-one/harmony/internal/db" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rlp" + "github.com/harmony-one/harmony/internal/db" ) // Prove constructs a merkle proof for key. The result contains all encoded nodes diff --git a/trie/sync_test.go b/trie/sync_test.go index ae73d21fa..f2d9c5504 100644 --- a/trie/sync_test.go +++ b/trie/sync_test.go @@ -20,9 +20,8 @@ import ( "bytes" "testing" - "github.com/harmony-one/harmony/internal/db" - "github.com/ethereum/go-ethereum/common" + "github.com/harmony-one/harmony/internal/db" ) // makeTestTrie create a sample test trie to test node-wise reconstruction. From a6d7c050db82195b988a6840659c64d5e0777689 Mon Sep 17 00:00:00 2001 From: Minh Doan Date: Tue, 1 Jan 2019 11:31:25 -0800 Subject: [PATCH 3/3] move profiler into internal --- benchmark.go | 2 +- consensus/consensus_leader.go | 15 +++++++-------- {profiler => internal/profiler}/profiler.go | 0 3 files changed, 8 insertions(+), 9 deletions(-) rename {profiler => internal/profiler}/profiler.go (100%) diff --git a/benchmark.go b/benchmark.go index a444eab16..d5f6623fc 100644 --- a/benchmark.go +++ b/benchmark.go @@ -12,12 +12,12 @@ import ( "github.com/harmony-one/harmony/consensus" "github.com/harmony-one/harmony/internal/attack" "github.com/harmony-one/harmony/internal/db" + "github.com/harmony-one/harmony/internal/profiler" "github.com/harmony-one/harmony/log" pkg_newnode "github.com/harmony-one/harmony/newnode" "github.com/harmony-one/harmony/node" "github.com/harmony-one/harmony/p2p" "github.com/harmony-one/harmony/p2p/p2pimpl" - "github.com/harmony-one/harmony/profiler" ) var ( diff --git a/consensus/consensus_leader.go b/consensus/consensus_leader.go index 32b237836..5a93af3a3 100644 --- a/consensus/consensus_leader.go +++ b/consensus/consensus_leader.go @@ -4,22 +4,21 @@ import ( "bytes" "encoding/hex" "errors" - "github.com/ethereum/go-ethereum/rlp" "strconv" "time" - "github.com/harmony-one/harmony/core/types" - "github.com/harmony-one/harmony/p2p/host" - "github.com/harmony-one/harmony/services/explorer" - - consensus_proto "github.com/harmony-one/harmony/api/consensus" - "github.com/harmony-one/harmony/profiler" - "github.com/dedis/kyber" "github.com/dedis/kyber/sign/schnorr" + "github.com/ethereum/go-ethereum/rlp" + + consensus_proto "github.com/harmony-one/harmony/api/consensus" + "github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/crypto" + "github.com/harmony-one/harmony/internal/profiler" "github.com/harmony-one/harmony/log" "github.com/harmony-one/harmony/p2p" + "github.com/harmony-one/harmony/p2p/host" + "github.com/harmony-one/harmony/services/explorer" ) const ( diff --git a/profiler/profiler.go b/internal/profiler/profiler.go similarity index 100% rename from profiler/profiler.go rename to internal/profiler/profiler.go