Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
Problem: grpc query fail on legacy blocks
Browse files Browse the repository at this point in the history
`BaseFee` and `EthCall`.

Solution:
- since grpc query handlers are used for all versions of the blocks, it need to be compatible with legacy formats.

debug

fix basefee fetch

Revert "debug"

This reverts commit 50ebaf697fc06b0d6e26abd8de8f89717e8a219d.

update gomod2nix

Update CHANGELOG.md

debug

fix panic

Revert "debug"

This reverts commit e08af04b0776bd390c42706cc9ec978e00bcb3bb.
  • Loading branch information
yihuang committed Sep 22, 2022
1 parent 6574019 commit bec1a6a
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (rpc) [#1179](https://github.com/evmos/ethermint/pull/1179) Fix gas used in traceTransaction response.
* (rpc) [#1284](https://github.com/evmos/ethermint/pull/1284) Fix internal trace response upon incomplete `eth_sendTransaction` call.
* (rpc) [#1340](https://github.com/evmos/ethermint/pull/1340) Fix error response when `eth_estimateGas` height provided is not found.
* (rpc) [#1354](https://github.com/evmos/ethermint/pull/1354) Fix grpc query failure(`BaseFee` and `EthCall`) on legacy block states.

## [v0.19.2] - 2022-08-29

Expand Down
36 changes: 18 additions & 18 deletions gomod2nix.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ schema = 3
version = "v1.0.53"
hash = "sha256-W6qOvqu8sokMlZrpOF1SWG138H0/BotywKNLlDF8Zug="
[mod."github.com/armon/go-metrics"]
version = "v0.4.0"
hash = "sha256-mB6EFtn8BZ0u9TcJ6QTYw2SNAr4CnTVOMpiRKaoNH7k="
version = "v0.4.1"
hash = "sha256-usxTUHA0QQMdM6sHi2z51nmnEKMbA0qUilxJFpWHlYE="
[mod."github.com/aws/aws-sdk-go"]
version = "v1.40.45"
hash = "sha256-7m4jOfXs356SUZG9tR+z3Yfa/O0CorkSkOXg/AmbqRM="
Expand Down Expand Up @@ -103,8 +103,8 @@ schema = 3
version = "v0.19.1"
hash = "sha256-XrJeCNK0W8j3Qwxya4sr6R05zpI6+oYXFucWguiMiqM="
[mod."github.com/cosmos/ibc-go/v5"]
version = "v5.0.0-rc1"
hash = "sha256-y+9EXodnZnV4fobdY0hQcCmNkNwAKNUl+1iivowhMM8="
version = "v5.0.0-rc2"
hash = "sha256-p4tpb6I6bdXix1sTYivJEygUtM4q+nTIKdSlf6c/LCw="
[mod."github.com/cosmos/ledger-cosmos-go"]
version = "v0.11.1"
hash = "sha256-yli+VvVtZmHo2LPvCY6lYVUfcCDn3sBLDL+a8KIlqDA="
Expand Down Expand Up @@ -272,8 +272,8 @@ schema = 3
version = "v2.0.3"
hash = "sha256-5VsJMQzJSNd4F7yAl3iF/q6JodWOlE4dUvTQ0UGPe+k="
[mod."github.com/holiman/uint256"]
version = "v1.2.0"
hash = "sha256-5CG+o1Q7hpis9Wpp1EFs7nmR1LlDuTK3bf6zsn+JID4="
version = "v1.2.1"
hash = "sha256-1N+MvvzTIegV1UPEGUVyxBZaxczId/Z/BUVcnx7ckHE="
[mod."github.com/huin/goupnp"]
version = "v1.0.3"
hash = "sha256-EMGmTdoQhP2bVbCPX37hes5krqXn6NFexfnKr9E5u8I="
Expand Down Expand Up @@ -344,17 +344,17 @@ schema = 3
version = "v0.0.5"
hash = "sha256-/5i70IkH/qSW5KjGzv8aQNKh9tHoz98tqtL0K2DMFn4="
[mod."github.com/onsi/ginkgo/v2"]
version = "v2.1.6"
hash = "sha256-3g0WFID8e1qGnW8aUTljMrG0hF+dKFgEXj/pds4iRVE="
version = "v2.2.0"
hash = "sha256-+VzAN6pB5DwEqT/KHdhgfPnWBtyIIcHi1J4HQkqCvvU="
[mod."github.com/onsi/gomega"]
version = "v1.20.1"
hash = "sha256-HFjxj1pjHnY/weEqMM8hkhI+me+302fpg9hTZkJBVNw="
version = "v1.20.2"
hash = "sha256-3SGyvhWVlR3tYojnRSDr2SRToontAtw4hbZX+agn/Hs="
[mod."github.com/pelletier/go-toml"]
version = "v1.9.5"
hash = "sha256-RJ9K1BTId0Mled7S66iGgxHkZ5JKEIsrrNaEfM8aImc="
[mod."github.com/pelletier/go-toml/v2"]
version = "v2.0.2"
hash = "sha256-z3JgSi7AKZul1Ta5NwpLVebKw30mGUKc+ijssiAClVU="
version = "v2.0.5"
hash = "sha256-YWdHmuCGliWfiH0tTHuf07AAn/zOJNoq7g+5fvqdnrQ="
[mod."github.com/petermattis/goid"]
version = "v0.0.0-20180202154549-b0b1615b78e5"
hash = "sha256-TCyVuP7rAtrvlterVCapFtbf6UmIf72FXQvkQoDtDj4="
Expand Down Expand Up @@ -419,8 +419,8 @@ schema = 3
version = "v1.0.5"
hash = "sha256-w9LLYzxxP74WHT4ouBspH/iQZXjuAh2WQCHsuvyEjAw="
[mod."github.com/spf13/viper"]
version = "v1.12.0"
hash = "sha256-51kkvy5tGqdyNgQgZWG5WRYnjgCwwGyuIGZsIdPB2n0="
version = "v1.13.0"
hash = "sha256-yHviS3lMo1hB6jwyiU3zpyGtxP6v9AsyZUKiLeCVz+k="
[mod."github.com/status-im/keycard-go"]
version = "v0.0.0-20200402102358-957c09536969"
hash = "sha256-yddXXuu6mEFEO2/K6c1tWymeBKzOcvLQnNsFGRjtfXk="
Expand All @@ -431,8 +431,8 @@ schema = 3
version = "v1.8.0"
hash = "sha256-LDxBAebK+A06y4vbH7cd1sVBOameIY81Xm8/9OPZh7o="
[mod."github.com/subosito/gotenv"]
version = "v1.4.0"
hash = "sha256-H5mdiXO7LZ7ggJMjeiOLGWa1UbweXy/10KwEpFOrPv8="
version = "v1.4.1"
hash = "sha256-aHAUs8Gh+BREUulljWr7vBZQg1BLu/M/8UfNK8CWSn8="
[mod."github.com/syndtr/goleveldb"]
version = "v1.0.1-0.20210819022825-2ae1ddf74ef7"
hash = "sha256-36a4hgVQfwtS2zhylKpQuFhrjdc/Y8pF0dxc26jcZIU="
Expand Down Expand Up @@ -515,8 +515,8 @@ schema = 3
version = "v1.28.1"
hash = "sha256-sTJYgvlv5is7vHNxcuigF2lNASp0QonhUgnrguhfHSU="
[mod."gopkg.in/ini.v1"]
version = "v1.66.6"
hash = "sha256-icGrattKhCLweSJqNhyOs6AavHapLFaOQ9xCA8wID08="
version = "v1.67.0"
hash = "sha256-V10ahGNGT+NLRdKUyRg1dos5RxLBXBk1xutcnquc/+4="
[mod."gopkg.in/natefinch/npipe.v2"]
version = "v2.0.0-20160621034901-c1b8fa8bdcce"
hash = "sha256-ytqeVZqn4kd2uc65HvEjPlpPA2VnBmPfu5DsFlO0o+g="
Expand Down
4 changes: 4 additions & 0 deletions x/evm/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,10 @@ func (k Keeper) getBaseFee(ctx sdk.Context, london bool) *big.Int {
// GetMinGasMultiplier returns the MinGasMultiplier param from the fee market module
func (k Keeper) GetMinGasMultiplier(ctx sdk.Context) sdk.Dec {
fmkParmas := k.feeMarketKeeper.GetParams(ctx)
if fmkParmas.MinGasMultiplier.IsNil() {
// in case we are executing eth_call on a legacy block, returns a zero value.
return sdk.ZeroDec()
}
return fmkParmas.MinGasMultiplier
}

Expand Down
14 changes: 14 additions & 0 deletions x/feemarket/keeper/keeper.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package keeper

import (
"math/big"

"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/tendermint/tendermint/libs/log"

v010 "github.com/evmos/ethermint/x/feemarket/migrations/v010"
"github.com/evmos/ethermint/x/feemarket/types"
)

Expand Down Expand Up @@ -90,3 +93,14 @@ func (k Keeper) AddTransientGasWanted(ctx sdk.Context, gasWanted uint64) (uint64
k.SetTransientBlockGasWanted(ctx, result)
return result, nil
}

// GetBaseFeeV1 get the base fee from v1 version of states.
// return nil if base fee is not enabled
func (k Keeper) GetBaseFeeV1(ctx sdk.Context) *big.Int {
store := ctx.KVStore(k.storeKey)
bz := store.Get(v010.KeyPrefixBaseFeeV1)
if len(bz) == 0 {
return nil
}
return new(big.Int).SetBytes(bz)
}
8 changes: 7 additions & 1 deletion x/feemarket/keeper/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ func (k Keeper) GetBaseFee(ctx sdk.Context) *big.Int {
return nil
}

return params.BaseFee.BigInt()
baseFee := params.BaseFee.BigInt()
if baseFee == nil || baseFee.Sign() == 0 {
// try v1 format
return k.GetBaseFeeV1(ctx)
}

return baseFee
}

// SetBaseFee set's the base fee in the paramSpace
Expand Down

0 comments on commit bec1a6a

Please sign in to comment.