Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

- [\#589](https://github.com/cosmos/evm/pull/589) Remove parallelization blockers via migration from transient to object store, refactoring of gas, indexing, and bloom utilities.
- [\#768](https://github.com/cosmos/evm/pull/768) Added ICS-02 Client Router precompile
- [\#815](https://github.com/cosmos/evm/pull/815) Support for multi gRPC query clients serve with old binary.

### BUG FIXES

Expand Down
1 change: 1 addition & 0 deletions evmd/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ require (
replace (
// use cosmos fork of keyring
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0
github.com/cosmos/cosmos-sdk => github.com/mmsqe/cosmos-sdk v0.46.0-beta2.0.20251117111808-6aaa69ce93f3
github.com/cosmos/evm => ../
// use Cosmos geth fork
// branch: release/1.16
Expand Down
4 changes: 2 additions & 2 deletions evmd/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,6 @@ github.com/cosmos/cosmos-db v1.1.3 h1:7QNT77+vkefostcKkhrzDK9uoIEryzFrU9eoMeaQOP
github.com/cosmos/cosmos-db v1.1.3/go.mod h1:kN+wGsnwUJZYn8Sy5Q2O0vCYA99MJllkKASbs6Unb9U=
github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+RC5W7ZfmxJLA=
github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec=
github.com/cosmos/cosmos-sdk v0.54.0-beta.0 h1:KOyM1CjuriSxMm2CNhceGfEc2LbRWuImKw7L9yp3+SM=
github.com/cosmos/cosmos-sdk v0.54.0-beta.0/go.mod h1:VBGchDTNoLW3xNy5mPNlnDFZiEjgRN/06vwSkXuBQdg=
github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY=
github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw=
github.com/cosmos/go-ethereum v1.16.2-cosmos-1 h1:QIaIS6HIdPSBdTvpFhxswhMLUJgcr4irbd2o9ZKldAI=
Expand Down Expand Up @@ -738,6 +736,8 @@ github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyua
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A=
github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4=
github.com/mmsqe/cosmos-sdk v0.46.0-beta2.0.20251117111808-6aaa69ce93f3 h1:/QA3gFnuWLFihwNzVxvaE7GU9hhMH6PASvaLG5QdHu8=
github.com/mmsqe/cosmos-sdk v0.46.0-beta2.0.20251117111808-6aaa69ce93f3/go.mod h1:VBGchDTNoLW3xNy5mPNlnDFZiEjgRN/06vwSkXuBQdg=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
Expand Down
1 change: 0 additions & 1 deletion evmd/tests/network/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ func startInProcess(cfg Config, val *Validator) error {
if val.Ctx == nil || val.Ctx.Viper == nil {
return fmt.Errorf("validator %s context is nil", val.Moniker)
}

val.jsonrpc, err = server.StartJSONRPC(
ctx,
val.Ctx,
Expand Down
6 changes: 1 addition & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ require (
github.com/bytedance/sonic/loader v0.3.0 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/chigopher/pathlib v0.19.1 // indirect
github.com/chzyer/readline v1.5.1 // indirect
github.com/cloudwego/base64x v0.1.5 // indirect
github.com/cncf/xds/go v0.0.0-20250501225837-2ac532fd4443 // indirect
Expand Down Expand Up @@ -184,12 +183,10 @@ require (
github.com/hdevalence/ed25519consensus v0.2.0 // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
github.com/huandu/skiplist v1.2.1 // indirect
github.com/huandu/xstrings v1.4.0 // indirect
github.com/huin/goupnp v1.3.0 // indirect
github.com/iancoleman/strcase v0.3.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
github.com/jinzhu/copier v0.4.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/klauspost/compress v1.18.0 // indirect
github.com/klauspost/cpuid/v2 v2.2.10 // indirect
Expand Down Expand Up @@ -246,7 +243,6 @@ require (
github.com/tklauser/numcpus v0.10.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ulikunitz/xz v0.5.15 // indirect
github.com/vektra/mockery/v2 v2.53.5 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
github.com/zeebo/errs v1.4.0 // indirect
github.com/zondax/golem v0.27.0 // indirect
Expand All @@ -268,7 +264,6 @@ require (
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/arch v0.21.0 // indirect
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 // indirect
golang.org/x/mod v0.28.0 // indirect
golang.org/x/oauth2 v0.31.0 // indirect
golang.org/x/sys v0.37.0 // indirect
golang.org/x/term v0.36.0 // indirect
Expand All @@ -288,6 +283,7 @@ require (
replace (
// use cosmos fork of keyring
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0
github.com/cosmos/cosmos-sdk => github.com/mmsqe/cosmos-sdk v0.46.0-beta2.0.20251117111808-6aaa69ce93f3
// use Cosmos geth fork
// branch: release/1.16
github.com/ethereum/go-ethereum => github.com/cosmos/go-ethereum v1.16.2-cosmos-1
Expand Down
14 changes: 2 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,6 @@ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UF
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
github.com/chigopher/pathlib v0.19.1 h1:RoLlUJc0CqBGwq239cilyhxPNLXTK+HXoASGyGznx5A=
github.com/chigopher/pathlib v0.19.1/go.mod h1:tzC1dZLW8o33UQpWkNkhvPwL5n4yyFRFm/jL1YGWFvY=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/logex v1.2.1 h1:XHDu3E6q+gdHgsdTPH6ImJMIp436vR6MPtH8gP05QzM=
github.com/chzyer/logex v1.2.1/go.mod h1:JLbx6lG2kDbNRFnfkgvh4eRJRPX1QCoOIWomwysCBrQ=
Expand Down Expand Up @@ -269,8 +267,6 @@ github.com/cosmos/cosmos-db v1.1.3 h1:7QNT77+vkefostcKkhrzDK9uoIEryzFrU9eoMeaQOP
github.com/cosmos/cosmos-db v1.1.3/go.mod h1:kN+wGsnwUJZYn8Sy5Q2O0vCYA99MJllkKASbs6Unb9U=
github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+RC5W7ZfmxJLA=
github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec=
github.com/cosmos/cosmos-sdk v0.54.0-beta.0 h1:KOyM1CjuriSxMm2CNhceGfEc2LbRWuImKw7L9yp3+SM=
github.com/cosmos/cosmos-sdk v0.54.0-beta.0/go.mod h1:VBGchDTNoLW3xNy5mPNlnDFZiEjgRN/06vwSkXuBQdg=
github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY=
github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw=
github.com/cosmos/go-ethereum v1.16.2-cosmos-1 h1:QIaIS6HIdPSBdTvpFhxswhMLUJgcr4irbd2o9ZKldAI=
Expand Down Expand Up @@ -602,8 +598,6 @@ github.com/huandu/go-assert v1.1.5 h1:fjemmA7sSfYHJD7CUqs9qTwwfdNAx7/j2/ZlHXzNB3
github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0JrPVhn/06U=
github.com/huandu/skiplist v1.2.1 h1:dTi93MgjwErA/8idWTzIw4Y1kZsMWx35fmI2c8Rij7w=
github.com/huandu/skiplist v1.2.1/go.mod h1:7v3iFjLcSAzO4fN5B8dvebvo/qsfumiLiDXMrPiHF9w=
github.com/huandu/xstrings v1.4.0 h1:D17IlohoQq4UcpqD7fDk80P7l+lwAmlFaBHgOipl2FU=
github.com/huandu/xstrings v1.4.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc=
github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8=
Expand All @@ -627,8 +621,6 @@ github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jhump/protoreflect v1.17.0 h1:qOEr613fac2lOuTgWN4tPAtLL7fUSbuJL5X5XumQh94=
github.com/jhump/protoreflect v1.17.0/go.mod h1:h9+vUUL38jiBzck8ck+6G/aeMX8Z4QUY/NiJPwPNi+8=
github.com/jinzhu/copier v0.4.0 h1:w3ciUoD19shMCRargcpm0cm91ytaBhDvuRpz1ODO/U8=
github.com/jinzhu/copier v0.4.0/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U=
github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ=
Expand Down Expand Up @@ -725,6 +717,8 @@ github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyua
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A=
github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4=
github.com/mmsqe/cosmos-sdk v0.46.0-beta2.0.20251117111808-6aaa69ce93f3 h1:/QA3gFnuWLFihwNzVxvaE7GU9hhMH6PASvaLG5QdHu8=
github.com/mmsqe/cosmos-sdk v0.46.0-beta2.0.20251117111808-6aaa69ce93f3/go.mod h1:VBGchDTNoLW3xNy5mPNlnDFZiEjgRN/06vwSkXuBQdg=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
Expand Down Expand Up @@ -985,8 +979,6 @@ github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY=
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/urfave/cli/v2 v2.27.5 h1:WoHEJLdsXr6dDWoJgMq/CboDmyY/8HMMH1fTECbih+w=
github.com/urfave/cli/v2 v2.27.5/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ=
github.com/vektra/mockery/v2 v2.53.5 h1:iktAY68pNiMvLoHxKqlSNSv/1py0QF/17UGrrAMYDI8=
github.com/vektra/mockery/v2 v2.53.5/go.mod h1:hIFFb3CvzPdDJJiU7J4zLRblUMv7OuezWsHPmswriwo=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4=
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
Expand Down Expand Up @@ -1097,8 +1089,6 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.28.0 h1:gQBtGhjxykdjY9YhZpSlZIsbnaE2+PgjfLWUQTnoZ1U=
golang.org/x/mod v0.28.0/go.mod h1:yfB/L0NOf/kmEbXjzCPOx1iK1fRutOydrCMsqRhEBxI=
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=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down
16 changes: 10 additions & 6 deletions rpc/backend/account_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ func (b *Backend) GetCode(address common.Address, blockNrOrHash rpctypes.BlockNu
Address: address.String(),
}

res, err := b.QueryClient.Code(rpctypes.ContextWithHeight(blockNum.Int64()), req)
height := blockNum.Int64()
res, err := b.getGrpcClient(height).Code(rpctypes.ContextWithHeight(height), req)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -76,9 +77,10 @@ func (b *Backend) GetProof(address common.Address, storageKeys []string, blockNr
// query storage proofs
storageProofs := make([]rpctypes.StorageResult, len(storageKeys))

queryClient := b.getGrpcClient(height)
for i, key := range storageKeys {
hexKey := common.HexToHash(key)
valueBz, proof, err := b.QueryClient.GetProof(clientCtx, evmtypes.StoreKey, evmtypes.StateKey(address, hexKey.Bytes()))
valueBz, proof, err := queryClient.GetProof(clientCtx, evmtypes.StoreKey, evmtypes.StateKey(address, hexKey.Bytes()))
if err != nil {
return nil, err
}
Expand All @@ -95,14 +97,14 @@ func (b *Backend) GetProof(address common.Address, storageKeys []string, blockNr
Address: address.String(),
}

res, err := b.QueryClient.Account(ctx, req)
res, err := queryClient.Account(ctx, req)
if err != nil {
return nil, err
}

// query account proofs
accountKey := bytes.HexBytes(append(authtypes.AddressStoreKeyPrefix, address.Bytes()...))
_, proof, err := b.QueryClient.GetProof(clientCtx, authtypes.StoreKey, accountKey)
_, proof, err := queryClient.GetProof(clientCtx, authtypes.StoreKey, accountKey)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -135,7 +137,8 @@ func (b *Backend) GetStorageAt(address common.Address, key string, blockNrOrHash
Key: key,
}

res, err := b.QueryClient.Storage(rpctypes.ContextWithHeight(blockNum.Int64()), req)
height := blockNum.Int64()
res, err := b.getGrpcClient(height).Storage(rpctypes.ContextWithHeight(height), req)
if err != nil {
return nil, err
}
Expand All @@ -160,7 +163,8 @@ func (b *Backend) GetBalance(address common.Address, blockNrOrHash rpctypes.Bloc
return nil, err
}

res, err := b.QueryClient.Balance(rpctypes.ContextWithHeight(blockNum.Int64()), req)
height := blockNum.Int64()
res, err := b.getGrpcClient(height).Balance(rpctypes.ContextWithHeight(height), req)
if err != nil {
return nil, err
}
Expand Down
1 change: 1 addition & 0 deletions rpc/backend/blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
func (b *Backend) BlockNumber() (hexutil.Uint64, error) {
// do any grpc query, ignore the response and use the returned block height
var header metadata.MD
// use latest queryClient to get block height
_, err := b.QueryClient.Params(b.Ctx, &evmtypes.QueryParamsRequest{}, grpc.Header(&header))
if err != nil {
return hexutil.Uint64(0), err
Expand Down
5 changes: 3 additions & 2 deletions rpc/backend/call_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,8 @@ func (b *Backend) EstimateGas(
// From ContextWithHeight: if the provided height is 0,
// it will return an empty context and the gRPC query will use
// the latest block height for querying.
res, err := b.QueryClient.EstimateGas(rpctypes.ContextWithHeight(blockNr.Int64()), &req)
height := blockNr.Int64()
res, err := b.getGrpcClient(height).EstimateGas(rpctypes.ContextWithHeight(height), &req)
if err != nil {
return 0, err
}
Expand Down Expand Up @@ -416,7 +417,7 @@ func (b *Backend) DoCall(
// this makes sure resources are cleaned up.
defer cancel()

res, err := b.QueryClient.EthCall(ctx, &req)
res, err := b.getGrpcClient(blockNr.Int64()).EthCall(ctx, &req)
if err != nil {
return nil, err
}
Expand Down
6 changes: 5 additions & 1 deletion rpc/backend/chain_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func (b *Backend) ChainConfig() *params.ChainConfig {

// GlobalMinGasPrice returns MinGasPrice param from FeeMarket
func (b *Backend) GlobalMinGasPrice() (*big.Int, error) {
// use latest queryClient to get GlobalMinGasPrice
res, err := b.QueryClient.GlobalMinGasPrice(b.Ctx, &evmtypes.QueryGlobalMinGasPriceRequest{})
if err != nil {
return nil, err
Expand All @@ -65,7 +66,8 @@ func (b *Backend) GlobalMinGasPrice() (*big.Int, error) {
// return nil.
func (b *Backend) BaseFee(blockRes *cmtrpctypes.ResultBlockResults) (*big.Int, error) {
// return BaseFee if London hard fork is activated and feemarket is enabled
res, err := b.QueryClient.BaseFee(rpctypes.ContextWithHeight(blockRes.Height), &evmtypes.QueryBaseFeeRequest{})
height := blockRes.Height
res, err := b.getGrpcClient(height).BaseFee(rpctypes.ContextWithHeight(height), &evmtypes.QueryBaseFeeRequest{})
if err != nil || res.BaseFee == nil {
// we can't tell if it's london HF not enabled or the state is pruned,
// in either case, we'll fallback to parsing from begin blocker event,
Expand Down Expand Up @@ -138,6 +140,7 @@ func (b *Backend) GetCoinbase() (sdk.AccAddress, error) {
ConsAddress: sdk.ConsAddress(status.ValidatorInfo.Address).String(),
}

// use latest queryClient to get coinbase
res, err := b.QueryClient.ValidatorAccount(b.Ctx, req)
if err != nil {
return nil, err
Expand Down Expand Up @@ -326,6 +329,7 @@ func (b *Backend) SuggestGasTipCap(baseFee *big.Int) (*big.Int, error) {
return big.NewInt(0), nil
}

// use latest queryClient to get params
params, err := b.QueryClient.FeeMarket.Params(b.Ctx, &feemarkettypes.QueryParamsRequest{})
if err != nil {
return nil, err
Expand Down
1 change: 1 addition & 0 deletions rpc/backend/comet_to_eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ func (b *Backend) MinerFromCometBlock(
var validatorAccAddr sdk.AccAddress

ctx := rpctypes.ContextWithHeight(cmtBlock.Height)
// use latest queryClient to get miner
res, err := b.QueryClient.ValidatorAccount(ctx, req)
if err != nil {
b.Logger.Debug(
Expand Down
6 changes: 3 additions & 3 deletions rpc/backend/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (b *Backend) TraceTransaction(hash common.Hash, config *rpctypes.TraceConfi
// So here we set the minimum requested height to 1.
contextHeight = 1
}
traceResult, err := b.QueryClient.TraceTx(rpctypes.ContextWithHeight(contextHeight), &traceTxRequest)
traceResult, err := b.getGrpcClient(contextHeight).TraceTx(rpctypes.ContextWithHeight(contextHeight), &traceTxRequest)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -218,7 +218,7 @@ func (b *Backend) TraceBlock(height rpctypes.BlockNumber,
BlockMaxGas: cp.ConsensusParams.Block.MaxGas,
}

res, err := b.QueryClient.TraceBlock(ctxWithHeight, traceBlockRequest)
res, err := b.getGrpcClient(int64(contextHeight)).TraceBlock(ctxWithHeight, traceBlockRequest)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -281,7 +281,7 @@ func (b *Backend) TraceCall(

// Use the block height as context for the query
ctxWithHeight := rpctypes.ContextWithHeight(contextHeight)
traceResult, err := b.QueryClient.TraceCall(ctxWithHeight, &traceCallRequest)
traceResult, err := b.getGrpcClient(contextHeight).TraceCall(ctxWithHeight, &traceCallRequest)
if err != nil {
return nil, err
}
Expand Down
16 changes: 16 additions & 0 deletions rpc/backend/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"cosmossdk.io/log"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/tx"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
)

Expand Down Expand Up @@ -177,6 +178,7 @@ func (b *Backend) ProcessBlock(

if cfg.IsLondon(big.NewInt(blockHeight + 1)) {
ctx := types.ContextWithHeight(blockHeight)
// use latest queryClient to get params
params, err := b.QueryClient.FeeMarket.Params(ctx, &feemarkettypes.QueryParamsRequest{})
if err != nil {
return err
Expand Down Expand Up @@ -337,3 +339,17 @@ func GetHexProofs(proof *crypto.ProofOps) []string {
}
return proofs
}

// getGrpcClient returns a query client for the given height using SDK's connection routing
func (b *Backend) getGrpcClient(height int64) *types.QueryClient {
// Use SDK's GRPCConnProvider to get the appropriate connection
grpcConn := b.ClientCtx.GetGRPCConn(height)
if grpcConn == nil {
return b.QueryClient
}
return &types.QueryClient{
ServiceClient: tx.NewServiceClient(grpcConn),
QueryClient: evmtypes.NewQueryClient(grpcConn),
FeeMarket: feemarkettypes.NewQueryClient(grpcConn),
}
}
5 changes: 5 additions & 0 deletions server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,11 @@ func GetConfig(v *viper.Viper) (Config, error) {
if err := v.Unmarshal(conf); err != nil {
return Config{}, fmt.Errorf("error extracting app config: %w", err)
}
sdkConf, err := config.GetConfig(v)
if err != nil {
return Config{}, err
}
conf.GRPC.BackupGRPCBlockAddressBlockRange = sdkConf.GRPC.BackupGRPCBlockAddressBlockRange
return *conf, nil
}

Expand Down
13 changes: 13 additions & 0 deletions server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,19 @@ func startGrpcServer(
clientCtx = clientCtx.WithGRPCClient(grpcClient)
svrCtx.Logger.Debug("gRPC client assigned to client context", "address", config.Address)

// Setup backup gRPC connections if configured
clientCtx, err = server.SetupBackupGRPCConnections(
clientCtx,
grpcClient,
config.BackupGRPCBlockAddressBlockRange,
maxRecvMsgSize,
maxSendMsgSize,
svrCtx.Logger,
)
if err != nil {
return nil, clientCtx, err
}

grpcSrv, err := servergrpc.NewGRPCServer(clientCtx, app, config)
if err != nil {
return nil, clientCtx, err
Expand Down
Loading