Skip to content

Commit

Permalink
evm, rpc: query ChainConfig via gRPC (evmos#239)
Browse files Browse the repository at this point in the history
* evm, rpc: query ChainConfig via gRPC

* c++
  • Loading branch information
fedekunze authored Jul 8, 2021
1 parent 6129607 commit 6238632
Show file tree
Hide file tree
Showing 14 changed files with 864 additions and 128 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Improvements

* (gRPC) [tharsis#239](https://github.com/tharsis/ethermint/pull/239) Query `ChainConfig` via gRPC.
* (rpc) [tharsis#181](https://github.com/tharsis/ethermint/pull/181) Use evm denomination for params on tx fee.
* (deps) [tharsis#165](https://github.com/tharsis/ethermint/pull/165) Bump Cosmos SDK and Tendermint versions to [v0.42.6](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.42.6) and [v0.34.11](https://github.com/tendermint/tendermint/releases/tag/v0.34.11), respectively.
* (evm) [tharsis#66](https://github.com/tharsis/ethermint/issues/66) Support legacy transaction types for signing.
Expand Down
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

254 changes: 254 additions & 0 deletions client/docs/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,113 @@ paths:
type: boolean
tags:
- Query
/ethermint/evm/v1alpha1/chain_config:
get:
summary: ChainConfig queries the chain configuration values of EVM.
operationId: ChainConfig
responses:
'200':
description: A successful response.
schema:
type: object
properties:
config:
description: ChainConfig define the evm chain configuration.
type: object
properties:
homestead_block:
type: string
title: >-
Homestead switch block (< 0 no fork, 0 = already
homestead)
dao_fork_block:
type: string
title: TheDAO hard-fork switch block (< 0 no fork)
dao_fork_support:
type: boolean
title: Whether the nodes supports or opposes the DAO hard-fork
eip150_block:
type: string
title: >-
EIP150 implements the Gas price changes

(https://github.com/ethereum/EIPs/issues/150) EIP150 HF
block (< 0 no fork)
eip150_hash:
type: string
title: >-
EIP150 HF hash (needed for header only clients as only gas
pricing changed)
eip155_block:
type: string
title: EIP155Block HF block
eip158_block:
type: string
title: EIP158 HF block
byzantium_block:
type: string
title: >-
Byzantium switch block (< 0 no fork, 0 = already on
byzantium)
constantinople_block:
type: string
title: >-
Constantinople switch block (< 0 no fork, 0 = already
activated)
petersburg_block:
type: string
title: Petersburg switch block (< 0 same as Constantinople)
istanbul_block:
type: string
title: >-
Istanbul switch block (< 0 no fork, 0 = already on
istanbul)
muir_glacier_block:
type: string
title: >-
Eip-2384 (bomb delay) switch block (< 0 no fork, 0 =
already activated)
berlin_block:
type: string
title: 'Berlin switch block (< 0 = no fork, 0 = already on berlin)'
yolo_v3_block:
type: string
title: 'YOLO v3: Gas repricings'
ewasm_block:
type: string
title: 'EWASM switch block (< 0 no fork, 0 = already activated)'
catalyst_block:
type: string
title: >-
Catalyst switch block (< 0 = no fork, 0 = already on
catalyst)
description: >-
QueryChainConfigResponse defines the response type for querying
x/evm chain configuration.
default:
description: An unexpected error response.
schema:
type: object
properties:
error:
type: string
code:
type: integer
format: int32
message:
type: string
details:
type: array
items:
type: object
properties:
type_url:
type: string
value:
type: string
format: byte
tags:
- Query
'/ethermint/evm/v1alpha1/codes/{address}':
get:
summary: Code queries the balance of all coins for a single account.
Expand Down Expand Up @@ -10500,6 +10607,87 @@ definitions:
repeated Bar results = 1;
PageResponse page = 2;
}
ethermint.evm.v1alpha1.ChainConfig:
type: object
properties:
homestead_block:
type: string
title: 'Homestead switch block (< 0 no fork, 0 = already homestead)'
dao_fork_block:
type: string
title: TheDAO hard-fork switch block (< 0 no fork)
dao_fork_support:
type: boolean
title: Whether the nodes supports or opposes the DAO hard-fork
eip150_block:
type: string
title: >-
EIP150 implements the Gas price changes

(https://github.com/ethereum/EIPs/issues/150) EIP150 HF block (< 0 no
fork)
eip150_hash:
type: string
title: >-
EIP150 HF hash (needed for header only clients as only gas pricing
changed)
eip155_block:
type: string
title: EIP155Block HF block
eip158_block:
type: string
title: EIP158 HF block
byzantium_block:
type: string
title: 'Byzantium switch block (< 0 no fork, 0 = already on byzantium)'
constantinople_block:
type: string
title: 'Constantinople switch block (< 0 no fork, 0 = already activated)'
petersburg_block:
type: string
title: Petersburg switch block (< 0 same as Constantinople)
istanbul_block:
type: string
title: 'Istanbul switch block (< 0 no fork, 0 = already on istanbul)'
muir_glacier_block:
type: string
title: >-
Eip-2384 (bomb delay) switch block (< 0 no fork, 0 = already
activated)
berlin_block:
type: string
title: 'Berlin switch block (< 0 = no fork, 0 = already on berlin)'
yolo_v3_block:
type: string
title: 'YOLO v3: Gas repricings'
ewasm_block:
type: string
title: 'EWASM switch block (< 0 no fork, 0 = already activated)'
catalyst_block:
type: string
title: 'Catalyst switch block (< 0 = no fork, 0 = already on catalyst)'
description: >-
ChainConfig defines the Ethereum ChainConfig parameters using sdk.Int
values

instead of big.Int.


NOTE 1: Since empty/uninitialized Ints (i.e with a nil big.Int value) are

parsed to zero, we need to manually specify that negative Int values will
be

considered as nil. See getBlockValue for reference.


NOTE 2: This type is not a configurable Param since the SDK does not allow

for validation against a previous stored parameter values or the current

block height (retrieved from context). If you want to update the config

values, use an software upgrade procedure.
ethermint.evm.v1alpha1.Log:
type: object
properties:
Expand Down Expand Up @@ -10698,6 +10886,72 @@ definitions:

was set, its value is undefined otherwise
description: QueryTxLogs is the response type for the Query/BlockLogs RPC method.
ethermint.evm.v1alpha1.QueryChainConfigResponse:
type: object
properties:
config:
description: ChainConfig define the evm chain configuration.
type: object
properties:
homestead_block:
type: string
title: 'Homestead switch block (< 0 no fork, 0 = already homestead)'
dao_fork_block:
type: string
title: TheDAO hard-fork switch block (< 0 no fork)
dao_fork_support:
type: boolean
title: Whether the nodes supports or opposes the DAO hard-fork
eip150_block:
type: string
title: >-
EIP150 implements the Gas price changes

(https://github.com/ethereum/EIPs/issues/150) EIP150 HF block (< 0
no fork)
eip150_hash:
type: string
title: >-
EIP150 HF hash (needed for header only clients as only gas pricing
changed)
eip155_block:
type: string
title: EIP155Block HF block
eip158_block:
type: string
title: EIP158 HF block
byzantium_block:
type: string
title: 'Byzantium switch block (< 0 no fork, 0 = already on byzantium)'
constantinople_block:
type: string
title: 'Constantinople switch block (< 0 no fork, 0 = already activated)'
petersburg_block:
type: string
title: Petersburg switch block (< 0 same as Constantinople)
istanbul_block:
type: string
title: 'Istanbul switch block (< 0 no fork, 0 = already on istanbul)'
muir_glacier_block:
type: string
title: >-
Eip-2384 (bomb delay) switch block (< 0 no fork, 0 = already
activated)
berlin_block:
type: string
title: 'Berlin switch block (< 0 = no fork, 0 = already on berlin)'
yolo_v3_block:
type: string
title: 'YOLO v3: Gas repricings'
ewasm_block:
type: string
title: 'EWASM switch block (< 0 no fork, 0 = already activated)'
catalyst_block:
type: string
title: 'Catalyst switch block (< 0 = no fork, 0 = already on catalyst)'
description: >-
QueryChainConfigResponse defines the response type for querying x/evm
chain configuration.
ethermint.evm.v1alpha1.QueryCodeResponse:
type: object
properties:
Expand Down
28 changes: 28 additions & 0 deletions docs/core/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
- [QueryBlockBloomResponse](#ethermint.evm.v1alpha1.QueryBlockBloomResponse)
- [QueryBlockLogsRequest](#ethermint.evm.v1alpha1.QueryBlockLogsRequest)
- [QueryBlockLogsResponse](#ethermint.evm.v1alpha1.QueryBlockLogsResponse)
- [QueryChainConfigRequest](#ethermint.evm.v1alpha1.QueryChainConfigRequest)
- [QueryChainConfigResponse](#ethermint.evm.v1alpha1.QueryChainConfigResponse)
- [QueryCodeRequest](#ethermint.evm.v1alpha1.QueryCodeRequest)
- [QueryCodeResponse](#ethermint.evm.v1alpha1.QueryCodeResponse)
- [QueryCosmosAccountRequest](#ethermint.evm.v1alpha1.QueryCosmosAccountRequest)
Expand Down Expand Up @@ -463,6 +465,31 @@ QueryTxLogs is the response type for the Query/BlockLogs RPC method.



<a name="ethermint.evm.v1alpha1.QueryChainConfigRequest"></a>

### QueryChainConfigRequest
QueryChainConfigRequest defines the request type for querying x/evm chain configuration.






<a name="ethermint.evm.v1alpha1.QueryChainConfigResponse"></a>

### QueryChainConfigResponse
QueryChainConfigResponse defines the response type for querying x/evm chain configuration.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `config` | [ChainConfig](#ethermint.evm.v1alpha1.ChainConfig) | | ChainConfig define the evm chain configuration. |






<a name="ethermint.evm.v1alpha1.QueryCodeRequest"></a>

### QueryCodeRequest
Expand Down Expand Up @@ -699,6 +726,7 @@ Query defines the gRPC querier service.
| `BlockLogs` | [QueryBlockLogsRequest](#ethermint.evm.v1alpha1.QueryBlockLogsRequest) | [QueryBlockLogsResponse](#ethermint.evm.v1alpha1.QueryBlockLogsResponse) | BlockLogs queries all the ethereum logs for a given block hash. | GET|/ethermint/evm/v1alpha1/block_logs/{hash}|
| `BlockBloom` | [QueryBlockBloomRequest](#ethermint.evm.v1alpha1.QueryBlockBloomRequest) | [QueryBlockBloomResponse](#ethermint.evm.v1alpha1.QueryBlockBloomResponse) | BlockBloom queries the block bloom filter bytes at a given height. | GET|/ethermint/evm/v1alpha1/block_bloom|
| `Params` | [QueryParamsRequest](#ethermint.evm.v1alpha1.QueryParamsRequest) | [QueryParamsResponse](#ethermint.evm.v1alpha1.QueryParamsResponse) | Params queries the parameters of x/evm module. | GET|/ethermint/evm/v1alpha1/params|
| `ChainConfig` | [QueryChainConfigRequest](#ethermint.evm.v1alpha1.QueryChainConfigRequest) | [QueryChainConfigResponse](#ethermint.evm.v1alpha1.QueryChainConfigResponse) | ChainConfig queries the chain configuration values of EVM. | GET|/ethermint/evm/v1alpha1/chain_config|
| `StaticCall` | [QueryStaticCallRequest](#ethermint.evm.v1alpha1.QueryStaticCallRequest) | [QueryStaticCallResponse](#ethermint.evm.v1alpha1.QueryStaticCallResponse) | StaticCall queries the static call value of x/evm module. | GET|/ethermint/evm/v1alpha1/static_call|

<!-- end services -->
Expand Down
14 changes: 14 additions & 0 deletions ethereum/rpc/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/params"

ethermint "github.com/tharsis/ethermint/types"
evmtypes "github.com/tharsis/ethermint/x/evm/types"
Expand All @@ -40,6 +41,8 @@ type Backend interface {
// Used by log filter
GetTransactionLogs(txHash common.Hash) ([]*ethtypes.Log, error)
BloomStatus() (uint64, uint64)

ChainConfig() *params.ChainConfig
}

var _ Backend = (*EVMBackend)(nil)
Expand Down Expand Up @@ -359,3 +362,14 @@ func (e *EVMBackend) GetLogsByNumber(blockNum types.BlockNumber) ([][]*ethtypes.
func (e *EVMBackend) BloomStatus() (uint64, uint64) {
return 4096, 0
}

// ChainConfig returns the chain configuration for the chain. This method returns a nil pointer if
// the query fails.
func (e *EVMBackend) ChainConfig() *params.ChainConfig {
res, err := e.queryClient.QueryClient.ChainConfig(e.ctx, &evmtypes.QueryChainConfigRequest{})
if err != nil {
return nil
}

return res.Config.EthereumConfig(e.chainID)
}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ require (
github.com/xlab/closer v0.0.0-20190328110542-03326addb7c2
github.com/xlab/suplog v1.3.0
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e // indirect
google.golang.org/genproto v0.0.0-20210701191553-46259e63a0a9
google.golang.org/grpc v1.38.0
google.golang.org/genproto v0.0.0-20210707164411-8c882eb9abba
google.golang.org/grpc v1.39.0
gopkg.in/yaml.v2 v2.4.0
nhooyr.io/websocket v1.8.7 // indirect
)
Expand Down
Loading

0 comments on commit 6238632

Please sign in to comment.