diff --git a/CHANGELOG.md b/CHANGELOG.md index d815baf9..63505b77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (evm) [\#621](https://github.com/cosmos/ethermint/issues/621) EVM `GenesisAccount` fields now share the same format as the auth module `Account`. * (evm) [\#618](https://github.com/cosmos/ethermint/issues/618) Add missing EVM `Context` `GetHash` field that retrieves a the header hash from a given block height. * (app) [\#617](https://github.com/cosmos/ethermint/issues/617) Fix genesis export functionality. +* (rpc) [\#574](https://github.com/cosmos/ethermint/issues/574) Fix outdated version from `eth_protocolVersion`. ## [v0.3.1] - 2020-11-24 diff --git a/Makefile b/Makefile index c33bed08..6315c431 100644 --- a/Makefile +++ b/Makefile @@ -123,6 +123,7 @@ all: tools verify install ############################################################################### build: go.sum + ifeq ($(OS), Windows_NT) go build -mod=readonly $(BUILD_FLAGS) -o build/$(ETHERMINT_DAEMON_BINARY).exe ./cmd/$(ETHERMINT_DAEMON_BINARY) go build -mod=readonly $(BUILD_FLAGS) -o build/$(ETHERMINT_CLI_BINARY).exe ./cmd/$(ETHERMINT_CLI_BINARY) @@ -130,7 +131,6 @@ else go build -mod=readonly $(BUILD_FLAGS) -o build/$(ETHERMINT_DAEMON_BINARY) ./cmd/$(ETHERMINT_DAEMON_BINARY) go build -mod=readonly $(BUILD_FLAGS) -o build/$(ETHERMINT_CLI_BINARY) ./cmd/$(ETHERMINT_CLI_BINARY) endif - go build -mod=readonly ./... build-ethermint: go.sum mkdir -p $(BUILDDIR) diff --git a/rpc/namespaces/eth/api.go b/rpc/namespaces/eth/api.go index 050436fa..66104dd1 100644 --- a/rpc/namespaces/eth/api.go +++ b/rpc/namespaces/eth/api.go @@ -17,7 +17,6 @@ import ( rpctypes "github.com/cosmos/ethermint/rpc/types" ethermint "github.com/cosmos/ethermint/types" "github.com/cosmos/ethermint/utils" - "github.com/cosmos/ethermint/version" evmtypes "github.com/cosmos/ethermint/x/evm/types" abci "github.com/tendermint/tendermint/abci/types" @@ -124,7 +123,7 @@ func (api *PublicEthereumAPI) SetKeys(keys []ethsecp256k1.PrivKey) { // ProtocolVersion returns the supported Ethereum protocol version. func (api *PublicEthereumAPI) ProtocolVersion() hexutil.Uint { api.logger.Debug("eth_protocolVersion") - return hexutil.Uint(version.ProtocolVersion) + return hexutil.Uint(ethermint.ProtocolVersion) } // ChainId returns the chain's identifier in hex format diff --git a/rpc/namespaces/web3/api.go b/rpc/namespaces/web3/api.go index 24885692..2034a80a 100644 --- a/rpc/namespaces/web3/api.go +++ b/rpc/namespaces/web3/api.go @@ -1,23 +1,26 @@ package web3 import ( - "github.com/cosmos/ethermint/version" + "fmt" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/crypto" + + "github.com/cosmos/cosmos-sdk/version" ) // PublicWeb3API is the web3_ prefixed set of APIs in the Web3 JSON-RPC spec. type PublicWeb3API struct{} -// New creates an instance of the Web3 API. +// NewAPI creates an instance of the Web3 API. func NewAPI() *PublicWeb3API { return &PublicWeb3API{} } // ClientVersion returns the client version in the Web3 user agent format. func (PublicWeb3API) ClientVersion() string { - return version.ClientVersion() + info := version.NewInfo() + return fmt.Sprintf("%s-%s", info.Name, info.Version) } // Sha3 returns the keccak-256 hash of the passed-in input. diff --git a/tests/rpc_test.go b/tests/rpc_test.go index 81b4997d..1ec813e0 100644 --- a/tests/rpc_test.go +++ b/tests/rpc_test.go @@ -24,7 +24,7 @@ import ( ethtypes "github.com/ethereum/go-ethereum/core/types" rpctypes "github.com/cosmos/ethermint/rpc/types" - "github.com/cosmos/ethermint/version" + ethermint "github.com/cosmos/ethermint/types" ) const ( @@ -258,7 +258,7 @@ func TestEth_GetTransactionLogs(t *testing.T) { } func TestEth_protocolVersion(t *testing.T) { - expectedRes := hexutil.Uint(version.ProtocolVersion) + expectedRes := hexutil.Uint(ethermint.ProtocolVersion) rpcRes := call(t, "eth_protocolVersion", []string{}) diff --git a/types/protocol.go b/types/protocol.go new file mode 100644 index 00000000..580c344c --- /dev/null +++ b/types/protocol.go @@ -0,0 +1,9 @@ +package types + +// Constants to match up protocol versions and messages +const ( + eth65 = 65 + + // ProtocolVersion is the latest supported version of the eth protocol. + ProtocolVersion = eth65 +) diff --git a/version/version.go b/version/version.go deleted file mode 100644 index b969a7fd..00000000 --- a/version/version.go +++ /dev/null @@ -1,26 +0,0 @@ -package version - -import ( - "fmt" - "runtime" -) - -// AppName represents the application name as the 'user agent' on the larger Ethereum network. -const AppName = "Ethermint" - -// Version contains the application semantic version. -// -// TODO: How do we want to version this being that an initial Ethermint has -// been developed? -const Version = "0.0.0" - -// ProtocolVersion is the supported Ethereum protocol version (e.g., Homestead, Olympic, etc.) -const ProtocolVersion = 63 - -// GitCommit contains the git SHA1 short hash set by build flags. -var GitCommit = "" - -// ClientVersion returns the full version string for identification on the larger Ethereum network. -func ClientVersion() string { - return fmt.Sprintf("%s/%s+%s/%s/%s", AppName, Version, GitCommit, runtime.GOOS, runtime.Version()) -} diff --git a/x/evm/keeper/querier.go b/x/evm/keeper/querier.go index df824e9a..783d9828 100644 --- a/x/evm/keeper/querier.go +++ b/x/evm/keeper/querier.go @@ -10,11 +10,9 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/ethermint/utils" - "github.com/cosmos/ethermint/version" "github.com/cosmos/ethermint/x/evm/types" ethcmn "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" abci "github.com/tendermint/tendermint/abci/types" ) @@ -23,8 +21,6 @@ import ( func NewQuerier(keeper Keeper) sdk.Querier { return func(ctx sdk.Context, path []string, _ abci.RequestQuery) ([]byte, error) { switch path[0] { - case types.QueryProtocolVersion: - return queryProtocolVersion(keeper) case types.QueryBalance: return queryBalance(ctx, path, keeper) case types.QueryBlockNumber: @@ -51,17 +47,6 @@ func NewQuerier(keeper Keeper) sdk.Querier { } } -func queryProtocolVersion(keeper Keeper) ([]byte, error) { - vers := version.ProtocolVersion - - bz, err := codec.MarshalJSONIndent(keeper.cdc, hexutil.Uint(vers)) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return bz, nil -} - func queryBalance(ctx sdk.Context, path []string, keeper Keeper) ([]byte, error) { addr := ethcmn.HexToAddress(path[1]) balance := keeper.GetBalance(ctx, addr) diff --git a/x/evm/keeper/querier_test.go b/x/evm/keeper/querier_test.go index c5a70ae8..3b2f6c17 100644 --- a/x/evm/keeper/querier_test.go +++ b/x/evm/keeper/querier_test.go @@ -17,7 +17,6 @@ func (suite *KeeperTestSuite) TestQuerier() { malleate func() expPass bool }{ - {"protocol version", []string{types.QueryProtocolVersion}, func() {}, true}, {"balance", []string{types.QueryBalance, addrHex}, func() { suite.app.EvmKeeper.SetBalance(suite.ctx, suite.address, big.NewInt(5)) }, true}, diff --git a/x/evm/types/querier.go b/x/evm/types/querier.go index 397c37ca..df0dd506 100644 --- a/x/evm/types/querier.go +++ b/x/evm/types/querier.go @@ -8,7 +8,6 @@ import ( // Supported endpoints const ( - QueryProtocolVersion = "protocolVersion" QueryBalance = "balance" QueryBlockNumber = "blockNumber" QueryStorage = "storage" @@ -22,15 +21,6 @@ const ( QueryExportAccount = "exportAccount" ) -// QueryResProtocolVersion is response type for protocol version query -type QueryResProtocolVersion struct { - Version string `json:"version"` -} - -func (q QueryResProtocolVersion) String() string { - return q.Version -} - // QueryResBalance is response type for balance query type QueryResBalance struct { Balance string `json:"balance"`