rpc: debug_traceTransaction fails for succesful tx (#720)

* Problem: traceTransaction fails for succesful tx

Solution:
- Change the context to the begining of the block, rather than the end
  of it, while override block context to correct one

pass predecessors

pass current block information to grpc query

* changelog

* fix build

* fix lint

* refactor traceBlock

* update protobuf

* fix Predecessors

* traceBlock refactor

* refactor traceBlock response

* Update proto/ethermint/evm/v1/tx.proto

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>

* Update proto/ethermint/evm/v1/query.proto

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>

* Update proto/ethermint/evm/v1/query.proto

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>

* Update proto/ethermint/evm/v1/query.proto

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>

* Update proto/ethermint/evm/v1/query.proto

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>

* Update proto/ethermint/evm/v1/query.proto

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>

* check tx index is not out of bound

* fix build

* Update rpc/ethereum/namespaces/debug/api.go

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>

* Update rpc/ethereum/namespaces/debug/api.go

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>

* Update rpc/ethereum/namespaces/debug/api.go

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>

* Update rpc/ethereum/namespaces/debug/api.go

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>

* remove prealloc

* add traceBlock test

* Update x/evm/keeper/grpc_query.go

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>

* use bytes2Hex

* fix error message

* add comment

* Apply suggestions from code review

Co-authored-by: Freddy Caceres <freddy.caceres@crypto.com>
Co-authored-by: crypto-facs <84574577+crypto-facs@users.noreply.github.com>
Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
This commit is contained in:
yihuang
2021-11-09 18:38:22 +00:00
committed by GitHub
co-authored by Federico Kunze Küllmer Freddy Caceres crypto-facs
parent 7c7f3f02bb
commit 2a205e561a
15 changed files with 3314 additions and 347 deletions
+35
View File
@@ -6,6 +6,7 @@ import "cosmos/base/query/v1beta1/pagination.proto";
import "google/api/annotations.proto";
import "ethermint/evm/v1/evm.proto";
import "ethermint/evm/v1/tx.proto";
import "google/protobuf/timestamp.proto";
option go_package = "github.com/tharsis/ethermint/x/evm/types";
@@ -65,6 +66,11 @@ service Query {
rpc TraceTx(QueryTraceTxRequest) returns (QueryTraceTxResponse) {
option (google.api.http).get = "/ethermint/evm/v1/trace_tx";
}
// TraceBlock implements the `debug_traceBlockByNumber` and `debug_traceBlockByHash` rpc api
rpc TraceBlock(QueryTraceBlockRequest) returns (QueryTraceBlockResponse) {
option (google.api.http).get = "/ethermint/evm/v1/trace_block";
}
}
// QueryAccountRequest is the request type for the Query/Account RPC method.
@@ -228,6 +234,15 @@ message QueryTraceTxRequest {
uint64 tx_index = 2;
// TraceConfig holds extra parameters to trace functions.
TraceConfig trace_config = 3;
// the predecessor transactions included in the same block
// need to be replayed first to get correct context for tracing.
repeated MsgEthereumTx predecessors = 4;
// block number of requested transaction
int64 block_number = 5;
// block hex hash of requested transaction
string block_hash = 6;
// block time of requested transaction
google.protobuf.Timestamp block_time = 7 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
}
// QueryTraceTxResponse defines TraceTx response
@@ -235,3 +250,23 @@ message QueryTraceTxResponse {
// response serialized in bytes
bytes data = 1;
}
// QueryTraceBlockRequest defines TraceTx request
message QueryTraceBlockRequest {
// txs messages in the block
repeated MsgEthereumTx txs = 1;
// TraceConfig holds extra parameters to trace functions.
TraceConfig trace_config = 3;
// block number
int64 block_number = 5;
// block hex hash
string block_hash = 6;
// block time
google.protobuf.Timestamp block_time = 7 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
}
// QueryTraceBlockResponse defines TraceBlock response
message QueryTraceBlockResponse {
bytes data = 1;
}
+1 -1
View File
@@ -13,7 +13,7 @@ option go_package = "github.com/tharsis/ethermint/x/evm/types";
service Msg {
// EthereumTx defines a method submitting Ethereum transactions.
rpc EthereumTx(MsgEthereumTx) returns (MsgEthereumTxResponse) {
option (google.api.http).get = "/ethermint/evm/v1/ethereum_tx";
option (google.api.http).post = "/ethermint/evm/v1/ethereum_tx";
};
}