diff --git a/accounts/abi/bind/backends/simulated.go b/accounts/abi/bind/backends/simulated.go index 33d7b4c87..d2053943b 100644 --- a/accounts/abi/bind/backends/simulated.go +++ b/accounts/abi/bind/backends/simulated.go @@ -27,6 +27,7 @@ import ( "github.com/holiman/uint256" ethereum "github.com/ledgerwatch/erigon" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/accounts/abi" "github.com/ledgerwatch/erigon/accounts/abi/bind" "github.com/ledgerwatch/erigon/common" @@ -42,7 +43,6 @@ import ( "github.com/ledgerwatch/erigon/core/vm" "github.com/ledgerwatch/erigon/eth/filters" "github.com/ledgerwatch/erigon/ethdb" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/olddb" "github.com/ledgerwatch/erigon/event" "github.com/ledgerwatch/erigon/params" diff --git a/accounts/abi/bind/backends/simulated_test.go b/accounts/abi/bind/backends/simulated_test.go index ddd569c80..ba3003cbb 100644 --- a/accounts/abi/bind/backends/simulated_test.go +++ b/accounts/abi/bind/backends/simulated_test.go @@ -28,6 +28,7 @@ import ( "github.com/holiman/uint256" ethereum "github.com/ledgerwatch/erigon" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/accounts/abi" "github.com/ledgerwatch/erigon/accounts/abi/bind" "github.com/ledgerwatch/erigon/common" @@ -37,7 +38,6 @@ import ( "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/crypto" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/params" ) diff --git a/cmd/cons/commands/clique.go b/cmd/cons/commands/clique.go index c2b37b2cd..efef2f9b6 100644 --- a/cmd/cons/commands/clique.go +++ b/cmd/cons/commands/clique.go @@ -19,12 +19,12 @@ import ( "github.com/holiman/uint256" "github.com/ledgerwatch/erigon-lib/gointerfaces" proto_cons "github.com/ledgerwatch/erigon-lib/gointerfaces/consensus" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/cmd/utils" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/consensus/clique" "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/metrics" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/log/v3" diff --git a/cmd/cons/commands/root.go b/cmd/cons/commands/root.go index b40a187a1..32602d91d 100644 --- a/cmd/cons/commands/root.go +++ b/cmd/cons/commands/root.go @@ -4,10 +4,10 @@ import ( "fmt" "os" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/mdbx" "github.com/ledgerwatch/erigon/cmd/utils" "github.com/ledgerwatch/erigon/common/paths" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/erigon/internal/debug" "github.com/ledgerwatch/log/v3" "github.com/spf13/cobra" diff --git a/cmd/erigon/main.go b/cmd/erigon/main.go index d0b04b820..b50937fef 100644 --- a/cmd/erigon/main.go +++ b/cmd/erigon/main.go @@ -5,11 +5,11 @@ import ( "fmt" "os" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/cmd/utils" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/debug" "github.com/ledgerwatch/erigon/core/rawdb" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/params" erigoncli "github.com/ledgerwatch/erigon/turbo/cli" "github.com/ledgerwatch/erigon/turbo/node" diff --git a/cmd/evm/internal/t8ntool/execution.go b/cmd/evm/internal/t8ntool/execution.go index e014e79fa..5d2cc74e0 100644 --- a/cmd/evm/internal/t8ntool/execution.go +++ b/cmd/evm/internal/t8ntool/execution.go @@ -22,6 +22,8 @@ import ( "math/big" "github.com/holiman/uint256" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/math" "github.com/ledgerwatch/erigon/consensus/misc" @@ -30,8 +32,6 @@ import ( "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/vm" "github.com/ledgerwatch/erigon/crypto" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/memdb" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/erigon/turbo/trie" diff --git a/cmd/evm/runner.go b/cmd/evm/runner.go index 4a237ce02..e2d26ac35 100644 --- a/cmd/evm/runner.go +++ b/cmd/evm/runner.go @@ -30,7 +30,7 @@ import ( "time" "github.com/holiman/uint256" - "github.com/ledgerwatch/erigon/ethdb/memdb" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/urfave/cli" "github.com/ledgerwatch/erigon/cmd/evm/internal/compiler" diff --git a/cmd/evm/staterunner.go b/cmd/evm/staterunner.go index 9d1ae2819..2ec676484 100644 --- a/cmd/evm/staterunner.go +++ b/cmd/evm/staterunner.go @@ -24,10 +24,10 @@ import ( "io/ioutil" "os" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/core/vm" - "github.com/ledgerwatch/erigon/ethdb/memdb" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/tests" "github.com/ledgerwatch/erigon/turbo/trie" diff --git a/cmd/hack/db/lmdb.go b/cmd/hack/db/lmdb.go index 1abe74d7b..39bed92d1 100644 --- a/cmd/hack/db/lmdb.go +++ b/cmd/hack/db/lmdb.go @@ -15,9 +15,9 @@ import ( "path" "strings" + "github.com/ledgerwatch/erigon-lib/kv" + kv2 "github.com/ledgerwatch/erigon-lib/kv/mdbx" "github.com/ledgerwatch/erigon/common/debug" - "github.com/ledgerwatch/erigon/ethdb/kv" - kv2 "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/log/v3" ) diff --git a/cmd/hack/hack.go b/cmd/hack/hack.go index e4e5b597b..74f4d7949 100644 --- a/cmd/hack/hack.go +++ b/cmd/hack/hack.go @@ -20,12 +20,12 @@ import ( "github.com/RoaringBitmap/roaring/roaring64" "github.com/holiman/uint256" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/mdbx" "github.com/ledgerwatch/erigon/consensus/ethash" "github.com/ledgerwatch/erigon/consensus/misc" "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/ethdb/cbor" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/erigon/params" "github.com/wcharczuk/go-chart" "github.com/wcharczuk/go-chart/util" diff --git a/cmd/integration/commands/refetence_db.go b/cmd/integration/commands/refetence_db.go index 46f49f5cc..3889d407b 100644 --- a/cmd/integration/commands/refetence_db.go +++ b/cmd/integration/commands/refetence_db.go @@ -9,10 +9,10 @@ import ( "strings" "time" + "github.com/ledgerwatch/erigon-lib/kv" + mdbx2 "github.com/ledgerwatch/erigon-lib/kv/mdbx" "github.com/ledgerwatch/erigon/cmd/utils" "github.com/ledgerwatch/erigon/common" - "github.com/ledgerwatch/erigon/ethdb/kv" - mdbx2 "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/log/v3" "github.com/spf13/cobra" "github.com/torquem-ch/mdbx-go/mdbx" diff --git a/cmd/integration/commands/reset_state.go b/cmd/integration/commands/reset_state.go index 5d54aaea4..4308e4860 100644 --- a/cmd/integration/commands/reset_state.go +++ b/cmd/integration/commands/reset_state.go @@ -6,11 +6,11 @@ import ( "os" "text/tabwriter" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/cmd/utils" "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/eth/stagedsync" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/prune" "github.com/ledgerwatch/log/v3" "github.com/spf13/cobra" diff --git a/cmd/integration/commands/root.go b/cmd/integration/commands/root.go index 0ef9e849e..df29f2028 100644 --- a/cmd/integration/commands/root.go +++ b/cmd/integration/commands/root.go @@ -3,9 +3,9 @@ package commands import ( "path" + "github.com/ledgerwatch/erigon-lib/kv" + kv2 "github.com/ledgerwatch/erigon-lib/kv/mdbx" "github.com/ledgerwatch/erigon/cmd/utils" - "github.com/ledgerwatch/erigon/ethdb/kv" - kv2 "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/erigon/internal/debug" "github.com/ledgerwatch/erigon/migrations" "github.com/ledgerwatch/log/v3" diff --git a/cmd/integration/commands/snapshot_check.go b/cmd/integration/commands/snapshot_check.go index 8ee3959fc..c817d3c7d 100644 --- a/cmd/integration/commands/snapshot_check.go +++ b/cmd/integration/commands/snapshot_check.go @@ -9,12 +9,12 @@ import ( "time" "github.com/c2h5oh/datasize" + "github.com/ledgerwatch/erigon-lib/kv" + kv2 "github.com/ledgerwatch/erigon-lib/kv/mdbx" "github.com/ledgerwatch/erigon/cmd/utils" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/eth/stagedsync" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" - "github.com/ledgerwatch/erigon/ethdb/kv" - kv2 "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/erigon/ethdb/prune" "github.com/ledgerwatch/erigon/ethdb/snapshotdb" "github.com/ledgerwatch/erigon/turbo/snapshotsync" diff --git a/cmd/integration/commands/stages.go b/cmd/integration/commands/stages.go index ef357e608..9025364b2 100644 --- a/cmd/integration/commands/stages.go +++ b/cmd/integration/commands/stages.go @@ -8,6 +8,7 @@ import ( "strings" "github.com/c2h5oh/datasize" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/cmd/sentry/download" "github.com/ledgerwatch/erigon/cmd/utils" "github.com/ledgerwatch/erigon/common" @@ -21,7 +22,6 @@ import ( "github.com/ledgerwatch/erigon/eth/integrity" "github.com/ledgerwatch/erigon/eth/stagedsync" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/privateapi" "github.com/ledgerwatch/erigon/ethdb/prune" "github.com/ledgerwatch/erigon/migrations" diff --git a/cmd/integration/commands/state_stages.go b/cmd/integration/commands/state_stages.go index b7b99da2e..66f8546d7 100644 --- a/cmd/integration/commands/state_stages.go +++ b/cmd/integration/commands/state_stages.go @@ -11,7 +11,7 @@ import ( "time" "github.com/c2h5oh/datasize" - "github.com/ledgerwatch/erigon/ethdb/kv" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/spf13/cobra" "github.com/ledgerwatch/erigon/cmd/utils" diff --git a/cmd/pics/state.go b/cmd/pics/state.go index c9b30d49a..75cd63cd4 100644 --- a/cmd/pics/state.go +++ b/cmd/pics/state.go @@ -12,6 +12,8 @@ import ( "strings" "github.com/holiman/uint256" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/accounts/abi/bind" "github.com/ledgerwatch/erigon/accounts/abi/bind/backends" "github.com/ledgerwatch/erigon/cmd/pics/contracts" @@ -19,8 +21,6 @@ import ( "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/crypto" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/memdb" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/turbo/stages" "github.com/ledgerwatch/erigon/turbo/trie" diff --git a/cmd/rpcdaemon/cli/config.go b/cmd/rpcdaemon/cli/config.go index f08b6fc0d..417f84ae3 100644 --- a/cmd/rpcdaemon/cli/config.go +++ b/cmd/rpcdaemon/cli/config.go @@ -9,11 +9,11 @@ import ( "time" "github.com/ledgerwatch/erigon-lib/gointerfaces" + "github.com/ledgerwatch/erigon-lib/kv" + kv2 "github.com/ledgerwatch/erigon-lib/kv/mdbx" "github.com/ledgerwatch/erigon/cmd/rpcdaemon/services" "github.com/ledgerwatch/erigon/cmd/utils" "github.com/ledgerwatch/erigon/common/paths" - "github.com/ledgerwatch/erigon/ethdb/kv" - kv2 "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/erigon/ethdb/remotedb" "github.com/ledgerwatch/erigon/ethdb/remotedbserver" "github.com/ledgerwatch/erigon/internal/debug" diff --git a/cmd/rpcdaemon/commands/daemon.go b/cmd/rpcdaemon/commands/daemon.go index 8678712ee..5e064cee2 100644 --- a/cmd/rpcdaemon/commands/daemon.go +++ b/cmd/rpcdaemon/commands/daemon.go @@ -4,10 +4,10 @@ import ( "context" "github.com/ledgerwatch/erigon-lib/gointerfaces/txpool" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/cmd/rpcdaemon/cli" "github.com/ledgerwatch/erigon/cmd/rpcdaemon/filters" "github.com/ledgerwatch/erigon/cmd/rpcdaemon/services" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/rpc" ) diff --git a/cmd/rpcdaemon/commands/debug_api.go b/cmd/rpcdaemon/commands/debug_api.go index 7e208cfcb..6eb4c56c9 100644 --- a/cmd/rpcdaemon/commands/debug_api.go +++ b/cmd/rpcdaemon/commands/debug_api.go @@ -5,6 +5,7 @@ import ( "fmt" jsoniter "github.com/json-iterator/go" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/changeset" "github.com/ledgerwatch/erigon/common/hexutil" @@ -16,7 +17,6 @@ import ( "github.com/ledgerwatch/erigon/eth/stagedsync/stages" "github.com/ledgerwatch/erigon/eth/tracers" "github.com/ledgerwatch/erigon/ethdb" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/internal/ethapi" "github.com/ledgerwatch/erigon/rpc" "github.com/ledgerwatch/erigon/turbo/transactions" diff --git a/cmd/rpcdaemon/commands/erigon_api.go b/cmd/rpcdaemon/commands/erigon_api.go index 75a01a21d..9870b6b68 100644 --- a/cmd/rpcdaemon/commands/erigon_api.go +++ b/cmd/rpcdaemon/commands/erigon_api.go @@ -3,9 +3,9 @@ package commands import ( "context" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/rpc" ) diff --git a/cmd/rpcdaemon/commands/erigon_issuance.go b/cmd/rpcdaemon/commands/erigon_issuance.go index aa1c8b79f..b45d60cbc 100644 --- a/cmd/rpcdaemon/commands/erigon_issuance.go +++ b/cmd/rpcdaemon/commands/erigon_issuance.go @@ -3,11 +3,11 @@ package commands import ( "context" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/consensus/ethash" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/rpc" ) diff --git a/cmd/rpcdaemon/commands/eth_api.go b/cmd/rpcdaemon/commands/eth_api.go index 39cafe306..f522db64c 100644 --- a/cmd/rpcdaemon/commands/eth_api.go +++ b/cmd/rpcdaemon/commands/eth_api.go @@ -7,8 +7,8 @@ import ( "sync" "github.com/holiman/uint256" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/consensus/misc" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon-lib/gointerfaces/txpool" "github.com/ledgerwatch/erigon/cmd/rpcdaemon/filters" diff --git a/cmd/rpcdaemon/commands/eth_call.go b/cmd/rpcdaemon/commands/eth_call.go index 917397fcf..03e9608db 100644 --- a/cmd/rpcdaemon/commands/eth_call.go +++ b/cmd/rpcdaemon/commands/eth_call.go @@ -6,6 +6,7 @@ import ( "fmt" "math/big" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/core" @@ -13,7 +14,6 @@ import ( "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/vm" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/internal/ethapi" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rpc" diff --git a/cmd/rpcdaemon/commands/eth_receipts.go b/cmd/rpcdaemon/commands/eth_receipts.go index 008c69fe1..edfd25be0 100644 --- a/cmd/rpcdaemon/commands/eth_receipts.go +++ b/cmd/rpcdaemon/commands/eth_receipts.go @@ -8,7 +8,7 @@ import ( "math/big" "github.com/holiman/uint256" - "github.com/ledgerwatch/erigon/ethdb/kv" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/RoaringBitmap/roaring" "github.com/ledgerwatch/erigon/common" diff --git a/cmd/rpcdaemon/commands/get_chain_config_test.go b/cmd/rpcdaemon/commands/get_chain_config_test.go index c7b136a3f..a4ed4fdad 100644 --- a/cmd/rpcdaemon/commands/get_chain_config_test.go +++ b/cmd/rpcdaemon/commands/get_chain_config_test.go @@ -4,8 +4,8 @@ import ( "context" "testing" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/core" - "github.com/ledgerwatch/erigon/ethdb/memdb" ) func TestGetChainConfig(t *testing.T) { diff --git a/cmd/rpcdaemon/commands/rpc_block.go b/cmd/rpcdaemon/commands/rpc_block.go index d3a746c25..2465831c0 100644 --- a/cmd/rpcdaemon/commands/rpc_block.go +++ b/cmd/rpcdaemon/commands/rpc_block.go @@ -3,8 +3,8 @@ package commands import ( "fmt" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/rpc" ) diff --git a/cmd/rpcdaemon/commands/trace_adhoc.go b/cmd/rpcdaemon/commands/trace_adhoc.go index 36e17d9ee..01997b9b4 100644 --- a/cmd/rpcdaemon/commands/trace_adhoc.go +++ b/cmd/rpcdaemon/commands/trace_adhoc.go @@ -10,6 +10,7 @@ import ( "time" "github.com/holiman/uint256" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/hexutil" math2 "github.com/ledgerwatch/erigon/common/math" @@ -20,7 +21,6 @@ import ( "github.com/ledgerwatch/erigon/core/types/accounts" "github.com/ledgerwatch/erigon/core/vm" "github.com/ledgerwatch/erigon/core/vm/stack" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/rpc" "github.com/ledgerwatch/erigon/turbo/rpchelper" "github.com/ledgerwatch/erigon/turbo/shards" diff --git a/cmd/rpcdaemon/commands/trace_adhoc_test.go b/cmd/rpcdaemon/commands/trace_adhoc_test.go index 8bcb36b61..a2f8df200 100644 --- a/cmd/rpcdaemon/commands/trace_adhoc_test.go +++ b/cmd/rpcdaemon/commands/trace_adhoc_test.go @@ -5,12 +5,12 @@ import ( "encoding/json" "testing" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/cmd/rpcdaemon/cli" "github.com/ledgerwatch/erigon/cmd/rpcdaemon/rpcdaemontest" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/core/rawdb" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/rpc" "github.com/stretchr/testify/require" ) diff --git a/cmd/rpcdaemon/commands/trace_api.go b/cmd/rpcdaemon/commands/trace_api.go index 33505fc07..df58c8c74 100644 --- a/cmd/rpcdaemon/commands/trace_api.go +++ b/cmd/rpcdaemon/commands/trace_api.go @@ -5,10 +5,10 @@ import ( "encoding/json" jsoniter "github.com/json-iterator/go" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/cmd/rpcdaemon/cli" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/hexutil" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/rpc" ) diff --git a/cmd/rpcdaemon/commands/trace_filtering.go b/cmd/rpcdaemon/commands/trace_filtering.go index 942efb3b4..82694f0a8 100644 --- a/cmd/rpcdaemon/commands/trace_filtering.go +++ b/cmd/rpcdaemon/commands/trace_filtering.go @@ -6,13 +6,13 @@ import ( "github.com/RoaringBitmap/roaring/roaring64" jsoniter "github.com/json-iterator/go" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/consensus/ethash" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/ethdb/bitmapdb" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/rpc" ) diff --git a/cmd/rpcdaemon/commands/txpool_api.go b/cmd/rpcdaemon/commands/txpool_api.go index 336af0727..bb6a321fc 100644 --- a/cmd/rpcdaemon/commands/txpool_api.go +++ b/cmd/rpcdaemon/commands/txpool_api.go @@ -6,10 +6,10 @@ import ( "fmt" proto_txpool "github.com/ledgerwatch/erigon-lib/gointerfaces/txpool" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/rlp" ) diff --git a/cmd/rpcdaemon/rpcdaemontest/test_util.go b/cmd/rpcdaemon/rpcdaemontest/test_util.go index dbb5c25a8..45bf89484 100644 --- a/cmd/rpcdaemon/rpcdaemontest/test_util.go +++ b/cmd/rpcdaemon/rpcdaemontest/test_util.go @@ -9,6 +9,7 @@ import ( "github.com/holiman/uint256" "github.com/ledgerwatch/erigon-lib/gointerfaces/txpool" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/accounts/abi/bind" "github.com/ledgerwatch/erigon/accounts/abi/bind/backends" "github.com/ledgerwatch/erigon/cmd/rpcdaemon/commands/contracts" @@ -17,7 +18,6 @@ import ( "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/crypto" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/privateapi" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/turbo/stages" diff --git a/cmd/rpctest/rpctest/account_range_verify.go b/cmd/rpctest/rpctest/account_range_verify.go index 7e7a41f60..a8a0f92cc 100644 --- a/cmd/rpctest/rpctest/account_range_verify.go +++ b/cmd/rpctest/rpctest/account_range_verify.go @@ -11,10 +11,10 @@ import ( "time" "github.com/davecgh/go-spew/spew" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/mdbx" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core/state" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/log/v3" ) diff --git a/cmd/sentry/download/downloader.go b/cmd/sentry/download/downloader.go index 4ba51463c..b9cdeb401 100644 --- a/cmd/sentry/download/downloader.go +++ b/cmd/sentry/download/downloader.go @@ -14,12 +14,12 @@ import ( "github.com/holiman/uint256" "github.com/ledgerwatch/erigon-lib/gointerfaces" proto_sentry "github.com/ledgerwatch/erigon-lib/gointerfaces/sentry" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" debug2 "github.com/ledgerwatch/erigon/common/debug" "github.com/ledgerwatch/erigon/consensus" "github.com/ledgerwatch/erigon/core/forkid" "github.com/ledgerwatch/erigon/eth/protocols/eth" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/erigon/turbo/remote" diff --git a/cmd/sentry/download/sentry_test.go b/cmd/sentry/download/sentry_test.go index 23818a956..d9852573e 100644 --- a/cmd/sentry/download/sentry_test.go +++ b/cmd/sentry/download/sentry_test.go @@ -9,13 +9,13 @@ import ( "github.com/holiman/uint256" "github.com/ledgerwatch/erigon-lib/gointerfaces" proto_sentry "github.com/ledgerwatch/erigon-lib/gointerfaces/sentry" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/forkid" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/eth/protocols/eth" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/memdb" "github.com/ledgerwatch/erigon/p2p" "github.com/ledgerwatch/erigon/params" "github.com/stretchr/testify/require" diff --git a/cmd/snapshots/debug/debug_test.go b/cmd/snapshots/debug/debug_test.go index f9596c7f4..cb5e510e4 100644 --- a/cmd/snapshots/debug/debug_test.go +++ b/cmd/snapshots/debug/debug_test.go @@ -9,6 +9,8 @@ import ( "time" "github.com/holiman/uint256" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/mdbx" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/consensus/ethash" @@ -19,8 +21,6 @@ import ( "github.com/ledgerwatch/erigon/core/types/accounts" "github.com/ledgerwatch/erigon/core/vm" "github.com/ledgerwatch/erigon/ethdb" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/erigon/ethdb/snapshotdb" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/log/v3" diff --git a/cmd/snapshots/generator/commands/copy_from_state.go b/cmd/snapshots/generator/commands/copy_from_state.go index 55ca97075..d2274ad81 100644 --- a/cmd/snapshots/generator/commands/copy_from_state.go +++ b/cmd/snapshots/generator/commands/copy_from_state.go @@ -6,8 +6,8 @@ import ( "os" "time" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/mdbx" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/mdbx" "github.com/ledgerwatch/log/v3" "github.com/spf13/cobra" ) diff --git a/cmd/snapshots/generator/commands/generate_body_snapshot.go b/cmd/snapshots/generator/commands/generate_body_snapshot.go index 1e88cd667..194acebfc 100644 --- a/cmd/snapshots/generator/commands/generate_body_snapshot.go +++ b/cmd/snapshots/generator/commands/generate_body_snapshot.go @@ -6,8 +6,8 @@ import ( "os" "time" - "github.com/ledgerwatch/erigon/ethdb/kv" - kv2 "github.com/ledgerwatch/erigon/ethdb/mdbx" + "github.com/ledgerwatch/erigon-lib/kv" + kv2 "github.com/ledgerwatch/erigon-lib/kv/mdbx" "github.com/spf13/cobra" "github.com/ledgerwatch/erigon/common" diff --git a/cmd/snapshots/generator/commands/generate_header_snapshot.go b/cmd/snapshots/generator/commands/generate_header_snapshot.go index 0c24cfa90..fd3b85d67 100644 --- a/cmd/snapshots/generator/commands/generate_header_snapshot.go +++ b/cmd/snapshots/generator/commands/generate_header_snapshot.go @@ -7,8 +7,8 @@ import ( "os" "time" - "github.com/ledgerwatch/erigon/ethdb/kv" - kv2 "github.com/ledgerwatch/erigon/ethdb/mdbx" + "github.com/ledgerwatch/erigon-lib/kv" + kv2 "github.com/ledgerwatch/erigon-lib/kv/mdbx" "github.com/spf13/cobra" "github.com/ledgerwatch/erigon/common" diff --git a/cmd/snapshots/generator/commands/generate_state_snapshot.go b/cmd/snapshots/generator/commands/generate_state_snapshot.go index 08f900d72..45490e8c4 100644 --- a/cmd/snapshots/generator/commands/generate_state_snapshot.go +++ b/cmd/snapshots/generator/commands/generate_state_snapshot.go @@ -7,13 +7,13 @@ import ( "os" "time" + "github.com/ledgerwatch/erigon-lib/kv" + kv2 "github.com/ledgerwatch/erigon-lib/kv/mdbx" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/core/types/accounts" "github.com/ledgerwatch/erigon/ethdb" - "github.com/ledgerwatch/erigon/ethdb/kv" - kv2 "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/erigon/turbo/trie" "github.com/ledgerwatch/log/v3" "github.com/spf13/cobra" diff --git a/cmd/snapshots/generator/commands/verify_headers.go b/cmd/snapshots/generator/commands/verify_headers.go index df1dfdb3a..07043204b 100644 --- a/cmd/snapshots/generator/commands/verify_headers.go +++ b/cmd/snapshots/generator/commands/verify_headers.go @@ -6,8 +6,8 @@ import ( "sync/atomic" "time" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/erigon/turbo/snapshotsync" "github.com/ledgerwatch/log/v3" diff --git a/cmd/snapshots/generator/commands/verify_state_snapshot.go b/cmd/snapshots/generator/commands/verify_state_snapshot.go index aef481b31..fa3d0ffc9 100644 --- a/cmd/snapshots/generator/commands/verify_state_snapshot.go +++ b/cmd/snapshots/generator/commands/verify_state_snapshot.go @@ -7,10 +7,10 @@ import ( "os" "time" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/mdbx" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/eth/stagedsync" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/erigon/ethdb/snapshotdb" "github.com/ledgerwatch/log/v3" "github.com/spf13/cobra" diff --git a/cmd/snapshots/tracker/commands/root.go b/cmd/snapshots/tracker/commands/root.go index 23f11df78..6c443015e 100644 --- a/cmd/snapshots/tracker/commands/root.go +++ b/cmd/snapshots/tracker/commands/root.go @@ -16,11 +16,11 @@ import ( "github.com/anacrolix/torrent/bencode" "github.com/anacrolix/torrent/tracker" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/mdbx" "github.com/ledgerwatch/erigon/cmd/utils" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/ethdb" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/erigon/internal/debug" "github.com/ledgerwatch/log/v3" "github.com/spf13/cobra" diff --git a/cmd/snapshots/utils/utils.go b/cmd/snapshots/utils/utils.go index 0bfea7b85..ed7930f9d 100644 --- a/cmd/snapshots/utils/utils.go +++ b/cmd/snapshots/utils/utils.go @@ -4,8 +4,8 @@ import ( "errors" "os" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/mdbx" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/mdbx" "github.com/ledgerwatch/log/v3" ) diff --git a/cmd/state/commands/check_change_sets.go b/cmd/state/commands/check_change_sets.go index 1363214b7..c2cd22839 100644 --- a/cmd/state/commands/check_change_sets.go +++ b/cmd/state/commands/check_change_sets.go @@ -10,6 +10,8 @@ import ( "syscall" "time" + "github.com/ledgerwatch/erigon-lib/kv" + kv2 "github.com/ledgerwatch/erigon-lib/kv/mdbx" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/changeset" "github.com/ledgerwatch/erigon/common/dbutils" @@ -19,8 +21,6 @@ import ( "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/vm" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" - "github.com/ledgerwatch/erigon/ethdb/kv" - kv2 "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/log/v3" "github.com/spf13/cobra" ) diff --git a/cmd/state/commands/global_flags_vars.go b/cmd/state/commands/global_flags_vars.go index d1759f913..71df5183d 100644 --- a/cmd/state/commands/global_flags_vars.go +++ b/cmd/state/commands/global_flags_vars.go @@ -1,8 +1,8 @@ package commands import ( + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common/paths" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/spf13/cobra" ) diff --git a/cmd/state/commands/opcode_tracer.go b/cmd/state/commands/opcode_tracer.go index cf86db05b..edfd3fa64 100644 --- a/cmd/state/commands/opcode_tracer.go +++ b/cmd/state/commands/opcode_tracer.go @@ -13,6 +13,8 @@ import ( "syscall" "time" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/mdbx" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/debug" "github.com/ledgerwatch/erigon/consensus/ethash" @@ -23,8 +25,6 @@ import ( "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/vm" "github.com/ledgerwatch/erigon/core/vm/stack" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/log/v3" "github.com/spf13/cobra" diff --git a/cmd/state/generate/regenerate_tx_lookup.go b/cmd/state/generate/regenerate_tx_lookup.go index 3f98e74aa..89b388a9f 100644 --- a/cmd/state/generate/regenerate_tx_lookup.go +++ b/cmd/state/generate/regenerate_tx_lookup.go @@ -6,11 +6,11 @@ import ( "os/signal" "time" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/mdbx" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/eth/stagedsync" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/erigon/ethdb/prune" "github.com/ledgerwatch/log/v3" ) diff --git a/cmd/state/stats/index_stats.go b/cmd/state/stats/index_stats.go index 4a02e1097..11a82336d 100644 --- a/cmd/state/stats/index_stats.go +++ b/cmd/state/stats/index_stats.go @@ -12,9 +12,9 @@ import ( "strings" "time" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/mdbx" "github.com/ledgerwatch/erigon/common" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/mdbx" ) func IndexStats(chaindata string, indexBucket string, statsFile string) error { diff --git a/cmd/state/verify/check_changeset_enc.go b/cmd/state/verify/check_changeset_enc.go index 0a4f63425..bd1f49705 100644 --- a/cmd/state/verify/check_changeset_enc.go +++ b/cmd/state/verify/check_changeset_enc.go @@ -9,9 +9,9 @@ import ( "sync/atomic" "time" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/mdbx" "github.com/ledgerwatch/erigon/common/changeset" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/mdbx" "golang.org/x/sync/errgroup" ) diff --git a/cmd/state/verify/check_indexes.go b/cmd/state/verify/check_indexes.go index 6dccc97e1..f11b3459d 100644 --- a/cmd/state/verify/check_indexes.go +++ b/cmd/state/verify/check_indexes.go @@ -5,11 +5,11 @@ import ( "fmt" "time" + "github.com/ledgerwatch/erigon-lib/kv/mdbx" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/changeset" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/ethdb/bitmapdb" - "github.com/ledgerwatch/erigon/ethdb/mdbx" ) func CheckIndex(ctx context.Context, chaindata string, changeSetBucket string, indexBucket string) error { diff --git a/cmd/state/verify/verify_headers_snapshot.go b/cmd/state/verify/verify_headers_snapshot.go index 67f0b9d88..0debde447 100644 --- a/cmd/state/verify/verify_headers_snapshot.go +++ b/cmd/state/verify/verify_headers_snapshot.go @@ -4,9 +4,9 @@ import ( "context" "errors" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/mdbx" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/log/v3" ) diff --git a/cmd/state/verify/verify_txlookup.go b/cmd/state/verify/verify_txlookup.go index 73c30c536..872f93983 100644 --- a/cmd/state/verify/verify_txlookup.go +++ b/cmd/state/verify/verify_txlookup.go @@ -9,10 +9,10 @@ import ( "os/signal" "time" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/mdbx" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core/rawdb" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/log/v3" ) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 12cfffd6f..011fee7d3 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -30,8 +30,8 @@ import ( "text/tabwriter" "text/template" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/eth/protocols/eth" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/spf13/cobra" "github.com/spf13/pflag" "github.com/urfave/cli" diff --git a/common/changeset/account_changeset.go b/common/changeset/account_changeset.go index 02f8ef8b5..57f3b1d2b 100644 --- a/common/changeset/account_changeset.go +++ b/common/changeset/account_changeset.go @@ -5,9 +5,9 @@ import ( "encoding/binary" "sort" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" - "github.com/ledgerwatch/erigon/ethdb/kv" ) type Encoder func(blockN uint64, s *ChangeSet, f func(k, v []byte) error) error diff --git a/common/changeset/account_changeset_test.go b/common/changeset/account_changeset_test.go index 02d051b72..a2ec20230 100644 --- a/common/changeset/account_changeset_test.go +++ b/common/changeset/account_changeset_test.go @@ -6,8 +6,8 @@ import ( "reflect" "testing" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/stretchr/testify/assert" ) diff --git a/common/changeset/changeset.go b/common/changeset/changeset.go index 0b8f542cb..36799ebb1 100644 --- a/common/changeset/changeset.go +++ b/common/changeset/changeset.go @@ -6,11 +6,11 @@ import ( "fmt" "reflect" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/common/math" "github.com/ledgerwatch/erigon/ethdb" - "github.com/ledgerwatch/erigon/ethdb/kv" ) func NewChangeSet() *ChangeSet { diff --git a/common/changeset/storage_changeset.go b/common/changeset/storage_changeset.go index 632a0d917..b595f493b 100644 --- a/common/changeset/storage_changeset.go +++ b/common/changeset/storage_changeset.go @@ -6,11 +6,11 @@ import ( "errors" "sort" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/common/etl" "github.com/ledgerwatch/erigon/ethdb" - "github.com/ledgerwatch/erigon/ethdb/kv" ) const ( diff --git a/common/changeset/storage_changeset_test.go b/common/changeset/storage_changeset_test.go index 0139e09d5..74e4505c6 100644 --- a/common/changeset/storage_changeset_test.go +++ b/common/changeset/storage_changeset_test.go @@ -8,10 +8,10 @@ import ( "strconv" "testing" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/memdb" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/common/etl/buffers.go b/common/etl/buffers.go index 7ea98ac1d..f07876ef7 100644 --- a/common/etl/buffers.go +++ b/common/etl/buffers.go @@ -7,7 +7,7 @@ import ( "strconv" "github.com/c2h5oh/datasize" - "github.com/ledgerwatch/erigon/ethdb/kv" + "github.com/ledgerwatch/erigon-lib/kv" ) const ( diff --git a/common/etl/collector.go b/common/etl/collector.go index 360fb43b5..d080d7f87 100644 --- a/common/etl/collector.go +++ b/common/etl/collector.go @@ -12,8 +12,8 @@ import ( "time" "github.com/c2h5oh/datasize" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/log/v3" "github.com/ugorji/go/codec" ) diff --git a/common/etl/etl.go b/common/etl/etl.go index b1114ebd9..2769bdd0a 100644 --- a/common/etl/etl.go +++ b/common/etl/etl.go @@ -9,9 +9,9 @@ import ( "time" "github.com/c2h5oh/datasize" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/ethdb" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/log/v3" "github.com/ugorji/go/codec" ) diff --git a/common/etl/etl_test.go b/common/etl/etl_test.go index 8450d3fb4..8466b4148 100644 --- a/common/etl/etl_test.go +++ b/common/etl/etl_test.go @@ -8,9 +8,9 @@ import ( "strings" "testing" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/common" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/memdb" "github.com/stretchr/testify/assert" "github.com/ugorji/go/codec" ) diff --git a/common/etl/heap.go b/common/etl/heap.go index 3e5ff8d37..37c8f7426 100644 --- a/common/etl/heap.go +++ b/common/etl/heap.go @@ -3,7 +3,7 @@ package etl import ( "bytes" - "github.com/ledgerwatch/erigon/ethdb/kv" + "github.com/ledgerwatch/erigon-lib/kv" ) type HeapElem struct { diff --git a/consensus/aura/aura.go b/consensus/aura/aura.go index c30befd86..5e34525c1 100644 --- a/consensus/aura/aura.go +++ b/consensus/aura/aura.go @@ -28,6 +28,7 @@ import ( lru "github.com/hashicorp/golang-lru" "github.com/holiman/uint256" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/accounts/abi" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/consensus" @@ -37,7 +38,6 @@ import ( "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/crypto" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/erigon/rpc" diff --git a/consensus/aura/aura_test.go b/consensus/aura/aura_test.go index 51a4d4fce..64f330810 100644 --- a/consensus/aura/aura_test.go +++ b/consensus/aura/aura_test.go @@ -5,14 +5,14 @@ import ( "fmt" "testing" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/consensus/aura" "github.com/ledgerwatch/erigon/consensus/aura/test" "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types/accounts" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/memdb" "github.com/ledgerwatch/erigon/turbo/stages" "github.com/stretchr/testify/require" ) diff --git a/consensus/clique/clique.go b/consensus/clique/clique.go index 88e0e888b..a35d55acd 100644 --- a/consensus/clique/clique.go +++ b/consensus/clique/clique.go @@ -29,7 +29,7 @@ import ( "github.com/goccy/go-json" lru "github.com/hashicorp/golang-lru" - "github.com/ledgerwatch/erigon/ethdb/kv" + "github.com/ledgerwatch/erigon-lib/kv" "golang.org/x/crypto/sha3" "github.com/ledgerwatch/erigon/common" diff --git a/consensus/clique/clique_test.go b/consensus/clique/clique_test.go index 40096c6d0..1d0946de8 100644 --- a/consensus/clique/clique_test.go +++ b/consensus/clique/clique_test.go @@ -22,8 +22,8 @@ import ( "testing" "github.com/holiman/uint256" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/memdb" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/consensus/clique" diff --git a/consensus/clique/snapshot.go b/consensus/clique/snapshot.go index 20012de63..f8fdb21f0 100644 --- a/consensus/clique/snapshot.go +++ b/consensus/clique/snapshot.go @@ -26,7 +26,7 @@ import ( "github.com/goccy/go-json" lru "github.com/hashicorp/golang-lru" - "github.com/ledgerwatch/erigon/ethdb/kv" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" diff --git a/consensus/clique/snapshot_test.go b/consensus/clique/snapshot_test.go index e5550acd9..9043bfdca 100644 --- a/consensus/clique/snapshot_test.go +++ b/consensus/clique/snapshot_test.go @@ -22,13 +22,13 @@ import ( "sort" "testing" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/consensus/clique" "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/crypto" "github.com/ledgerwatch/erigon/eth/stagedsync" - "github.com/ledgerwatch/erigon/ethdb/memdb" "github.com/ledgerwatch/erigon/ethdb/olddb" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/turbo/stages" diff --git a/consensus/db/db.go b/consensus/db/db.go index 89ee07786..72db22fc7 100644 --- a/consensus/db/db.go +++ b/consensus/db/db.go @@ -1,8 +1,8 @@ package db import ( - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/mdbx" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/mdbx" "github.com/ledgerwatch/log/v3" ) diff --git a/core/chain_makers.go b/core/chain_makers.go index a881c6145..9cfac15cf 100644 --- a/core/chain_makers.go +++ b/core/chain_makers.go @@ -21,13 +21,13 @@ import ( "fmt" "math/big" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/consensus" "github.com/ledgerwatch/erigon/consensus/misc" "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/vm" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/turbo/trie" ) diff --git a/core/genesis.go b/core/genesis.go index e6ab96afa..e7de75ced 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -29,6 +29,8 @@ import ( "sync" "github.com/holiman/uint256" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/mdbx" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/common/math" @@ -36,8 +38,6 @@ import ( "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/crypto" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/erigon/turbo/trie" diff --git a/core/rawdb/accessors_account.go b/core/rawdb/accessors_account.go index e4154e572..59c58b3b5 100644 --- a/core/rawdb/accessors_account.go +++ b/core/rawdb/accessors_account.go @@ -17,9 +17,9 @@ package rawdb import ( + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core/types/accounts" - "github.com/ledgerwatch/erigon/ethdb/kv" ) func ReadAccount(db kv.Tx, addrHash common.Address, acc *accounts.Account) (bool, error) { diff --git a/core/rawdb/accessors_chain.go b/core/rawdb/accessors_chain.go index 7db1c566a..1de358438 100644 --- a/core/rawdb/accessors_chain.go +++ b/core/rawdb/accessors_chain.go @@ -23,11 +23,11 @@ import ( "math" "math/big" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/ethdb/cbor" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/log/v3" ) diff --git a/core/rawdb/accessors_chain_test.go b/core/rawdb/accessors_chain_test.go index fa8a584a1..beb318e26 100644 --- a/core/rawdb/accessors_chain_test.go +++ b/core/rawdb/accessors_chain_test.go @@ -23,11 +23,11 @@ import ( "math/big" "testing" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/u256" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/crypto" - "github.com/ledgerwatch/erigon/ethdb/memdb" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rlp" "github.com/stretchr/testify/require" diff --git a/core/rawdb/accessors_indexes.go b/core/rawdb/accessors_indexes.go index ae6e82b4e..5ea1e7ecf 100644 --- a/core/rawdb/accessors_indexes.go +++ b/core/rawdb/accessors_indexes.go @@ -19,9 +19,9 @@ package rawdb import ( "math/big" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/log/v3" ) diff --git a/core/rawdb/accessors_indexes_test.go b/core/rawdb/accessors_indexes_test.go index 3e77f17b8..f98aa8600 100644 --- a/core/rawdb/accessors_indexes_test.go +++ b/core/rawdb/accessors_indexes_test.go @@ -21,8 +21,8 @@ import ( "testing" "github.com/holiman/uint256" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/memdb" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core/types" diff --git a/core/rawdb/accessors_metadata.go b/core/rawdb/accessors_metadata.go index 1fb5029f7..b2d29ce7f 100644 --- a/core/rawdb/accessors_metadata.go +++ b/core/rawdb/accessors_metadata.go @@ -20,7 +20,7 @@ import ( "encoding/json" "fmt" - "github.com/ledgerwatch/erigon/ethdb/kv" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/params" diff --git a/core/rlp_test.go b/core/rlp_test.go index 95e5d4899..2bb4f9e1a 100644 --- a/core/rlp_test.go +++ b/core/rlp_test.go @@ -21,7 +21,7 @@ import ( "math/big" "testing" - "github.com/ledgerwatch/erigon/ethdb/memdb" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "golang.org/x/crypto/sha3" "github.com/ledgerwatch/erigon/common" diff --git a/core/state/change_set_writer.go b/core/state/change_set_writer.go index 47edd87ff..85f6ca313 100644 --- a/core/state/change_set_writer.go +++ b/core/state/change_set_writer.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/holiman/uint256" - "github.com/ledgerwatch/erigon/ethdb/kv" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/changeset" diff --git a/core/state/database_test.go b/core/state/database_test.go index 08f3ba2a3..905461901 100644 --- a/core/state/database_test.go +++ b/core/state/database_test.go @@ -24,8 +24,8 @@ import ( "testing" "github.com/holiman/uint256" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/memdb" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/turbo/stages" "github.com/ledgerwatch/erigon/turbo/trie" "github.com/stretchr/testify/assert" diff --git a/core/state/db_state_reader.go b/core/state/db_state_reader.go index 864bc3ee3..44cea5b45 100644 --- a/core/state/db_state_reader.go +++ b/core/state/db_state_reader.go @@ -5,10 +5,10 @@ import ( "encoding/binary" "github.com/VictoriaMetrics/fastcache" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/core/types/accounts" - "github.com/ledgerwatch/erigon/ethdb/kv" ) // Implements StateReader by wrapping database only, without trie diff --git a/core/state/db_state_writer.go b/core/state/db_state_writer.go index 67832a2dd..5e5adcd9a 100644 --- a/core/state/db_state_writer.go +++ b/core/state/db_state_writer.go @@ -7,6 +7,7 @@ import ( "github.com/RoaringBitmap/roaring/roaring64" "github.com/holiman/uint256" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/changeset" "github.com/ledgerwatch/erigon/common/dbutils" @@ -14,7 +15,6 @@ import ( "github.com/ledgerwatch/erigon/core/types/accounts" "github.com/ledgerwatch/erigon/ethdb" "github.com/ledgerwatch/erigon/ethdb/bitmapdb" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/turbo/trie" ) diff --git a/core/state/dump.go b/core/state/dump.go index 8027d4629..c0427f565 100644 --- a/core/state/dump.go +++ b/core/state/dump.go @@ -21,12 +21,12 @@ import ( "encoding/json" "fmt" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/core/types/accounts" "github.com/ledgerwatch/erigon/crypto" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/turbo/trie" ) diff --git a/core/state/history.go b/core/state/history.go index f158bbc00..629a52cc6 100644 --- a/core/state/history.go +++ b/core/state/history.go @@ -7,13 +7,13 @@ import ( "fmt" "github.com/RoaringBitmap/roaring/roaring64" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/changeset" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/core/types/accounts" "github.com/ledgerwatch/erigon/ethdb" "github.com/ledgerwatch/erigon/ethdb/bitmapdb" - "github.com/ledgerwatch/erigon/ethdb/kv" ) func GetAsOf(tx kv.Tx, storage bool, key []byte, timestamp uint64) ([]byte, error) { diff --git a/core/state/history_test.go b/core/state/history_test.go index 9abb899de..b07ca3eff 100644 --- a/core/state/history_test.go +++ b/core/state/history_test.go @@ -10,6 +10,8 @@ import ( "github.com/davecgh/go-spew/spew" "github.com/holiman/uint256" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/changeset" "github.com/ledgerwatch/erigon/common/dbutils" @@ -17,8 +19,6 @@ import ( "github.com/ledgerwatch/erigon/core/types/accounts" "github.com/ledgerwatch/erigon/crypto" "github.com/ledgerwatch/erigon/ethdb/bitmapdb" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/memdb" "github.com/ledgerwatch/erigon/turbo/trie" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/core/state/intra_block_state_test.go b/core/state/intra_block_state_test.go index 35d6f1027..3b6c0b4be 100644 --- a/core/state/intra_block_state_test.go +++ b/core/state/intra_block_state_test.go @@ -30,7 +30,7 @@ import ( "testing/quick" "github.com/holiman/uint256" - "github.com/ledgerwatch/erigon/ethdb/memdb" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/params" "gopkg.in/check.v1" diff --git a/core/state/plain_readonly.go b/core/state/plain_readonly.go index e577d84d6..a3f5f824b 100644 --- a/core/state/plain_readonly.go +++ b/core/state/plain_readonly.go @@ -21,10 +21,10 @@ import ( "encoding/binary" "github.com/holiman/uint256" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/core/types/accounts" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/log/v3" "github.com/petar/GoLLRB/llrb" ) diff --git a/core/state/plain_state_reader.go b/core/state/plain_state_reader.go index 81a65feb7..864dcc2dd 100644 --- a/core/state/plain_state_reader.go +++ b/core/state/plain_state_reader.go @@ -4,10 +4,10 @@ import ( "bytes" "encoding/binary" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/core/types/accounts" - "github.com/ledgerwatch/erigon/ethdb/kv" ) var _ StateReader = (*PlainStateReader)(nil) diff --git a/core/state/plain_state_writer.go b/core/state/plain_state_writer.go index 21e55ce08..a8dc51fc6 100644 --- a/core/state/plain_state_writer.go +++ b/core/state/plain_state_writer.go @@ -4,10 +4,10 @@ import ( "encoding/binary" "github.com/holiman/uint256" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/core/types/accounts" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/turbo/shards" ) diff --git a/core/state/state_test.go b/core/state/state_test.go index a41190c1e..af7e9785f 100644 --- a/core/state/state_test.go +++ b/core/state/state_test.go @@ -22,8 +22,8 @@ import ( "testing" "github.com/holiman/uint256" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/memdb" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/params" checker "gopkg.in/check.v1" diff --git a/core/tx_pool.go b/core/tx_pool.go index 009829078..289df2668 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -25,13 +25,13 @@ import ( "github.com/VictoriaMetrics/metrics" "github.com/holiman/uint256" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/debug" "github.com/ledgerwatch/erigon/common/prque" "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/ethdb" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/olddb" "github.com/ledgerwatch/erigon/event" "github.com/ledgerwatch/erigon/params" diff --git a/core/tx_pool_test.go b/core/tx_pool_test.go index 358bfb9be..84664b211 100644 --- a/core/tx_pool_test.go +++ b/core/tx_pool_test.go @@ -28,13 +28,13 @@ import ( "time" "github.com/holiman/uint256" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/u256" "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/crypto" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/memdb" "github.com/ledgerwatch/erigon/params" "github.com/stretchr/testify/require" ) diff --git a/core/vm/gas_table_test.go b/core/vm/gas_table_test.go index c175421f1..dd26a0b83 100644 --- a/core/vm/gas_table_test.go +++ b/core/vm/gas_table_test.go @@ -23,10 +23,10 @@ import ( "testing" "github.com/holiman/uint256" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/core/state" - "github.com/ledgerwatch/erigon/ethdb/memdb" "github.com/ledgerwatch/erigon/params" ) diff --git a/core/vm/runtime/runtime.go b/core/vm/runtime/runtime.go index c147ce652..799e49274 100644 --- a/core/vm/runtime/runtime.go +++ b/core/vm/runtime/runtime.go @@ -22,7 +22,7 @@ import ( "time" "github.com/holiman/uint256" - "github.com/ledgerwatch/erigon/ethdb/memdb" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/ethdb/olddb" "github.com/ledgerwatch/erigon/common" diff --git a/core/vm/runtime/runtime_test.go b/core/vm/runtime/runtime_test.go index 5a125cf55..6dd6e2475 100644 --- a/core/vm/runtime/runtime_test.go +++ b/core/vm/runtime/runtime_test.go @@ -23,6 +23,7 @@ import ( "strings" "testing" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/accounts/abi" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/consensus" @@ -31,7 +32,6 @@ import ( "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/vm" - "github.com/ledgerwatch/erigon/ethdb/memdb" "github.com/ledgerwatch/erigon/params" ) diff --git a/eth/backend.go b/eth/backend.go index 43fdbed4b..a2c30f919 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -34,6 +34,7 @@ import ( "github.com/holiman/uint256" "github.com/ledgerwatch/erigon-lib/gointerfaces/sentry" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/cmd/sentry/download" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/debug" @@ -52,7 +53,6 @@ import ( "github.com/ledgerwatch/erigon/eth/protocols/eth" "github.com/ledgerwatch/erigon/eth/stagedsync" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/privateapi" "github.com/ledgerwatch/erigon/ethdb/prune" remotedbserver2 "github.com/ledgerwatch/erigon/ethdb/remotedbserver" diff --git a/eth/fetcher/block_fetcher_test.go b/eth/fetcher/block_fetcher_test.go index b5e531d71..402bfe66b 100644 --- a/eth/fetcher/block_fetcher_test.go +++ b/eth/fetcher/block_fetcher_test.go @@ -25,7 +25,7 @@ import ( "time" "github.com/holiman/uint256" - "github.com/ledgerwatch/erigon/ethdb/memdb" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/consensus/ethash" diff --git a/eth/gasprice/gasprice_test.go b/eth/gasprice/gasprice_test.go index 6179f282b..05bdc5d0c 100644 --- a/eth/gasprice/gasprice_test.go +++ b/eth/gasprice/gasprice_test.go @@ -23,13 +23,13 @@ import ( "testing" "github.com/holiman/uint256" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/crypto" "github.com/ledgerwatch/erigon/eth/gasprice" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rpc" "github.com/ledgerwatch/erigon/turbo/stages" diff --git a/eth/integrity/trie.go b/eth/integrity/trie.go index 0f308e048..50c9629c9 100644 --- a/eth/integrity/trie.go +++ b/eth/integrity/trie.go @@ -8,10 +8,10 @@ import ( "math/bits" "time" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/ethdb" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/turbo/trie" "github.com/ledgerwatch/log/v3" ) diff --git a/eth/protocols/eth/handler.go b/eth/protocols/eth/handler.go index 1f63ca577..8466099c0 100644 --- a/eth/protocols/eth/handler.go +++ b/eth/protocols/eth/handler.go @@ -21,10 +21,10 @@ import ( "math/big" "time" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/p2p" "github.com/ledgerwatch/erigon/p2p/enode" "github.com/ledgerwatch/erigon/p2p/enr" diff --git a/eth/protocols/eth/handler_test.go b/eth/protocols/eth/handler_test.go index 2874bc048..cfcf5a0d6 100644 --- a/eth/protocols/eth/handler_test.go +++ b/eth/protocols/eth/handler_test.go @@ -25,13 +25,13 @@ import ( "github.com/holiman/uint256" "github.com/ledgerwatch/erigon-lib/gointerfaces/sentry" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/crypto" "github.com/ledgerwatch/erigon/eth/protocols/eth" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/p2p" "github.com/ledgerwatch/erigon/p2p/enode" "github.com/ledgerwatch/erigon/params" diff --git a/eth/protocols/eth/handlers.go b/eth/protocols/eth/handlers.go index 9d847dfdb..7ebee75e2 100644 --- a/eth/protocols/eth/handlers.go +++ b/eth/protocols/eth/handlers.go @@ -20,10 +20,10 @@ import ( "context" "fmt" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/log/v3" ) diff --git a/eth/stagedsync/all_stages.go b/eth/stagedsync/all_stages.go index 4fb04177f..1ff3dffbf 100644 --- a/eth/stagedsync/all_stages.go +++ b/eth/stagedsync/all_stages.go @@ -1,8 +1,8 @@ package stagedsync import ( + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" - "github.com/ledgerwatch/erigon/ethdb/kv" ) // UpdateMetrics - need update metrics manually because current "metrics" package doesn't support labels diff --git a/eth/stagedsync/chain_reader.go b/eth/stagedsync/chain_reader.go index 17bf2f518..ba3c5738f 100644 --- a/eth/stagedsync/chain_reader.go +++ b/eth/stagedsync/chain_reader.go @@ -1,10 +1,10 @@ package stagedsync import ( + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/log/v3" ) diff --git a/eth/stagedsync/default_stages.go b/eth/stagedsync/default_stages.go index 493f0f71a..ce8876d75 100644 --- a/eth/stagedsync/default_stages.go +++ b/eth/stagedsync/default_stages.go @@ -3,8 +3,8 @@ package stagedsync import ( "context" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/prune" ) diff --git a/eth/stagedsync/stage.go b/eth/stagedsync/stage.go index 0194139d3..1b6af6494 100644 --- a/eth/stagedsync/stage.go +++ b/eth/stagedsync/stage.go @@ -1,9 +1,9 @@ package stagedsync import ( + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" - "github.com/ledgerwatch/erigon/ethdb/kv" ) // ExecFunc is the execution function for the stage to move forward. diff --git a/eth/stagedsync/stage_blockhashes.go b/eth/stagedsync/stage_blockhashes.go index 6d2f579e3..886fdbb7a 100644 --- a/eth/stagedsync/stage_blockhashes.go +++ b/eth/stagedsync/stage_blockhashes.go @@ -5,12 +5,12 @@ import ( "encoding/binary" "fmt" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/common/etl" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" - "github.com/ledgerwatch/erigon/ethdb/kv" ) func extractHeaders(k []byte, v []byte, next etl.ExtractNextFunc) error { diff --git a/eth/stagedsync/stage_bodies.go b/eth/stagedsync/stage_bodies.go index d888a0549..b5abe7ecf 100644 --- a/eth/stagedsync/stage_bodies.go +++ b/eth/stagedsync/stage_bodies.go @@ -7,10 +7,10 @@ import ( "time" "github.com/c2h5oh/datasize" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/turbo/adapter" "github.com/ledgerwatch/erigon/turbo/stages/bodydownload" diff --git a/eth/stagedsync/stage_bodies_snapshot.go b/eth/stagedsync/stage_bodies_snapshot.go index 965f67662..09800f67e 100644 --- a/eth/stagedsync/stage_bodies_snapshot.go +++ b/eth/stagedsync/stage_bodies_snapshot.go @@ -3,8 +3,8 @@ package stagedsync import ( "context" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/eth/ethconfig" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/turbo/snapshotsync" ) diff --git a/eth/stagedsync/stage_call_traces.go b/eth/stagedsync/stage_call_traces.go index 1bd07cbb0..a5952da98 100644 --- a/eth/stagedsync/stage_call_traces.go +++ b/eth/stagedsync/stage_call_traces.go @@ -13,6 +13,7 @@ import ( "github.com/RoaringBitmap/roaring/roaring64" "github.com/c2h5oh/datasize" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/common/etl" @@ -20,7 +21,6 @@ import ( "github.com/ledgerwatch/erigon/core/vm" "github.com/ledgerwatch/erigon/core/vm/stack" "github.com/ledgerwatch/erigon/ethdb/bitmapdb" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/prune" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/log/v3" diff --git a/eth/stagedsync/stage_execute.go b/eth/stagedsync/stage_execute.go index 8efd4922c..cf2284d55 100644 --- a/eth/stagedsync/stage_execute.go +++ b/eth/stagedsync/stage_execute.go @@ -10,7 +10,7 @@ import ( metrics2 "github.com/VictoriaMetrics/metrics" "github.com/c2h5oh/datasize" - "github.com/ledgerwatch/erigon/ethdb/kv" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/ethdb/olddb" "github.com/ledgerwatch/erigon/ethdb/prune" diff --git a/eth/stagedsync/stage_execute_test.go b/eth/stagedsync/stage_execute_test.go index 48a751d5d..b50cfb157 100644 --- a/eth/stagedsync/stage_execute_test.go +++ b/eth/stagedsync/stage_execute_test.go @@ -4,10 +4,10 @@ import ( "context" "testing" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/common/changeset" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/memdb" "github.com/ledgerwatch/erigon/ethdb/prune" "github.com/stretchr/testify/assert" ) diff --git a/eth/stagedsync/stage_finish.go b/eth/stagedsync/stage_finish.go index 830567270..c7c37ab0a 100644 --- a/eth/stagedsync/stage_finish.go +++ b/eth/stagedsync/stage_finish.go @@ -4,9 +4,9 @@ import ( "context" "fmt" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/turbo/snapshotsync" "github.com/ledgerwatch/log/v3" ) diff --git a/eth/stagedsync/stage_hashstate.go b/eth/stagedsync/stage_hashstate.go index 9feb114c6..2421aee64 100644 --- a/eth/stagedsync/stage_hashstate.go +++ b/eth/stagedsync/stage_hashstate.go @@ -7,12 +7,12 @@ import ( "fmt" "os" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/changeset" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/common/etl" "github.com/ledgerwatch/erigon/core/types/accounts" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/log/v3" ) diff --git a/eth/stagedsync/stage_hashstate_test.go b/eth/stagedsync/stage_hashstate_test.go index f4198f998..5e18d4f86 100644 --- a/eth/stagedsync/stage_hashstate_test.go +++ b/eth/stagedsync/stage_hashstate_test.go @@ -5,8 +5,8 @@ import ( "errors" "testing" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/memdb" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/stretchr/testify/require" "github.com/ledgerwatch/erigon/common" diff --git a/eth/stagedsync/stage_headers.go b/eth/stagedsync/stage_headers.go index 5c34b5799..5ddd4a439 100644 --- a/eth/stagedsync/stage_headers.go +++ b/eth/stagedsync/stage_headers.go @@ -10,12 +10,12 @@ import ( "github.com/VictoriaMetrics/metrics" "github.com/c2h5oh/datasize" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/erigon/turbo/stages/headerdownload" diff --git a/eth/stagedsync/stage_headers_snapshot.go b/eth/stagedsync/stage_headers_snapshot.go index fcc67a015..aab81d5f7 100644 --- a/eth/stagedsync/stage_headers_snapshot.go +++ b/eth/stagedsync/stage_headers_snapshot.go @@ -6,9 +6,9 @@ import ( "sync/atomic" "time" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/eth/ethconfig" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/turbo/snapshotsync" "github.com/ledgerwatch/log/v3" ) diff --git a/eth/stagedsync/stage_indexes.go b/eth/stagedsync/stage_indexes.go index 0707eaa9f..25e53b9ce 100644 --- a/eth/stagedsync/stage_indexes.go +++ b/eth/stagedsync/stage_indexes.go @@ -12,13 +12,13 @@ import ( "github.com/RoaringBitmap/roaring/roaring64" "github.com/c2h5oh/datasize" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/changeset" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/common/etl" "github.com/ledgerwatch/erigon/ethdb" "github.com/ledgerwatch/erigon/ethdb/bitmapdb" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/prune" "github.com/ledgerwatch/log/v3" ) diff --git a/eth/stagedsync/stage_indexes_test.go b/eth/stagedsync/stage_indexes_test.go index 03620fd54..cfb077dc0 100644 --- a/eth/stagedsync/stage_indexes_test.go +++ b/eth/stagedsync/stage_indexes_test.go @@ -10,14 +10,14 @@ import ( "testing" "time" + "github.com/ledgerwatch/erigon-lib/kv" + kv2 "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/changeset" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/common/math" "github.com/ledgerwatch/erigon/crypto" "github.com/ledgerwatch/erigon/ethdb/bitmapdb" - "github.com/ledgerwatch/erigon/ethdb/kv" - kv2 "github.com/ledgerwatch/erigon/ethdb/memdb" "github.com/ledgerwatch/erigon/ethdb/prune" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/eth/stagedsync/stage_interhashes.go b/eth/stagedsync/stage_interhashes.go index 0512504fe..236dd6ca3 100644 --- a/eth/stagedsync/stage_interhashes.go +++ b/eth/stagedsync/stage_interhashes.go @@ -8,6 +8,7 @@ import ( "os" "sort" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/changeset" "github.com/ledgerwatch/erigon/common/dbutils" @@ -15,7 +16,6 @@ import ( "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types/accounts" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/turbo/trie" "github.com/ledgerwatch/log/v3" ) diff --git a/eth/stagedsync/stage_interhashes_test.go b/eth/stagedsync/stage_interhashes_test.go index d144f2974..555212f3c 100644 --- a/eth/stagedsync/stage_interhashes_test.go +++ b/eth/stagedsync/stage_interhashes_test.go @@ -4,11 +4,11 @@ import ( "encoding/binary" "testing" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/core/types/accounts" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/memdb" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/turbo/trie" diff --git a/eth/stagedsync/stage_log_index.go b/eth/stagedsync/stage_log_index.go index 185b970ae..3b4b9487c 100644 --- a/eth/stagedsync/stage_log_index.go +++ b/eth/stagedsync/stage_log_index.go @@ -11,13 +11,13 @@ import ( "github.com/RoaringBitmap/roaring" "github.com/c2h5oh/datasize" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/common/etl" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/ethdb/bitmapdb" "github.com/ledgerwatch/erigon/ethdb/cbor" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/prune" "github.com/ledgerwatch/log/v3" ) diff --git a/eth/stagedsync/stage_log_index_test.go b/eth/stagedsync/stage_log_index_test.go index 23f3ae7a3..edc63c60f 100644 --- a/eth/stagedsync/stage_log_index_test.go +++ b/eth/stagedsync/stage_log_index_test.go @@ -6,12 +6,12 @@ import ( "testing" "time" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/ethdb/bitmapdb" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/memdb" "github.com/ledgerwatch/erigon/ethdb/prune" "github.com/stretchr/testify/require" diff --git a/eth/stagedsync/stage_mining_create_block.go b/eth/stagedsync/stage_mining_create_block.go index 89213a324..0483807f5 100644 --- a/eth/stagedsync/stage_mining_create_block.go +++ b/eth/stagedsync/stage_mining_create_block.go @@ -8,6 +8,7 @@ import ( "time" mapset "github.com/deckarep/golang-set" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/debug" "github.com/ledgerwatch/erigon/consensus" @@ -15,7 +16,6 @@ import ( "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/eth/ethutils" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/log/v3" ) diff --git a/eth/stagedsync/stage_mining_exec.go b/eth/stagedsync/stage_mining_exec.go index b33f7742d..5ba6050bd 100644 --- a/eth/stagedsync/stage_mining_exec.go +++ b/eth/stagedsync/stage_mining_exec.go @@ -3,6 +3,7 @@ package stagedsync import ( "fmt" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/consensus" "github.com/ledgerwatch/erigon/consensus/misc" @@ -13,7 +14,6 @@ import ( "github.com/ledgerwatch/erigon/core/vm" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" "github.com/ledgerwatch/erigon/ethdb" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/log/v3" ) diff --git a/eth/stagedsync/stage_mining_finish.go b/eth/stagedsync/stage_mining_finish.go index d7150bba0..a7b67c711 100644 --- a/eth/stagedsync/stage_mining_finish.go +++ b/eth/stagedsync/stage_mining_finish.go @@ -3,9 +3,9 @@ package stagedsync import ( "fmt" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/consensus" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/log/v3" ) diff --git a/eth/stagedsync/stage_senders.go b/eth/stagedsync/stage_senders.go index 31df20c91..b75cb171d 100644 --- a/eth/stagedsync/stage_senders.go +++ b/eth/stagedsync/stage_senders.go @@ -9,6 +9,7 @@ import ( "sync" "time" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/common/debug" @@ -16,7 +17,6 @@ import ( "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/log/v3" "github.com/ledgerwatch/secp256k1" diff --git a/eth/stagedsync/stage_senders_test.go b/eth/stagedsync/stage_senders_test.go index 6dd20eca6..7dde79ebc 100644 --- a/eth/stagedsync/stage_senders_test.go +++ b/eth/stagedsync/stage_senders_test.go @@ -4,13 +4,13 @@ import ( "context" "testing" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/u256" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/crypto" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" - "github.com/ledgerwatch/erigon/ethdb/memdb" "github.com/ledgerwatch/erigon/params" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/eth/stagedsync/stage_state_snapshot.go b/eth/stagedsync/stage_state_snapshot.go index b4f3ea8c2..b308775b0 100644 --- a/eth/stagedsync/stage_state_snapshot.go +++ b/eth/stagedsync/stage_state_snapshot.go @@ -3,8 +3,8 @@ package stagedsync import ( "context" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/eth/ethconfig" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/turbo/snapshotsync" ) diff --git a/eth/stagedsync/stage_tevm.go b/eth/stagedsync/stage_tevm.go index 5d5edd953..1e337e23a 100644 --- a/eth/stagedsync/stage_tevm.go +++ b/eth/stagedsync/stage_tevm.go @@ -8,13 +8,13 @@ import ( "time" "github.com/c2h5oh/datasize" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/core/types/accounts" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" "github.com/ledgerwatch/erigon/ethdb" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/olddb" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/log/v3" diff --git a/eth/stagedsync/stage_txlookup.go b/eth/stagedsync/stage_txlookup.go index 31788c637..5070654c2 100644 --- a/eth/stagedsync/stage_txlookup.go +++ b/eth/stagedsync/stage_txlookup.go @@ -7,12 +7,12 @@ import ( "fmt" "math/big" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/common/etl" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/prune" "github.com/ledgerwatch/erigon/rlp" ) diff --git a/eth/stagedsync/stage_txpool.go b/eth/stagedsync/stage_txpool.go index bc2abc028..e9ac5d7ee 100644 --- a/eth/stagedsync/stage_txpool.go +++ b/eth/stagedsync/stage_txpool.go @@ -5,12 +5,12 @@ import ( "encoding/binary" "fmt" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/log/v3" ) diff --git a/eth/stagedsync/stagebuilder.go b/eth/stagedsync/stagebuilder.go index 87d39005d..a197feba9 100644 --- a/eth/stagedsync/stagebuilder.go +++ b/eth/stagedsync/stagebuilder.go @@ -3,9 +3,9 @@ package stagedsync import ( "context" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/privateapi" "github.com/ledgerwatch/erigon/turbo/shards" ) diff --git a/eth/stagedsync/stages/stages.go b/eth/stagedsync/stages/stages.go index bff850cc9..8da1d31d9 100644 --- a/eth/stagedsync/stages/stages.go +++ b/eth/stagedsync/stages/stages.go @@ -20,7 +20,7 @@ import ( "encoding/binary" "fmt" - "github.com/ledgerwatch/erigon/ethdb/kv" + "github.com/ledgerwatch/erigon-lib/kv" ) // SyncStage represents the stages of syncronisation in the SyncMode.StagedSync mode diff --git a/eth/stagedsync/sync.go b/eth/stagedsync/sync.go index f75d1c475..fd20796a1 100644 --- a/eth/stagedsync/sync.go +++ b/eth/stagedsync/sync.go @@ -6,10 +6,10 @@ import ( "os" "time" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/debug" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/log/v3" ) diff --git a/eth/stagedsync/sync_test.go b/eth/stagedsync/sync_test.go index b2f1864b9..0b9f1e348 100644 --- a/eth/stagedsync/sync_test.go +++ b/eth/stagedsync/sync_test.go @@ -5,10 +5,10 @@ import ( "fmt" "testing" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/memdb" "github.com/stretchr/testify/assert" ) diff --git a/eth/stagedsync/testutil.go b/eth/stagedsync/testutil.go index 53a04028d..e03649787 100644 --- a/eth/stagedsync/testutil.go +++ b/eth/stagedsync/testutil.go @@ -6,10 +6,10 @@ import ( "testing" "github.com/holiman/uint256" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/core/types/accounts" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/stretchr/testify/assert" ) diff --git a/eth/tracers/tracers_test.go b/eth/tracers/tracers_test.go index 40aeaf467..65dfac255 100644 --- a/eth/tracers/tracers_test.go +++ b/eth/tracers/tracers_test.go @@ -28,6 +28,7 @@ import ( "strings" "testing" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/common/math" @@ -35,7 +36,6 @@ import ( "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/vm" "github.com/ledgerwatch/erigon/crypto" - "github.com/ledgerwatch/erigon/ethdb/memdb" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/erigon/tests" diff --git a/ethdb/bitmapdb/dbutils.go b/ethdb/bitmapdb/dbutils.go index e2b1b267e..0e2fae7e5 100644 --- a/ethdb/bitmapdb/dbutils.go +++ b/ethdb/bitmapdb/dbutils.go @@ -8,10 +8,10 @@ import ( "github.com/RoaringBitmap/roaring" "github.com/RoaringBitmap/roaring/roaring64" "github.com/c2h5oh/datasize" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/math" "github.com/ledgerwatch/erigon/ethdb" - "github.com/ledgerwatch/erigon/ethdb/kv" ) const ChunkLimit = uint64(1950 * datasize.B) // threshold beyond which MDBX overflow pages appear: 4096 / 2 - (keySize + 8) diff --git a/ethdb/db_interface.go b/ethdb/db_interface.go index 6683307e1..49ead52c2 100644 --- a/ethdb/db_interface.go +++ b/ethdb/db_interface.go @@ -20,7 +20,7 @@ import ( "context" "errors" - "github.com/ledgerwatch/erigon/ethdb/kv" + "github.com/ledgerwatch/erigon-lib/kv" ) // DESCRIBED: For info on database buckets see docs/programmers_guide/db_walkthrough.MD diff --git a/ethdb/kv/bucket.go b/ethdb/kv/bucket.go deleted file mode 100644 index 837a14e25..000000000 --- a/ethdb/kv/bucket.go +++ /dev/null @@ -1,424 +0,0 @@ -package kv - -import ( - "sort" - "strings" - - "github.com/ledgerwatch/erigon-lib/gointerfaces/types" -) - -// DBSchemaVersion -var DBSchemaVersion = types.VersionReply{Major: 3, Minor: 0, Patch: 0} - -// ChaindataTables - -// Dictionary: -// "Plain State" - state where keys arent' hashed. "CurrentState" - same, but keys are hashed. "PlainState" used for blocks execution. "CurrentState" used mostly for Merkle root calculation. -// "incarnation" - uint64 number - how much times given account was SelfDestruct'ed. - -/* -PlainState logical layout: - Contains Accounts: - key - address (unhashed) - value - account encoded for storage - Contains Storage: - key - address (unhashed) + incarnation + storage key (unhashed) - value - storage value(common.hash) - -Physical layout: - PlainState and HashedStorage utilises DupSort feature of MDBX (store multiple values inside 1 key). -------------------------------------------------------------- - key | value -------------------------------------------------------------- -[acc_hash] | [acc_value] -[acc_hash]+[inc] | [storage1_hash]+[storage1_value] - | [storage2_hash]+[storage2_value] // this value has no own key. it's 2nd value of [acc_hash]+[inc] key. - | [storage3_hash]+[storage3_value] - | ... -[acc_hash]+[old_inc] | [storage1_hash]+[storage1_value] - | ... -[acc2_hash] | [acc2_value] - ... -*/ -const PlainState = "PlainState" - -//PlainContractCode - -//key - address+incarnation -//value - code hash -const PlainContractCode = "PlainCodeHash" - -/* -AccountChangeSet and StorageChangeSet - of block N store values of state before block N changed them. -Because values "after" change stored in PlainState. -Logical format: - key - blockNum_u64 + key_in_plain_state - value - value_in_plain_state_before_blockNum_changes - -Example: If block N changed account A from value X to Y. Then: - AccountChangeSet has record: bigEndian(N) + A -> X - PlainState has record: A -> Y - -See also: docs/programmers_guide/db_walkthrough.MD#table-history-of-accounts - -As you can see if block N changes much accounts - then all records have repetitive prefix `bigEndian(N)`. -MDBX can store such prefixes only once - by DupSort feature (see `docs/programmers_guide/dupsort.md`). -Both buckets are DupSort-ed and have physical format: -AccountChangeSet: - key - blockNum_u64 - value - address + account(encoded) - -StorageChangeSet: - key - blockNum_u64 + address + incarnation_u64 - value - plain_storage_key + value -*/ -const AccountChangeSet = "AccountChangeSet" -const StorageChangeSet = "StorageChangeSet" - -const ( - - //HashedAccounts - // key - address hash - // value - account encoded for storage - // Contains Storage: - //key - address hash + incarnation + storage key hash - //value - storage value(common.hash) - HashedAccounts = "HashedAccount" - HashedStorage = "HashedStorage" -) - -/* -AccountsHistory and StorageHistory - indices designed to serve next 2 type of requests: -1. what is smallest block number >= X where account A changed -2. get last shard of A - to append there new block numbers - -Task 1. is part of "get historical state" operation (see `core/state:GetAsOf`): -If `db.Seek(A+bigEndian(X))` returns non-last shard - - then get block number from shard value Y := RoaringBitmap(shard_value).GetGte(X) - and with Y go to ChangeSets: db.Get(ChangeSets, Y+A) -If `db.Seek(A+bigEndian(X))` returns last shard - - then we go to PlainState: db.Get(PlainState, A) - -Format: - - index split to shards by 2Kb - RoaringBitmap encoded sorted list of block numbers - (to avoid performance degradation of popular accounts or look deep into history. - Also 2Kb allows avoid Overflow pages inside DB.) - - if shard is not last - then key has suffix 8 bytes = bigEndian(max_block_num_in_this_shard) - - if shard is last - then key has suffix 8 bytes = 0xFF - -It allows: - - server task 1. by 1 db operation db.Seek(A+bigEndian(X)) - - server task 2. by 1 db operation db.Get(A+0xFF) - -see also: docs/programmers_guide/db_walkthrough.MD#table-change-sets - -AccountsHistory: - key - address + shard_id_u64 - value - roaring bitmap - list of block where it changed -StorageHistory - key - address + storage_key + shard_id_u64 - value - roaring bitmap - list of block where it changed -*/ -const AccountsHistory = "AccountHistory" -const StorageHistory = "StorageHistory" - -const ( - - //key - contract code hash - //value - contract code - Code = "Code" - - //key - addressHash+incarnation - //value - code hash - ContractCode = "HashedCodeHash" - - // IncarnationMap for deleted accounts - //key - address - //value - incarnation of account when it was last deleted - IncarnationMap = "IncarnationMap" - - //TEVMCode - - //key - contract code hash - //value - contract TEVM code - ContractTEVMCode = "TEVMCode" -) - -/*TrieOfAccounts and TrieOfStorage -hasState,groups - mark prefixes existing in hashed_account table -hasTree - mark prefixes existing in trie_account table (not related with branchNodes) -hasHash - mark prefixes which hashes are saved in current trie_account record (actually only hashes of branchNodes can be saved) -@see UnmarshalTrieNode -@see integrity.Trie - -+-----------------------------------------------------------------------------------------------------+ -| DB record: 0x0B, hasState: 0b1011, hasTree: 0b1001, hasHash: 0b1001, hashes: [x,x] | -+-----------------------------------------------------------------------------------------------------+ - | | | - v | v -+---------------------------------------------+ | +--------------------------------------+ -| DB record: 0x0B00, hasState: 0b10001 | | | DB record: 0x0B03, hasState: 0b10010 | -| hasTree: 0, hasHash: 0b10000, hashes: [x] | | | hasTree: 0, hasHash: 0, hashes: [] | -+---------------------------------------------+ | +--------------------------------------+ - | | | | | - v v v v v -+------------------+ +----------------------+ +---------------+ +---------------+ +---------------+ -| Account: | | BranchNode: 0x0B0004 | | Account: | | Account: | | Account: | -| 0x0B0000... | | has no record in | | 0x0B01... | | 0x0B0301... | | 0x0B0304... | -| in HashedAccount | | TrieAccount | | | | | | | -+------------------+ +----------------------+ +---------------+ +---------------+ +---------------+ - | | - v v - +---------------+ +---------------+ - | Account: | | Account: | - | 0x0B000400... | | 0x0B000401... | - +---------------+ +---------------+ -Invariants: -- hasTree is subset of hasState -- hasHash is subset of hasState -- first level in account_trie always exists if hasState>0 -- TrieStorage record of account.root (length=40) must have +1 hash - it's account.root -- each record in TrieAccount table must have parent (may be not direct) and this parent must have correct bit in hasTree bitmap -- if hasState has bit - then HashedAccount table must have record according to this bit -- each TrieAccount record must cover some state (means hasState is always > 0) -- TrieAccount records with length=1 can satisfy (hasBranch==0&&hasHash==0) condition -- Other records in TrieAccount and TrieStorage must (hasTree!=0 || hasHash!=0) -*/ -const TrieOfAccounts = "TrieAccount" -const TrieOfStorage = "TrieStorage" - -const ( - // DatabaseInfo is used to store information about data layout. - DatabaseInfo = "DbInfo" - SnapshotInfo = "SnapshotInfo" - BittorrentInfo = "BittorrentInfo" - - // Data item prefixes (use single byte to avoid mixing data types, avoid `i`, used for indexes). - HeaderPrefixOld = "h" // block_num_u64 + hash -> header - HeaderNumber = "HeaderNumber" // headerNumberPrefix + hash -> num (uint64 big endian) - - HeaderCanonical = "CanonicalHeader" // block_num_u64 -> header hash - Headers = "Header" // block_num_u64 + hash -> header (RLP) - HeaderTD = "HeadersTotalDifficulty" // block_num_u64 + hash -> td (RLP) - - BlockBody = "BlockBody" // block_num_u64 + hash -> block body - EthTx = "BlockTransaction" // tbl_sequence_u64 -> rlp(tx) - Receipts = "Receipt" // block_num_u64 -> canonical block receipts (non-canonical are not stored) - Log = "TransactionLog" // block_num_u64 + txId -> logs of transaction - - // Stores bitmap indices - in which block numbers saw logs of given 'address' or 'topic' - // [addr or topic] + [2 bytes inverted shard number] -> bitmap(blockN) - // indices are sharded - because some bitmaps are >1Mb and when new incoming blocks process it - // updates ~300 of bitmaps - by append small amount new values. It cause much big writes (MDBX does copy-on-write). - // - // if last existing shard size merge it with delta - // if serialized size of delta > ShardLimit - break down to multiple shards - // shard number - it's biggest value in bitmap - LogTopicIndex = "LogTopicIndex" - LogAddressIndex = "LogAddressIndex" - - // CallTraceSet is the name of the table that contain the mapping of block number to the set (sorted) of all accounts - // touched by call traces. It is DupSort-ed table - // 8-byte BE block number -> account address -> two bits (one for "from", another for "to") - CallTraceSet = "CallTraceSet" - // Indices for call traces - have the same format as LogTopicIndex and LogAddressIndex - // Store bitmap indices - in which block number we saw calls from (CallFromIndex) or to (CallToIndex) some addresses - CallFromIndex = "CallFromIndex" - CallToIndex = "CallToIndex" - - TxLookup = "BlockTransactionLookup" // hash -> transaction/receipt lookup metadata - - ConfigTable = "Config" // config prefix for the db - - // Progress of sync stages: stageName -> stageData - SyncStageProgress = "SyncStage" - - Clique = "Clique" - CliqueSeparate = "CliqueSeparate" - CliqueSnapshot = "CliqueSnapshot" - CliqueLastSnapshot = "CliqueLastSnapshot" - - // this bucket stored in separated database - Inodes = "Inode" - - // Transaction senders - stored separately from the block bodies - Senders = "TxSender" // block_num_u64 + blockHash -> sendersList (no serialization format, every 20 bytes is new sender) - - // headBlockKey tracks the latest know full block's hash. - HeadBlockKey = "LastBlock" - - // migrationName -> serialized SyncStageProgress and SyncStageUnwind buckets - // it stores stages progress to understand in which context was executed migration - // in case of bug-report developer can ask content of this bucket - Migrations = "Migration" - - Sequence = "Sequence" // tbl_name -> seq_u64 - HeadHeaderKey = "LastHeader" - - Epoch = "DevEpoch" // block_num_u64+block_hash->transition_proof - PendingEpoch = "DevPendingEpoch" // block_num_u64+block_hash->transition_proof -) - -// Keys -var ( - //StorageModeTEVM - does not translate EVM to TEVM - StorageModeTEVM = []byte("smTEVM") - - PruneDistanceHistory = []byte("pruneHistory") - PruneDistanceReceipts = []byte("pruneReceipts") - PruneDistanceTxIndex = []byte("pruneTxIndex") - PruneDistanceCallTraces = []byte("pruneCallTraces") - - DBSchemaVersionKey = []byte("dbVersion") - - BittorrentPeerID = "peerID" - CurrentHeadersSnapshotHash = []byte("CurrentHeadersSnapshotHash") - CurrentHeadersSnapshotBlock = []byte("CurrentHeadersSnapshotBlock") - CurrentBodiesSnapshotHash = []byte("CurrentBodiesSnapshotHash") - CurrentBodiesSnapshotBlock = []byte("CurrentBodiesSnapshotBlock") -) - -// ChaindataTables - list of all buckets. App will panic if some bucket is not in this list. -// This list will be sorted in `init` method. -// ChaindataTablesCfg - can be used to find index in sorted version of ChaindataTables list by name -var ChaindataTables = []string{ - AccountsHistory, - StorageHistory, - Code, - ContractCode, - HeaderNumber, - BlockBody, - Receipts, - TxLookup, - ConfigTable, - DatabaseInfo, - IncarnationMap, - ContractTEVMCode, - CliqueSeparate, - CliqueLastSnapshot, - CliqueSnapshot, - SyncStageProgress, - PlainState, - PlainContractCode, - AccountChangeSet, - StorageChangeSet, - Senders, - HeadBlockKey, - HeadHeaderKey, - Migrations, - LogTopicIndex, - LogAddressIndex, - SnapshotInfo, - CallTraceSet, - CallFromIndex, - CallToIndex, - Log, - Sequence, - EthTx, - TrieOfAccounts, - TrieOfStorage, - HashedAccounts, - HashedStorage, - BittorrentInfo, - HeaderCanonical, - Headers, - HeaderTD, - Epoch, - PendingEpoch, -} - -var TxPoolTables = []string{} -var SentryTables = []string{} - -// ChaindataDeprecatedTables - list of buckets which can be programmatically deleted - for example after migration -var ChaindataDeprecatedTables = []string{ - HeaderPrefixOld, - Clique, -} - -type CmpFunc func(k1, k2, v1, v2 []byte) int - -type TableCfg map[string]TableCfgItem -type Bucket string - -type DBI uint -type TableFlags uint - -const ( - Default TableFlags = 0x00 - ReverseKey TableFlags = 0x02 - DupSort TableFlags = 0x04 - IntegerKey TableFlags = 0x08 - IntegerDup TableFlags = 0x20 - ReverseDup TableFlags = 0x40 -) - -type TableCfgItem struct { - Flags TableFlags - // AutoDupSortKeysConversion - enables some keys transformation - to change db layout without changing app code. - // Use it wisely - it helps to do experiments with DB format faster, but better reduce amount of Magic in app. - // If good DB format found, push app code to accept this format and then disable this property. - AutoDupSortKeysConversion bool - IsDeprecated bool - DBI DBI - // DupFromLen - if user provide key of this length, then next transformation applied: - // v = append(k[DupToLen:], v...) - // k = k[:DupToLen] - // And opposite at retrieval - // Works only if AutoDupSortKeysConversion enabled - DupFromLen int - DupToLen int -} - -var ChaindataTablesCfg = TableCfg{ - HashedStorage: { - Flags: DupSort, - AutoDupSortKeysConversion: true, - DupFromLen: 72, - DupToLen: 40, - }, - AccountChangeSet: { - Flags: DupSort, - }, - StorageChangeSet: { - Flags: DupSort, - }, - PlainState: { - Flags: DupSort, - AutoDupSortKeysConversion: true, - DupFromLen: 60, - DupToLen: 28, - }, - CallTraceSet: { - Flags: DupSort, - }, -} - -func sortBuckets() { - sort.SliceStable(ChaindataTables, func(i, j int) bool { - return strings.Compare(ChaindataTables[i], ChaindataTables[j]) < 0 - }) -} - -func init() { - reinit() -} - -func reinit() { - sortBuckets() - - for _, name := range ChaindataTables { - _, ok := ChaindataTablesCfg[name] - if !ok { - ChaindataTablesCfg[name] = TableCfgItem{} - } - } - - for _, name := range ChaindataDeprecatedTables { - _, ok := ChaindataTablesCfg[name] - if !ok { - ChaindataTablesCfg[name] = TableCfgItem{} - } - tmp := ChaindataTablesCfg[name] - tmp.IsDeprecated = true - ChaindataTablesCfg[name] = tmp - } -} diff --git a/ethdb/kv/kv_interface.go b/ethdb/kv/kv_interface.go deleted file mode 100644 index 55d077e39..000000000 --- a/ethdb/kv/kv_interface.go +++ /dev/null @@ -1,311 +0,0 @@ -package kv - -import ( - "context" - "errors" - - "github.com/VictoriaMetrics/metrics" -) - -const ReadersLimit = 32000 // MDBX_READERS_LIMIT=32767 - -var ( - ErrAttemptToDeleteNonDeprecatedBucket = errors.New("only buckets from dbutils.ChaindataDeprecatedTables can be deleted") - ErrUnknownBucket = errors.New("unknown bucket. add it to dbutils.ChaindataTables") - - DbSize = metrics.NewCounter(`db_size`) //nolint - TxLimit = metrics.NewCounter(`tx_limit`) //nolint - TxSpill = metrics.NewCounter(`tx_spill`) //nolint - TxUnspill = metrics.NewCounter(`tx_unspill`) //nolint - TxDirty = metrics.NewCounter(`tx_dirty`) //nolint - - DbCommitPreparation = metrics.GetOrCreateSummary(`db_commit_seconds{phase="preparation"}`) //nolint - DbCommitGc = metrics.GetOrCreateSummary(`db_commit_seconds{phase="gc"}`) //nolint - DbCommitAudit = metrics.GetOrCreateSummary(`db_commit_seconds{phase="audit"}`) //nolint - DbCommitWrite = metrics.GetOrCreateSummary(`db_commit_seconds{phase="write"}`) //nolint - DbCommitSync = metrics.GetOrCreateSummary(`db_commit_seconds{phase="sync"}`) //nolint - DbCommitEnding = metrics.GetOrCreateSummary(`db_commit_seconds{phase="ending"}`) //nolint - DbCommitTotal = metrics.GetOrCreateSummary(`db_commit_seconds{phase="total"}`) //nolint - - DbPgopsNewly = metrics.NewCounter(`db_pgops_newly`) //nolint - DbPgopsCow = metrics.NewCounter(`db_pgops_cow`) //nolint - DbPgopsClone = metrics.NewCounter(`db_pgops_clone`) //nolint - DbPgopsSplit = metrics.NewCounter(`db_pgops_split`) //nolint - DbPgopsMerge = metrics.NewCounter(`db_pgops_merge`) //nolint - DbPgopsSpill = metrics.NewCounter(`db_pgops_spill`) //nolint - DbPgopsUnspill = metrics.NewCounter(`db_pgops_unspill`) //nolint - DbPgopsWops = metrics.NewCounter(`db_pgops_wops`) //nolint - - GcLeafMetric = metrics.NewCounter(`db_gc_leaf`) //nolint - GcOverflowMetric = metrics.NewCounter(`db_gc_overflow`) //nolint - GcPagesMetric = metrics.NewCounter(`db_gc_pages`) //nolint - - TableScsLeaf = metrics.NewCounter(`table_scs_leaf`) //nolint - TableScsBranch = metrics.NewCounter(`table_scs_branch`) //nolint - TableScsEntries = metrics.NewCounter(`table_scs_entries`) //nolint - TableScsSize = metrics.NewCounter(`table_scs_size`) //nolint - TableStateLeaf = metrics.NewCounter(`table_state_leaf`) //nolint - TableStateBranch = metrics.NewCounter(`table_state_branch`) //nolint - TableStateEntries = metrics.NewCounter(`table_state_entries`) //nolint - TableStateSize = metrics.NewCounter(`table_state_size`) //nolint - TableLogLeaf = metrics.NewCounter(`table_log_leaf`) //nolint - TableLogBranch = metrics.NewCounter(`table_log_branch`) //nolint - TableLogOverflow = metrics.NewCounter(`table_log_overflow`) //nolint - TableLogEntries = metrics.NewCounter(`table_log_entries`) //nolint - TableLogSize = metrics.NewCounter(`table_log_size`) //nolint - TableTxLeaf = metrics.NewCounter(`table_tx_leaf`) //nolint - TableTxBranch = metrics.NewCounter(`table_tx_branch`) //nolint - TableTxOverflow = metrics.NewCounter(`table_tx_overflow`) //nolint - TableTxEntries = metrics.NewCounter(`table_tx_entries`) //nolint - TableTxSize = metrics.NewCounter(`table_tx_size`) //nolint -) - -type DBVerbosityLvl int8 -type Label uint8 - -const ( - ChainDB Label = 0 - TxPoolDB Label = 1 - SentryDB Label = 2 -) - -func (l Label) String() string { - switch l { - case ChainDB: - return "chaindata" - case TxPoolDB: - return "txpool" - case SentryDB: - return "sentry" - default: - return "unknown" - } -} - -type Has interface { - // Has indicates whether a key exists in the database. - Has(bucket string, key []byte) (bool, error) -} -type GetPut interface { - Getter - Putter -} -type Getter interface { - Has - - GetOne(bucket string, key []byte) (val []byte, err error) - - // ForEach iterates over entries with keys greater or equal to fromPrefix. - // walker is called for each eligible entry. - // If walker returns an error: - // - implementations of local db - stop - // - implementations of remote db - do not handle this error and may finish (send all entries to client) before error happen. - ForEach(bucket string, fromPrefix []byte, walker func(k, v []byte) error) error - ForPrefix(bucket string, prefix []byte, walker func(k, v []byte) error) error - ForAmount(bucket string, prefix []byte, amount uint32, walker func(k, v []byte) error) error -} - -// Putter wraps the database write operations. -type Putter interface { - // Put inserts or updates a single entry. - Put(bucket string, key, value []byte) error -} - -// Deleter wraps the database delete operations. -type Deleter interface { - // Delete removes a single entry. - Delete(bucket string, k, v []byte) error -} - -type Closer interface { - Close() -} - -// RoDB - Read-only version of KV. -type RoDB interface { - Closer - - View(ctx context.Context, f func(tx Tx) error) error - - // BeginRo - creates transaction - // tx may be discarded by .Rollback() method - // - // A transaction and its cursors must only be used by a single - // thread (not goroutine), and a thread may only have a single transaction at a time. - // It happen automatically by - because this method calls runtime.LockOSThread() inside (Rollback/Commit releases it) - // By this reason application code can't call runtime.UnlockOSThread() - it leads to undefined behavior. - // - // If this `parent` is non-NULL, the new transaction - // will be a nested transaction, with the transaction indicated by parent - // as its parent. Transactions may be nested to any level. A parent - // transaction and its cursors may not issue any other operations than - // Commit and Rollback while it has active child transactions. - BeginRo(ctx context.Context) (Tx, error) - AllBuckets() TableCfg -} - -// RwDB low-level database interface - main target is - to provide common abstraction over top of MDBX and RemoteKV. -// -// Common pattern for short-living transactions: -// -// if err := db.View(ctx, func(tx ethdb.Tx) error { -// ... code which uses database in transaction -// }); err != nil { -// return err -// } -// -// Common pattern for long-living transactions: -// tx, err := db.Begin() -// if err != nil { -// return err -// } -// defer tx.Rollback() -// -// ... code which uses database in transaction -// -// err := tx.Commit() -// if err != nil { -// return err -// } -// -type RwDB interface { - RoDB - - Update(ctx context.Context, f func(tx RwTx) error) error - - BeginRw(ctx context.Context) (RwTx, error) -} - -type StatelessReadTx interface { - Getter - - Commit() error // Commit all the operations of a transaction into the database. - Rollback() // Rollback - abandon all the operations of the transaction instead of saving them. - - // ReadSequence - allows to create a linear sequence of unique positive integers for each table. - // Can be called for a read transaction to retrieve the current sequence value, and the increment must be zero. - // Sequence changes become visible outside the current write transaction after it is committed, and discarded on abort. - // Starts from 0. - ReadSequence(bucket string) (uint64, error) - - BucketSize(bucket string) (uint64, error) -} - -type StatelessWriteTx interface { - Putter - Deleter - - IncrementSequence(bucket string, amount uint64) (uint64, error) - Append(bucket string, k, v []byte) error - AppendDup(bucket string, k, v []byte) error -} - -type StatelessRwTx interface { - StatelessReadTx - StatelessWriteTx -} - -type Tx interface { - StatelessReadTx - - // Cursor - creates cursor object on top of given bucket. Type of cursor - depends on bucket configuration. - // If bucket was created with mdbx.DupSort flag, then cursor with interface CursorDupSort created - // Otherwise - object of interface Cursor created - // - // Cursor, also provides a grain of magic - it can use a declarative configuration - and automatically break - // long keys into DupSort key/values. See docs for `bucket.go:TableCfgItem` - Cursor(bucket string) (Cursor, error) - CursorDupSort(bucket string) (CursorDupSort, error) // CursorDupSort - can be used if bucket has mdbx.DupSort flag - - ForEach(bucket string, fromPrefix []byte, walker func(k, v []byte) error) error - ForPrefix(bucket string, prefix []byte, walker func(k, v []byte) error) error - ForAmount(bucket string, prefix []byte, amount uint32, walker func(k, v []byte) error) error -} - -type RwTx interface { - Tx - StatelessWriteTx - BucketMigrator - - RwCursor(bucket string) (RwCursor, error) - RwCursorDupSort(bucket string) (RwCursorDupSort, error) - - // CollectMetrics - does collect all DB-related and Tx-related metrics - // this method exists only in RwTx to avoid concurrency - CollectMetrics() -} - -// BucketMigrator used for buckets migration, don't use it in usual app code -type BucketMigrator interface { - DropBucket(string) error - CreateBucket(string) error - ExistsBucket(string) (bool, error) - ClearBucket(string) error - ListBuckets() ([]string, error) -} - -// Cursor - class for navigating through a database -// CursorDupSort are inherit this class -// -// If methods (like First/Next/Seek) return error, then returned key SHOULD not be nil (can be []byte{} for example). -// Then looping code will look as: -// c := kv.Cursor(bucketName) -// for k, v, err := c.First(); k != nil; k, v, err = c.Next() { -// if err != nil { -// return err -// } -// ... logic -// } -type Cursor interface { - First() ([]byte, []byte, error) // First - position at first key/data item - Seek(seek []byte) ([]byte, []byte, error) // Seek - position at first key greater than or equal to specified key - SeekExact(key []byte) ([]byte, []byte, error) // SeekExact - position at exact matching key if exists - Next() ([]byte, []byte, error) // Next - position at next key/value (can iterate over DupSort key/values automatically) - Prev() ([]byte, []byte, error) // Prev - position at previous key - Last() ([]byte, []byte, error) // Last - position at last key and last possible value - Current() ([]byte, []byte, error) // Current - return key/data at current cursor position - - Count() (uint64, error) // Count - fast way to calculate amount of keys in bucket. It counts all keys even if Prefix was set. - - Close() -} - -type RwCursor interface { - Cursor - - Put(k, v []byte) error // Put - based on order - Append(k []byte, v []byte) error // Append - append the given key/data pair to the end of the database. This option allows fast bulk loading when keys are already known to be in the correct order. - Delete(k, v []byte) error // Delete - short version of SeekExact+DeleteCurrent or SeekBothExact+DeleteCurrent - - // DeleteCurrent This function deletes the key/data pair to which the cursor refers. - // This does not invalidate the cursor, so operations such as MDB_NEXT - // can still be used on it. - // Both MDB_NEXT and MDB_GET_CURRENT will return the same record after - // this operation. - DeleteCurrent() error -} - -type CursorDupSort interface { - Cursor - - // SeekBothExact - - // second parameter can be nil only if searched key has no duplicates, or return error - SeekBothExact(key, value []byte) ([]byte, []byte, error) - SeekBothRange(key, value []byte) ([]byte, error) - FirstDup() ([]byte, error) // FirstDup - position at first data item of current key - NextDup() ([]byte, []byte, error) // NextDup - position at next data item of current key - NextNoDup() ([]byte, []byte, error) // NextNoDup - position at first data item of next key - LastDup() ([]byte, error) // LastDup - position at last data item of current key - - CountDuplicates() (uint64, error) // CountDuplicates - number of duplicates for the current key -} - -type RwCursorDupSort interface { - CursorDupSort - RwCursor - - DeleteCurrentDuplicates() error // DeleteCurrentDuplicates - deletes all of the data items for the current key - AppendDup(key, value []byte) error // AppendDup - same as Append, but for sorted dup data -} - -var ErrNotSupported = errors.New("not supported") diff --git a/ethdb/kv_util.go b/ethdb/kv_util.go index 8acacca96..586d294e0 100644 --- a/ethdb/kv_util.go +++ b/ethdb/kv_util.go @@ -5,8 +5,8 @@ import ( "errors" "fmt" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" - "github.com/ledgerwatch/erigon/ethdb/kv" ) func Walk(c kv.Cursor, startkey []byte, fixedbits int, walker func(k, v []byte) (bool, error)) error { diff --git a/ethdb/mdbx/kv_abstract_test.go b/ethdb/mdbx/kv_abstract_test.go deleted file mode 100644 index 632a5e36d..000000000 --- a/ethdb/mdbx/kv_abstract_test.go +++ /dev/null @@ -1,496 +0,0 @@ -package mdbx_test - -import ( - "context" - "errors" - "fmt" - "testing" - "time" - - "github.com/ledgerwatch/erigon-lib/gointerfaces" - "github.com/ledgerwatch/erigon-lib/gointerfaces/remote" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/mdbx" - "github.com/ledgerwatch/erigon/ethdb/remotedb" - "github.com/ledgerwatch/erigon/ethdb/remotedbserver" - "github.com/ledgerwatch/log/v3" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "google.golang.org/grpc" - "google.golang.org/grpc/test/bufconn" -) - -func TestSequence(t *testing.T) { - writeDBs, _ := setupDatabases(t, log.New(), func(defaultBuckets kv.TableCfg) kv.TableCfg { - return defaultBuckets - }) - ctx := context.Background() - - for _, db := range writeDBs { - db := db - tx, err := db.BeginRw(ctx) - require.NoError(t, err) - defer tx.Rollback() - - i, err := tx.ReadSequence(kv.ChaindataTables[0]) - require.NoError(t, err) - require.Equal(t, uint64(0), i) - i, err = tx.IncrementSequence(kv.ChaindataTables[0], 1) - require.NoError(t, err) - require.Equal(t, uint64(0), i) - i, err = tx.IncrementSequence(kv.ChaindataTables[0], 6) - require.NoError(t, err) - require.Equal(t, uint64(1), i) - i, err = tx.IncrementSequence(kv.ChaindataTables[0], 1) - require.NoError(t, err) - require.Equal(t, uint64(7), i) - - i, err = tx.ReadSequence(kv.ChaindataTables[1]) - require.NoError(t, err) - require.Equal(t, uint64(0), i) - i, err = tx.IncrementSequence(kv.ChaindataTables[1], 1) - require.NoError(t, err) - require.Equal(t, uint64(0), i) - i, err = tx.IncrementSequence(kv.ChaindataTables[1], 6) - require.NoError(t, err) - require.Equal(t, uint64(1), i) - i, err = tx.IncrementSequence(kv.ChaindataTables[1], 1) - require.NoError(t, err) - require.Equal(t, uint64(7), i) - tx.Rollback() - } -} - -func TestManagedTx(t *testing.T) { - defaultConfig := kv.ChaindataTablesCfg - defer func() { - kv.ChaindataTablesCfg = defaultConfig - }() - - bucketID := 0 - bucket1 := kv.ChaindataTables[bucketID] - bucket2 := kv.ChaindataTables[bucketID+1] - writeDBs, readDBs := setupDatabases(t, log.New(), func(defaultBuckets kv.TableCfg) kv.TableCfg { - return map[string]kv.TableCfgItem{ - bucket1: { - Flags: kv.DupSort, - AutoDupSortKeysConversion: true, - DupToLen: 4, - DupFromLen: 6, - }, - bucket2: { - Flags: 0, - }, - } - }) - - ctx := context.Background() - - for _, db := range writeDBs { - db := db - tx, err := db.BeginRw(ctx) - require.NoError(t, err) - defer tx.Rollback() - - c, err := tx.RwCursor(bucket1) - require.NoError(t, err) - c1, err := tx.RwCursor(bucket2) - require.NoError(t, err) - require.NoError(t, c.Append([]byte{0}, []byte{1})) - require.NoError(t, c1.Append([]byte{0}, []byte{1})) - require.NoError(t, c.Append([]byte{0, 0, 0, 0, 0, 1}, []byte{1})) // prefixes of len=FromLen for DupSort test (other keys must be 0 { - db.log.Info("[db] cleared reader slots from dead processes", "amount", staleReaders) - } - } - return db, nil -} - -func (opts MdbxOpts) MustOpen() kv.RwDB { - db, err := opts.Open() - if err != nil { - panic(fmt.Errorf("fail to open mdbx: %w", err)) - } - return db -} - -type MdbxKV struct { - env *mdbx.Env - log log.Logger - wg *sync.WaitGroup - buckets kv.TableCfg - opts MdbxOpts - txSize uint64 -} - -// Close closes db -// All transactions must be closed before closing the database. -func (db *MdbxKV) Close() { - if db.env == nil { - return - } - - db.wg.Wait() - db.env.Close() - db.env = nil - - if db.opts.inMem { - if err := os.RemoveAll(db.opts.path); err != nil { - db.log.Warn("failed to remove in-mem db file", "err", err) - } - } else { - db.log.Info("database closed (MDBX)") - } -} - -func (db *MdbxKV) BeginRo(_ context.Context) (txn kv.Tx, err error) { - if db.env == nil { - return nil, fmt.Errorf("db closed") - } - defer func() { - if err == nil { - db.wg.Add(1) - } - }() - - tx, err := db.env.BeginTxn(nil, mdbx.Readonly) - if err != nil { - return nil, fmt.Errorf("%w, label: %s, trace: %s", err, db.opts.label.String(), debug.Callers(10)) - } - tx.RawRead = true - return &MdbxTx{ - db: db, - tx: tx, - readOnly: true, - }, nil -} - -func (db *MdbxKV) BeginRw(_ context.Context) (txn kv.RwTx, err error) { - if db.env == nil { - return nil, fmt.Errorf("db closed") - } - runtime.LockOSThread() - defer func() { - if err == nil { - db.wg.Add(1) - } - }() - - tx, err := db.env.BeginTxn(nil, 0) - if err != nil { - runtime.UnlockOSThread() // unlock only in case of error. normal flow is "defer .Rollback()" - return nil, fmt.Errorf("%w, lable: %s, trace: %s", err, db.opts.label.String(), debug.Callers(10)) - } - tx.RawRead = true - return &MdbxTx{ - db: db, - tx: tx, - }, nil -} - -type MdbxTx struct { - tx *mdbx.Txn - db *MdbxKV - cursors map[uint64]*mdbx.Cursor - statelessCursors map[string]kv.Cursor - readOnly bool - cursorID uint64 -} - -type MdbxCursor struct { - tx *MdbxTx - c *mdbx.Cursor - bucketName string - bucketCfg kv.TableCfgItem - dbi mdbx.DBI - id uint64 -} - -func (db *MdbxKV) Env() *mdbx.Env { - return db.env -} - -func (db *MdbxKV) AllDBI() map[string]kv.DBI { - res := map[string]kv.DBI{} - for name, cfg := range db.buckets { - res[name] = cfg.DBI - } - return res -} - -func (db *MdbxKV) AllBuckets() kv.TableCfg { - return db.buckets -} - -func (tx *MdbxTx) ForEach(bucket string, fromPrefix []byte, walker func(k, v []byte) error) error { - c, err := tx.Cursor(bucket) - if err != nil { - return err - } - defer c.Close() - - for k, v, err := c.Seek(fromPrefix); k != nil; k, v, err = c.Next() { - if err != nil { - return err - } - if err := walker(k, v); err != nil { - return err - } - } - return nil -} - -func (tx *MdbxTx) ForPrefix(bucket string, prefix []byte, walker func(k, v []byte) error) error { - c, err := tx.Cursor(bucket) - if err != nil { - return err - } - defer c.Close() - - for k, v, err := c.Seek(prefix); k != nil; k, v, err = c.Next() { - if err != nil { - return err - } - if !bytes.HasPrefix(k, prefix) { - break - } - if err := walker(k, v); err != nil { - return err - } - } - return nil -} -func (tx *MdbxTx) ForAmount(bucket string, fromPrefix []byte, amount uint32, walker func(k, v []byte) error) error { - c, err := tx.Cursor(bucket) - if err != nil { - return err - } - defer c.Close() - - for k, v, err := c.Seek(fromPrefix); k != nil && amount > 0; k, v, err = c.Next() { - if err != nil { - return err - } - if err := walker(k, v); err != nil { - return err - } - amount-- - } - return nil -} - -func (tx *MdbxTx) CollectMetrics() { - if tx.db.opts.label != kv.ChainDB { - return - } - - info, err := tx.db.env.Info(tx.tx) - if err != nil { - return - } - if info.SinceReaderCheck.Hours() > 1 { - if staleReaders, err := tx.db.env.ReaderCheck(); err != nil { - tx.db.log.Error("failed ReaderCheck", "err", err) - } else if staleReaders > 0 { - tx.db.log.Info("[db] cleared reader slots from dead processes", "amount", staleReaders) - } - } - - kv.DbSize.Set(info.Geo.Current) - kv.DbPgopsNewly.Set(info.PageOps.Newly) - kv.DbPgopsCow.Set(info.PageOps.Cow) - kv.DbPgopsClone.Set(info.PageOps.Clone) - kv.DbPgopsSplit.Set(info.PageOps.Split) - kv.DbPgopsMerge.Set(info.PageOps.Merge) - kv.DbPgopsSpill.Set(info.PageOps.Spill) - kv.DbPgopsUnspill.Set(info.PageOps.Unspill) - kv.DbPgopsWops.Set(info.PageOps.Wops) - - txInfo, err := tx.tx.Info(true) - if err != nil { - return - } - - kv.TxDirty.Set(txInfo.SpaceDirty) - kv.TxLimit.Set(tx.db.txSize) - kv.TxSpill.Set(txInfo.Spill) - kv.TxUnspill.Set(txInfo.Unspill) - - gc, err := tx.BucketStat("gc") - if err != nil { - return - } - kv.GcLeafMetric.Set(gc.LeafPages) - kv.GcOverflowMetric.Set(gc.OverflowPages) - kv.GcPagesMetric.Set((gc.LeafPages + gc.OverflowPages) * pageSize / 8) - - { - st, err := tx.BucketStat(kv.PlainState) - if err != nil { - return - } - kv.TableStateLeaf.Set(st.LeafPages) - kv.TableStateBranch.Set(st.BranchPages) - kv.TableStateEntries.Set(st.Entries) - kv.TableStateSize.Set((st.LeafPages + st.BranchPages + st.OverflowPages) * pageSize) - } - { - st, err := tx.BucketStat(kv.StorageChangeSet) - if err != nil { - return - } - kv.TableScsLeaf.Set(st.LeafPages) - kv.TableScsBranch.Set(st.BranchPages) - kv.TableScsEntries.Set(st.Entries) - kv.TableScsSize.Set((st.LeafPages + st.BranchPages + st.OverflowPages) * pageSize) - } - { - st, err := tx.BucketStat(kv.EthTx) - if err != nil { - return - } - kv.TableTxLeaf.Set(st.LeafPages) - kv.TableTxBranch.Set(st.BranchPages) - kv.TableTxOverflow.Set(st.OverflowPages) - kv.TableTxEntries.Set(st.Entries) - kv.TableTxSize.Set((st.LeafPages + st.BranchPages + st.OverflowPages) * pageSize) - } - { - st, err := tx.BucketStat(kv.Log) - if err != nil { - return - } - kv.TableLogLeaf.Set(st.LeafPages) - kv.TableLogBranch.Set(st.BranchPages) - kv.TableLogOverflow.Set(st.OverflowPages) - kv.TableLogEntries.Set(st.Entries) - kv.TableLogSize.Set((st.LeafPages + st.BranchPages + st.OverflowPages) * pageSize) - } -} - -// ExistingBuckets - all buckets stored as keys of un-named bucket -func (tx *MdbxTx) ListBuckets() ([]string, error) { - return tx.tx.ListDBI() -} - -func (db *MdbxKV) View(ctx context.Context, f func(tx kv.Tx) error) (err error) { - if db.env == nil { - return fmt.Errorf("db closed") - } - db.wg.Add(1) - defer db.wg.Done() - - // can't use db.evn.View method - because it calls commit for read transactions - it conflicts with write transactions. - tx, err := db.BeginRo(ctx) - if err != nil { - return err - } - defer tx.Rollback() - - return f(tx) -} - -func (db *MdbxKV) Update(ctx context.Context, f func(tx kv.RwTx) error) (err error) { - if db.env == nil { - return fmt.Errorf("db closed") - } - db.wg.Add(1) - defer db.wg.Done() - - tx, err := db.BeginRw(ctx) - if err != nil { - return err - } - defer tx.Rollback() - err = f(tx) - if err != nil { - return err - } - err = tx.Commit() - if err != nil { - return err - } - return nil -} - -func (tx *MdbxTx) CreateBucket(name string) error { - cnfCopy := tx.db.buckets[name] - dbi, err := tx.tx.OpenDBI(name, mdbx.DBAccede, nil, nil) - if err != nil && !mdbx.IsNotFound(err) { - return fmt.Errorf("create bucket: %s, %w", name, err) - } - if err == nil { - cnfCopy.DBI = kv.DBI(dbi) - var flags uint - flags, err = tx.tx.Flags(dbi) - if err != nil { - return err - } - cnfCopy.Flags = kv.TableFlags(flags) - - tx.db.buckets[name] = cnfCopy - return nil - } - - // if bucket doesn't exists - create it - - var flags = tx.db.buckets[name].Flags - var nativeFlags uint - if tx.db.opts.flags&mdbx.Readonly == 0 { - nativeFlags |= mdbx.Create - } - - if flags&kv.DupSort != 0 { - nativeFlags |= mdbx.DupSort - flags ^= kv.DupSort - } - if flags != 0 { - return fmt.Errorf("some not supported flag provided for bucket") - } - - dbi, err = tx.tx.OpenDBI(name, nativeFlags, nil, nil) - - if err != nil { - return fmt.Errorf("create bucket: %s, %w", name, err) - } - cnfCopy.DBI = kv.DBI(dbi) - - tx.db.buckets[name] = cnfCopy - return nil -} - -func (tx *MdbxTx) dropEvenIfBucketIsNotDeprecated(name string) error { - dbi := tx.db.buckets[name].DBI - // if bucket was not open on db start, then it's may be deprecated - // try to open it now without `Create` flag, and if fail then nothing to drop - if dbi == NonExistingDBI { - nativeDBI, err := tx.tx.OpenDBI(name, 0, nil, nil) - if err != nil { - if mdbx.IsNotFound(err) { - return nil // DBI doesn't exists means no drop needed - } - return fmt.Errorf("bucket: %s, %w", name, err) - } - dbi = kv.DBI(nativeDBI) - } - - if err := tx.tx.Drop(mdbx.DBI(dbi), true); err != nil { - return err - } - cnfCopy := tx.db.buckets[name] - cnfCopy.DBI = NonExistingDBI - tx.db.buckets[name] = cnfCopy - return nil -} - -func (tx *MdbxTx) ClearBucket(bucket string) error { - dbi := tx.db.buckets[bucket].DBI - if dbi == NonExistingDBI { - return nil - } - return tx.tx.Drop(mdbx.DBI(dbi), false) -} - -func (tx *MdbxTx) DropBucket(bucket string) error { - if cfg, ok := tx.db.buckets[bucket]; !(ok && cfg.IsDeprecated) { - return fmt.Errorf("%w, bucket: %s", kv.ErrAttemptToDeleteNonDeprecatedBucket, bucket) - } - - return tx.dropEvenIfBucketIsNotDeprecated(bucket) -} - -func (tx *MdbxTx) ExistsBucket(bucket string) (bool, error) { - if cfg, ok := tx.db.buckets[bucket]; ok { - return cfg.DBI != NonExistingDBI, nil - } - return false, nil -} - -func (tx *MdbxTx) Commit() error { - if tx.db.env == nil { - return fmt.Errorf("db closed") - } - if tx.tx == nil { - return nil - } - defer func() { - tx.tx = nil - tx.db.wg.Done() - if !tx.readOnly { - runtime.UnlockOSThread() - } - }() - tx.closeCursors() - - slowTx := 10 * time.Second - if debug.SlowCommit() > 0 { - slowTx = debug.SlowCommit() - } - - if debug.BigRoTxKb() > 0 || debug.BigRwTxKb() > 0 { - tx.PrintDebugInfo() - } - tx.CollectMetrics() - - latency, err := tx.tx.Commit() - if err != nil { - return err - } - - if tx.db.opts.label == kv.ChainDB { - kv.DbCommitPreparation.Update(latency.Preparation.Seconds()) - kv.DbCommitGc.Update(latency.GC.Seconds()) - kv.DbCommitAudit.Update(latency.Audit.Seconds()) - kv.DbCommitWrite.Update(latency.Write.Seconds()) - kv.DbCommitSync.Update(latency.Sync.Seconds()) - kv.DbCommitEnding.Update(latency.Ending.Seconds()) - kv.DbCommitTotal.Update(latency.Whole.Seconds()) - } - - if latency.Whole > slowTx { - log.Info("Commit", - "preparation", latency.Preparation, - "gc", latency.GC, - "audit", latency.Audit, - "write", latency.Write, - "fsync", latency.Sync, - "ending", latency.Ending, - "whole", latency.Whole, - ) - } - - return nil -} - -func (tx *MdbxTx) Rollback() { - if tx.db.env == nil { - return - } - if tx.tx == nil { - return - } - defer func() { - tx.tx = nil - tx.db.wg.Done() - if !tx.readOnly { - runtime.UnlockOSThread() - } - }() - tx.closeCursors() - //tx.printDebugInfo() - tx.tx.Abort() -} - -//nolint -func (tx *MdbxTx) SpaceDirty() (uint64, uint64, error) { - txInfo, err := tx.tx.Info(true) - if err != nil { - return 0, 0, err - } - - return txInfo.SpaceDirty, tx.db.txSize, nil -} - -//nolint -func (tx *MdbxTx) PrintDebugInfo() { - txInfo, err := tx.tx.Info(true) - if err != nil { - panic(err) - } - - txSize := uint(txInfo.SpaceDirty / 1024) - doPrint := debug.BigRoTxKb() == 0 && debug.BigRwTxKb() == 0 || - tx.readOnly && debug.BigRoTxKb() > 0 && txSize > debug.BigRoTxKb() || - (!tx.readOnly && debug.BigRwTxKb() > 0 && txSize > debug.BigRwTxKb()) - if doPrint { - tx.db.log.Info("Tx info", - "id", txInfo.Id, - "read_lag", txInfo.ReadLag, - "ro", tx.readOnly, - //"space_retired_mb", txInfo.SpaceRetired/1024/1024, - "space_dirty_mb", txInfo.SpaceDirty/1024/1024, - //"callers", debug.Callers(7), - ) - } -} - -func (tx *MdbxTx) closeCursors() { - for _, c := range tx.cursors { - if c != nil { - c.Close() - } - } - tx.cursors = nil - tx.statelessCursors = nil -} - -func (tx *MdbxTx) statelessCursor(bucket string) (kv.RwCursor, error) { - if tx.statelessCursors == nil { - tx.statelessCursors = make(map[string]kv.Cursor) - } - c, ok := tx.statelessCursors[bucket] - if !ok { - var err error - c, err = tx.Cursor(bucket) - if err != nil { - return nil, err - } - tx.statelessCursors[bucket] = c - } - return c.(kv.RwCursor), nil -} - -func (tx *MdbxTx) Put(bucket string, k, v []byte) error { - c, err := tx.statelessCursor(bucket) - if err != nil { - return err - } - return c.Put(k, v) -} - -func (tx *MdbxTx) Delete(bucket string, k, v []byte) error { - c, err := tx.statelessCursor(bucket) - if err != nil { - return err - } - return c.Delete(k, v) -} - -func (tx *MdbxTx) GetOne(bucket string, k []byte) ([]byte, error) { - c, err := tx.statelessCursor(bucket) - if err != nil { - return nil, err - } - _, v, err := c.SeekExact(k) - return v, err -} - -func (tx *MdbxTx) Has(bucket string, key []byte) (bool, error) { - c, err := tx.statelessCursor(bucket) - if err != nil { - return false, err - } - k, _, err := c.Seek(key) - if err != nil { - return false, err - } - return bytes.Equal(key, k), nil -} - -func (tx *MdbxTx) Append(bucket string, k, v []byte) error { - c, err := tx.statelessCursor(bucket) - if err != nil { - return err - } - return c.Append(k, v) -} -func (tx *MdbxTx) AppendDup(bucket string, k, v []byte) error { - c, err := tx.statelessCursor(bucket) - if err != nil { - return err - } - return c.(*MdbxDupSortCursor).AppendDup(k, v) -} - -func (tx *MdbxTx) IncrementSequence(bucket string, amount uint64) (uint64, error) { - c, err := tx.statelessCursor(kv.Sequence) - if err != nil { - return 0, err - } - _, v, err := c.SeekExact([]byte(bucket)) - if err != nil { - return 0, err - } - - var currentV uint64 = 0 - if len(v) > 0 { - currentV = binary.BigEndian.Uint64(v) - } - - newVBytes := make([]byte, 8) - binary.BigEndian.PutUint64(newVBytes, currentV+amount) - err = c.Put([]byte(bucket), newVBytes) - if err != nil { - return 0, err - } - return currentV, nil -} - -func (tx *MdbxTx) ReadSequence(bucket string) (uint64, error) { - c, err := tx.statelessCursor(kv.Sequence) - if err != nil { - return 0, err - } - _, v, err := c.SeekExact([]byte(bucket)) - if err != nil && !mdbx.IsNotFound(err) { - return 0, err - } - - var currentV uint64 = 0 - if len(v) > 0 { - currentV = binary.BigEndian.Uint64(v) - } - - return currentV, nil -} - -func (tx *MdbxTx) BucketSize(name string) (uint64, error) { - st, err := tx.BucketStat(name) - if err != nil { - return 0, err - } - return (st.LeafPages + st.BranchPages + st.OverflowPages) * pageSize, nil -} - -func (tx *MdbxTx) BucketStat(name string) (*mdbx.Stat, error) { - if name == "freelist" || name == "gc" || name == "free_list" { - return tx.tx.StatDBI(mdbx.DBI(0)) - } - if name == "root" { - return tx.tx.StatDBI(mdbx.DBI(1)) - } - st, err := tx.tx.StatDBI(mdbx.DBI(tx.db.buckets[name].DBI)) - if err != nil { - return nil, fmt.Errorf("bucket: %s, %w", name, err) - } - return st, nil -} - -func (tx *MdbxTx) RwCursor(bucket string) (kv.RwCursor, error) { - b := tx.db.buckets[bucket] - if b.AutoDupSortKeysConversion { - return tx.stdCursor(bucket) - } - - if b.Flags&kv.DupSort != 0 { - return tx.RwCursorDupSort(bucket) - } - - return tx.stdCursor(bucket) -} - -func (tx *MdbxTx) Cursor(bucket string) (kv.Cursor, error) { - return tx.RwCursor(bucket) -} - -func (tx *MdbxTx) stdCursor(bucket string) (kv.RwCursor, error) { - b := tx.db.buckets[bucket] - c := &MdbxCursor{bucketName: bucket, tx: tx, bucketCfg: b, dbi: mdbx.DBI(tx.db.buckets[bucket].DBI), id: tx.cursorID} - tx.cursorID++ - - var err error - c.c, err = tx.tx.OpenCursor(c.dbi) - if err != nil { - return nil, fmt.Errorf("table: %s, %w", c.bucketName, err) - } - - // add to auto-cleanup on end of transactions - if tx.cursors == nil { - tx.cursors = map[uint64]*mdbx.Cursor{} - } - tx.cursors[c.id] = c.c - return c, nil -} - -func (tx *MdbxTx) RwCursorDupSort(bucket string) (kv.RwCursorDupSort, error) { - basicCursor, err := tx.stdCursor(bucket) - if err != nil { - return nil, err - } - return &MdbxDupSortCursor{MdbxCursor: basicCursor.(*MdbxCursor)}, nil -} - -func (tx *MdbxTx) CursorDupSort(bucket string) (kv.CursorDupSort, error) { - return tx.RwCursorDupSort(bucket) -} - -// methods here help to see better pprof picture -func (c *MdbxCursor) set(k []byte) ([]byte, []byte, error) { return c.c.Get(k, nil, mdbx.Set) } -func (c *MdbxCursor) getCurrent() ([]byte, []byte, error) { return c.c.Get(nil, nil, mdbx.GetCurrent) } -func (c *MdbxCursor) first() ([]byte, []byte, error) { return c.c.Get(nil, nil, mdbx.First) } -func (c *MdbxCursor) next() ([]byte, []byte, error) { return c.c.Get(nil, nil, mdbx.Next) } -func (c *MdbxCursor) nextDup() ([]byte, []byte, error) { return c.c.Get(nil, nil, mdbx.NextDup) } -func (c *MdbxCursor) nextNoDup() ([]byte, []byte, error) { return c.c.Get(nil, nil, mdbx.NextNoDup) } -func (c *MdbxCursor) prev() ([]byte, []byte, error) { return c.c.Get(nil, nil, mdbx.Prev) } -func (c *MdbxCursor) prevDup() ([]byte, []byte, error) { return c.c.Get(nil, nil, mdbx.PrevDup) } -func (c *MdbxCursor) prevNoDup() ([]byte, []byte, error) { return c.c.Get(nil, nil, mdbx.PrevNoDup) } -func (c *MdbxCursor) last() ([]byte, []byte, error) { return c.c.Get(nil, nil, mdbx.Last) } -func (c *MdbxCursor) delCurrent() error { return c.c.Del(mdbx.Current) } -func (c *MdbxCursor) delNoDupData() error { return c.c.Del(mdbx.NoDupData) } -func (c *MdbxCursor) put(k, v []byte) error { return c.c.Put(k, v, 0) } -func (c *MdbxCursor) putCurrent(k, v []byte) error { return c.c.Put(k, v, mdbx.Current) } -func (c *MdbxCursor) putNoOverwrite(k, v []byte) error { return c.c.Put(k, v, mdbx.NoOverwrite) } -func (c *MdbxCursor) putNoDupData(k, v []byte) error { return c.c.Put(k, v, mdbx.NoDupData) } -func (c *MdbxCursor) append(k, v []byte) error { return c.c.Put(k, v, mdbx.Append) } -func (c *MdbxCursor) appendDup(k, v []byte) error { return c.c.Put(k, v, mdbx.AppendDup) } -func (c *MdbxCursor) getBoth(k, v []byte) ([]byte, error) { - _, v, err := c.c.Get(k, v, mdbx.GetBoth) - return v, err -} -func (c *MdbxCursor) setRange(k []byte) ([]byte, []byte, error) { - return c.c.Get(k, nil, mdbx.SetRange) -} -func (c *MdbxCursor) getBothRange(k, v []byte) ([]byte, error) { - _, v, err := c.c.Get(k, v, mdbx.GetBothRange) - return v, err -} -func (c *MdbxCursor) firstDup() ([]byte, error) { - _, v, err := c.c.Get(nil, nil, mdbx.FirstDup) - return v, err -} -func (c *MdbxCursor) lastDup() ([]byte, error) { - _, v, err := c.c.Get(nil, nil, mdbx.LastDup) - return v, err -} - -func (c *MdbxCursor) Count() (uint64, error) { - st, err := c.tx.tx.StatDBI(c.dbi) - if err != nil { - return 0, err - } - return st.Entries, nil -} - -func (c *MdbxCursor) First() ([]byte, []byte, error) { - return c.Seek(nil) -} - -func (c *MdbxCursor) Last() ([]byte, []byte, error) { - k, v, err := c.last() - if err != nil { - if mdbx.IsNotFound(err) { - return nil, nil, nil - } - err = fmt.Errorf("failed MdbxKV cursor.Last(): %w, bucket: %s", err, c.bucketName) - return []byte{}, nil, err - } - - b := c.bucketCfg - if b.AutoDupSortKeysConversion && len(k) == b.DupToLen { - keyPart := b.DupFromLen - b.DupToLen - k = append(k, v[:keyPart]...) - v = v[keyPart:] - } - - return k, v, nil -} - -func (c *MdbxCursor) Seek(seek []byte) (k, v []byte, err error) { - if c.bucketCfg.AutoDupSortKeysConversion { - return c.seekDupSort(seek) - } - - if len(seek) == 0 { - k, v, err = c.first() - } else { - k, v, err = c.setRange(seek) - } - if err != nil { - if mdbx.IsNotFound(err) { - return nil, nil, nil - } - err = fmt.Errorf("failed MdbxKV cursor.Seek(): %w, bucket: %s, key: %x", err, c.bucketName, seek) - return []byte{}, nil, err - } - - return k, v, nil -} - -func (c *MdbxCursor) seekDupSort(seek []byte) (k, v []byte, err error) { - b := c.bucketCfg - from, to := b.DupFromLen, b.DupToLen - if len(seek) == 0 { - k, v, err = c.first() - if err != nil { - if mdbx.IsNotFound(err) { - return nil, nil, nil - } - return []byte{}, nil, err - } - - if len(k) == to { - k2 := make([]byte, 0, len(k)+from-to) - k2 = append(append(k2, k...), v[:from-to]...) - v = v[from-to:] - k = k2 - } - return k, v, nil - } - - var seek1, seek2 []byte - if len(seek) > to { - seek1, seek2 = seek[:to], seek[to:] - } else { - seek1 = seek - } - k, v, err = c.setRange(seek1) - if err != nil { - if mdbx.IsNotFound(err) { - return nil, nil, nil - } - - return []byte{}, nil, err - } - - if seek2 != nil && bytes.Equal(seek1, k) { - v, err = c.getBothRange(seek1, seek2) - if err != nil && mdbx.IsNotFound(err) { - k, v, err = c.next() - if err != nil { - if mdbx.IsNotFound(err) { - return nil, nil, nil - } - return []byte{}, nil, err - } - } else if err != nil { - return []byte{}, nil, err - } - } - if len(k) == to { - k2 := make([]byte, 0, len(k)+from-to) - k2 = append(append(k2, k...), v[:from-to]...) - v = v[from-to:] - k = k2 - } - - return k, v, nil -} - -func (c *MdbxCursor) Next() (k, v []byte, err error) { - k, v, err = c.next() - if err != nil { - if mdbx.IsNotFound(err) { - return nil, nil, nil - } - return []byte{}, nil, fmt.Errorf("failed MdbxKV cursor.Next(): %w", err) - } - - b := c.bucketCfg - if b.AutoDupSortKeysConversion && len(k) == b.DupToLen { - keyPart := b.DupFromLen - b.DupToLen - k = append(k, v[:keyPart]...) - v = v[keyPart:] - } - - return k, v, nil -} - -func (c *MdbxCursor) Prev() (k, v []byte, err error) { - k, v, err = c.prev() - if err != nil { - if mdbx.IsNotFound(err) { - return nil, nil, nil - } - return []byte{}, nil, fmt.Errorf("failed MdbxKV cursor.Prev(): %w", err) - } - - b := c.bucketCfg - if b.AutoDupSortKeysConversion && len(k) == b.DupToLen { - keyPart := b.DupFromLen - b.DupToLen - k = append(k, v[:keyPart]...) - v = v[keyPart:] - } - - return k, v, nil -} - -// Current - return key/data at current cursor position -func (c *MdbxCursor) Current() ([]byte, []byte, error) { - k, v, err := c.getCurrent() - if err != nil { - if mdbx.IsNotFound(err) { - return nil, nil, nil - } - return []byte{}, nil, err - } - - b := c.bucketCfg - if b.AutoDupSortKeysConversion && len(k) == b.DupToLen { - keyPart := b.DupFromLen - b.DupToLen - k = append(k, v[:keyPart]...) - v = v[keyPart:] - } - - return k, v, nil -} - -func (c *MdbxCursor) Delete(k, v []byte) error { - if c.bucketCfg.AutoDupSortKeysConversion { - return c.deleteDupSort(k) - } - - if c.bucketCfg.Flags&mdbx.DupSort != 0 { - _, err := c.getBoth(k, v) - if err != nil { - if mdbx.IsNotFound(err) { - return nil - } - return err - } - return c.delCurrent() - } - - _, _, err := c.set(k) - if err != nil { - if mdbx.IsNotFound(err) { - return nil - } - return err - } - - return c.delCurrent() -} - -// DeleteCurrent This function deletes the key/data pair to which the cursor refers. -// This does not invalidate the cursor, so operations such as MDB_NEXT -// can still be used on it. -// Both MDB_NEXT and MDB_GET_CURRENT will return the same record after -// this operation. -func (c *MdbxCursor) DeleteCurrent() error { - return c.delCurrent() -} - -func (c *MdbxCursor) deleteDupSort(key []byte) error { - b := c.bucketCfg - from, to := b.DupFromLen, b.DupToLen - if len(key) != from && len(key) >= to { - return fmt.Errorf("delete from dupsort bucket: %s, can have keys of len==%d and len<%d. key: %x,%d", c.bucketName, from, to, key, len(key)) - } - - if len(key) == from { - v, err := c.getBothRange(key[:to], key[to:]) - if err != nil { // if key not found, or found another one - then nothing to delete - if mdbx.IsNotFound(err) { - return nil - } - return err - } - if !bytes.Equal(v[:from-to], key[to:]) { - return nil - } - return c.delCurrent() - } - - _, _, err := c.set(key) - if err != nil { - if mdbx.IsNotFound(err) { - return nil - } - return err - } - - return c.delCurrent() -} - -func (c *MdbxCursor) PutNoOverwrite(key []byte, value []byte) error { - if len(key) == 0 { - return fmt.Errorf("mdbx doesn't support empty keys. bucket: %s", c.bucketName) - } - if c.bucketCfg.AutoDupSortKeysConversion { - panic("not implemented") - } - - return c.putNoOverwrite(key, value) -} - -func (c *MdbxCursor) Put(key []byte, value []byte) error { - if len(key) == 0 { - return fmt.Errorf("mdbx doesn't support empty keys. bucket: %s", c.bucketName) - } - - b := c.bucketCfg - if b.AutoDupSortKeysConversion { - if err := c.putDupSort(key, value); err != nil { - return err - } - return nil - } - if err := c.put(key, value); err != nil { - return err - } - return nil -} - -func (c *MdbxCursor) putDupSort(key []byte, value []byte) error { - b := c.bucketCfg - from, to := b.DupFromLen, b.DupToLen - if len(key) != from && len(key) >= to { - return fmt.Errorf("put dupsort bucket: %s, can have keys of len==%d and len<%d. key: %x,%d", c.bucketName, from, to, key, len(key)) - } - - if len(key) != from { - err := c.putNoOverwrite(key, value) - if err != nil { - if mdbx.IsKeyExists(err) { - return c.putCurrent(key, value) - } - return fmt.Errorf("putNoOverwrite, bucket: %s, key: %x, val: %x, err: %w", c.bucketName, key, value, err) - } - return nil - } - - value = append(key[to:], value...) - key = key[:to] - v, err := c.getBothRange(key, value[:from-to]) - if err != nil { // if key not found, or found another one - then just insert - if mdbx.IsNotFound(err) { - return c.put(key, value) - } - return err - } - - if bytes.Equal(v[:from-to], value[:from-to]) { - if len(v) == len(value) { // in DupSort case mdbx.Current works only with values of same length - return c.putCurrent(key, value) - } - err = c.delCurrent() - if err != nil { - return err - } - } - - return c.put(key, value) -} - -func (c *MdbxCursor) SeekExact(key []byte) ([]byte, []byte, error) { - b := c.bucketCfg - if b.AutoDupSortKeysConversion && len(key) == b.DupFromLen { - from, to := b.DupFromLen, b.DupToLen - v, err := c.getBothRange(key[:to], key[to:]) - if err != nil { - if mdbx.IsNotFound(err) { - return nil, nil, nil - } - return []byte{}, nil, err - } - if !bytes.Equal(key[to:], v[:from-to]) { - return nil, nil, nil - } - return key[:to], v[from-to:], nil - } - - k, v, err := c.set(key) - if err != nil { - if mdbx.IsNotFound(err) { - return nil, nil, nil - } - return []byte{}, nil, err - } - return k, v, nil -} - -// Append - speedy feature of mdbx which is not part of KV interface. -// Cast your cursor to *MdbxCursor to use this method. -// Return error - if provided data will not sorted (or bucket have old records which mess with new in sorting manner). -func (c *MdbxCursor) Append(k []byte, v []byte) error { - if len(k) == 0 { - return fmt.Errorf("mdbx doesn't support empty keys. bucket: %s", c.bucketName) - } - b := c.bucketCfg - if b.AutoDupSortKeysConversion { - from, to := b.DupFromLen, b.DupToLen - if len(k) != from && len(k) >= to { - return fmt.Errorf("append dupsort bucket: %s, can have keys of len==%d and len<%d. key: %x,%d", c.bucketName, from, to, k, len(k)) - } - - if len(k) == from { - v = append(k[to:], v...) - k = k[:to] - } - } - - if b.Flags&mdbx.DupSort != 0 { - if err := c.appendDup(k, v); err != nil { - return fmt.Errorf("bucket: %s, %w", c.bucketName, err) - } - return nil - } - if err := c.append(k, v); err != nil { - return fmt.Errorf("bucket: %s, %w", c.bucketName, err) - } - return nil -} - -func (c *MdbxCursor) Close() { - if c.c != nil { - c.c.Close() - delete(c.tx.cursors, c.id) - c.c = nil - } -} - -type MdbxDupSortCursor struct { - *MdbxCursor -} - -func (c *MdbxDupSortCursor) Internal() *mdbx.Cursor { - return c.c -} - -// DeleteExact - does delete -func (c *MdbxDupSortCursor) DeleteExact(k1, k2 []byte) error { - _, err := c.getBoth(k1, k2) - if err != nil { // if key not found, or found another one - then nothing to delete - if mdbx.IsNotFound(err) { - return nil - } - return err - } - return c.delCurrent() -} - -func (c *MdbxDupSortCursor) SeekBothExact(key, value []byte) ([]byte, []byte, error) { - v, err := c.getBoth(key, value) - if err != nil { - if mdbx.IsNotFound(err) { - return nil, nil, nil - } - return []byte{}, nil, fmt.Errorf("in SeekBothExact: %w", err) - } - return key, v, nil -} - -func (c *MdbxDupSortCursor) SeekBothRange(key, value []byte) ([]byte, error) { - v, err := c.getBothRange(key, value) - if err != nil { - if mdbx.IsNotFound(err) { - return nil, nil - } - return nil, fmt.Errorf("in SeekBothRange: %w", err) - } - return v, nil -} - -func (c *MdbxDupSortCursor) FirstDup() ([]byte, error) { - v, err := c.firstDup() - if err != nil { - if mdbx.IsNotFound(err) { - return nil, nil - } - return nil, fmt.Errorf("in FirstDup: %w", err) - } - return v, nil -} - -// NextDup - iterate only over duplicates of current key -func (c *MdbxDupSortCursor) NextDup() ([]byte, []byte, error) { - k, v, err := c.nextDup() - if err != nil { - if mdbx.IsNotFound(err) { - return nil, nil, nil - } - return []byte{}, nil, fmt.Errorf("in NextDup: %w", err) - } - return k, v, nil -} - -// NextNoDup - iterate with skipping all duplicates -func (c *MdbxDupSortCursor) NextNoDup() ([]byte, []byte, error) { - k, v, err := c.nextNoDup() - if err != nil { - if mdbx.IsNotFound(err) { - return nil, nil, nil - } - return []byte{}, nil, fmt.Errorf("in NextNoDup: %w", err) - } - return k, v, nil -} - -func (c *MdbxDupSortCursor) PrevDup() ([]byte, []byte, error) { - k, v, err := c.prevDup() - if err != nil { - if mdbx.IsNotFound(err) { - return nil, nil, nil - } - return []byte{}, nil, fmt.Errorf("in PrevDup: %w", err) - } - return k, v, nil -} - -func (c *MdbxDupSortCursor) PrevNoDup() ([]byte, []byte, error) { - k, v, err := c.prevNoDup() - if err != nil { - if mdbx.IsNotFound(err) { - return nil, nil, nil - } - return []byte{}, nil, fmt.Errorf("in PrevNoDup: %w", err) - } - return k, v, nil -} - -func (c *MdbxDupSortCursor) LastDup() ([]byte, error) { - v, err := c.lastDup() - if err != nil { - if mdbx.IsNotFound(err) { - return nil, nil - } - return nil, fmt.Errorf("in LastDup: %w", err) - } - return v, nil -} - -func (c *MdbxDupSortCursor) Append(k []byte, v []byte) error { - if err := c.c.Put(k, v, mdbx.Append|mdbx.AppendDup); err != nil { - return fmt.Errorf("in Append: bucket=%s, %w", c.bucketName, err) - } - return nil -} - -func (c *MdbxDupSortCursor) AppendDup(k []byte, v []byte) error { - if err := c.appendDup(k, v); err != nil { - return fmt.Errorf("in AppendDup: bucket=%s, %w", c.bucketName, err) - } - return nil -} - -func (c *MdbxDupSortCursor) PutNoDupData(key, value []byte) error { - if err := c.putNoDupData(key, value); err != nil { - return fmt.Errorf("in PutNoDupData: %w", err) - } - - return nil -} - -// DeleteCurrentDuplicates - delete all of the data items for the current key. -func (c *MdbxDupSortCursor) DeleteCurrentDuplicates() error { - if err := c.delNoDupData(); err != nil { - return fmt.Errorf("in DeleteCurrentDuplicates: %w", err) - } - return nil -} - -// Count returns the number of duplicates for the current key. See mdb_cursor_count -func (c *MdbxDupSortCursor) CountDuplicates() (uint64, error) { - res, err := c.c.Count() - if err != nil { - return 0, fmt.Errorf("in CountDuplicates: %w", err) - } - return res, nil -} - -func bucketSlice(b kv.TableCfg) []string { - buckets := make([]string, 0, len(b)) - for name := range b { - buckets = append(buckets, name) - } - sort.Slice(buckets, func(i, j int) bool { - return strings.Compare(buckets[i], buckets[j]) < 0 - }) - return buckets -} diff --git a/ethdb/mdbx/kv_migrator_test.go b/ethdb/mdbx/kv_migrator_test.go deleted file mode 100644 index f7af31d45..000000000 --- a/ethdb/mdbx/kv_migrator_test.go +++ /dev/null @@ -1,109 +0,0 @@ -package mdbx_test - -import ( - "context" - "errors" - "testing" - - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/mdbx" - "github.com/ledgerwatch/erigon/ethdb/memdb" - "github.com/ledgerwatch/log/v3" - "github.com/stretchr/testify/require" -) - -func TestBucketCRUD(t *testing.T) { - require := require.New(t) - db := memdb.New() - defer db.Close() - - ctx := context.Background() - tx, err := db.BeginRw(ctx) - require.NoError(err) - defer tx.Rollback() - - normalBucket := kv.ChaindataTables[15] - deprecatedBucket := kv.ChaindataDeprecatedTables[0] - migrator, ok := tx.(kv.BucketMigrator) - if !ok { - return - } - - // check thad buckets have unique DBI's - uniquness := map[kv.DBI]bool{} - castedKv, ok := db.(*mdbx.MdbxKV) - if !ok { - t.Skip() - } - for _, dbi := range castedKv.AllDBI() { - if dbi == mdbx.NonExistingDBI { - continue - } - _, ok := uniquness[dbi] - require.False(ok) - uniquness[dbi] = true - } - - require.True(migrator.ExistsBucket(normalBucket)) - require.True(errors.Is(migrator.DropBucket(normalBucket), kv.ErrAttemptToDeleteNonDeprecatedBucket)) - - require.False(migrator.ExistsBucket(deprecatedBucket)) - require.NoError(migrator.CreateBucket(deprecatedBucket)) - require.True(migrator.ExistsBucket(deprecatedBucket)) - - require.NoError(migrator.DropBucket(deprecatedBucket)) - require.False(migrator.ExistsBucket(deprecatedBucket)) - - require.NoError(migrator.CreateBucket(deprecatedBucket)) - require.True(migrator.ExistsBucket(deprecatedBucket)) - - c, err := tx.RwCursor(deprecatedBucket) - require.NoError(err) - err = c.Put([]byte{1}, []byte{1}) - require.NoError(err) - v, err := tx.GetOne(deprecatedBucket, []byte{1}) - require.NoError(err) - require.Equal([]byte{1}, v) - - buckets, err := migrator.ListBuckets() - require.NoError(err) - require.True(len(buckets) > 10) - - // check thad buckets have unique DBI's - uniquness = map[kv.DBI]bool{} - for _, dbi := range castedKv.AllDBI() { - if dbi == mdbx.NonExistingDBI { - continue - } - _, ok := uniquness[dbi] - require.False(ok) - uniquness[dbi] = true - } -} - -func TestReadOnlyMode(t *testing.T) { - path := t.TempDir() - logger := log.New() - db1 := mdbx.NewMDBX(logger).Path(path).WithTablessCfg(func(defaultBuckets kv.TableCfg) kv.TableCfg { - return kv.TableCfg{ - kv.Headers: kv.TableCfgItem{}, - } - }).MustOpen() - db1.Close() - - db2 := mdbx.NewMDBX(logger).Readonly().Path(path).WithTablessCfg(func(defaultBuckets kv.TableCfg) kv.TableCfg { - return kv.TableCfg{ - kv.Headers: kv.TableCfgItem{}, - } - }).MustOpen() - defer db2.Close() - - tx, err := db2.BeginRo(context.Background()) - require.NoError(t, err) - defer tx.Rollback() - - c, err := tx.Cursor(kv.Headers) - require.NoError(t, err) - _, _, err = c.Seek([]byte("some prefix")) - require.NoError(t, err) -} diff --git a/ethdb/mdbx/util.go b/ethdb/mdbx/util.go deleted file mode 100644 index 9a10577d9..000000000 --- a/ethdb/mdbx/util.go +++ /dev/null @@ -1,31 +0,0 @@ -package mdbx - -import ( - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/log/v3" - mdbxbind "github.com/torquem-ch/mdbx-go/mdbx" -) - -func MustOpen(path string) kv.RwDB { - db, err := Open(path, log.New(), false) - if err != nil { - panic(err) - } - return db -} - -// Open - main method to open database. -func Open(path string, logger log.Logger, readOnly bool) (kv.RwDB, error) { - var db kv.RwDB - var err error - opts := NewMDBX(logger).Path(path) - if readOnly { - opts = opts.Flags(func(flags uint) uint { return flags | mdbxbind.Readonly }) - } - db, err = opts.Open() - - if err != nil { - return nil, err - } - return db, nil -} diff --git a/ethdb/memdb/memory_database.go b/ethdb/memdb/memory_database.go deleted file mode 100644 index 5cdbdea39..000000000 --- a/ethdb/memdb/memory_database.go +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2014 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package memdb - -import ( - "context" - "testing" - - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/mdbx" - "github.com/ledgerwatch/log/v3" -) - -func New() kv.RwDB { - logger := log.New() //TODO: move higher - return mdbx.NewMDBX(logger).InMem().MustOpen() -} - -func NewTestDB(t testing.TB) kv.RwDB { - db := New() - t.Cleanup(db.Close) - return db -} - -func NewTestTx(t testing.TB) (kv.RwDB, kv.RwTx) { - db := New() - t.Cleanup(db.Close) - tx, err := db.BeginRw(context.Background()) //nolint - if err != nil { - t.Fatal(err) - } - switch tt := t.(type) { - case *testing.T: - if tt != nil { - tt.Cleanup(tx.Rollback) - } - } - return db, tx -} diff --git a/ethdb/olddb/database_test.go b/ethdb/olddb/database_test.go index c0e646121..329493657 100644 --- a/ethdb/olddb/database_test.go +++ b/ethdb/olddb/database_test.go @@ -27,10 +27,10 @@ import ( "testing" "time" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/ethdb" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/memdb" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/ethdb/olddb/mutation.go b/ethdb/olddb/mutation.go index cfed4ec6d..128277985 100644 --- a/ethdb/olddb/mutation.go +++ b/ethdb/olddb/mutation.go @@ -11,9 +11,9 @@ import ( "unsafe" "github.com/google/btree" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/ethdb" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/log/v3" ) diff --git a/ethdb/olddb/object_db.go b/ethdb/olddb/object_db.go index d5e170e32..37a5abc01 100644 --- a/ethdb/olddb/object_db.go +++ b/ethdb/olddb/object_db.go @@ -21,9 +21,9 @@ import ( "context" "fmt" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/ethdb" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/log/v3" ) diff --git a/ethdb/olddb/tx_db.go b/ethdb/olddb/tx_db.go index a5bf69e93..b8cb58d6b 100644 --- a/ethdb/olddb/tx_db.go +++ b/ethdb/olddb/tx_db.go @@ -4,8 +4,8 @@ import ( "context" "fmt" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/ethdb" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/log/v3" ) diff --git a/ethdb/prune/storage_mode.go b/ethdb/prune/storage_mode.go index 0bd3e11f4..e251be644 100644 --- a/ethdb/prune/storage_mode.go +++ b/ethdb/prune/storage_mode.go @@ -5,7 +5,7 @@ import ( "fmt" "math" - "github.com/ledgerwatch/erigon/ethdb/kv" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/params" ) diff --git a/ethdb/prune/storage_mode_test.go b/ethdb/prune/storage_mode_test.go index 2bf0c143f..d5fad1331 100644 --- a/ethdb/prune/storage_mode_test.go +++ b/ethdb/prune/storage_mode_test.go @@ -3,8 +3,8 @@ package prune import ( "testing" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/common/math" - "github.com/ledgerwatch/erigon/ethdb/memdb" "github.com/stretchr/testify/assert" ) diff --git a/ethdb/remotedb/kv_remote.go b/ethdb/remotedb/kv_remote.go index b17e59d6d..2fe57348b 100644 --- a/ethdb/remotedb/kv_remote.go +++ b/ethdb/remotedb/kv_remote.go @@ -15,8 +15,8 @@ import ( "github.com/c2h5oh/datasize" "github.com/ledgerwatch/erigon-lib/gointerfaces" "github.com/ledgerwatch/erigon-lib/gointerfaces/remote" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/mdbx" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/mdbx" "github.com/ledgerwatch/log/v3" "google.golang.org/grpc" "google.golang.org/grpc/backoff" diff --git a/ethdb/remotedbserver/server.go b/ethdb/remotedbserver/server.go index c9aa17246..0a43d00ee 100644 --- a/ethdb/remotedbserver/server.go +++ b/ethdb/remotedbserver/server.go @@ -8,8 +8,8 @@ import ( "github.com/ledgerwatch/erigon-lib/gointerfaces/remote" "github.com/ledgerwatch/erigon-lib/gointerfaces/types" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" - "github.com/ledgerwatch/erigon/ethdb/kv" "google.golang.org/protobuf/types/known/emptypb" ) diff --git a/ethdb/snapshotdb/kv_snapshot.go b/ethdb/snapshotdb/kv_snapshot.go index 5e8ee3a43..a66a3e00f 100644 --- a/ethdb/snapshotdb/kv_snapshot.go +++ b/ethdb/snapshotdb/kv_snapshot.go @@ -7,9 +7,9 @@ import ( "fmt" "sync" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/ethdb" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/log/v3" ) diff --git a/ethdb/snapshotdb/kv_snapshot_property_test.go b/ethdb/snapshotdb/kv_snapshot_property_test.go index a05bcc060..6a0723377 100644 --- a/ethdb/snapshotdb/kv_snapshot_property_test.go +++ b/ethdb/snapshotdb/kv_snapshot_property_test.go @@ -4,9 +4,9 @@ import ( "context" "testing" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/common" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/memdb" "github.com/stretchr/testify/require" "pgregory.net/rapid" ) diff --git a/ethdb/snapshotdb/kv_snapshot_test.go b/ethdb/snapshotdb/kv_snapshot_test.go index 28d652c19..ce39dee72 100644 --- a/ethdb/snapshotdb/kv_snapshot_test.go +++ b/ethdb/snapshotdb/kv_snapshot_test.go @@ -7,12 +7,12 @@ import ( "testing" "time" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/mdbx" + kv2 "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/ethdb" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/mdbx" - kv2 "github.com/ledgerwatch/erigon/ethdb/memdb" "github.com/ledgerwatch/log/v3" "github.com/stretchr/testify/require" ) diff --git a/ethdb/walk.go b/ethdb/walk.go index 0117f0673..006b1785f 100644 --- a/ethdb/walk.go +++ b/ethdb/walk.go @@ -19,7 +19,7 @@ package ethdb import ( "bytes" - "github.com/ledgerwatch/erigon/ethdb/kv" + "github.com/ledgerwatch/erigon-lib/kv" ) // splitCursor implements cursor with two keys diff --git a/go.mod b/go.mod index 5e34a875d..6d46a5aed 100644 --- a/go.mod +++ b/go.mod @@ -39,7 +39,7 @@ require ( github.com/json-iterator/go v1.1.11 github.com/julienschmidt/httprouter v1.3.0 github.com/kevinburke/go-bindata v3.21.0+incompatible - github.com/ledgerwatch/erigon-lib v0.0.0-20210709133046-4df3c6b79da0 + github.com/ledgerwatch/erigon-lib v0.0.0-20210729103303-5f20dea6b691 github.com/ledgerwatch/log/v3 v3.2.0 github.com/ledgerwatch/secp256k1 v0.0.0-20210626115225-cd5cd00ed72d github.com/logrusorgru/aurora v2.0.3+incompatible @@ -61,10 +61,10 @@ require ( github.com/wcharczuk/go-chart v2.0.1+incompatible go.uber.org/atomic v1.9.0 golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e - golang.org/x/sync v0.0.0-20201207232520-09787c993a3a + golang.org/x/sync v0.0.0-20210220032951-036812b2e83c golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 - golang.org/x/tools v0.0.0-20210106214847-113979e3529a + golang.org/x/tools v0.1.1 google.golang.org/grpc v1.39.0 google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0 google.golang.org/protobuf v1.27.1 diff --git a/go.sum b/go.sum index 29ba5b799..5c304a529 100644 --- a/go.sum +++ b/go.sum @@ -194,6 +194,7 @@ github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN github.com/aws/aws-sdk-go v1.34.21 h1:M97FXuiJgDHwD4mXhrIZ7RJ4xXV6uZVPvIC2qb+HfYE= github.com/aws/aws-sdk-go v1.34.21/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= +github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benbjohnson/immutable v0.2.0/go.mod h1:uc6OHo6PN2++n98KHLxW8ef4W42ylHiQSENghE1ezxI= github.com/benbjohnson/immutable v0.3.0 h1:TVRhuZx2wG9SZ0LRdqlbs9S5BZ6Y24hJEHTCgWHZEIw= github.com/benbjohnson/immutable v0.3.0/go.mod h1:uc6OHo6PN2++n98KHLxW8ef4W42ylHiQSENghE1ezxI= @@ -633,8 +634,9 @@ github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+ github.com/leanovate/gopter v0.2.8/go.mod h1:gNcbPWNEWRe4lm+bycKqxUYoH5uoVje5SkOJ3uoLer8= github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= -github.com/ledgerwatch/erigon-lib v0.0.0-20210709133046-4df3c6b79da0 h1:ccfmrKMAnxPE3p6z/h1qlvos8wjMrOcB95ThfR37RjQ= -github.com/ledgerwatch/erigon-lib v0.0.0-20210709133046-4df3c6b79da0/go.mod h1:y8vIF0uAO6raqzgKZ5AILLXC+7gfr8nyRLbacmZrZ8Y= +github.com/ledgerwatch/erigon-lib v0.0.0-20210729103303-5f20dea6b691 h1:KARGAw9hAnpzUNLvCwU+ziF8Mu5rz6dXP/aXlIOPRsU= +github.com/ledgerwatch/erigon-lib v0.0.0-20210729103303-5f20dea6b691/go.mod h1:QIgxl5C3lfZX6pBrFFy70CdBZFNJd66gG4HIx0HYLMA= +github.com/ledgerwatch/log/v3 v3.1.2/go.mod h1:J58eOHHrIYHxl7LKkRsb/0YibKwtLfauUryl5SLRGm0= github.com/ledgerwatch/log/v3 v3.2.0 h1:g0lVx5/hDQs+t+l7xzLTXDDlx+7W2JeTcoWQJQXhXJk= github.com/ledgerwatch/log/v3 v3.2.0/go.mod h1:J58eOHHrIYHxl7LKkRsb/0YibKwtLfauUryl5SLRGm0= github.com/ledgerwatch/secp256k1 v0.0.0-20210626115225-cd5cd00ed72d h1:/IKMrJdfRsoYNc36PXqP4xMH3vhW/8IQyBKGQbKZUno= @@ -665,6 +667,7 @@ github.com/marten-seemann/qtls v0.10.0/go.mod h1:UvMd1oaYDACI99/oZUYLzMCkBXQVT0a github.com/marten-seemann/qtls-go1-15 v0.1.0/go.mod h1:GyFwywLKkRt+6mfU99csTEY1joMZz5vmB1WNZH3P81I= github.com/marten-seemann/qtls-go1-15 v0.1.1 h1:LIH6K34bPVttyXnUWixk0bzH6/N07VxbSabxn5A5gZQ= github.com/marten-seemann/qtls-go1-15 v0.1.1/go.mod h1:GyFwywLKkRt+6mfU99csTEY1joMZz5vmB1WNZH3P81I= +github.com/matryer/moq v0.2.3/go.mod h1:9RtPYjTnH1bSBIkpvtHkFN7nbWAnO7oRpdJkEIn6UtE= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.0/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= @@ -994,8 +997,6 @@ github.com/tklauser/numcpus v0.2.2 h1:oyhllyrScuYI6g+h/zUvNXNp1wy7x8qQy3t/piefld github.com/tklauser/numcpus v0.2.2/go.mod h1:x3qojaO3uyYt0i56EW/VUYs7uBvdl2fkfZFu0T9wgjM= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= -github.com/torquem-ch/mdbx-go v0.16.0 h1:x4dTXDvy1w9MxjlAX6J3/bDqIqu4XQDqTR/u2jMnTiA= -github.com/torquem-ch/mdbx-go v0.16.0/go.mod h1:T2fsoJDVppxfAPTLd1svUgH1kpPmeXdPESmroSHcL1E= github.com/torquem-ch/mdbx-go v0.17.0 h1:X8le6dDqWkkJf/T3H2H+Y/kmsmhBD72ds0fP3vchJgg= github.com/torquem-ch/mdbx-go v0.17.0/go.mod h1:T2fsoJDVppxfAPTLd1svUgH1kpPmeXdPESmroSHcL1E= github.com/ttacon/chalk v0.0.0-20160626202418-22c06c80ed31/go.mod h1:onvgF043R+lC5RZ8IT9rBXDaEDnpnw/Cl+HFiw+v/7Q= @@ -1038,6 +1039,7 @@ github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= @@ -1058,15 +1060,19 @@ go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= +go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= +go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= go4.org v0.0.0-20180809161055-417644f6feb5/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE= golang.org/x/build v0.0.0-20190111050920-041ab4dc3f9d/go.mod h1:OWs+y06UdEOHN4y+MfF/py+xQ/tYqIWW03b70/CG9Rw= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -1130,8 +1136,9 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.1.1-0.20191209134235-331c550502dd/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180524181706-dfa909b99c79/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1183,8 +1190,9 @@ golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwY golang.org/x/net v0.0.0-20201201195509-5d6afe98e0b7/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 h1:qWPm9rbaAMKs8Bq/9LRpbMqxWRVUAQwMI9fVrssnTfw= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -1203,8 +1211,9 @@ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201207232520-09787c993a3a h1:DcqTD9SDLc+1P/r1EmRBwnVsrOwW+kk2vWf9n+1sGhs= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1273,6 +1282,8 @@ golang.org/x/sys v0.0.0-20210105210732-16f7687f5001/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1314,6 +1325,7 @@ golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -1343,12 +1355,14 @@ golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200815165600-90abf76919f3/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200928182047-19e03678916f/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= golang.org/x/tools v0.0.0-20201022035929-9cf592e881e9/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201204162204-73cf035baebf/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a h1:CB3a9Nez8M13wwlr/E2YtwoU+qYHKfC+JrDa45RXXoQ= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.1 h1:wGiQel/hW0NnEkJUk8lbzkX2gFJU6PFxf1v5OlCfuOs= +golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1496,8 +1510,9 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ= gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= grpc.go4.org v0.0.0-20170609214715-11d0a25b4919/go.mod h1:77eQGdRu53HpSqPFJFmuJdjuHRquDANNeA4x7B8WQ9o= diff --git a/migrations/call_trace_index.go b/migrations/call_trace_index.go index 1211877c8..8f0654b2f 100644 --- a/migrations/call_trace_index.go +++ b/migrations/call_trace_index.go @@ -4,9 +4,9 @@ import ( "context" "encoding/binary" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/eth/stagedsync" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/prune" "github.com/ledgerwatch/log/v3" ) diff --git a/migrations/db_schema_version.go b/migrations/db_schema_version.go index ea5556339..a4ee3416e 100644 --- a/migrations/db_schema_version.go +++ b/migrations/db_schema_version.go @@ -3,7 +3,7 @@ package migrations import ( "context" - "github.com/ledgerwatch/erigon/ethdb/kv" + "github.com/ledgerwatch/erigon-lib/kv" ) var dbSchemaVersion = Migration{ diff --git a/migrations/fix_sequences.go b/migrations/fix_sequences.go index c1274951b..a890c045b 100644 --- a/migrations/fix_sequences.go +++ b/migrations/fix_sequences.go @@ -3,7 +3,7 @@ package migrations import ( "context" - "github.com/ledgerwatch/erigon/ethdb/kv" + "github.com/ledgerwatch/erigon-lib/kv" ) var oldSequences = map[string]string{ diff --git a/migrations/header_prefix.go b/migrations/header_prefix.go index 73bfe7ac1..240b19a0d 100644 --- a/migrations/header_prefix.go +++ b/migrations/header_prefix.go @@ -5,10 +5,10 @@ import ( "context" "fmt" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/common/etl" - "github.com/ledgerwatch/erigon/ethdb/kv" ) var headerPrefixToSeparateBuckets = Migration{ diff --git a/migrations/header_prefix_test.go b/migrations/header_prefix_test.go index e1b768dc4..c9c06b5af 100644 --- a/migrations/header_prefix_test.go +++ b/migrations/header_prefix_test.go @@ -7,10 +7,10 @@ import ( "strconv" "testing" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/memdb" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/migrations/migrations.go b/migrations/migrations.go index bea501779..356c7b4f1 100644 --- a/migrations/migrations.go +++ b/migrations/migrations.go @@ -7,9 +7,9 @@ import ( "fmt" "path" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/log/v3" "github.com/ugorji/go/codec" ) diff --git a/migrations/migrations_test.go b/migrations/migrations_test.go index e4ff5f1db..e4e951b6a 100644 --- a/migrations/migrations_test.go +++ b/migrations/migrations_test.go @@ -5,9 +5,9 @@ import ( "errors" "testing" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/memdb" "github.com/stretchr/testify/require" ) diff --git a/migrations/prune.go b/migrations/prune.go index 2ea97d68e..9d00eda74 100644 --- a/migrations/prune.go +++ b/migrations/prune.go @@ -3,8 +3,8 @@ package migrations import ( "context" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common/math" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/prune" "github.com/ledgerwatch/erigon/params" ) diff --git a/migrations/receipt_cbor.go b/migrations/receipt_cbor.go index 3b03d361e..598201608 100644 --- a/migrations/receipt_cbor.go +++ b/migrations/receipt_cbor.go @@ -10,12 +10,12 @@ import ( "strconv" "time" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" "github.com/ledgerwatch/erigon/ethdb/cbor" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/log/v3" pkg1_common "github.com/ledgerwatch/erigon/common" diff --git a/migrations/receipt_repair.go b/migrations/receipt_repair.go index ceb7690c4..41cc0684a 100644 --- a/migrations/receipt_repair.go +++ b/migrations/receipt_repair.go @@ -7,6 +7,7 @@ import ( "fmt" "time" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/changeset" "github.com/ledgerwatch/erigon/consensus/ethash" @@ -17,7 +18,6 @@ import ( "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/vm" "github.com/ledgerwatch/erigon/ethdb/cbor" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/log/v3" ) diff --git a/migrations/remove_clique.go b/migrations/remove_clique.go index 13cfe552a..2675c112c 100644 --- a/migrations/remove_clique.go +++ b/migrations/remove_clique.go @@ -3,7 +3,7 @@ package migrations import ( "context" - "github.com/ledgerwatch/erigon/ethdb/kv" + "github.com/ledgerwatch/erigon-lib/kv" ) var removeCliqueBucket = Migration{ diff --git a/node/config.go b/node/config.go index 2127f98ed..133770a34 100644 --- a/node/config.go +++ b/node/config.go @@ -25,7 +25,7 @@ import ( "strings" "sync" - "github.com/ledgerwatch/erigon/ethdb/kv" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/paths" diff --git a/node/node.go b/node/node.go index 8d231b985..6a9aac82a 100644 --- a/node/node.go +++ b/node/node.go @@ -27,9 +27,9 @@ import ( "strings" "sync" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/mdbx" - "github.com/ledgerwatch/erigon/ethdb/memdb" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/mdbx" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/migrations" "github.com/ledgerwatch/erigon/p2p" "github.com/ledgerwatch/erigon/rpc" diff --git a/node/node_test.go b/node/node_test.go index 6af99a310..920e24b18 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -28,8 +28,8 @@ import ( "strings" "testing" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/crypto" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/p2p" "github.com/ledgerwatch/erigon/rpc" "github.com/ledgerwatch/log/v3" diff --git a/p2p/enode/nodedb.go b/p2p/enode/nodedb.go index 3e96d8fce..56f2ea506 100644 --- a/p2p/enode/nodedb.go +++ b/p2p/enode/nodedb.go @@ -29,8 +29,8 @@ import ( "time" "github.com/c2h5oh/datasize" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/mdbx" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/mdbx" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/rlp" diff --git a/tests/block_test_util.go b/tests/block_test_util.go index 13d50534b..1500c3606 100644 --- a/tests/block_test_util.go +++ b/tests/block_test_util.go @@ -26,6 +26,7 @@ import ( "math/big" "testing" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/common/math" @@ -35,7 +36,6 @@ import ( "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/erigon/turbo/stages" diff --git a/tests/state_test.go b/tests/state_test.go index 72c11d24a..949f6d30c 100644 --- a/tests/state_test.go +++ b/tests/state_test.go @@ -25,8 +25,8 @@ import ( "runtime" "testing" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/core/vm" - "github.com/ledgerwatch/erigon/ethdb/memdb" ) func TestState(t *testing.T) { diff --git a/tests/state_test_util.go b/tests/state_test_util.go index 9566e2662..750002e79 100644 --- a/tests/state_test_util.go +++ b/tests/state_test_util.go @@ -25,6 +25,7 @@ import ( "strings" "github.com/holiman/uint256" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/common/math" "github.com/ledgerwatch/erigon/core" @@ -32,7 +33,6 @@ import ( "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/vm" "github.com/ledgerwatch/erigon/crypto" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/erigon/turbo/trie" diff --git a/tests/statedb_insert_chain_transaction_test.go b/tests/statedb_insert_chain_transaction_test.go index c3fe89a88..26ab29f4d 100644 --- a/tests/statedb_insert_chain_transaction_test.go +++ b/tests/statedb_insert_chain_transaction_test.go @@ -8,7 +8,7 @@ import ( "testing" "github.com/holiman/uint256" - "github.com/ledgerwatch/erigon/ethdb/kv" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/turbo/stages" "github.com/stretchr/testify/require" diff --git a/tests/vm_test.go b/tests/vm_test.go index 1be5173f7..9f153ac30 100644 --- a/tests/vm_test.go +++ b/tests/vm_test.go @@ -20,8 +20,8 @@ import ( "context" "testing" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/core/vm" - "github.com/ledgerwatch/erigon/ethdb/memdb" ) func TestVM(t *testing.T) { diff --git a/tests/vm_test_util.go b/tests/vm_test_util.go index b0552e4f8..c4de0d2cf 100644 --- a/tests/vm_test_util.go +++ b/tests/vm_test_util.go @@ -23,7 +23,7 @@ import ( "math/big" "github.com/holiman/uint256" - "github.com/ledgerwatch/erigon/ethdb/kv" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/turbo/trie" "github.com/ledgerwatch/erigon/common" diff --git a/turbo/adapter/block_getter.go b/turbo/adapter/block_getter.go index 95d1f3b18..c92fa56d5 100644 --- a/turbo/adapter/block_getter.go +++ b/turbo/adapter/block_getter.go @@ -1,10 +1,10 @@ package adapter import ( + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/ethdb/kv" ) func NewBlockGetter(tx kv.Tx) *blockGetter { diff --git a/turbo/adapter/chain_context.go b/turbo/adapter/chain_context.go index 6eec051c4..8224efd25 100644 --- a/turbo/adapter/chain_context.go +++ b/turbo/adapter/chain_context.go @@ -3,12 +3,12 @@ package adapter import ( "math/big" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/consensus" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/erigon/rpc" diff --git a/turbo/adapter/reader.go b/turbo/adapter/reader.go index 2add7f03f..44a11a3b8 100644 --- a/turbo/adapter/reader.go +++ b/turbo/adapter/reader.go @@ -3,12 +3,12 @@ package adapter import ( "bytes" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/core/types/accounts" "github.com/ledgerwatch/erigon/crypto" - "github.com/ledgerwatch/erigon/ethdb/kv" ) type StateReader struct { diff --git a/turbo/cli/flags.go b/turbo/cli/flags.go index 40f944c4a..f23c6354c 100644 --- a/turbo/cli/flags.go +++ b/turbo/cli/flags.go @@ -6,10 +6,10 @@ import ( "time" "github.com/c2h5oh/datasize" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/cmd/utils" "github.com/ledgerwatch/erigon/common/etl" "github.com/ledgerwatch/erigon/eth/ethconfig" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/prune" "github.com/ledgerwatch/erigon/node" "github.com/ledgerwatch/erigon/turbo/snapshotsync" diff --git a/turbo/node/node.go b/turbo/node/node.go index 28bb8c17f..933e30f1c 100644 --- a/turbo/node/node.go +++ b/turbo/node/node.go @@ -2,10 +2,10 @@ package node import ( + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/cmd/utils" "github.com/ledgerwatch/erigon/eth" "github.com/ledgerwatch/erigon/eth/ethconfig" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/node" "github.com/ledgerwatch/erigon/params" erigoncli "github.com/ledgerwatch/erigon/turbo/cli" diff --git a/turbo/rpchelper/helper.go b/turbo/rpchelper/helper.go index 9a2fd5cb7..4014c7237 100644 --- a/turbo/rpchelper/helper.go +++ b/turbo/rpchelper/helper.go @@ -3,12 +3,12 @@ package rpchelper import ( "fmt" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/cmd/rpcdaemon/filters" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types/accounts" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/rpc" "github.com/ledgerwatch/erigon/turbo/adapter" ) diff --git a/turbo/snapshotsync/bodies_snapshot.go b/turbo/snapshotsync/bodies_snapshot.go index 85b69214c..9000fd08c 100644 --- a/turbo/snapshotsync/bodies_snapshot.go +++ b/turbo/snapshotsync/bodies_snapshot.go @@ -8,13 +8,13 @@ import ( "fmt" "os" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/mdbx" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/common/etl" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/ethdb" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/erigon/ethdb/snapshotdb" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/log/v3" diff --git a/turbo/snapshotsync/downloader.go b/turbo/snapshotsync/downloader.go index c3047969d..9aedb3bf6 100644 --- a/turbo/snapshotsync/downloader.go +++ b/turbo/snapshotsync/downloader.go @@ -10,7 +10,7 @@ import ( "time" "github.com/anacrolix/torrent/bencode" - "github.com/ledgerwatch/erigon/ethdb/kv" + "github.com/ledgerwatch/erigon-lib/kv" lg "github.com/anacrolix/log" "github.com/anacrolix/torrent" diff --git a/turbo/snapshotsync/headers_snapshot.go b/turbo/snapshotsync/headers_snapshot.go index f06431a5b..18df3b423 100644 --- a/turbo/snapshotsync/headers_snapshot.go +++ b/turbo/snapshotsync/headers_snapshot.go @@ -7,12 +7,12 @@ import ( "os" "time" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/mdbx" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/ethdb" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/erigon/ethdb/snapshotdb" "github.com/ledgerwatch/log/v3" ) diff --git a/turbo/snapshotsync/postprocessing.go b/turbo/snapshotsync/postprocessing.go index dad64c1a7..d6703f8a0 100644 --- a/turbo/snapshotsync/postprocessing.go +++ b/turbo/snapshotsync/postprocessing.go @@ -8,6 +8,7 @@ import ( "math/big" "os" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/common/etl" @@ -15,7 +16,6 @@ import ( "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" "github.com/ledgerwatch/erigon/ethdb" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/log/v3" ) diff --git a/turbo/snapshotsync/postprocessing_test.go b/turbo/snapshotsync/postprocessing_test.go index f47840f0f..222732303 100644 --- a/turbo/snapshotsync/postprocessing_test.go +++ b/turbo/snapshotsync/postprocessing_test.go @@ -6,11 +6,11 @@ import ( "os" "testing" + "github.com/ledgerwatch/erigon-lib/kv" + mdbx2 "github.com/ledgerwatch/erigon-lib/kv/mdbx" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/ethdb/kv" - mdbx2 "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/erigon/ethdb/snapshotdb" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/log/v3" diff --git a/turbo/snapshotsync/server.go b/turbo/snapshotsync/server.go index 9de47fc9a..9aecdd09f 100644 --- a/turbo/snapshotsync/server.go +++ b/turbo/snapshotsync/server.go @@ -7,8 +7,8 @@ import ( "github.com/anacrolix/torrent" "github.com/golang/protobuf/ptypes/empty" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/mdbx" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/mdbx" ) var ( diff --git a/turbo/snapshotsync/snapshot_builder.go b/turbo/snapshotsync/snapshot_builder.go index 621ae4aaf..b63c7464f 100644 --- a/turbo/snapshotsync/snapshot_builder.go +++ b/turbo/snapshotsync/snapshot_builder.go @@ -13,11 +13,11 @@ import ( "time" "github.com/anacrolix/torrent/metainfo" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/common/debug" "github.com/ledgerwatch/erigon/ethdb" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/snapshotdb" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/log/v3" diff --git a/turbo/snapshotsync/snapshot_builder_test.go b/turbo/snapshotsync/snapshot_builder_test.go index e7341587b..9911ef903 100644 --- a/turbo/snapshotsync/snapshot_builder_test.go +++ b/turbo/snapshotsync/snapshot_builder_test.go @@ -17,13 +17,13 @@ import ( "time" "github.com/holiman/uint256" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/mdbx" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/ethdb" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/erigon/ethdb/snapshotdb" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/log/v3" diff --git a/turbo/snapshotsync/wrapdb.go b/turbo/snapshotsync/wrapdb.go index afa4d5001..65d149227 100644 --- a/turbo/snapshotsync/wrapdb.go +++ b/turbo/snapshotsync/wrapdb.go @@ -6,9 +6,9 @@ import ( "errors" "time" + "github.com/ledgerwatch/erigon-lib/kv" + kv2 "github.com/ledgerwatch/erigon-lib/kv/mdbx" "github.com/ledgerwatch/erigon/ethdb" - "github.com/ledgerwatch/erigon/ethdb/kv" - kv2 "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/erigon/ethdb/snapshotdb" "github.com/ledgerwatch/log/v3" ) diff --git a/turbo/stages/blockchain_test.go b/turbo/stages/blockchain_test.go index fc73e3ff1..06bc839e5 100644 --- a/turbo/stages/blockchain_test.go +++ b/turbo/stages/blockchain_test.go @@ -26,8 +26,8 @@ import ( "testing" "github.com/holiman/uint256" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/ethdb/bitmapdb" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/olddb" "github.com/ledgerwatch/erigon/ethdb/prune" "github.com/stretchr/testify/assert" diff --git a/turbo/stages/bodydownload/body_algos.go b/turbo/stages/bodydownload/body_algos.go index 86e44e26e..4c5a55106 100644 --- a/turbo/stages/bodydownload/body_algos.go +++ b/turbo/stages/bodydownload/body_algos.go @@ -7,13 +7,13 @@ import ( "math/big" "github.com/holiman/uint256" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/debug" "github.com/ledgerwatch/erigon/consensus" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/turbo/adapter" "github.com/ledgerwatch/erigon/turbo/stages/headerdownload" "github.com/ledgerwatch/log/v3" diff --git a/turbo/stages/bodydownload/body_test.go b/turbo/stages/bodydownload/body_test.go index 68c15f71c..5522855d3 100644 --- a/turbo/stages/bodydownload/body_test.go +++ b/turbo/stages/bodydownload/body_test.go @@ -3,8 +3,8 @@ package bodydownload import ( "testing" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/consensus/ethash" - "github.com/ledgerwatch/erigon/ethdb/memdb" ) func TestCreateBodyDownload(t *testing.T) { diff --git a/turbo/stages/genesis_test.go b/turbo/stages/genesis_test.go index 7389e72dc..6fd443cf6 100644 --- a/turbo/stages/genesis_test.go +++ b/turbo/stages/genesis_test.go @@ -23,13 +23,13 @@ import ( "testing" "github.com/davecgh/go-spew/spew" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/crypto" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/memdb" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/erigon/turbo/stages" diff --git a/turbo/stages/headerdownload/header_algo_test.go b/turbo/stages/headerdownload/header_algo_test.go index 3a0b09ad2..5f09a3a07 100644 --- a/turbo/stages/headerdownload/header_algo_test.go +++ b/turbo/stages/headerdownload/header_algo_test.go @@ -4,10 +4,10 @@ import ( "math/big" "testing" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/ethdb/memdb" ) func TestInserter1(t *testing.T) { diff --git a/turbo/stages/headerdownload/header_algos.go b/turbo/stages/headerdownload/header_algos.go index 90d483435..aacbc6329 100644 --- a/turbo/stages/headerdownload/header_algos.go +++ b/turbo/stages/headerdownload/header_algos.go @@ -14,13 +14,13 @@ import ( "strings" "time" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/consensus" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/log/v3" diff --git a/turbo/stages/mock_sentry.go b/turbo/stages/mock_sentry.go index 581622bc2..c1b8827a1 100644 --- a/turbo/stages/mock_sentry.go +++ b/turbo/stages/mock_sentry.go @@ -14,6 +14,8 @@ import ( "github.com/ledgerwatch/erigon-lib/gointerfaces" proto_sentry "github.com/ledgerwatch/erigon-lib/gointerfaces/sentry" ptypes "github.com/ledgerwatch/erigon-lib/gointerfaces/types" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/cmd/sentry/download" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/consensus" @@ -28,8 +30,6 @@ import ( "github.com/ledgerwatch/erigon/eth/protocols/eth" "github.com/ledgerwatch/erigon/eth/stagedsync" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/memdb" "github.com/ledgerwatch/erigon/ethdb/privateapi" "github.com/ledgerwatch/erigon/ethdb/prune" "github.com/ledgerwatch/erigon/params" diff --git a/turbo/stages/stageloop.go b/turbo/stages/stageloop.go index ed6606e15..1f8b587e9 100644 --- a/turbo/stages/stageloop.go +++ b/turbo/stages/stageloop.go @@ -8,6 +8,7 @@ import ( "time" "github.com/holiman/uint256" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/cmd/sentry/download" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/debug" @@ -17,7 +18,6 @@ import ( "github.com/ledgerwatch/erigon/eth/ethconfig" "github.com/ledgerwatch/erigon/eth/stagedsync" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/turbo/shards" "github.com/ledgerwatch/erigon/turbo/snapshotsync" "github.com/ledgerwatch/erigon/turbo/stages/headerdownload" diff --git a/turbo/transactions/call.go b/turbo/transactions/call.go index c8cedf604..f58889073 100644 --- a/turbo/transactions/call.go +++ b/turbo/transactions/call.go @@ -7,6 +7,7 @@ import ( "time" "github.com/holiman/uint256" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/cmd/rpcdaemon/filters" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core" @@ -14,7 +15,6 @@ import ( "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/vm" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/internal/ethapi" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rpc" diff --git a/turbo/transactions/tracing.go b/turbo/transactions/tracing.go index 19610805f..a01a6da6f 100644 --- a/turbo/transactions/tracing.go +++ b/turbo/transactions/tracing.go @@ -10,6 +10,7 @@ import ( "github.com/holiman/uint256" jsoniter "github.com/json-iterator/go" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/consensus" "github.com/ledgerwatch/erigon/core" @@ -18,7 +19,6 @@ import ( "github.com/ledgerwatch/erigon/core/vm" "github.com/ledgerwatch/erigon/core/vm/stack" "github.com/ledgerwatch/erigon/eth/tracers" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/params" ) diff --git a/turbo/trie/structural_branch_test.go b/turbo/trie/structural_branch_test.go index da0d22043..efe5a1d4f 100644 --- a/turbo/trie/structural_branch_test.go +++ b/turbo/trie/structural_branch_test.go @@ -21,10 +21,10 @@ import ( "fmt" "testing" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/eth/integrity" - "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/ethdb/memdb" "github.com/ledgerwatch/erigon/turbo/trie" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/turbo/trie/trie_root.go b/turbo/trie/trie_root.go index a2da9c687..e7ec72fd3 100644 --- a/turbo/trie/trie_root.go +++ b/turbo/trie/trie_root.go @@ -7,11 +7,11 @@ import ( "math/bits" "time" + "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/core/types/accounts" - "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/turbo/rlphacks" "github.com/ledgerwatch/log/v3" )