Skip to content
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,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,715 changes: 4,558 additions & 2,157 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.

34 changes: 34 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,20 @@ 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;
// is_static indicates if it's a static precompile (true) or dynamic precompile (false)
bool is_static = 2;
}

// QueryAccountRequest is the request type for the Query/Account RPC method.
message QueryAccountRequest {
option (gogoproto.equal) = false;
Expand Down Expand Up @@ -251,6 +270,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 +297,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 @@ -372,19 +372,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 @@ -404,6 +391,36 @@ func (b *Backend) DoCall(
// this makes sure resources are cleaned up.
defer cancel()

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

evmOverrides, cosmosOverrides, err := rpctypes.ParseOverrides(overrides, isDynamic)
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