@@ -13,20 +13,20 @@ import (
13
13
"time"
14
14
15
15
"github.com/armon/go-metrics"
16
- "github.com/gogo/protobuf/proto"
17
- abci "github.com/tendermint/tendermint/abci/types"
18
- tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
19
- "google.golang.org/grpc/codes"
20
- grpcstatus "google.golang.org/grpc/status"
21
-
22
16
"github.com/cosmos/cosmos-sdk/codec"
23
17
snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types"
18
+ "github.com/cosmos/cosmos-sdk/store/types"
24
19
"github.com/cosmos/cosmos-sdk/tasks"
25
20
"github.com/cosmos/cosmos-sdk/telemetry"
26
21
sdk "github.com/cosmos/cosmos-sdk/types"
27
22
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
28
23
"github.com/cosmos/cosmos-sdk/types/legacytm"
29
24
"github.com/cosmos/cosmos-sdk/utils"
25
+ "github.com/gogo/protobuf/proto"
26
+ abci "github.com/tendermint/tendermint/abci/types"
27
+ tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
28
+ "google.golang.org/grpc/codes"
29
+ grpcstatus "google.golang.org/grpc/status"
30
30
)
31
31
32
32
// InitChain implements the ABCI interface. It runs the initialization logic
@@ -705,7 +705,8 @@ func checkNegativeHeight(height int64) error {
705
705
// CreateQueryContext creates a new sdk.Context for a query, taking as args
706
706
// the block height and whether the query needs a proof or not.
707
707
func (app * BaseApp ) CreateQueryContext (height int64 , prove bool ) (sdk.Context , error ) {
708
- if err := checkNegativeHeight (height ); err != nil {
708
+ err := checkNegativeHeight (height )
709
+ if err != nil {
709
710
return sdk.Context {}, err
710
711
}
711
712
@@ -731,7 +732,15 @@ func (app *BaseApp) CreateQueryContext(height int64, prove bool) (sdk.Context, e
731
732
)
732
733
}
733
734
734
- cacheMS , err := app .cms .CacheMultiStoreWithVersion (height )
735
+ var cacheMS types.CacheMultiStore
736
+ if height < app .migrationHeight && app .qms != nil {
737
+ cacheMS , err = app .qms .CacheMultiStoreWithVersion (height )
738
+ app .logger .Info ("SeiDB Archive Migration: Serving Query From Iavl" , "height" , height )
739
+ } else {
740
+ cacheMS , err = app .cms .CacheMultiStoreWithVersion (height )
741
+ app .logger .Info ("SeiDB Archive Migration: Serving Query From State Store" , "height" , height )
742
+ }
743
+
735
744
if err != nil {
736
745
return sdk.Context {},
737
746
sdkerrors .Wrapf (
@@ -902,12 +911,26 @@ func handleQueryApp(app *BaseApp, path []string, req abci.RequestQuery) abci.Res
902
911
}
903
912
904
913
func handleQueryStore (app * BaseApp , path []string , req abci.RequestQuery ) abci.ResponseQuery {
905
- // "/store" prefix for store queries
906
- queryable , ok := app .cms .(sdk.Queryable )
907
- if ! ok {
908
- return sdkerrors .QueryResultWithDebug (sdkerrors .Wrap (sdkerrors .ErrUnknownRequest , "multistore doesn't support queries" ), app .trace )
914
+ var (
915
+ queryable sdk.Queryable
916
+ ok bool
917
+ )
918
+ // Check if online migration is enabled for fallback read
919
+ if req .Height < app .migrationHeight && app .qms != nil {
920
+ queryable , ok = app .qms .(sdk.Queryable )
921
+ if ! ok {
922
+ return sdkerrors .QueryResultWithDebug (sdkerrors .Wrap (sdkerrors .ErrUnknownRequest , "multistore doesn't support queries" ), app .trace )
923
+ }
924
+ app .logger .Info ("SeiDB Archive Migration: Serving Query From Iavl" , "height" , req .Height )
925
+ } else {
926
+ queryable , ok = app .cms .(sdk.Queryable )
927
+ if ! ok {
928
+ return sdkerrors .QueryResultWithDebug (sdkerrors .Wrap (sdkerrors .ErrUnknownRequest , "multistore doesn't support queries" ), app .trace )
929
+ }
930
+ app .logger .Info ("SeiDB Archive Migration: Serving Query From State Store" , "height" , req .Height )
909
931
}
910
932
933
+ // "/store" prefix for store queries
911
934
req .Path = "/" + strings .Join (path [1 :], "/" )
912
935
913
936
if req .Height <= 1 && req .Prove {
0 commit comments