Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

rpc, evm: remove tx Receipt #81

Merged
merged 10 commits into from
Jun 8, 2021
Merged
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,16 @@ Ref: https://keepachangelog.com/en/1.0.0/

### State Machine Breaking

* (rpc, evm) [tharsis#81](https://github.com/tharsis/ethermint/pull/81) Remove tx `Receipt` from store and replace it with fields obtained from the Tendermint RPC client.
* (evm) [tharsis#72](https://github.com/tharsis/ethermint/issues/72) Update `AccessList` to use `TransientStore` instead of map.
* (evm) [tharsis#68](https://github.com/tharsis/ethermint/issues/68) Replace block hash storage map to use staking `HistoricalInfo`.

### API Breaking

* (proto, evm) [tharsis#81](https://github.com/tharsis/ethermint/pull/81) gRPC Query and Tx service changes:
* The `TxReceipt`, `TxReceiptsByBlockHeight` endpoints have been removed from the Query service.
* The `ContractAddress`, `Bloom` have been removed from the `MsgEthereumTxResponse` and the
response now contains the ethereum-formatted `Hash` in hex format.
* (eth) [\#845](https://github.com/cosmos/ethermint/pull/845) The `eth` namespace must be included in the list of API's as default to run the rpc server without error.

### Improvements
Expand All @@ -53,6 +58,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Bug Fixes

* (rpc) [tharsis#81](https://github.com/tharsis/ethermint/pull/81) Fix transaction hashing and decoding on `eth_sendTransaction`.
* (rpc) [tharsis#45](https://github.com/tharsis/ethermint/pull/45) Use `EmptyUncleHash` and `EmptyRootHash` for empty ethereum `Header` fields.

## [v0.4.1] - 2021-03-01
Expand Down
68 changes: 3 additions & 65 deletions docs/core/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@
- [QueryStorageResponse](#ethermint.evm.v1alpha1.QueryStorageResponse)
- [QueryTxLogsRequest](#ethermint.evm.v1alpha1.QueryTxLogsRequest)
- [QueryTxLogsResponse](#ethermint.evm.v1alpha1.QueryTxLogsResponse)
- [QueryTxReceiptRequest](#ethermint.evm.v1alpha1.QueryTxReceiptRequest)
- [QueryTxReceiptResponse](#ethermint.evm.v1alpha1.QueryTxReceiptResponse)
- [QueryTxReceiptsByBlockHeightRequest](#ethermint.evm.v1alpha1.QueryTxReceiptsByBlockHeightRequest)
- [QueryTxReceiptsByBlockHeightResponse](#ethermint.evm.v1alpha1.QueryTxReceiptsByBlockHeightResponse)

- [Query](#ethermint.evm.v1alpha1.Query)

Expand Down Expand Up @@ -708,61 +704,6 @@ QueryTxLogs is the response type for the Query/TxLogs RPC method.




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

### QueryTxReceiptRequest
QueryTxReceiptRequest is the request type for the Query/TxReceipt RPC method.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `hash` | [string](#string) | | hash is the ethereum transaction hex hash to query the receipt for. |






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

### QueryTxReceiptResponse
QueryTxReceiptResponse is the response type for the Query/TxReceipt RPC method.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `receipt` | [TxReceipt](#ethermint.evm.v1alpha1.TxReceipt) | | receipt represents the ethereum receipt for the given transaction. |






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

### QueryTxReceiptsByBlockHeightRequest
QueryTxReceiptsByBlockHeightRequest is the request type for the Query/TxReceiptsByBlockHeight RPC method.






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

### QueryTxReceiptsByBlockHeightResponse
QueryTxReceiptsByBlockHeightResponse is the response type for the Query/TxReceiptsByBlockHeight RPC method.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `receipts` | [TxReceipt](#ethermint.evm.v1alpha1.TxReceipt) | repeated | tx receipts list for the block |





<!-- end messages -->

<!-- end enums -->
Expand All @@ -783,8 +724,6 @@ Query defines the gRPC querier service.
| `Storage` | [QueryStorageRequest](#ethermint.evm.v1alpha1.QueryStorageRequest) | [QueryStorageResponse](#ethermint.evm.v1alpha1.QueryStorageResponse) | Storage queries the balance of all coins for a single account. | GET|/ethermint/evm/v1alpha1/storage/{address}/{key}|
| `Code` | [QueryCodeRequest](#ethermint.evm.v1alpha1.QueryCodeRequest) | [QueryCodeResponse](#ethermint.evm.v1alpha1.QueryCodeResponse) | Code queries the balance of all coins for a single account. | GET|/ethermint/evm/v1alpha1/codes/{address}|
| `TxLogs` | [QueryTxLogsRequest](#ethermint.evm.v1alpha1.QueryTxLogsRequest) | [QueryTxLogsResponse](#ethermint.evm.v1alpha1.QueryTxLogsResponse) | TxLogs queries ethereum logs from a transaction. | GET|/ethermint/evm/v1alpha1/tx_logs/{hash}|
| `TxReceipt` | [QueryTxReceiptRequest](#ethermint.evm.v1alpha1.QueryTxReceiptRequest) | [QueryTxReceiptResponse](#ethermint.evm.v1alpha1.QueryTxReceiptResponse) | TxReceipt queries a receipt by a transaction hash. | GET|/ethermint/evm/v1alpha1/tx_receipt/{hash}|
| `TxReceiptsByBlockHeight` | [QueryTxReceiptsByBlockHeightRequest](#ethermint.evm.v1alpha1.QueryTxReceiptsByBlockHeightRequest) | [QueryTxReceiptsByBlockHeightResponse](#ethermint.evm.v1alpha1.QueryTxReceiptsByBlockHeightResponse) | TxReceiptsByBlockHeight queries tx receipts by a block height. | GET|/ethermint/evm/v1alpha1/tx_receipts_block|
| `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|
Expand Down Expand Up @@ -849,10 +788,9 @@ MsgEthereumTxResponse defines the Msg/EthereumTx response type.

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `contract_address` | [string](#string) | | contract_address contains the ethereum address of the created contract (if any). If the state transition is an evm.Call, the contract address will be empty. |
| `bloom` | [bytes](#bytes) | | bloom represents the bloom filter bytes |
| `tx_logs` | [TransactionLogs](#ethermint.evm.v1alpha1.TransactionLogs) | | tx_logs contains the transaction hash and the proto-compatible ethereum logs. |
| `ret` | [bytes](#bytes) | | ret defines the bytes from the execution. |
| `hash` | [string](#string) | | ethereum transaction hash in hex format. This hash differs from the Tendermint sha256 hash of the transaction bytes. See https://github.com/tendermint/tendermint/issues/6539 for reference |
| `logs` | [Log](#ethermint.evm.v1alpha1.Log) | repeated | logs contains the transaction hash and the proto-compatible ethereum logs. |
| `ret` | [bytes](#bytes) | | returned data from evm function (result or data supplied with revert opcode) |
| `reverted` | [bool](#bool) | | reverted flag is set to true when the call has been reverted |


Expand Down
67 changes: 34 additions & 33 deletions ethereum/rpc/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,43 +133,44 @@ func (e *EVMBackend) EthBlockFromTendermint(
fullTx bool,
) (map[string]interface{}, error) {

req := &evmtypes.QueryTxReceiptsByBlockHeightRequest{}
gasUsed := uint64(0)

txReceiptsResp, err := queryClient.TxReceiptsByBlockHeight(types.ContextWithHeight(block.Height), req)
if err != nil {
e.logger.WithError(err).Debugln("TxReceiptsByBlockHeight failed")
}
ethRPCTxs := []interface{}{}

gasUsed := big.NewInt(0)
for i, txBz := range block.Txs {
// TODO: use msg.AsTransaction.Hash() for txHash once hashing is fixed on Tendermint
// https://github.com/tendermint/tendermint/issues/6539
hash := common.BytesToHash(txBz.Hash())

ethRPCTxs := []interface{}{}
tx, gas := types.DecodeTx(e.clientCtx, txBz)

gasUsed += gas

msg, isEthTx := tx.(*evmtypes.MsgEthereumTx)

if fullTx {
if !isEthTx {
// TODO: eventually support Cosmos txs in the block
continue
}

tx, err := types.NewTransactionFromData(
msg.Data,
common.HexToAddress(msg.From),
hash,
common.BytesToHash(block.Hash()),
uint64(block.Height),
uint64(i),
)

ethRPCTxs = append(ethRPCTxs, tx)

if txReceiptsResp != nil {

for _, receipt := range txReceiptsResp.Receipts {
hash := common.HexToHash(receipt.Hash)
if fullTx {
// full txs from receipts
tx, err := types.NewTransactionFromData(
receipt.Data,
common.HexToAddress(receipt.From),
hash,
common.HexToHash(receipt.BlockHash),
receipt.BlockHeight,
receipt.Index,
)

if err != nil {
e.logger.WithError(err).Warningf("NewTransactionFromData for receipt %s failed", hash)
continue
}

ethRPCTxs = append(ethRPCTxs, tx)
gasUsed.Add(gasUsed, new(big.Int).SetUint64(receipt.Result.GasUsed))
} else {
// simply hashes
ethRPCTxs = append(ethRPCTxs, hash)
if err != nil {
e.logger.WithError(err).Debugln("NewTransactionFromData for receipt failed", "hash", hash.Hex)
continue
}
} else {
ethRPCTxs = append(ethRPCTxs, hash)
}
}

Expand All @@ -181,7 +182,7 @@ func (e *EVMBackend) EthBlockFromTendermint(
}

bloom := ethtypes.BytesToBloom(blockBloomResp.Bloom)
formattedBlock := types.FormatBlock(block.Header, block.Size(), ethermint.DefaultRPCGasLimit, gasUsed, ethRPCTxs, bloom)
formattedBlock := types.FormatBlock(block.Header, block.Size(), ethermint.DefaultRPCGasLimit, new(big.Int).SetUint64(gasUsed), ethRPCTxs, bloom)

e.logger.Infoln(formattedBlock)
return formattedBlock, nil
Expand Down
Loading