diff --git a/scripts/build/build.mk b/scripts/build/build.mk index d5b43eb9e7..1fb1908d75 100644 --- a/scripts/build/build.mk +++ b/scripts/build/build.mk @@ -6,7 +6,7 @@ export COMMIT := $(shell git log -1 --format='%H') LEDGER_ENABLED ?= true BINDIR ?= $(GOPATH)/bin BUILDDIR ?= $(CURDIR)/build -SIMAPP = ./simapp +SIMAPP = simapp MOCKS_DIR = $(CURDIR)/tests/mocks HTTPS_GIT := https://github.com/cosmos/cosmos-sdk.git DOCKER := $(shell which docker) @@ -49,6 +49,10 @@ ifeq (legacy,$(findstring legacy,$(COSMOS_BUILD_OPTIONS))) build_tags += app_v1 endif +ifeq (v2,$(findstring v2,$(COSMOS_BUILD_OPTIONS))) + SIMAPP = simapp/v2 +endif + # DB backend selection ifeq (cleveldb,$(findstring cleveldb,$(COSMOS_BUILD_OPTIONS))) build_tags += gcc @@ -123,7 +127,7 @@ build-linux-arm64: GOOS=linux GOARCH=arm64 LEDGER_ENABLED=false $(MAKE) build $(BUILD_TARGETS): go.sum $(BUILDDIR)/ - cd ${CURRENT_DIR}/simapp && go $@ -mod=readonly $(BUILD_FLAGS) $(BUILD_ARGS) ./... + cd ${CURRENT_DIR}/${SIMAPP} && go $@ -mod=readonly $(BUILD_FLAGS) $(BUILD_ARGS) ./... $(BUILDDIR)/: mkdir -p $(BUILDDIR)/ diff --git a/scripts/simapp-v2-init.sh b/scripts/simapp-v2-init.sh index 6bdb51de7b..a41cfba082 100755 --- a/scripts/simapp-v2-init.sh +++ b/scripts/simapp-v2-init.sh @@ -5,13 +5,11 @@ set -o nounset set -x ROOT=$PWD -SIMAPP_DIR="$ROOT/simapp/v2" SIMD="$ROOT/build/simdv2" CONFIG="${CONFIG:-$HOME/.simappv2/config}" -cd "$SIMAPP_DIR" -go build -o "$ROOT/build/simdv2" simdv2/main.go +COSMOS_BUILD_OPTIONS=v2 make build if [ -d "$($SIMD config home)" ]; then rm -r $($SIMD config home); fi @@ -48,4 +46,4 @@ while ! $SIMD query block --type=height 5; do sleep 1 done -kill -9 "$SIMD_PID" \ No newline at end of file +kill -9 "$SIMD_PID" diff --git a/server/v2/cometbft/abci.go b/server/v2/cometbft/abci.go index a14a793a00..4f3c211294 100644 --- a/server/v2/cometbft/abci.go +++ b/server/v2/cometbft/abci.go @@ -17,6 +17,7 @@ import ( "cosmossdk.io/core/transaction" errorsmod "cosmossdk.io/errors" "cosmossdk.io/server/v2/appmanager" + "cosmossdk.io/server/v2/cometbft/client/grpc/cmtservice" "cosmossdk.io/server/v2/cometbft/handlers" "cosmossdk.io/server/v2/cometbft/mempool" "cosmossdk.io/server/v2/cometbft/types" @@ -26,12 +27,6 @@ import ( consensustypes "cosmossdk.io/x/consensus/types" ) -const ( - QueryPathApp = "app" - QueryPathP2P = "p2p" - QueryPathStore = "store" -) - var _ abci.Application = (*Consensus[transaction.Tx])(nil) type Consensus[T transaction.Tx] struct { @@ -212,13 +207,13 @@ func (c *Consensus[T]) Query(ctx context.Context, req *abciproto.QueryRequest) ( var resp *abciproto.QueryResponse switch path[0] { - case QueryPathApp: + case cmtservice.QueryPathApp: resp, err = c.handlerQueryApp(ctx, path, req) - case QueryPathStore: + case cmtservice.QueryPathStore: resp, err = c.handleQueryStore(path, c.store, req) - case QueryPathP2P: + case cmtservice.QueryPathP2P: resp, err = c.handleQueryP2P(path) default: diff --git a/server/v2/cometbft/client/grpc/cmtservice/service.go b/server/v2/cometbft/client/grpc/cmtservice/service.go index 096889a5a2..426b32aa45 100644 --- a/server/v2/cometbft/client/grpc/cmtservice/service.go +++ b/server/v2/cometbft/client/grpc/cmtservice/service.go @@ -2,7 +2,6 @@ package cmtservice import ( "context" - "fmt" "strings" abci "github.com/cometbft/cometbft/api/cometbft/abci/v1" @@ -27,6 +26,12 @@ var ( _ codectypes.UnpackInterfacesMessage = &GetLatestValidatorSetResponse{} ) +const ( + QueryPathApp = "app" + QueryPathP2P = "p2p" + QueryPathStore = "store" +) + type ( abciQueryFn = func(context.Context, *abci.QueryRequest) (*abci.QueryResponse, error) @@ -265,8 +270,8 @@ func (s queryServer) ABCIQuery(ctx context.Context, req *ABCIQueryRequest) (*ABC if path := SplitABCIQueryPath(req.Path); len(path) > 0 { switch path[0] { - case "app", "store", "p2p", "custom": // TODO: check if we can use the ones from abci.go without having circular deps. - return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("ABCI query path not yet implemented: %s", req.Path)) + case QueryPathApp, QueryPathStore, QueryPathP2P: + // valid path default: // Otherwise, error as to prevent either valid gRPC service requests or