diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0e29f4229f1e..3239b746066a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -45,7 +45,7 @@ jobs: run: ./.github/scripts/install-rocksdb.sh - name: Saves rocksdb libraries cache if: matrix.go-arch == 'amd64' && steps.install_rocksdb.outcome == 'success' - uses: actions/cache/restore@v4 + uses: actions/cache/save@v4 with: path: | /usr/local/lib/librocksdb.* diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b5ea960668e3..2995ea9a320c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -46,7 +46,7 @@ jobs: run: ./.github/scripts/install-rocksdb.sh - name: Saves rocksdb libraries cache if: steps.install_rocksdb.outcome == 'success' - uses: actions/cache/restore@v4 + uses: actions/cache/save@v4 with: path: | /usr/local/lib/librocksdb.* diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c1df906f9906..563df8a185ef 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -800,13 +800,16 @@ jobs: /usr/local/lib/librocksdb.* /usr/local/include/rocksdb key: ${{ runner.os }}-rocksdb-${{ env.ROCKSDB_VERSION }}-amd64 + - name: Install rocksdb deps + run: | + sudo apt-get update && sudo apt-get install -y libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev - name: Install rocksdb - if: env.GIT_DIFF && steps.cache-rocksdb.outputs.cache-hit != 'true' + if: steps.cache-rocksdb.outputs.cache-hit != 'true' id: install_rocksdb run: ./.github/scripts/install-rocksdb.sh - name: Saves rocksdb libraries cache if: steps.install_rocksdb.outcome == 'success' - uses: actions/cache/restore@v4 + uses: actions/cache/save@v4 with: path: | /usr/local/lib/librocksdb.* @@ -816,7 +819,7 @@ jobs: if: env.GIT_DIFF run: | cd store - go test -mod=readonly -timeout 30m -coverprofile=coverage.out -covermode=atomic -tags='norace ledger test_ledger_mock rocksdb' ./... + go test -ldflags "-r /usr/local/lib" -mod=readonly -timeout 30m -coverprofile=coverage.out -covermode=atomic -tags='norace ledger test_ledger_mock rocksdb' ./... - name: sonarcloud if: ${{ env.GIT_DIFF && !github.event.pull_request.draft && env.SONAR_TOKEN != null }} uses: SonarSource/sonarcloud-github-action@master @@ -855,13 +858,16 @@ jobs: /usr/local/lib/librocksdb.* /usr/local/include/rocksdb key: ${{ runner.os }}-rocksdb-${{ env.ROCKSDB_VERSION }}-amd64 + - name: Install rocksdb deps + run: | + sudo apt-get update && sudo apt-get install -y libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev - name: Install rocksdb if: env.GIT_DIFF && steps.cache-rocksdb.outputs.cache-hit != 'true' id: install_rocksdb run: ./.github/scripts/install-rocksdb.sh - name: Saves rocksdb libraries cache if: steps.install_rocksdb.outcome == 'success' - uses: actions/cache/restore@v4 + uses: actions/cache/save@v4 with: path: | /usr/local/lib/librocksdb.* @@ -871,7 +877,7 @@ jobs: if: env.GIT_DIFF run: | cd store/v2 - go test -mod=readonly -timeout 30m -coverprofile=coverage.out -covermode=atomic -tags='norace ledger test_ledger_mock rocksdb' ./... + go test -ldflags "-r /usr/local/lib" -mod=readonly -timeout 30m -coverprofile=coverage.out -covermode=atomic -tags='norace ledger test_ledger_mock rocksdb' ./... - name: sonarcloud if: ${{ env.GIT_DIFF && !github.event.pull_request.draft && env.SONAR_TOKEN != null }} uses: SonarSource/sonarcloud-github-action@master diff --git a/server/v2/server_test.go b/server/v2/server_test.go index 572d91272062..98b1def5ab9f 100644 --- a/server/v2/server_test.go +++ b/server/v2/server_test.go @@ -17,6 +17,7 @@ import ( serverv2 "cosmossdk.io/server/v2" grpc "cosmossdk.io/server/v2/api/grpc" "cosmossdk.io/server/v2/appmanager" + "cosmossdk.io/server/v2/store" ) type mockInterfaceRegistry struct{} @@ -61,12 +62,17 @@ func TestServer(t *testing.T) { err = grpcServer.Init(&mockApp[transaction.Tx]{}, v, logger) require.NoError(t, err) + storeServer := store.New[transaction.Tx](nil /* nil appCreator as not using CLI commands */) + err = storeServer.Init(&mockApp[transaction.Tx]{}, v, logger) + require.NoError(t, err) + mockServer := &mockServer{name: "mock-server-1", ch: make(chan string, 100)} server := serverv2.NewServer( logger, serverv2.DefaultServerConfig(), grpcServer, + storeServer, mockServer, ) diff --git a/server/v2/testdata/app.toml b/server/v2/testdata/app.toml index 192dc8d67865..3581b2ae7e63 100644 --- a/server/v2/testdata/app.toml +++ b/server/v2/testdata/app.toml @@ -10,6 +10,12 @@ max-recv-msg-size = 10485760 # The default value is math.MaxInt32. max-send-msg-size = 2147483647 +[mock-server-1] +# Mock field +mock_field = 'default' +# Mock field two +mock_field_two = 1 + [server] # minimum-gas-prices defines the price which a validator is willing to accept for processing a transaction. A transaction's fees must meet the minimum of any denomination specified in this config (e.g. 0.25token1;0.0001token2). minimum-gas-prices = '0stake' @@ -19,10 +25,10 @@ minimum-gas-prices = '0stake' app-db-backend = 'goleveldb' [store.options] -# State storage database type. Currently we support: 0 for SQLite, 1 for Pebble -ss-type = 0 -# State commitment database type. Currently we support:0 for iavl, 1 for iavl v2 -sc-type = 0 +# SState storage database type. Currently we support: "sqlite" and "pebble" +ss-type = 'sqlite' +# State commitment database type. Currently we support: "iavl" and "iavl-v2" +sc-type = 'iavl' # Pruning options for state storage [store.options.ss-pruning-option] @@ -43,9 +49,3 @@ interval = 100 cache-size = 100000 # If true, the tree will work like no fast storage and always not upgrade fast storage. skip-fast-storage-upgrade = true - -[mock-server-1] -# Mock field -mock_field = 'default' -# Mock field two -mock_field_two = 1 diff --git a/store/v2/root/factory.go b/store/v2/root/factory.go index b10c87770aee..c906c4bfecf2 100644 --- a/store/v2/root/factory.go +++ b/store/v2/root/factory.go @@ -20,27 +20,28 @@ import ( ) type ( - SSType int - SCType int + SSType string + SCType string ) const ( - SSTypeSQLite SSType = 0 - SSTypePebble SSType = 1 - SSTypeRocks SSType = 2 - SCTypeIavl SCType = 0 - SCTypeIavlV2 SCType = 1 + SSTypeSQLite SSType = "sqlite" + SSTypePebble SSType = "pebble" + SSTypeRocks SSType = "rocksdb" + SCTypeIavl SCType = "iavl" + SCTypeIavlV2 SCType = "iavl-v2" ) // app.toml config options type Options struct { - SSType SSType `mapstructure:"ss-type" toml:"ss-type" comment:"State storage database type. Currently we support: 0 for SQLite, 1 for Pebble"` - SCType SCType `mapstructure:"sc-type" toml:"sc-type" comment:"State commitment database type. Currently we support:0 for iavl, 1 for iavl v2"` + SSType SSType `mapstructure:"ss-type" toml:"ss-type" comment:"SState storage database type. Currently we support: \"sqlite\" and \"pebble\""` + SCType SCType `mapstructure:"sc-type" toml:"sc-type" comment:"State commitment database type. Currently we support: \"iavl\" and \"iavl-v2\""` SSPruningOption *store.PruningOption `mapstructure:"ss-pruning-option" toml:"ss-pruning-option" comment:"Pruning options for state storage"` SCPruningOption *store.PruningOption `mapstructure:"sc-pruning-option" toml:"sc-pruning-option" comment:"Pruning options for state commitment"` IavlConfig *iavl.Config `mapstructure:"iavl-config" toml:"iavl-config"` } +// FactoryOptions are the options for creating a root store. type FactoryOptions struct { Logger log.Logger RootDir string @@ -49,10 +50,11 @@ type FactoryOptions struct { SCRawDB corestore.KVStoreWithBatch } +// DefaultStoreOptions returns the default options for creating a root store. func DefaultStoreOptions() Options { return Options{ - SSType: 0, - SCType: 0, + SSType: SSTypeSQLite, + SCType: SCTypeIavl, SCPruningOption: &store.PruningOption{ KeepRecent: 2, Interval: 100,