evm: remove tx logs and block bloom from chain state (#556)

Closes #452

fix unit tests

changelog and fix lint

fix unit test

Update ethereum/rpc/backend/backend.go

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

Update ethereum/rpc/backend/utils.go

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

changelog

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
This commit is contained in:
yihuang 2021-09-15 17:45:03 +08:00 committed by GitHub
parent 3f1eeb30b6
commit 116de54617
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 1972 additions and 3406 deletions

View File

@ -40,6 +40,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### State Machine Breaking
* (app) [tharsis#476](https://github.com/tharsis/ethermint/pull/476) Update Bech32 HRP to `ethm`.
* (evm) [tharsis#556](https://github.com/tharsis/ethermint/pull/556) Remove tx logs and block bloom from chain state
### API Breaking

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -40,10 +40,6 @@
- [QueryAccountResponse](#ethermint.evm.v1.QueryAccountResponse)
- [QueryBalanceRequest](#ethermint.evm.v1.QueryBalanceRequest)
- [QueryBalanceResponse](#ethermint.evm.v1.QueryBalanceResponse)
- [QueryBlockBloomRequest](#ethermint.evm.v1.QueryBlockBloomRequest)
- [QueryBlockBloomResponse](#ethermint.evm.v1.QueryBlockBloomResponse)
- [QueryBlockLogsRequest](#ethermint.evm.v1.QueryBlockLogsRequest)
- [QueryBlockLogsResponse](#ethermint.evm.v1.QueryBlockLogsResponse)
- [QueryCodeRequest](#ethermint.evm.v1.QueryCodeRequest)
- [QueryCodeResponse](#ethermint.evm.v1.QueryCodeResponse)
- [QueryCosmosAccountRequest](#ethermint.evm.v1.QueryCosmosAccountRequest)
@ -372,7 +368,6 @@ GenesisState defines the evm module's genesis state.
| ----- | ---- | ----- | ----------- |
| `accounts` | [GenesisAccount](#ethermint.evm.v1.GenesisAccount) | repeated | accounts is an array containing the ethereum genesis accounts. |
| `params` | [Params](#ethermint.evm.v1.Params) | | params defines all the paramaters of the module. |
| `txs_logs` | [TransactionLogs](#ethermint.evm.v1.TransactionLogs) | repeated | |
@ -637,70 +632,6 @@ QueryBalanceResponse is the response type for the Query/Balance RPC method.
<a name="ethermint.evm.v1.QueryBlockBloomRequest"></a>
### QueryBlockBloomRequest
QueryBlockBloomRequest is the request type for the Query/BlockBloom RPC
method.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `height` | [int64](#int64) | | height of the block which we want to query the bloom filter. Tendermint always replace the query request header by the current context header, height cannot be extracted from there, so we need to explicitly pass it in parameter. |
<a name="ethermint.evm.v1.QueryBlockBloomResponse"></a>
### QueryBlockBloomResponse
QueryBlockBloomResponse is the response type for the Query/BlockBloom RPC
method.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `bloom` | [bytes](#bytes) | | bloom represents bloom filter for the given block hash. |
<a name="ethermint.evm.v1.QueryBlockLogsRequest"></a>
### QueryBlockLogsRequest
QueryBlockLogsRequest is the request type for the Query/BlockLogs RPC method.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `hash` | [string](#string) | | hash is the block hash to query the logs for. |
| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an optional pagination for the request. |
<a name="ethermint.evm.v1.QueryBlockLogsResponse"></a>
### QueryBlockLogsResponse
QueryTxLogs is the response type for the Query/BlockLogs RPC method.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `tx_logs` | [TransactionLogs](#ethermint.evm.v1.TransactionLogs) | repeated | logs represents the ethereum logs generated at the given block hash. |
| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines the pagination in the response. |
<a name="ethermint.evm.v1.QueryCodeRequest"></a>
### QueryCodeRequest
@ -955,9 +886,6 @@ Query defines the gRPC querier service.
| `Balance` | [QueryBalanceRequest](#ethermint.evm.v1.QueryBalanceRequest) | [QueryBalanceResponse](#ethermint.evm.v1.QueryBalanceResponse) | Balance queries the balance of a the EVM denomination for a single EthAccount. | GET|/ethermint/evm/v1/balances/{address}|
| `Storage` | [QueryStorageRequest](#ethermint.evm.v1.QueryStorageRequest) | [QueryStorageResponse](#ethermint.evm.v1.QueryStorageResponse) | Storage queries the balance of all coins for a single account. | GET|/ethermint/evm/v1/storage/{address}/{key}|
| `Code` | [QueryCodeRequest](#ethermint.evm.v1.QueryCodeRequest) | [QueryCodeResponse](#ethermint.evm.v1.QueryCodeResponse) | Code queries the balance of all coins for a single account. | GET|/ethermint/evm/v1/codes/{address}|
| `TxLogs` | [QueryTxLogsRequest](#ethermint.evm.v1.QueryTxLogsRequest) | [QueryTxLogsResponse](#ethermint.evm.v1.QueryTxLogsResponse) | TxLogs queries ethereum logs from a transaction. | GET|/ethermint/evm/v1/tx_logs/{hash}|
| `BlockLogs` | [QueryBlockLogsRequest](#ethermint.evm.v1.QueryBlockLogsRequest) | [QueryBlockLogsResponse](#ethermint.evm.v1.QueryBlockLogsResponse) | BlockLogs queries all the ethereum logs for a given block hash. | GET|/ethermint/evm/v1/block_logs/{hash}|
| `BlockBloom` | [QueryBlockBloomRequest](#ethermint.evm.v1.QueryBlockBloomRequest) | [QueryBlockBloomResponse](#ethermint.evm.v1.QueryBlockBloomResponse) | BlockBloom queries the block bloom filter bytes at a given height. | GET|/ethermint/evm/v1/block_bloom|
| `Params` | [QueryParamsRequest](#ethermint.evm.v1.QueryParamsRequest) | [QueryParamsResponse](#ethermint.evm.v1.QueryParamsResponse) | Params queries the parameters of x/evm module. | GET|/ethermint/evm/v1/params|
| `EthCall` | [EthCallRequest](#ethermint.evm.v1.EthCallRequest) | [MsgEthereumTxResponse](#ethermint.evm.v1.MsgEthereumTxResponse) | EthCall implements the `eth_call` rpc api | GET|/ethermint/evm/v1/eth_call|
| `EstimateGas` | [EthCallRequest](#ethermint.evm.v1.EthCallRequest) | [EstimateGasResponse](#ethermint.evm.v1.EstimateGasResponse) | EstimateGas implements the `eth_estimateGas` rpc api | GET|/ethermint/evm/v1/estimate_gas|

View File

@ -1,11 +1,11 @@
package backend
import (
"bytes"
"context"
"encoding/json"
"fmt"
"math/big"
"regexp"
"strconv"
"github.com/cosmos/cosmos-sdk/client/flags"
@ -48,7 +48,8 @@ type Backend interface {
GetTransactionLogs(txHash common.Hash) ([]*ethtypes.Log, error)
GetTransactionCount(address common.Address, blockNum types.BlockNumber) (*hexutil.Uint64, error)
SendTransaction(args types.SendTxArgs) (common.Hash, error)
GetLogs(blockHash common.Hash) ([][]*ethtypes.Log, error)
GetLogsByHeight(height *int64) ([][]*ethtypes.Log, error)
GetLogs(hash common.Hash) ([][]*ethtypes.Log, error)
BloomStatus() (uint64, uint64)
GetCoinbase() (sdk.AccAddress, error)
GetTransactionByHash(txHash common.Hash) (*types.RPCTransaction, error)
@ -188,6 +189,26 @@ func (e *EVMBackend) GetTendermintBlockByNumber(blockNum types.BlockNumber) (*tm
return resBlock, nil
}
// BlockBloom query block bloom filter from block results
func (e *EVMBackend) BlockBloom(height *int64) (ethtypes.Bloom, error) {
result, err := e.clientCtx.Client.BlockResults(e.ctx, height)
if err != nil {
return ethtypes.Bloom{}, err
}
for _, event := range result.EndBlockEvents {
if event.Type != evmtypes.EventTypeBlockBloom {
continue
}
for _, attr := range event.Attributes {
if bytes.Equal(attr.Key, []byte(evmtypes.AttributeKeyEthereumBloom)) {
return ethtypes.BytesToBloom(attr.Value), nil
}
}
}
return ethtypes.Bloom{}, errors.New("block bloom event is not found")
}
// EthBlockFromTendermint returns a JSON-RPC compatible Ethereum block from a given Tendermint block and its block result.
func (e *EVMBackend) EthBlockFromTendermint(
block *tmtypes.Block,
@ -244,11 +265,9 @@ func (e *EVMBackend) EthBlockFromTendermint(
}
}
blockBloomResp, err := e.queryClient.BlockBloom(types.ContextWithHeight(block.Height), &evmtypes.QueryBlockBloomRequest{Height: block.Height})
bloom, err := e.BlockBloom(&block.Height)
if err != nil {
e.logger.Debug("failed to query BlockBloom", "height", block.Height, "error", err.Error())
blockBloomResp = &evmtypes.QueryBlockBloomResponse{Bloom: ethtypes.Bloom{}.Bytes()}
}
req := &evmtypes.QueryValidatorAccountRequest{
@ -268,8 +287,6 @@ func (e *EVMBackend) EthBlockFromTendermint(
validatorAddr := common.BytesToAddress(addr)
bloom := ethtypes.BytesToBloom(blockBloomResp.Bloom)
gasLimit, err := types.BlockMaxGasFromConsensusParams(types.ContextWithHeight(block.Height), e.clientCtx)
if err != nil {
e.logger.Error("failed to query consensus params", "error", err.Error())
@ -319,16 +336,13 @@ func (e *EVMBackend) HeaderByNumber(blockNum types.BlockNumber) (*ethtypes.Heade
return nil, err
}
req := &evmtypes.QueryBlockBloomRequest{Height: resBlock.Block.Height}
blockBloomResp, err := e.queryClient.BlockBloom(types.ContextWithHeight(resBlock.Block.Height), req)
bloom, err := e.BlockBloom(&resBlock.Block.Height)
if err != nil {
e.logger.Debug("HeaderByNumber BlockBloom failed", "height", resBlock.Block.Height)
blockBloomResp = &evmtypes.QueryBlockBloomResponse{Bloom: ethtypes.Bloom{}.Bytes()}
}
ethHeader := types.EthHeaderFromTendermint(resBlock.Block.Header)
ethHeader.Bloom = ethtypes.BytesToBloom(blockBloomResp.Bloom)
ethHeader.Bloom = bloom
return ethHeader, nil
}
@ -344,16 +358,13 @@ func (e *EVMBackend) HeaderByHash(blockHash common.Hash) (*ethtypes.Header, erro
return nil, errors.Errorf("block not found for hash %s", blockHash.Hex())
}
req := &evmtypes.QueryBlockBloomRequest{Height: resBlock.Block.Height}
blockBloomResp, err := e.queryClient.BlockBloom(types.ContextWithHeight(resBlock.Block.Height), req)
bloom, err := e.BlockBloom(&resBlock.Block.Height)
if err != nil {
e.logger.Debug("HeaderByHash BlockBloom failed", "height", resBlock.Block.Height)
blockBloomResp = &evmtypes.QueryBlockBloomResponse{Bloom: ethtypes.Bloom{}.Bytes()}
}
ethHeader := types.EthHeaderFromTendermint(resBlock.Block.Header)
ethHeader.Bloom = ethtypes.BytesToBloom(blockBloomResp.Bloom)
ethHeader.Bloom = bloom
return ethHeader, nil
}
@ -361,17 +372,11 @@ func (e *EVMBackend) HeaderByHash(blockHash common.Hash) (*ethtypes.Header, erro
// It returns an error if there's an encoding error.
// If no logs are found for the tx hash, the error is nil.
func (e *EVMBackend) GetTransactionLogs(txHash common.Hash) ([]*ethtypes.Log, error) {
req := &evmtypes.QueryTxLogsRequest{
Hash: txHash.String(),
}
res, err := e.queryClient.TxLogs(e.ctx, req)
tx, err := e.clientCtx.Client.Tx(e.ctx, txHash.Bytes(), false)
if err != nil {
e.logger.Debug("TxLogs failed", "tx-hash", req.Hash)
return nil, err
}
return evmtypes.LogsToEthereum(res.Logs), nil
return TxLogsFromEvents(e.clientCtx.Codec, tx.TxResult.Events), nil
}
// PendingTransactions returns the transactions that are in the transaction pool
@ -394,29 +399,31 @@ func (e *EVMBackend) PendingTransactions() ([]*sdk.Tx, error) {
return result, nil
}
// GetLogs returns all the logs from all the ethereum transactions in a block.
func (e *EVMBackend) GetLogs(blockHash common.Hash) ([][]*ethtypes.Log, error) {
// GetLogsByHeight returns all the logs from all the ethereum transactions in a block.
func (e *EVMBackend) GetLogsByHeight(height *int64) ([][]*ethtypes.Log, error) {
// NOTE: we query the state in case the tx result logs are not persisted after an upgrade.
req := &evmtypes.QueryBlockLogsRequest{
Hash: blockHash.String(),
}
res, err := e.queryClient.BlockLogs(e.ctx, req)
blockRes, err := e.clientCtx.Client.BlockResults(e.ctx, height)
if err != nil {
e.logger.Debug("BlockLogs failed", "hash", req.Hash)
return nil, err
}
blockLogs := [][]*ethtypes.Log{}
for _, txLog := range res.TxLogs {
blockLogs = append(blockLogs, txLog.EthLogs())
for _, txResult := range blockRes.TxsResults {
logs := TxLogsFromEvents(e.clientCtx.Codec, txResult.Events)
blockLogs = append(blockLogs, logs)
}
return blockLogs, nil
}
// This is very brittle, see: https://github.com/tendermint/tendermint/issues/4740
var regexpMissingHeight = regexp.MustCompile(`height \d+ (must be less than or equal to|is not available)`)
// GetLogs returns all the logs from all the ethereum transactions in a block.
func (e *EVMBackend) GetLogs(hash common.Hash) ([][]*ethtypes.Log, error) {
block, err := e.clientCtx.Client.BlockByHash(e.ctx, hash.Bytes())
if err != nil {
return nil, err
}
return e.GetLogsByHeight(&block.Block.Header.Height)
}
func (e *EVMBackend) GetLogsByNumber(blockNum types.BlockNumber) ([][]*ethtypes.Log, error) {
height := blockNum.Int64()
@ -439,17 +446,7 @@ func (e *EVMBackend) GetLogsByNumber(blockNum types.BlockNumber) ([][]*ethtypes.
}
}
resBlock, err := e.clientCtx.Client.Block(e.ctx, &height)
if err != nil {
if regexpMissingHeight.MatchString(err.Error()) {
return [][]*ethtypes.Log{}, nil
}
e.logger.Debug("failed to query block", "height", height)
return nil, err
}
return e.GetLogs(common.BytesToHash(resBlock.BlockID.Hash))
return e.GetLogsByHeight(&height)
}
// BloomStatus returns the BloomBitsBlocks and the number of processed sections maintained

View File

@ -5,9 +5,12 @@ import (
"errors"
"math/big"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/ethereum/go-ethereum/common"
ethtypes "github.com/ethereum/go-ethereum/core/types"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
"github.com/ethereum/go-ethereum/common/hexutil"
@ -130,3 +133,23 @@ func (e *EVMBackend) getAccountNonce(accAddr common.Address, pending bool, heigh
return nonce, nil
}
// TxLogsFromEvents parses ethereum logs from cosmos events
func TxLogsFromEvents(codec codec.Codec, events []abci.Event) []*ethtypes.Log {
logs := make([]*evmtypes.Log, 0)
for _, event := range events {
if event.Type != evmtypes.EventTypeTxLog {
continue
}
for _, attr := range event.Attributes {
if !bytes.Equal(attr.Key, []byte(evmtypes.AttributeKeyTxLog)) {
continue
}
var log evmtypes.Log
codec.MustUnmarshal(attr.Value, &log)
logs = append(logs, &log)
}
}
return evmtypes.LogsToEthereum(logs)
}

View File

@ -646,14 +646,11 @@ func (e *PublicAPI) GetTransactionReceipt(hash common.Hash) (map[string]interfac
return nil, err
}
resLogs, err := e.queryClient.TxLogs(e.ctx, &evmtypes.QueryTxLogsRequest{Hash: hash.Hex()})
logs, err := e.backend.GetTransactionLogs(hash)
if err != nil {
e.logger.Debug("logs not found", "hash", hash.Hex(), "error", err.Error())
resLogs = &evmtypes.QueryTxLogsResponse{Logs: []*evmtypes.Log{}}
}
logs := evmtypes.LogsToEthereum(resLogs.Logs)
receipt := map[string]interface{}{
// Consensus fields: These fields are defined by the Yellow Paper
"status": status,

2
go.mod
View File

@ -114,6 +114,7 @@ require (
github.com/minio/highwayhash v1.0.1 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/mapstructure v1.4.1 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/mtibben/percent v0.2.1 // indirect
github.com/mwitkow/go-proto-validators v0.3.2 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
@ -126,6 +127,7 @@ require (
github.com/prometheus/procfs v0.6.0 // indirect
github.com/prometheus/tsdb v0.7.1 // indirect
github.com/pseudomuto/protoc-gen-doc v1.5.0 // indirect
github.com/pseudomuto/protokit v0.2.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/rjeczalik/notify v0.9.1 // indirect
github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa // indirect

View File

@ -12,8 +12,6 @@ message GenesisState {
repeated GenesisAccount accounts = 1 [(gogoproto.nullable) = false];
// params defines all the paramaters of the module.
Params params = 3 [(gogoproto.nullable) = false];
repeated TransactionLogs txs_logs = 4 [(gogoproto.moretags) = "yaml:\"txs_logs\"", (gogoproto.nullable) = false];
}
// GenesisAccount defines an account to be initialized in the genesis state.

View File

@ -48,21 +48,6 @@ service Query {
option (google.api.http).get = "/ethermint/evm/v1/codes/{address}";
}
// TxLogs queries ethereum logs from a transaction.
rpc TxLogs(QueryTxLogsRequest) returns (QueryTxLogsResponse) {
option (google.api.http).get = "/ethermint/evm/v1/tx_logs/{hash}";
}
// BlockLogs queries all the ethereum logs for a given block hash.
rpc BlockLogs(QueryBlockLogsRequest) returns (QueryBlockLogsResponse) {
option (google.api.http).get = "/ethermint/evm/v1/block_logs/{hash}";
}
// BlockBloom queries the block bloom filter bytes at a given height.
rpc BlockBloom(QueryBlockBloomRequest) returns (QueryBlockBloomResponse) {
option (google.api.http).get = "/ethermint/evm/v1/block_bloom";
}
// Params queries the parameters of x/evm module.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/ethermint/evm/v1/params";
@ -214,42 +199,6 @@ message QueryTxLogsResponse {
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
// QueryBlockLogsRequest is the request type for the Query/BlockLogs RPC method.
message QueryBlockLogsRequest {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
// hash is the block hash to query the logs for.
string hash = 1;
// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 2;
}
// QueryTxLogs is the response type for the Query/BlockLogs RPC method.
message QueryBlockLogsResponse {
// logs represents the ethereum logs generated at the given block hash.
repeated TransactionLogs tx_logs = 1 [ (gogoproto.nullable) = false ];
// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
// QueryBlockBloomRequest is the request type for the Query/BlockBloom RPC
// method.
message QueryBlockBloomRequest {
// height of the block which we want to query the bloom filter.
// Tendermint always replace the query request header by the current context
// header, height cannot be extracted from there, so we need to explicitly
// pass it in parameter.
int64 height = 1;
}
// QueryBlockBloomResponse is the response type for the Query/BlockBloom RPC
// method.
message QueryBlockBloomResponse {
// bloom represents bloom filter for the given block hash.
bytes bloom = 1;
}
// QueryParamsRequest defines the request type for querying x/evm parameters.
message QueryParamsRequest {}

View File

@ -55,10 +55,6 @@ func InitGenesis(
}
}
for _, txLog := range data.TxsLogs {
k.SetLogs(common.HexToHash(txLog.Hash), txLog.EthLogs())
}
return []abci.ValidatorUpdate{}
}
@ -93,7 +89,6 @@ func ExportGenesis(ctx sdk.Context, k *keeper.Keeper, ak types.AccountKeeper) *t
return &types.GenesisState{
Accounts: ethGenAccounts,
TxsLogs: k.GetAllTxLogs(ctx),
Params: k.GetParams(ctx),
}
}

View File

@ -23,7 +23,7 @@ func (k *Keeper) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.Vali
k.WithContext(infCtx)
bloom := ethtypes.BytesToBloom(k.GetBlockBloomTransient().Bytes())
k.SetBlockBloom(infCtx, req.Height, bloom)
k.EmitBlockBloomEvent(infCtx, bloom)
k.WithContext(ctx)

View File

@ -14,10 +14,7 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"github.com/cosmos/cosmos-sdk/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/query"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
@ -199,126 +196,6 @@ func (k Keeper) Code(c context.Context, req *types.QueryCodeRequest) (*types.Que
}, nil
}
// TxLogs implements the Query/TxLogs gRPC method
func (k Keeper) TxLogs(c context.Context, req *types.QueryTxLogsRequest) (*types.QueryTxLogsResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}
if ethermint.IsEmptyHash(req.Hash) {
return nil, status.Error(
codes.InvalidArgument,
types.ErrEmptyHash.Error(),
)
}
ctx := sdk.UnwrapSDKContext(c)
k.WithContext(ctx)
hash := common.HexToHash(req.Hash)
store := prefix.NewStore(k.Ctx().KVStore(k.storeKey), append(types.KeyPrefixLogs, hash.Bytes()...))
var logs []*types.Log
pageRes, err := query.Paginate(store, req.Pagination, func(_, value []byte) error {
var log types.Log
if err := k.cdc.Unmarshal(value, &log); err != nil {
return err
}
logs = append(logs, &log)
return nil
})
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
return &types.QueryTxLogsResponse{
Logs: logs,
Pagination: pageRes,
}, nil
}
// BlockLogs implements the Query/BlockLogs gRPC method
func (k Keeper) BlockLogs(c context.Context, req *types.QueryBlockLogsRequest) (*types.QueryBlockLogsResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}
if ethermint.IsEmptyHash(req.Hash) {
return nil, status.Error(
codes.InvalidArgument,
types.ErrEmptyHash.Error(),
)
}
ctx := sdk.UnwrapSDKContext(c)
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixLogs)
mapOrder := []string{}
logs := make(map[string][]*types.Log)
pageRes, err := query.FilteredPaginate(store, req.Pagination, func(_, value []byte, accumulate bool) (bool, error) {
var txLog types.Log
if err := k.cdc.Unmarshal(value, &txLog); err != nil {
return false, err
}
if txLog.BlockHash == req.Hash {
if accumulate {
if len(logs[txLog.TxHash]) == 0 {
mapOrder = append(mapOrder, txLog.TxHash)
}
logs[txLog.TxHash] = append(logs[txLog.TxHash], &txLog)
}
return true, nil
}
return false, nil
})
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
txsLogs := []types.TransactionLogs{}
for _, txHash := range mapOrder {
if len(logs[txHash]) > 0 {
txsLogs = append(txsLogs, types.TransactionLogs{Hash: txHash, Logs: logs[txHash]})
}
}
return &types.QueryBlockLogsResponse{
TxLogs: txsLogs,
Pagination: pageRes,
}, nil
}
// BlockBloom implements the Query/BlockBloom gRPC method
func (k Keeper) BlockBloom(c context.Context, req *types.QueryBlockBloomRequest) (*types.QueryBlockBloomResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
bloom, found := k.GetBlockBloom(ctx, req.Height)
if !found {
// if the bloom is not found, query the transient store at the current height
k.WithContext(ctx)
bloomInt := k.GetBlockBloomTransient()
if bloomInt.Sign() == 0 {
return nil, status.Error(
codes.NotFound, sdkerrors.Wrapf(types.ErrBloomNotFound, "height: %d", req.Height).Error(),
)
}
bloom = ethtypes.BytesToBloom(bloomInt.Bytes())
}
return &types.QueryBlockBloomResponse{
Bloom: bloom.Bytes(),
}, nil
}
// Params implements the Query/Params gRPC method
func (k Keeper) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
ctx := sdk.UnwrapSDKContext(c)

View File

@ -5,19 +5,14 @@ import (
"fmt"
"math/big"
"google.golang.org/grpc/metadata"
"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/crypto"
sdk "github.com/cosmos/cosmos-sdk/types"
ethermint "github.com/tharsis/ethermint/types"
"github.com/tharsis/ethermint/x/evm/types"
grpctypes "github.com/cosmos/cosmos-sdk/types/grpc"
)
// Not valid Ethereum address
@ -341,38 +336,25 @@ func (suite *KeeperTestSuite) TestQueryCode() {
func (suite *KeeperTestSuite) TestQueryTxLogs() {
var (
req *types.QueryTxLogsRequest
txHash common.Hash
expLogs []*types.Log
)
testCases := []struct {
msg string
malleate func()
expPass bool
}{
{
"empty hash",
"empty logs",
func() {
req = &types.QueryTxLogsRequest{
Hash: common.Hash{}.String(),
}
txHash = common.BytesToHash([]byte("hash"))
expLogs = nil
},
false,
},
{
"logs not found",
func() {
hash := common.BytesToHash([]byte("hash"))
req = &types.QueryTxLogsRequest{
Hash: hash.String(),
}
},
true,
},
{
"success",
func() {
hash := common.BytesToHash([]byte("tx_hash"))
txHash = common.BytesToHash([]byte("tx_hash"))
expLogs = []*types.Log{
{
@ -380,21 +362,20 @@ func (suite *KeeperTestSuite) TestQueryTxLogs() {
Topics: []string{common.BytesToHash([]byte("topic")).String()},
Data: []byte("data"),
BlockNumber: 1,
TxHash: hash.String(),
TxHash: txHash.String(),
TxIndex: 1,
BlockHash: common.BytesToHash([]byte("block_hash")).String(),
BlockHash: common.BytesToHash(suite.ctx.HeaderHash()).Hex(),
Index: 0,
Removed: false,
},
}
suite.app.EvmKeeper.SetLogs(hash, types.LogsToEthereum(expLogs))
req = &types.QueryTxLogsRequest{
Hash: hash.String(),
suite.app.EvmKeeper.SetTxHashTransient(txHash)
suite.app.EvmKeeper.IncreaseTxIndexTransient()
for _, log := range types.LogsToEthereum(expLogs) {
suite.app.EvmKeeper.AddLog(log)
}
},
true,
},
}
@ -403,202 +384,8 @@ func (suite *KeeperTestSuite) TestQueryTxLogs() {
suite.SetupTest() // reset
tc.malleate()
ctx := sdk.WrapSDKContext(suite.ctx)
res, err := suite.queryClient.TxLogs(ctx, req)
if tc.expPass {
suite.Require().NoError(err)
suite.Require().NotNil(res)
suite.Require().Equal(expLogs, res.Logs)
} else {
suite.Require().Error(err)
}
})
}
}
func (suite *KeeperTestSuite) TestQueryBlockLogs() {
var (
req *types.QueryBlockLogsRequest
expLogs []types.TransactionLogs
)
testCases := []struct {
msg string
malleate func()
expPass bool
}{
{
"empty hash",
func() {
req = &types.QueryBlockLogsRequest{
Hash: common.Hash{}.String(),
}
},
false,
},
{
"logs not found",
func() {
hash := common.BytesToHash([]byte("hash"))
req = &types.QueryBlockLogsRequest{
Hash: hash.String(),
}
},
true,
},
{
"success",
func() {
hash := common.BytesToHash([]byte("block_hash"))
expLogs = []types.TransactionLogs{
{
Hash: common.BytesToHash([]byte("tx_hash_0")).String(),
Logs: []*types.Log{
{
Address: suite.address.String(),
Topics: []string{common.BytesToHash([]byte("topic")).String()},
Data: []byte("data"),
BlockNumber: 1,
TxHash: common.BytesToHash([]byte("tx_hash_0")).String(),
TxIndex: 1,
BlockHash: common.BytesToHash([]byte("block_hash")).String(),
Index: 0,
Removed: false,
},
},
},
{
Hash: common.BytesToHash([]byte("tx_hash_1")).String(),
Logs: []*types.Log{
{
Address: suite.address.String(),
Topics: []string{common.BytesToHash([]byte("topic")).String()},
Data: []byte("data"),
BlockNumber: 1,
TxHash: common.BytesToHash([]byte("tx_hash_1")).String(),
TxIndex: 1,
BlockHash: common.BytesToHash([]byte("block_hash")).String(),
Index: 1,
Removed: false,
},
{
Address: suite.address.String(),
Topics: []string{common.BytesToHash([]byte("topic_1")).String()},
Data: []byte("data_1"),
BlockNumber: 1,
TxHash: common.BytesToHash([]byte("tx_hash_1")).String(),
TxIndex: 1,
BlockHash: common.BytesToHash([]byte("block_hash")).String(),
Index: 2,
Removed: false,
},
},
},
}
suite.app.EvmKeeper.SetLogs(common.BytesToHash([]byte("tx_hash_0")), types.LogsToEthereum(expLogs[0].Logs))
suite.app.EvmKeeper.SetLogs(common.BytesToHash([]byte("tx_hash_1")), types.LogsToEthereum(expLogs[1].Logs))
req = &types.QueryBlockLogsRequest{
Hash: hash.String(),
}
},
true,
},
}
for _, tc := range testCases {
suite.Run(fmt.Sprintf("Case %s", tc.msg), func() {
suite.SetupTest() // reset
tc.malleate()
ctx := sdk.WrapSDKContext(suite.ctx)
res, err := suite.queryClient.BlockLogs(ctx, req)
if tc.expPass {
suite.Require().NoError(err)
suite.Require().NotNil(res)
suite.Require().Equal(expLogs, res.TxLogs)
} else {
suite.Require().Error(err)
}
})
}
}
func (suite *KeeperTestSuite) TestQueryBlockBloom() {
var (
req *types.QueryBlockBloomRequest
expBloom []byte
)
testCases := []struct {
msg string
malleate func()
expPass bool
}{
{
"bad height",
func() {
req = &types.QueryBlockBloomRequest{Height: -2}
},
false,
},
{
"bloom from transient store",
func() {
req = &types.QueryBlockBloomRequest{Height: 1}
bloom := ethtypes.BytesToBloom([]byte("bloom"))
expBloom = bloom.Bytes()
suite.app.EvmKeeper.WithContext(suite.ctx.WithBlockHeight(1))
suite.app.EvmKeeper.SetBlockBloomTransient(bloom.Big())
},
true,
},
{
"bloom not found for height",
func() {
req = &types.QueryBlockBloomRequest{Height: 100}
bloom := ethtypes.BytesToBloom([]byte("bloom"))
expBloom = bloom.Bytes()
suite.ctx = suite.ctx.WithBlockHeight(100)
suite.app.EvmKeeper.SetBlockBloom(suite.ctx, 2, bloom)
},
false,
},
{
"success",
func() {
req = &types.QueryBlockBloomRequest{Height: 3}
bloom := ethtypes.BytesToBloom([]byte("bloom"))
expBloom = bloom.Bytes()
suite.ctx = suite.ctx.WithBlockHeight(3)
suite.app.EvmKeeper.SetBlockBloom(suite.ctx, 3, bloom)
},
true,
},
}
for _, tc := range testCases {
suite.Run(fmt.Sprintf("Case %s", tc.msg), func() {
suite.SetupTest() // reset
tc.malleate()
ctx := sdk.WrapSDKContext(suite.ctx)
ctx = metadata.AppendToOutgoingContext(ctx, grpctypes.GRPCBlockHeightHeader, fmt.Sprintf("%d", suite.ctx.BlockHeight()))
res, err := suite.queryClient.BlockBloom(ctx, req)
if tc.expPass {
suite.Require().NoError(err)
suite.Require().NotNil(res)
suite.Require().Equal(expBloom, res.Bloom)
} else {
suite.Require().Error(err)
}
logs := suite.app.EvmKeeper.GetTxLogsTransient(txHash)
suite.Require().Equal(expLogs, types.NewLogsFromEth(logs))
})
}
}

View File

@ -68,7 +68,7 @@ func (suite *KeeperTestSuite) TestEvmHooks() {
Topics: []common.Hash{},
Address: suite.address,
})
logs := k.GetTxLogs(txHash)
logs := k.GetTxLogsTransient(txHash)
result := k.PostTxProcessing(txHash, logs)
tc.expFunc(hook, result)

View File

@ -139,23 +139,14 @@ func (k Keeper) ChainID() *big.Int {
// Required by Web3 API.
// ----------------------------------------------------------------------------
// GetBlockBloom gets bloombits from block height
func (k Keeper) GetBlockBloom(ctx sdk.Context, height int64) (ethtypes.Bloom, bool) {
store := ctx.KVStore(k.storeKey)
bz := store.Get(types.BloomKey(height))
if len(bz) == 0 {
return ethtypes.Bloom{}, false
}
return ethtypes.BytesToBloom(bz), true
}
// SetBlockBloom sets the mapping from block height to bloom bits
func (k Keeper) SetBlockBloom(ctx sdk.Context, height int64, bloom ethtypes.Bloom) {
store := ctx.KVStore(k.storeKey)
key := types.BloomKey(height)
store.Set(key, bloom.Bytes())
// EmitBlockBloomEvent emit block bloom events
func (k Keeper) EmitBlockBloomEvent(ctx sdk.Context, bloom ethtypes.Bloom) {
ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeBlockBloom,
sdk.NewAttribute(types.AttributeKeyEthereumBloom, string(bloom.Bytes())),
),
)
}
// GetBlockBloomTransient returns bloom bytes for the current block height
@ -233,41 +224,10 @@ func (k Keeper) ResetRefundTransient(ctx sdk.Context) {
// Log
// ----------------------------------------------------------------------------
// GetAllTxLogs return all the transaction logs from the store.
func (k Keeper) GetAllTxLogs(ctx sdk.Context) []types.TransactionLogs {
store := ctx.KVStore(k.storeKey)
iter := sdk.KVStorePrefixIterator(store, types.KeyPrefixLogs)
defer iter.Close()
mapOrder := []string{}
mapLogs := make(map[string][]*types.Log)
for ; iter.Valid(); iter.Next() {
var txLog types.Log
k.cdc.MustUnmarshal(iter.Value(), &txLog)
txlogs := mapLogs[txLog.TxHash]
if len(txlogs) == 0 {
mapOrder = append(mapOrder, txLog.TxHash)
}
txlogs = append(txlogs, &txLog)
mapLogs[txLog.TxHash] = txlogs
}
txsLogs := []types.TransactionLogs{}
for _, txHash := range mapOrder {
if len(mapLogs[txHash]) > 0 {
txLogs := types.TransactionLogs{Hash: txHash, Logs: mapLogs[txHash]}
txsLogs = append(txsLogs, txLogs)
}
}
return txsLogs
}
// GetLogs returns the current logs for a given transaction hash from the KVStore.
// GetTxLogsTransient returns the current logs for a given transaction hash from the KVStore.
// This function returns an empty, non-nil slice if no logs are found.
func (k Keeper) GetTxLogs(txHash common.Hash) []*ethtypes.Log {
store := prefix.NewStore(k.Ctx().KVStore(k.storeKey), types.KeyPrefixLogs)
func (k Keeper) GetTxLogsTransient(txHash common.Hash) []*ethtypes.Log {
store := prefix.NewStore(k.Ctx().TransientStore(k.transientKey), types.KeyPrefixTransientTxLogs)
// We store the logs with key equal to txHash.Bytes() | sdk.Uint64ToBigEndian(uint64(log.Index)),
// therefore, we set the end boundary(excluded) to txHash.Bytes() | uint64.Max -> []byte
@ -287,22 +247,9 @@ func (k Keeper) GetTxLogs(txHash common.Hash) []*ethtypes.Log {
return logs
}
// SetLogs sets the logs for a transaction in the KVStore.
func (k Keeper) SetLogs(txHash common.Hash, logs []*ethtypes.Log) {
store := prefix.NewStore(k.Ctx().KVStore(k.storeKey), types.KeyPrefixLogs)
for _, log := range logs {
key := txHash.Bytes()
key = append(key, sdk.Uint64ToBigEndian(uint64(log.Index))...)
txIndexLog := types.NewLogFromEth(log)
bz := k.cdc.MustMarshal(txIndexLog)
store.Set(key, bz)
}
}
// SetLog sets the log for a transaction in the KVStore.
func (k Keeper) SetLog(log *ethtypes.Log) {
store := prefix.NewStore(k.Ctx().KVStore(k.storeKey), types.KeyPrefixLogs)
func (k Keeper) AddLogTransient(log *ethtypes.Log) {
store := prefix.NewStore(k.Ctx().TransientStore(k.transientKey), types.KeyPrefixTransientTxLogs)
key := log.TxHash.Bytes()
key = append(key, sdk.Uint64ToBigEndian(uint64(log.Index))...)
@ -312,23 +259,6 @@ func (k Keeper) SetLog(log *ethtypes.Log) {
store.Set(key, bz)
}
// DeleteLogs removes the logs from the KVStore. It is used during journal.Revert.
func (k Keeper) DeleteTxLogs(ctx sdk.Context, txHash common.Hash) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixLogs)
// We store the logs with key equal to txHash.Bytes() | sdk.Uint64ToBigEndian(uint64(log.Index)),
// therefore, we set the end boundary(excluded) to txHash.Bytes() | uint64.Max -> []byte
end := txHash.Bytes()
end = append(end, []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}...)
iter := store.Iterator(txHash.Bytes(), end)
defer iter.Close()
for ; iter.Valid(); iter.Next() {
store.Delete(iter.Key())
}
}
// GetLogSizeTransient returns EVM log index on the current block.
func (k Keeper) GetLogSizeTransient() uint64 {
store := k.Ctx().TransientStore(k.transientKey)

View File

@ -52,12 +52,22 @@ func (k *Keeper) EthereumTx(goCtx context.Context, msg *types.MsgEthereumTx) (*t
attrs = append(attrs, sdk.NewAttribute(types.AttributeKeyEthereumTxFailed, response.VmError))
}
txLogAttrs := make([]sdk.Attribute, 0)
for _, log := range response.Logs {
bz := k.cdc.MustMarshal(log)
txLogAttrs = append(txLogAttrs, sdk.NewAttribute(types.AttributeKeyTxLog, string(bz)))
}
// emit events
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeEthereumTx,
attrs...,
),
sdk.NewEvent(
types.EventTypeTxLog,
txLogAttrs...,
),
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),

View File

@ -184,7 +184,7 @@ func (k *Keeper) ApplyTransaction(tx *ethtypes.Transaction) (*types.MsgEthereumT
}
res.Hash = txHash.Hex()
logs := k.GetTxLogs(txHash)
logs := k.GetTxLogsTransient(txHash)
if !res.Failed() {
// Only call hooks if tx executed successfully.

View File

@ -654,7 +654,7 @@ func (k *Keeper) AddLog(log *ethtypes.Log) {
log.Index = uint(k.GetLogSizeTransient())
k.IncreaseLogSizeTransient()
k.SetLog(log)
k.AddLogTransient(log)
k.Logger(ctx).Debug(
"log added",

View File

@ -608,7 +608,7 @@ func (suite *KeeperTestSuite) TestAddLog() {
suite.app.EvmKeeper.SetTxHashTransient(tc.hash)
suite.app.EvmKeeper.AddLog(tc.log)
logs := suite.app.EvmKeeper.GetTxLogs(tc.hash)
logs := suite.app.EvmKeeper.GetTxLogsTransient(tc.hash)
suite.Require().Equal(1, len(logs))
suite.Require().Equal(tc.expLog, logs[0])
})

View File

@ -3,15 +3,19 @@ package types
// Evm module events
const (
EventTypeEthereumTx = TypeMsgEthereumTx
EventTypeBlockBloom = "block_bloom"
EventTypeTxLog = "tx_log"
AttributeKeyContractAddress = "contract"
AttributeKeyRecipient = "recipient"
AttributeKeyTxHash = "txHash"
AttributeKeyEthereumTxHash = "ethereumTxHash"
AttributeKeyTxType = "txType"
AttributeKeyTxLog = "txLog"
// tx failed in eth vm execution
AttributeKeyEthereumTxFailed = "ethereumTxFailed"
AttributeValueCategory = ModuleName
AttributeKeyEthereumBloom = "bloom"
MetricKeyTransitionDB = "transition_db"
MetricKeyStaticCall = "static_call"

View File

@ -19,7 +19,6 @@ func (ga GenesisAccount) Validate() error {
func DefaultGenesisState() *GenesisState {
return &GenesisState{
Accounts: []GenesisAccount{},
TxsLogs: []TransactionLogs{},
Params: DefaultParams(),
}
}
@ -28,7 +27,6 @@ func DefaultGenesisState() *GenesisState {
// failure.
func (gs GenesisState) Validate() error {
seenAccounts := make(map[string]bool)
seenTxs := make(map[string]bool)
for _, acc := range gs.Accounts {
if seenAccounts[acc.Address] {
return fmt.Errorf("duplicated genesis account %s", acc.Address)
@ -39,17 +37,5 @@ func (gs GenesisState) Validate() error {
seenAccounts[acc.Address] = true
}
for _, tx := range gs.TxsLogs {
if seenTxs[tx.Hash] {
return fmt.Errorf("duplicated logs from transaction %s", tx.Hash)
}
if err := tx.Validate(); err != nil {
return fmt.Errorf("invalid logs from transaction %s: %w", tx.Hash, err)
}
seenTxs[tx.Hash] = true
}
return gs.Params.Validate()
}

View File

@ -29,7 +29,6 @@ type GenesisState struct {
Accounts []GenesisAccount `protobuf:"bytes,1,rep,name=accounts,proto3" json:"accounts"`
// params defines all the paramaters of the module.
Params Params `protobuf:"bytes,3,opt,name=params,proto3" json:"params"`
TxsLogs []TransactionLogs `protobuf:"bytes,4,rep,name=txs_logs,json=txsLogs,proto3" json:"txs_logs" yaml:"txs_logs"`
}
func (m *GenesisState) Reset() { *m = GenesisState{} }
@ -79,13 +78,6 @@ func (m *GenesisState) GetParams() Params {
return Params{}
}
func (m *GenesisState) GetTxsLogs() []TransactionLogs {
if m != nil {
return m.TxsLogs
}
return nil
}
// GenesisAccount defines an account to be initialized in the genesis state.
// Its main difference between with Geth's GenesisAccount is that it uses a
// custom storage type and that it doesn't contain the private key field.
@ -160,30 +152,26 @@ func init() {
func init() { proto.RegisterFile("ethermint/evm/v1/genesis.proto", fileDescriptor_9bcdec50cc9d156d) }
var fileDescriptor_9bcdec50cc9d156d = []byte{
// 353 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x51, 0xbf, 0x4e, 0xc2, 0x40,
0x18, 0xef, 0x09, 0xa1, 0x78, 0x18, 0x31, 0x17, 0x13, 0x1a, 0x86, 0x82, 0x9d, 0x3a, 0xb5, 0x01,
0x13, 0x07, 0x37, 0xbb, 0xb8, 0x38, 0x98, 0xa2, 0x8b, 0x8b, 0x39, 0xca, 0xe5, 0x68, 0x42, 0x7b,
0xe4, 0xbe, 0xa3, 0x81, 0xd5, 0x27, 0xf0, 0x39, 0x7c, 0x12, 0x46, 0x46, 0x27, 0x54, 0x78, 0x03,
0x9f, 0xc0, 0xf4, 0x0a, 0x18, 0xed, 0xf6, 0xdd, 0xfd, 0xfe, 0x7c, 0xbf, 0xbb, 0x1f, 0xb6, 0x99,
0x1a, 0x33, 0x99, 0xc4, 0xa9, 0xf2, 0x59, 0x96, 0xf8, 0x59, 0xcf, 0xe7, 0x2c, 0x65, 0x10, 0x83,
0x37, 0x95, 0x42, 0x09, 0x72, 0x76, 0xc0, 0x3d, 0x96, 0x25, 0x5e, 0xd6, 0x6b, 0x9f, 0x73, 0xc1,
0x85, 0x06, 0xfd, 0x7c, 0x2a, 0x78, 0xed, 0x76, 0xc9, 0x27, 0xa7, 0x6b, 0xcc, 0xf9, 0x42, 0xf8,
0xe4, 0xb6, 0x70, 0x1d, 0x28, 0xaa, 0x18, 0x09, 0x70, 0x9d, 0x46, 0x91, 0x98, 0xa5, 0x0a, 0x2c,
0xd4, 0xad, 0xb8, 0x8d, 0x7e, 0xd7, 0xfb, 0xbf, 0xc7, 0xdb, 0x29, 0x6e, 0x0a, 0x62, 0x50, 0x5d,
0xae, 0x3b, 0x46, 0x78, 0xd0, 0x91, 0x2b, 0x5c, 0x9b, 0x52, 0x49, 0x13, 0xb0, 0x2a, 0x5d, 0xe4,
0x36, 0xfa, 0x56, 0xd9, 0xe1, 0x5e, 0xe3, 0x3b, 0xe5, 0x8e, 0x4d, 0x1e, 0x71, 0x5d, 0xcd, 0xe1,
0x79, 0x22, 0x38, 0x58, 0x55, 0xbd, 0xfb, 0xa2, 0xac, 0x7c, 0x90, 0x34, 0x05, 0x1a, 0xa9, 0x58,
0xa4, 0x77, 0x82, 0x43, 0xd0, 0xca, 0x2d, 0xbe, 0xd7, 0x9d, 0xe6, 0x82, 0x26, 0x93, 0x6b, 0x67,
0x6f, 0xe0, 0x84, 0xa6, 0x9a, 0x43, 0xce, 0x70, 0x5e, 0x10, 0x3e, 0xfd, 0x9b, 0x98, 0x58, 0xd8,
0xa4, 0xa3, 0x91, 0x64, 0x90, 0x3f, 0x12, 0xb9, 0xc7, 0xe1, 0xfe, 0x48, 0x08, 0xae, 0x46, 0x62,
0xc4, 0xac, 0x23, 0x7d, 0xad, 0x67, 0x12, 0x60, 0x13, 0x94, 0x90, 0x94, 0x33, 0xab, 0xa2, 0x63,
0xb5, 0xca, 0xb1, 0xf4, 0xef, 0x05, 0xcd, 0x3c, 0xcc, 0xdb, 0x47, 0xc7, 0x1c, 0x14, 0xfc, 0x70,
0x2f, 0x0c, 0x82, 0xe5, 0xc6, 0x46, 0xab, 0x8d, 0x8d, 0x3e, 0x37, 0x36, 0x7a, 0xdd, 0xda, 0xc6,
0x6a, 0x6b, 0x1b, 0xef, 0x5b, 0xdb, 0x78, 0x72, 0x79, 0xac, 0xc6, 0xb3, 0xa1, 0x17, 0x89, 0xc4,
0x57, 0x63, 0x2a, 0x21, 0x06, 0xff, 0xb7, 0xb1, 0xb9, 0xee, 0x4c, 0x2d, 0xa6, 0x0c, 0x86, 0x35,
0xdd, 0xd9, 0xe5, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x76, 0xc7, 0x9e, 0xf9, 0x19, 0x02, 0x00,
0x00,
// 299 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x50, 0xbd, 0x4e, 0xeb, 0x30,
0x14, 0x8e, 0x6f, 0xab, 0xf6, 0xe2, 0x22, 0x40, 0x16, 0x12, 0x56, 0x07, 0xb7, 0xea, 0x94, 0xc9,
0x56, 0x8b, 0xc4, 0x8e, 0x17, 0x56, 0x94, 0x6e, 0x6c, 0x6e, 0x62, 0x25, 0x19, 0x12, 0x47, 0xb6,
0x1b, 0xc1, 0xca, 0xc8, 0xc4, 0x73, 0xf0, 0x24, 0x1d, 0x3b, 0x32, 0x01, 0x4a, 0x5e, 0x04, 0xc5,
0x49, 0x8b, 0x20, 0xdb, 0xb1, 0xbf, 0xbf, 0x73, 0x3e, 0x48, 0xa4, 0x4d, 0xa4, 0xce, 0xd2, 0xdc,
0x32, 0x59, 0x66, 0xac, 0x5c, 0xb2, 0x58, 0xe6, 0xd2, 0xa4, 0x86, 0x16, 0x5a, 0x59, 0x85, 0x2e,
0x8e, 0x38, 0x95, 0x65, 0x46, 0xcb, 0xe5, 0xf4, 0x32, 0x56, 0xb1, 0x72, 0x20, 0x6b, 0xa6, 0x96,
0x37, 0x9d, 0xf6, 0x7c, 0x1a, 0xba, 0xc3, 0x16, 0x2f, 0x00, 0x9e, 0xde, 0xb5, 0xae, 0x6b, 0x2b,
0xac, 0x44, 0x1c, 0xfe, 0x17, 0x61, 0xa8, 0xb6, 0xb9, 0x35, 0x18, 0xcc, 0x07, 0xfe, 0x64, 0x35,
0xa7, 0x7f, 0x73, 0x68, 0xa7, 0xb8, 0x6d, 0x89, 0x7c, 0xb8, 0xfb, 0x98, 0x79, 0xc1, 0x51, 0x87,
0x6e, 0xe0, 0xa8, 0x10, 0x5a, 0x64, 0x06, 0x0f, 0xe6, 0xc0, 0x9f, 0xac, 0x70, 0xdf, 0xe1, 0xde,
0xe1, 0x9d, 0xb2, 0x63, 0x2f, 0x9e, 0x01, 0x3c, 0xfb, 0x6d, 0x8d, 0x30, 0x1c, 0x8b, 0x28, 0xd2,
0xd2, 0x34, 0xdb, 0x00, 0xff, 0x24, 0x38, 0x3c, 0x11, 0x82, 0xc3, 0x50, 0x45, 0x12, 0xff, 0x73,
0xdf, 0x6e, 0x46, 0x1c, 0x8e, 0x8d, 0x55, 0x5a, 0xc4, 0x12, 0x0f, 0xdc, 0xee, 0x57, 0xfd, 0x64,
0x77, 0x26, 0x3f, 0x6f, 0x82, 0xdf, 0x3e, 0x67, 0xe3, 0x75, 0xcb, 0x0f, 0x0e, 0x42, 0xce, 0x77,
0x15, 0x01, 0xfb, 0x8a, 0x80, 0xaf, 0x8a, 0x80, 0xd7, 0x9a, 0x78, 0xfb, 0x9a, 0x78, 0xef, 0x35,
0xf1, 0x1e, 0xfc, 0x38, 0xb5, 0xc9, 0x76, 0x43, 0x43, 0x95, 0x31, 0x9b, 0x08, 0x6d, 0x52, 0xc3,
0x7e, 0xaa, 0x7d, 0x74, 0xe5, 0xda, 0xa7, 0x42, 0x9a, 0xcd, 0xc8, 0x95, 0x7b, 0xfd, 0x1d, 0x00,
0x00, 0xff, 0xff, 0x87, 0x96, 0x85, 0x5d, 0xc2, 0x01, 0x00, 0x00,
}
func (m *GenesisState) Marshal() (dAtA []byte, err error) {
@ -206,20 +194,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
if len(m.TxsLogs) > 0 {
for iNdEx := len(m.TxsLogs) - 1; iNdEx >= 0; iNdEx-- {
{
size, err := m.TxsLogs[iNdEx].MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintGenesis(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x22
}
}
{
size, err := m.Params.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
@ -323,12 +297,6 @@ func (m *GenesisState) Size() (n int) {
}
l = m.Params.Size()
n += 1 + l + sovGenesis(uint64(l))
if len(m.TxsLogs) > 0 {
for _, e := range m.TxsLogs {
l = e.Size()
n += 1 + l + sovGenesis(uint64(l))
}
}
return n
}
@ -457,40 +425,6 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error {
return err
}
iNdEx = postIndex
case 4:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field TxsLogs", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.TxsLogs = append(m.TxsLogs, TransactionLogs{})
if err := m.TxsLogs[len(m.TxsLogs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipGenesis(dAtA[iNdEx:])

View File

@ -106,24 +106,6 @@ func (suite *GenesisTestSuite) TestValidateGenesis() {
},
},
},
TxsLogs: []TransactionLogs{
{
Hash: suite.hash.String(),
Logs: []*Log{
{
Address: suite.address,
Topics: []string{suite.hash.String()},
Data: []byte("data"),
BlockNumber: 1,
TxHash: suite.hash.String(),
TxIndex: 1,
BlockHash: suite.hash.String(),
Index: 1,
Removed: false,
},
},
},
},
Params: DefaultParams(),
},
expPass: true,
@ -181,40 +163,6 @@ func (suite *GenesisTestSuite) TestValidateGenesis() {
},
},
},
TxsLogs: []TransactionLogs{
{
Hash: suite.hash.String(),
Logs: []*Log{
{
Address: suite.address,
Topics: []string{suite.hash.String()},
Data: []byte("data"),
BlockNumber: 1,
TxHash: suite.hash.String(),
TxIndex: 1,
BlockHash: suite.hash.String(),
Index: 1,
Removed: false,
},
},
},
{
Hash: suite.hash.String(),
Logs: []*Log{
{
Address: suite.address,
Topics: []string{suite.hash.String()},
Data: []byte("data"),
BlockNumber: 1,
TxHash: suite.hash.String(),
TxIndex: 1,
BlockHash: suite.hash.String(),
Index: 1,
Removed: false,
},
},
},
},
},
expPass: false,
},
@ -231,7 +179,6 @@ func (suite *GenesisTestSuite) TestValidateGenesis() {
},
},
},
TxsLogs: []TransactionLogs{NewTransactionLogs(common.Hash{}, nil)},
},
expPass: false,
},

View File

@ -1,8 +1,6 @@
package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
)
@ -16,7 +14,7 @@ const (
// The EVM module should use a prefix store.
StoreKey = ModuleName
// Transient Key is the key to access the EVM transient store, that is reset
// TransientKey is the key to access the EVM transient store, that is reset
// during the Commit phase.
TransientKey = "transient_" + ModuleName
@ -26,10 +24,7 @@ const (
// prefix bytes for the EVM persistent store
const (
prefixHeightToHeaderHash = iota + 1
prefixBloom
prefixLogs
prefixCode
prefixCode = iota + 1
prefixStorage
)
@ -43,13 +38,11 @@ const (
prefixTransientAccessListSlot
prefixTransientTxHash
prefixTransientLogSize
prefixTransientTxLogs
)
// KVStore key prefixes
var (
KeyPrefixHeightToHeaderHash = []byte{prefixHeightToHeaderHash}
KeyPrefixBloom = []byte{prefixBloom}
KeyPrefixLogs = []byte{prefixLogs}
KeyPrefixCode = []byte{prefixCode}
KeyPrefixStorage = []byte{prefixStorage}
)
@ -64,14 +57,9 @@ var (
KeyPrefixTransientAccessListSlot = []byte{prefixTransientAccessListSlot}
KeyPrefixTransientTxHash = []byte{prefixTransientTxHash}
KeyPrefixTransientLogSize = []byte{prefixTransientLogSize}
KeyPrefixTransientTxLogs = []byte{prefixTransientTxLogs}
)
// BloomKey defines the store key for a block Bloom
func BloomKey(height int64) []byte {
heightBytes := sdk.Uint64ToBigEndian(uint64(height))
return append(KeyPrefixBloom, heightBytes...)
}
// AddressStoragePrefix returns a prefix to iterate over a given account storage.
func AddressStoragePrefix(address common.Address) []byte {
return append(KeyPrefixStorage, address.Bytes()...)

File diff suppressed because it is too large Load Diff

View File

@ -20,6 +20,7 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
)
@ -30,6 +31,7 @@ var _ status.Status
var _ = runtime.String
var _ = utilities.NewDoubleArray
var _ = descriptor.ForMessage
var _ = metadata.Join
func request_Query_Account_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryAccountRequest
@ -377,186 +379,6 @@ func local_request_Query_Code_0(ctx context.Context, marshaler runtime.Marshaler
}
var (
filter_Query_TxLogs_0 = &utilities.DoubleArray{Encoding: map[string]int{"hash": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}}
)
func request_Query_TxLogs_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryTxLogsRequest
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["hash"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "hash")
}
protoReq.Hash, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "hash", err)
}
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_TxLogs_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.TxLogs(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Query_TxLogs_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryTxLogsRequest
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["hash"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "hash")
}
protoReq.Hash, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "hash", err)
}
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_TxLogs_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.TxLogs(ctx, &protoReq)
return msg, metadata, err
}
var (
filter_Query_BlockLogs_0 = &utilities.DoubleArray{Encoding: map[string]int{"hash": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}}
)
func request_Query_BlockLogs_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryBlockLogsRequest
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["hash"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "hash")
}
protoReq.Hash, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "hash", err)
}
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_BlockLogs_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.BlockLogs(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Query_BlockLogs_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryBlockLogsRequest
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["hash"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "hash")
}
protoReq.Hash, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "hash", err)
}
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_BlockLogs_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.BlockLogs(ctx, &protoReq)
return msg, metadata, err
}
var (
filter_Query_BlockBloom_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
)
func request_Query_BlockBloom_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryBlockBloomRequest
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_BlockBloom_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.BlockBloom(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Query_BlockBloom_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryBlockBloomRequest
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_BlockBloom_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.BlockBloom(ctx, &protoReq)
return msg, metadata, err
}
func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryParamsRequest
var metadata runtime.ServerMetadata
@ -686,12 +508,14 @@ func local_request_Query_TraceTx_0(ctx context.Context, marshaler runtime.Marsha
// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
// UnaryRPC :call QueryServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead.
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead.
func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error {
mux.Handle("GET", pattern_Query_Account_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
@ -699,6 +523,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
return
}
resp, md, err := local_request_Query_Account_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
@ -712,6 +537,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
mux.Handle("GET", pattern_Query_CosmosAccount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
@ -719,6 +546,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
return
}
resp, md, err := local_request_Query_CosmosAccount_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
@ -732,6 +560,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
mux.Handle("GET", pattern_Query_ValidatorAccount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
@ -739,6 +569,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
return
}
resp, md, err := local_request_Query_ValidatorAccount_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
@ -752,6 +583,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
mux.Handle("GET", pattern_Query_Balance_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
@ -759,6 +592,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
return
}
resp, md, err := local_request_Query_Balance_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
@ -772,6 +606,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
mux.Handle("GET", pattern_Query_Storage_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
@ -779,6 +615,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
return
}
resp, md, err := local_request_Query_Storage_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
@ -792,6 +629,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
mux.Handle("GET", pattern_Query_Code_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
@ -799,6 +638,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
return
}
resp, md, err := local_request_Query_Code_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
@ -809,69 +649,11 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
})
mux.Handle("GET", pattern_Query_TxLogs_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Query_TxLogs_0(rctx, inboundMarshaler, server, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_TxLogs_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Query_BlockLogs_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Query_BlockLogs_0(rctx, inboundMarshaler, server, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_BlockLogs_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Query_BlockBloom_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Query_BlockBloom_0(rctx, inboundMarshaler, server, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_BlockBloom_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
@ -879,6 +661,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
return
}
resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
@ -892,6 +675,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
mux.Handle("GET", pattern_Query_EthCall_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
@ -899,6 +684,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
return
}
resp, md, err := local_request_Query_EthCall_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
@ -912,6 +698,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
mux.Handle("GET", pattern_Query_EstimateGas_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
@ -919,6 +707,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
return
}
resp, md, err := local_request_Query_EstimateGas_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
@ -932,6 +721,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
mux.Handle("GET", pattern_Query_TraceTx_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
@ -939,6 +730,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
return
}
resp, md, err := local_request_Query_TraceTx_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
@ -1110,66 +902,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
})
mux.Handle("GET", pattern_Query_TxLogs_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Query_TxLogs_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_TxLogs_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Query_BlockLogs_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Query_BlockLogs_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_BlockLogs_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Query_BlockBloom_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Query_BlockBloom_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_BlockBloom_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
@ -1266,12 +998,6 @@ var (
pattern_Query_Code_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"ethermint", "evm", "v1", "codes", "address"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_Query_TxLogs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"ethermint", "evm", "v1", "tx_logs", "hash"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_Query_BlockLogs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"ethermint", "evm", "v1", "block_logs", "hash"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_Query_BlockBloom_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"ethermint", "evm", "v1", "block_bloom"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"ethermint", "evm", "v1", "params"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_Query_EthCall_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"ethermint", "evm", "v1", "eth_call"}, "", runtime.AssumeColonVerbOpt(true)))
@ -1294,12 +1020,6 @@ var (
forward_Query_Code_0 = runtime.ForwardResponseMessage
forward_Query_TxLogs_0 = runtime.ForwardResponseMessage
forward_Query_BlockLogs_0 = runtime.ForwardResponseMessage
forward_Query_BlockBloom_0 = runtime.ForwardResponseMessage
forward_Query_Params_0 = runtime.ForwardResponseMessage
forward_Query_EthCall_0 = runtime.ForwardResponseMessage

View File

@ -20,6 +20,7 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
)
@ -30,6 +31,7 @@ var _ status.Status
var _ = runtime.String
var _ = utilities.NewDoubleArray
var _ = descriptor.ForMessage
var _ = metadata.Join
func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryParamsRequest
@ -88,12 +90,14 @@ func local_request_Query_BlockGas_0(ctx context.Context, marshaler runtime.Marsh
// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
// UnaryRPC :call QueryServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead.
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead.
func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error {
mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
@ -101,6 +105,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
return
}
resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
@ -114,6 +119,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
mux.Handle("GET", pattern_Query_BaseFee_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
@ -121,6 +128,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
return
}
resp, md, err := local_request_Query_BaseFee_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
@ -134,6 +142,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
mux.Handle("GET", pattern_Query_BlockGas_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
@ -141,6 +151,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
return
}
resp, md, err := local_request_Query_BlockGas_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)