diff --git a/app/app.go b/app/app.go index 69d23a151..b4cea114d 100644 --- a/app/app.go +++ b/app/app.go @@ -93,6 +93,7 @@ import ( denomtypes "gitlab.com/thorchain/thornode/v3/x/denom/types" evm "github.com/cosmos/evm/encoding/codec" + "github.com/cosmos/evm/ethereum/eip712" ) @@ -689,6 +690,8 @@ func NewChainApp( if err != nil { panic(err) } + app.BaseApp.SetGRPCQueryRouter(app.GRPCQueryRouter()) + // RegisterUpgradeHandlers is used for registering any on-chain upgrades. // Make sure it's called after `app.ModuleManager` and `app.configurator` are set. @@ -1013,7 +1016,7 @@ func RegisterSwaggerAPI(rtr *mux.Router, swaggerEnabled bool) error { // RegisterTxService implements the Application.RegisterTxService method. func (app *THORChainApp) RegisterTxService(clientCtx client.Context) { - authtx.RegisterTxService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.BaseApp.Simulate, app.interfaceRegistry) + authtx.RegisterTxService(app.GRPCQueryRouter(), clientCtx, app.BaseApp.Simulate, app.interfaceRegistry) } // RegisterTendermintService implements the Application.RegisterTendermintService method. @@ -1021,7 +1024,7 @@ func (app *THORChainApp) RegisterTendermintService(clientCtx client.Context) { cmtApp := server.NewCometABCIWrapper(app) cmtservice.RegisterTendermintService( clientCtx, - app.BaseApp.GRPCQueryRouter(), + app.GRPCQueryRouter(), app.interfaceRegistry, cmtApp.Query, ) @@ -1067,6 +1070,10 @@ func BlockedAddresses() map[string]bool { return modAccAddrs } +func (app *THORChainApp) GRPCQueryRouter() *QueryServiceRouter { + return app.queryServiceRouter +} + // MsgServiceRouter returns the MsgServiceRouter. func (app *THORChainApp) MsgServiceRouter() *MsgServiceRouter { return app.msgServiceRouter diff --git a/app/query_service_router.go b/app/query_service_router.go index 4a584d72e..5ab4668e7 100644 --- a/app/query_service_router.go +++ b/app/query_service_router.go @@ -2,6 +2,8 @@ package app import ( "context" + "fmt" + "os" "github.com/cosmos/cosmos-sdk/baseapp" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -60,11 +62,17 @@ func (w *BankQueryWrapper) extractUserAPICall(goCtx context.Context) context.Con } func (w *BankQueryWrapper) Balance(goCtx context.Context, req *banktypes.QueryBalanceRequest) (*banktypes.QueryBalanceResponse, error) { + if os.Getenv("THOR_FORK_DEBUG") == "1" { + fmt.Printf("[rpc-debug] BankQueryWrapper.Balance entry\n") + } ctx := w.extractUserAPICall(goCtx) return w.originalHandler.Balance(ctx, req) } func (w *BankQueryWrapper) AllBalances(goCtx context.Context, req *banktypes.QueryAllBalancesRequest) (*banktypes.QueryAllBalancesResponse, error) { + if os.Getenv("THOR_FORK_DEBUG") == "1" { + fmt.Printf("[rpc-debug] BankQueryWrapper.AllBalances entry\n") + } ctx := w.extractUserAPICall(goCtx) return w.originalHandler.AllBalances(ctx, req) } diff --git a/x/thorchain/forking/store.go b/x/thorchain/forking/store.go index 244bbeae7..e0dd1931e 100644 --- a/x/thorchain/forking/store.go +++ b/x/thorchain/forking/store.go @@ -4,9 +4,11 @@ import ( "context" "encoding/hex" "fmt" - "gitlab.com/thorchain/thornode/v3/constants" + "os" "time" + "gitlab.com/thorchain/thornode/v3/constants" + storetypes "cosmossdk.io/core/store" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -90,6 +92,9 @@ func (f *forkingKVStore) shouldAllowRemoteFetch() bool { } func (f *forkingKVStore) Get(key []byte) ([]byte, error) { + if os.Getenv("THOR_FORK_DEBUG") == "1" && (f.storeKey == "bank" || f.storeKey == "auth" || f.storeKey == "acc") { + fmt.Printf("[rpc-debug][GET] store=%s key=%s allowRemote=%v\n", f.storeKey, hex.EncodeToString(key), f.shouldAllowRemoteFetch()) + } if f.storeKey == "wasm" && len(key) > 0 && key[0] == 0x02 { fmt.Printf("[forking][GET][wasm] ContractInfo key len=%d key=%s\n", len(key), hex.EncodeToString(key)) } @@ -190,13 +195,17 @@ func (f *forkingKVStore) Delete(key []byte) error { } func (f *forkingKVStore) Iterator(start, end []byte) (storetypes.Iterator, error) { + if os.Getenv("THOR_FORK_DEBUG") == "1" && (f.storeKey == "bank" || f.storeKey == "auth" || f.storeKey == "acc") { + s, e := start, end + fmt.Printf("[rpc-debug][ITER] store=%s start=%s end=%s allowRemote=%v\n", f.storeKey, hex.EncodeToString(s), hex.EncodeToString(e), f.shouldAllowRemoteFetch()) + } localIter, err := f.parent.Iterator(start, end) if err != nil { fmt.Printf("[forking][ITER] local-err store=%s err=%v\n", f.storeKey, err) return nil, err } - if !f.shouldAllowRemoteFetch() { + if f.storeKey == "bank" || f.storeKey == "auth" || f.storeKey == "acc" || !f.shouldAllowRemoteFetch() { return localIter, nil } @@ -208,13 +217,17 @@ func (f *forkingKVStore) Iterator(start, end []byte) (storetypes.Iterator, error } func (f *forkingKVStore) ReverseIterator(start, end []byte) (storetypes.Iterator, error) { + if os.Getenv("THOR_FORK_DEBUG") == "1" && (f.storeKey == "bank" || f.storeKey == "auth" || f.storeKey == "acc") { + s, e := start, end + fmt.Printf("[rpc-debug][RITER] store=%s start=%s end=%s allowRemote=%v\n", f.storeKey, hex.EncodeToString(s), hex.EncodeToString(e), f.shouldAllowRemoteFetch()) + } localIter, err := f.parent.ReverseIterator(start, end) if err != nil { fmt.Printf("[forking][RITER] local-err store=%s err=%v\n", f.storeKey, err) return nil, err } - if !f.shouldAllowRemoteFetch() { + if f.storeKey == "bank" || f.storeKey == "auth" || f.storeKey == "acc" || !f.shouldAllowRemoteFetch() { return localIter, nil }