Skip to content
Open
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 @@ -38,6 +38,7 @@
- [\#658](https://github.com/cosmos/evm/pull/658) Fix race condition between legacypool's RemoveTx and runReorg.
- [\#687](https://github.com/cosmos/evm/pull/687) Avoid blocking node shutdown when evm indexer is enabled, log startup failures instead of using errgroup.
- [\#689](https://github.com/cosmos/evm/pull/689) Align debug addr for hex address.
- [\#713](https://github.com/cosmos/evm/pull/713) Support cosmos state overrides in eth_call for dynamic precompiles.
- [\#668](https://github.com/cosmos/evm/pull/668) Fix panic in legacy mempool when Reset() was called with a skipped header between old and new block.
- [\#723](https://github.com/cosmos/evm/pull/723) Fix TransactionIndex in receipt generation to use actual EthTxIndex instead of loop index.
- [\#729](https://github.com/cosmos/evm/pull/729) Remove non-deterministic state mutation from EVM pre-blocker.
Expand Down
6,714 changes: 4,525 additions & 2,189 deletions api/cosmos/evm/vm/v1/query.pulsar.go

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions api/cosmos/evm/vm/v1/query_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions proto/cosmos/evm/vm/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ service Query {
option (google.api.http).get = "/cosmos/evm/vm/v1/config";
}

// Precompile queries if an address is a precompile (static or dynamic)
rpc Precompile(QueryPrecompileRequest) returns (QueryPrecompileResponse) {
option (google.api.http).get = "/cosmos/evm/vm/v1/precompile/{address}";
}

// GlobalMinGasPrice queries the MinGasPrice
// it's similar to feemarket module's method,
// but makes the conversion to 18 decimals
Expand All @@ -111,6 +116,18 @@ message QueryConfigResponse {
ChainConfig config = 1;
}

// QueryPrecompileRequest defines the request type for querying if an address is a precompile
message QueryPrecompileRequest {
// address is the ethereum hex address to check
string address = 1;
}

// QueryPrecompileResponse returns information about whether the address is a precompile
message QueryPrecompileResponse {
// is_precompile indicates if the address is a precompile contract
bool is_precompile = 1;
}

// QueryAccountRequest is the request type for the Query/Account RPC method.
message QueryAccountRequest {
option (gogoproto.equal) = false;
Expand Down Expand Up @@ -251,6 +268,19 @@ message QueryParamsResponse {
[ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ];
}

// StateEntry defines a single state change operation
message StateEntry {
bytes key = 1;
bytes value = 2;
bool delete = 3;
}

// StoreStateDiff defines a set of state changes for a single store
message StoreStateDiff {
string name = 1;
repeated StateEntry entries = 2 [ (gogoproto.nullable) = false ];
}

// EthCallRequest defines EthCall request
message EthCallRequest {
// args uses the same json format as the json rpc api.
Expand All @@ -265,6 +295,8 @@ message EthCallRequest {
int64 chain_id = 4;
// state overrides encoded as json
bytes overrides = 5;
// state_overrides represents the state overrides before executing the call
repeated StoreStateDiff state_overrides = 6 [ (gogoproto.nullable) = false ];
}

// EstimateGasResponse defines EstimateGas response
Expand Down
43 changes: 30 additions & 13 deletions rpc/backend/call_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,19 +384,6 @@ func (b *Backend) DoCall(
return nil, errors.New("header not found")
}

var bzOverrides []byte
if overrides != nil {
bzOverrides = *overrides
}

req := evmtypes.EthCallRequest{
Args: bz,
GasCap: b.RPCGasCap(),
ProposerAddress: sdk.ConsAddress(header.Header.ProposerAddress),
ChainId: b.EvmChainID.Int64(),
Overrides: bzOverrides,
}

// 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.
Expand All @@ -416,6 +403,36 @@ func (b *Backend) DoCall(
// this makes sure resources are cleaned up.
defer cancel()

var isPrecompile bool
if args.To != nil {
precompileReq := &evmtypes.QueryPrecompileRequest{Address: args.To.Hex()}
if res, err := b.QueryClient.Precompile(ctx, precompileReq); err == nil {
isPrecompile = res.IsPrecompile
}
}

evmOverrides, cosmosOverrides, err := rpctypes.ParseOverrides(overrides, isPrecompile)
if err != nil {
return nil, fmt.Errorf("failed to parse overrides: %w", err)
}

var bzOverrides []byte
if evmOverrides != nil {
bzOverrides, err = json.Marshal(evmOverrides)
if err != nil {
return nil, fmt.Errorf("failed to marshal EVM overrides: %w", err)
}
}

req := evmtypes.EthCallRequest{
Args: bz,
GasCap: b.RPCGasCap(),
ProposerAddress: sdk.ConsAddress(header.Header.ProposerAddress),
ChainId: b.EvmChainID.Int64(),
Overrides: bzOverrides,
StateOverrides: cosmosOverrides,
}

res, err := b.QueryClient.EthCall(ctx, &req)
if err != nil {
return nil, err
Expand Down
Loading
Loading