forked from cerc-io/laconicd-deprecated
rpc, evm: remove tx Receipt (#81)
* rpc, evm: remove tc receipt * rm receipt from gRPC query service * update eth block * update tx service response * rpc tx fixes * update bloom * fix * more fixes * c++
This commit is contained in:
+1
-38
@@ -1,14 +1,12 @@
|
||||
package evm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime/debug"
|
||||
|
||||
log "github.com/xlab/suplog"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
ethcmn "github.com/ethereum/go-ethereum/common"
|
||||
|
||||
"github.com/cosmos/ethermint/x/evm/keeper"
|
||||
"github.com/cosmos/ethermint/x/evm/types"
|
||||
@@ -25,42 +23,7 @@ func NewHandler(k *keeper.Keeper) sdk.Handler {
|
||||
case *types.MsgEthereumTx:
|
||||
// execute state transition
|
||||
res, err := k.EthereumTx(sdk.WrapSDKContext(ctx), msg)
|
||||
if err != nil {
|
||||
return sdk.WrapServiceResult(ctx, res, err)
|
||||
} else if result, err = sdk.WrapServiceResult(ctx, res, nil); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// log state transition result
|
||||
var recipientLog string
|
||||
if res.ContractAddress != "" {
|
||||
recipientLog = fmt.Sprintf("contract address %s", res.ContractAddress)
|
||||
} else {
|
||||
var recipient string
|
||||
if to := msg.To(); to != nil {
|
||||
recipient = to.Hex()
|
||||
}
|
||||
|
||||
recipientLog = fmt.Sprintf("recipient address %s", recipient)
|
||||
}
|
||||
|
||||
sender := ethcmn.BytesToAddress(msg.GetFrom().Bytes())
|
||||
|
||||
if res.Reverted {
|
||||
result.Log = "transaction reverted"
|
||||
log := fmt.Sprintf(
|
||||
"reverted EVM state transition; sender address %s; %s", sender.Hex(), recipientLog,
|
||||
)
|
||||
k.Logger(ctx).Info(log)
|
||||
} else {
|
||||
log := fmt.Sprintf(
|
||||
"executed EVM state transition; sender address %s; %s", sender.Hex(), recipientLog,
|
||||
)
|
||||
result.Log = log
|
||||
k.Logger(ctx).Info(log)
|
||||
}
|
||||
|
||||
return result, nil
|
||||
return sdk.WrapServiceResult(ctx, res, err)
|
||||
|
||||
default:
|
||||
err := sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized %s message type: %T", types.ModuleName, msg)
|
||||
|
||||
+7
-37
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
ethcmn "github.com/ethereum/go-ethereum/common"
|
||||
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||
@@ -98,7 +99,7 @@ func (suite *EvmTestSuite) TestHandleMsgEthereumTx() {
|
||||
"insufficient balance",
|
||||
func() {
|
||||
tx = types.NewMsgEthereumTxContract(suite.chainID, 0, big.NewInt(100), 0, big.NewInt(10000), nil, nil)
|
||||
|
||||
tx.From = suite.from.Hex()
|
||||
// sign transaction
|
||||
err := tx.Sign(suite.ethSigner, suite.signer)
|
||||
suite.Require().NoError(err)
|
||||
@@ -184,48 +185,17 @@ func (suite *EvmTestSuite) TestHandlerLogs() {
|
||||
txResponse, err := types.DecodeTxResponse(result.Data)
|
||||
suite.Require().NoError(err, "failed to decode result data")
|
||||
|
||||
suite.Require().Equal(len(txResponse.TxLogs.Logs), 1)
|
||||
suite.Require().Equal(len(txResponse.TxLogs.Logs[0].Topics), 2)
|
||||
suite.Require().Equal(len(txResponse.Logs), 1)
|
||||
suite.Require().Equal(len(txResponse.Logs[0].Topics), 2)
|
||||
|
||||
hash := []byte{1}
|
||||
err = suite.app.EvmKeeper.CommitStateDB.SetLogs(ethcmn.BytesToHash(hash), txResponse.TxLogs.EthLogs())
|
||||
err = suite.app.EvmKeeper.CommitStateDB.SetLogs(ethcmn.BytesToHash(hash), types.LogsToEthereum(txResponse.Logs))
|
||||
suite.Require().NoError(err)
|
||||
|
||||
logs, err := suite.app.EvmKeeper.CommitStateDB.GetLogs(ethcmn.BytesToHash(hash))
|
||||
suite.Require().NoError(err, "failed to get logs")
|
||||
|
||||
suite.Require().Equal(logs, txResponse.TxLogs.Logs)
|
||||
}
|
||||
|
||||
func (suite *EvmTestSuite) TestQueryTxLogs() {
|
||||
gasLimit := uint64(100000)
|
||||
gasPrice := big.NewInt(1000000)
|
||||
|
||||
// send contract deployment transaction with an event in the constructor
|
||||
bytecode := common.FromHex("0x6080604052348015600f57600080fd5b5060117f775a94827b8fd9b519d36cd827093c664f93347070a554f65e4a6f56cd73889860405160405180910390a2603580604b6000396000f3fe6080604052600080fdfea165627a7a723058206cab665f0f557620554bb45adf266708d2bd349b8a4314bdff205ee8440e3c240029")
|
||||
tx := types.NewMsgEthereumTx(suite.chainID, 1, nil, big.NewInt(0), gasLimit, gasPrice, bytecode, nil)
|
||||
tx.From = suite.from.String()
|
||||
|
||||
err := tx.Sign(suite.ethSigner, suite.signer)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
result, err := suite.handler(suite.ctx, tx)
|
||||
suite.Require().NoError(err)
|
||||
suite.Require().NotNil(result)
|
||||
|
||||
txResponse, err := types.DecodeTxResponse(result.Data)
|
||||
suite.Require().NoError(err, "failed to decode result data")
|
||||
|
||||
suite.Require().Equal(len(txResponse.TxLogs.Logs), 1)
|
||||
suite.Require().Equal(len(txResponse.TxLogs.Logs[0].Topics), 2)
|
||||
|
||||
// get logs by tx hash
|
||||
hash := txResponse.TxLogs.Hash
|
||||
|
||||
logs, err := suite.app.EvmKeeper.CommitStateDB.GetLogs(ethcmn.HexToHash(hash))
|
||||
suite.Require().NoError(err, "failed to get logs")
|
||||
|
||||
suite.Require().Equal(logs, txResponse.TxLogs.EthLogs())
|
||||
suite.Require().Equal(logs, txResponse.Logs)
|
||||
}
|
||||
|
||||
func (suite *EvmTestSuite) TestDeployAndCallContract() {
|
||||
@@ -303,7 +273,7 @@ func (suite *EvmTestSuite) TestDeployAndCallContract() {
|
||||
// store - changeOwner
|
||||
gasLimit = uint64(100000000000)
|
||||
gasPrice = big.NewInt(100)
|
||||
receiver := common.HexToAddress(txResponse.ContractAddress)
|
||||
receiver := crypto.CreateAddress(suite.from, 1)
|
||||
|
||||
storeAddr := "0xa6f9dae10000000000000000000000006a82e4a67715c8412a9114fbd2cbaefbc8181424"
|
||||
bytecode = common.FromHex(storeAddr)
|
||||
|
||||
@@ -203,44 +203,6 @@ func (k Keeper) TxLogs(c context.Context, req *types.QueryTxLogsRequest) (*types
|
||||
}, nil
|
||||
}
|
||||
|
||||
// TxReceipt implements the Query/TxReceipt gRPC method
|
||||
func (k Keeper) TxReceipt(c context.Context, req *types.QueryTxReceiptRequest) (*types.QueryTxReceiptResponse, 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)
|
||||
|
||||
hash := ethcmn.HexToHash(req.Hash)
|
||||
receipt, found := k.GetTxReceiptFromHash(ctx, hash)
|
||||
if !found {
|
||||
return nil, status.Errorf(
|
||||
codes.NotFound, "%s: %s", types.ErrTxReceiptNotFound.Error(), req.Hash,
|
||||
)
|
||||
}
|
||||
|
||||
return &types.QueryTxReceiptResponse{
|
||||
Receipt: receipt,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// TxReceiptsByBlockHeight implements the Query/TxReceiptsByBlockHeight gRPC method
|
||||
func (k Keeper) TxReceiptsByBlockHeight(c context.Context, _ *types.QueryTxReceiptsByBlockHeightRequest) (*types.QueryTxReceiptsByBlockHeightResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
|
||||
receipts := k.GetTxReceiptsByBlockHeight(ctx, uint64(ctx.BlockHeight()))
|
||||
return &types.QueryTxReceiptsByBlockHeightResponse{
|
||||
Receipts: receipts,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// BlockLogs implements the Query/BlockLogs gRPC method
|
||||
func (k Keeper) BlockLogs(c context.Context, req *types.QueryBlockLogsRequest) (*types.QueryBlockLogsResponse, error) {
|
||||
if req == nil {
|
||||
|
||||
@@ -517,136 +517,6 @@ func (suite *KeeperTestSuite) TestQueryBlockLogs() {
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestQueryTxReceipt() {
|
||||
var (
|
||||
req *types.QueryTxReceiptRequest
|
||||
expRes *types.QueryTxReceiptResponse
|
||||
)
|
||||
|
||||
testCases := []struct {
|
||||
msg string
|
||||
malleate func()
|
||||
expPass bool
|
||||
}{
|
||||
{"empty hash",
|
||||
func() {
|
||||
req = &types.QueryTxReceiptRequest{}
|
||||
},
|
||||
false,
|
||||
},
|
||||
{"tx receipt not found for hash",
|
||||
func() {
|
||||
hash := ethcmn.BytesToHash([]byte("thash"))
|
||||
req = &types.QueryTxReceiptRequest{
|
||||
Hash: hash.Hex(),
|
||||
}
|
||||
},
|
||||
false,
|
||||
},
|
||||
{"success",
|
||||
func() {
|
||||
hash := ethcmn.BytesToHash([]byte("thash"))
|
||||
receipt := &types.TxReceipt{
|
||||
Hash: hash.Hex(),
|
||||
From: suite.address.Hex(),
|
||||
BlockHeight: uint64(suite.ctx.BlockHeight()),
|
||||
BlockHash: ethcmn.BytesToHash(suite.ctx.BlockHeader().DataHash).Hex(),
|
||||
}
|
||||
|
||||
suite.app.EvmKeeper.SetTxReceiptToHash(suite.ctx, hash, receipt)
|
||||
req = &types.QueryTxReceiptRequest{
|
||||
Hash: hash.Hex(),
|
||||
}
|
||||
|
||||
expRes = &types.QueryTxReceiptResponse{
|
||||
Receipt: receipt,
|
||||
}
|
||||
},
|
||||
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.TxReceipt(ctx, req)
|
||||
|
||||
if tc.expPass {
|
||||
suite.Require().NoError(err)
|
||||
suite.Require().NotNil(res)
|
||||
|
||||
suite.Require().Equal(expRes, res)
|
||||
} else {
|
||||
suite.Require().Error(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestQueryTxReceiptByBlockHeight() {
|
||||
var (
|
||||
req = &types.QueryTxReceiptsByBlockHeightRequest{}
|
||||
expRes *types.QueryTxReceiptsByBlockHeightResponse
|
||||
)
|
||||
|
||||
testCases := []struct {
|
||||
msg string
|
||||
malleate func()
|
||||
expPass bool
|
||||
}{
|
||||
{"empty response",
|
||||
func() {
|
||||
expRes = &types.QueryTxReceiptsByBlockHeightResponse{
|
||||
Receipts: nil,
|
||||
}
|
||||
},
|
||||
true,
|
||||
},
|
||||
{"success",
|
||||
func() {
|
||||
hash := ethcmn.BytesToHash([]byte("thash"))
|
||||
receipt := &types.TxReceipt{
|
||||
Hash: hash.Hex(),
|
||||
From: suite.address.Hex(),
|
||||
BlockHeight: uint64(suite.ctx.BlockHeight()),
|
||||
BlockHash: ethcmn.BytesToHash(suite.ctx.BlockHeader().DataHash).Hex(),
|
||||
}
|
||||
|
||||
suite.app.EvmKeeper.AddTxHashToBlock(suite.ctx, suite.ctx.BlockHeight(), hash)
|
||||
suite.app.EvmKeeper.SetTxReceiptToHash(suite.ctx, hash, receipt)
|
||||
expRes = &types.QueryTxReceiptsByBlockHeightResponse{
|
||||
Receipts: []*types.TxReceipt{receipt},
|
||||
}
|
||||
},
|
||||
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.TxReceiptsByBlockHeight(ctx, req)
|
||||
|
||||
if tc.expPass {
|
||||
suite.Require().NoError(err)
|
||||
suite.Require().NotNil(res)
|
||||
|
||||
suite.Require().Equal(expRes, res)
|
||||
} else {
|
||||
suite.Require().Error(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestQueryBlockBloom() {
|
||||
var (
|
||||
req *types.QueryBlockBloomRequest
|
||||
|
||||
@@ -144,20 +144,6 @@ func (k Keeper) SetBlockBloomTransient(bloom *big.Int) {
|
||||
store.Set(types.KeyPrefixTransientBloom, bloom.Bytes())
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Block
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// SetTxReceiptToHash sets the mapping from tx hash to tx receipt
|
||||
func (k Keeper) SetTxReceiptToHash(ctx sdk.Context, hash common.Hash, receipt *types.TxReceipt) {
|
||||
ctx = ctx.WithGasMeter(sdk.NewInfiniteGasMeter())
|
||||
|
||||
data := k.cdc.MustMarshalBinaryBare(receipt)
|
||||
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
store.Set(types.KeyHashTxReceipt(hash), data)
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Tx
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -187,85 +173,6 @@ func (k Keeper) ResetRefundTransient(ctx sdk.Context) {
|
||||
store.Delete(types.KeyPrefixTransientRefund)
|
||||
}
|
||||
|
||||
// GetTxReceiptFromHash gets tx receipt by tx hash.
|
||||
func (k Keeper) GetTxReceiptFromHash(ctx sdk.Context, hash common.Hash) (*types.TxReceipt, bool) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
data := store.Get(types.KeyHashTxReceipt(hash))
|
||||
if len(data) == 0 {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
var receipt types.TxReceipt
|
||||
k.cdc.MustUnmarshalBinaryBare(data, &receipt)
|
||||
|
||||
return &receipt, true
|
||||
}
|
||||
|
||||
// AddTxHashToBlock stores tx hash in the list of tx for the block.
|
||||
func (k Keeper) AddTxHashToBlock(ctx sdk.Context, blockHeight int64, txHash common.Hash) {
|
||||
key := types.KeyBlockHeightTxs(uint64(blockHeight))
|
||||
|
||||
list := types.BytesList{}
|
||||
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
data := store.Get(key)
|
||||
if len(data) > 0 {
|
||||
k.cdc.MustUnmarshalBinaryBare(data, &list)
|
||||
}
|
||||
|
||||
list.Bytes = append(list.Bytes, txHash.Bytes())
|
||||
|
||||
data = k.cdc.MustMarshalBinaryBare(&list)
|
||||
store.Set(key, data)
|
||||
}
|
||||
|
||||
// GetTxsFromBlock returns list of tx hash in the block by height.
|
||||
func (k Keeper) GetTxsFromBlock(ctx sdk.Context, blockHeight uint64) []common.Hash {
|
||||
key := types.KeyBlockHeightTxs(blockHeight)
|
||||
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
data := store.Get(key)
|
||||
if len(data) > 0 {
|
||||
list := types.BytesList{}
|
||||
k.cdc.MustUnmarshalBinaryBare(data, &list)
|
||||
|
||||
txs := make([]common.Hash, 0, len(list.Bytes))
|
||||
for _, b := range list.Bytes {
|
||||
txs = append(txs, common.BytesToHash(b))
|
||||
}
|
||||
|
||||
return txs
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetTxReceiptsByBlockHeight gets tx receipts by block height.
|
||||
func (k Keeper) GetTxReceiptsByBlockHeight(ctx sdk.Context, blockHeight uint64) []*types.TxReceipt {
|
||||
txs := k.GetTxsFromBlock(ctx, blockHeight)
|
||||
if len(txs) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
|
||||
receipts := make([]*types.TxReceipt, 0, len(txs))
|
||||
|
||||
for idx, txHash := range txs {
|
||||
data := store.Get(types.KeyHashTxReceipt(txHash))
|
||||
if len(data) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
var receipt types.TxReceipt
|
||||
k.cdc.MustUnmarshalBinaryBare(data, &receipt)
|
||||
receipt.Index = uint64(idx)
|
||||
receipts = append(receipts, &receipt)
|
||||
}
|
||||
|
||||
return receipts
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Log
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"github.com/armon/go-metrics"
|
||||
ethcmn "github.com/ethereum/go-ethereum/common"
|
||||
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
|
||||
tmtypes "github.com/tendermint/tendermint/types"
|
||||
@@ -55,6 +56,9 @@ func (k *Keeper) EthereumTx(goCtx context.Context, msg *types.MsgEthereumTx) (*t
|
||||
txHash := tmtypes.Tx(ctx.TxBytes()).Hash()
|
||||
ethHash := ethcmn.BytesToHash(txHash)
|
||||
|
||||
// Ethereum formatted tx hash
|
||||
etherumTxHash := msg.AsTransaction().Hash()
|
||||
|
||||
st := &types.StateTransition{
|
||||
Message: ethMsg,
|
||||
Csdb: k.CommitStateDB.WithContext(ctx),
|
||||
@@ -77,25 +81,6 @@ func (k *Keeper) EthereumTx(goCtx context.Context, msg *types.MsgEthereumTx) (*t
|
||||
if errors.Is(err, vm.ErrExecutionReverted) && executionResult != nil {
|
||||
// keep the execution result for revert reason
|
||||
executionResult.Response.Reverted = true
|
||||
|
||||
if !st.Simulate {
|
||||
k.SetTxReceiptToHash(ctx, ethHash, &types.TxReceipt{
|
||||
Hash: ethHash.Hex(),
|
||||
From: sender.Hex(),
|
||||
Data: msg.Data,
|
||||
BlockHeight: uint64(ctx.BlockHeight()),
|
||||
BlockHash: k.headerHash.Hex(),
|
||||
Result: &types.TxResult{
|
||||
ContractAddress: executionResult.Response.ContractAddress,
|
||||
Bloom: executionResult.Response.Bloom,
|
||||
TxLogs: executionResult.Response.TxLogs,
|
||||
Ret: executionResult.Response.Ret,
|
||||
Reverted: executionResult.Response.Reverted,
|
||||
GasUsed: executionResult.GasInfo.GasConsumed,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
return executionResult.Response, nil
|
||||
}
|
||||
|
||||
@@ -108,33 +93,9 @@ func (k *Keeper) EthereumTx(goCtx context.Context, msg *types.MsgEthereumTx) (*t
|
||||
bloom = big.NewInt(0)
|
||||
}
|
||||
// update block bloom filter
|
||||
bloom = bloom.Or(bloom, executionResult.Bloom)
|
||||
logsBloom := ethtypes.LogsBloom(executionResult.Logs)
|
||||
bloom = bloom.Or(bloom, new(big.Int).SetBytes(logsBloom))
|
||||
k.SetBlockBloomTransient(bloom)
|
||||
|
||||
// update transaction logs in KVStore
|
||||
err = k.CommitStateDB.SetLogs(ethHash, executionResult.Logs)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
k.SetTxReceiptToHash(ctx, ethHash, &types.TxReceipt{
|
||||
Hash: ethHash.Hex(),
|
||||
From: sender.Hex(),
|
||||
Data: msg.Data,
|
||||
Index: uint64(st.Csdb.TxIndex()),
|
||||
BlockHeight: uint64(ctx.BlockHeight()),
|
||||
BlockHash: k.headerHash.Hex(),
|
||||
Result: &types.TxResult{
|
||||
ContractAddress: executionResult.Response.ContractAddress,
|
||||
Bloom: executionResult.Response.Bloom,
|
||||
TxLogs: executionResult.Response.TxLogs,
|
||||
Ret: executionResult.Response.Ret,
|
||||
Reverted: executionResult.Response.Reverted,
|
||||
GasUsed: executionResult.GasInfo.GasConsumed,
|
||||
},
|
||||
})
|
||||
|
||||
k.AddTxHashToBlock(ctx, ctx.BlockHeight(), ethHash)
|
||||
}
|
||||
|
||||
defer func() {
|
||||
@@ -155,6 +116,7 @@ func (k *Keeper) EthereumTx(goCtx context.Context, msg *types.MsgEthereumTx) (*t
|
||||
attrs := []sdk.Attribute{
|
||||
sdk.NewAttribute(sdk.AttributeKeyAmount, st.Message.Value().String()),
|
||||
sdk.NewAttribute(types.AttributeKeyTxHash, ethcmn.BytesToHash(txHash).Hex()),
|
||||
sdk.NewAttribute(types.AttributeKeyEthereumTxHash, etherumTxHash.Hex()),
|
||||
}
|
||||
|
||||
if len(msg.Data.To) > 0 {
|
||||
@@ -174,5 +136,6 @@ func (k *Keeper) EthereumTx(goCtx context.Context, msg *types.MsgEthereumTx) (*t
|
||||
),
|
||||
})
|
||||
|
||||
executionResult.Response.Hash = etherumTxHash.Hex()
|
||||
return executionResult.Response, nil
|
||||
}
|
||||
|
||||
@@ -145,10 +145,8 @@ func (k *Keeper) TransitionDb(msg core.Message) (*types.ExecutionResult, error)
|
||||
|
||||
func (k *Keeper) ApplyMessage(evm *vm.EVM, msg core.Message) (*types.ExecutionResult, error) {
|
||||
var (
|
||||
ret []byte // return bytes from evm execution
|
||||
contract common.Address
|
||||
contractAddr string
|
||||
vmErr, err error // vm errors do not effect consensus and are therefore not assigned to err
|
||||
ret []byte // return bytes from evm execution
|
||||
vmErr, err error // vm errors do not effect consensus and are therefore not assigned to err
|
||||
)
|
||||
|
||||
sender := vm.AccountRef(msg.From())
|
||||
@@ -174,8 +172,7 @@ func (k *Keeper) ApplyMessage(evm *vm.EVM, msg core.Message) (*types.ExecutionRe
|
||||
}
|
||||
|
||||
if contractCreation {
|
||||
ret, contract, leftoverGas, vmErr = evm.Create(sender, msg.Data(), leftoverGas, msg.Value())
|
||||
contractAddr = contract.Hex()
|
||||
ret, _, leftoverGas, vmErr = evm.Create(sender, msg.Data(), leftoverGas, msg.Value())
|
||||
} else {
|
||||
ret, leftoverGas, vmErr = evm.Call(sender, *msg.To(), msg.Data(), leftoverGas, msg.Value())
|
||||
}
|
||||
@@ -198,8 +195,7 @@ func (k *Keeper) ApplyMessage(evm *vm.EVM, msg core.Message) (*types.ExecutionRe
|
||||
|
||||
return &types.ExecutionResult{
|
||||
Response: &types.MsgEthereumTxResponse{
|
||||
ContractAddress: contractAddr,
|
||||
Ret: ret,
|
||||
Ret: ret,
|
||||
},
|
||||
GasInfo: types.GasInfo{
|
||||
GasLimit: k.ctx.GasMeter().Limit(),
|
||||
|
||||
@@ -7,6 +7,7 @@ const (
|
||||
AttributeKeyContractAddress = "contract"
|
||||
AttributeKeyRecipient = "recipient"
|
||||
AttributeKeyTxHash = "txHash"
|
||||
AttributeKeyEthereumTxHash = "ethereumTxHash"
|
||||
AttributeValueCategory = ModuleName
|
||||
|
||||
MetricKeyTransitionDB = "transition_db"
|
||||
|
||||
+10
-6
@@ -20,14 +20,9 @@ func NewTransactionLogs(hash ethcmn.Hash, logs []*Log) TransactionLogs { // noli
|
||||
|
||||
// NewTransactionLogsFromEth creates a new NewTransactionLogs instance using []*ethtypes.Log.
|
||||
func NewTransactionLogsFromEth(hash ethcmn.Hash, ethlogs []*ethtypes.Log) TransactionLogs { // nolint: interfacer
|
||||
logs := make([]*Log, len(ethlogs))
|
||||
for i := range ethlogs {
|
||||
logs[i] = NewLogFromEth(ethlogs[i])
|
||||
}
|
||||
|
||||
return TransactionLogs{
|
||||
Hash: hash.String(),
|
||||
Logs: logs,
|
||||
Logs: NewLogsFromEth(ethlogs),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,6 +88,15 @@ func (log *Log) ToEthereum() *ethtypes.Log {
|
||||
}
|
||||
}
|
||||
|
||||
func NewLogsFromEth(ethlogs []*ethtypes.Log) []*Log {
|
||||
var logs []*Log
|
||||
for _, ethlog := range ethlogs {
|
||||
logs = append(logs, NewLogFromEth(ethlog))
|
||||
}
|
||||
|
||||
return logs
|
||||
}
|
||||
|
||||
// LogsToEthereum casts the Ethermint Logs to a slice of Ethereum Logs.
|
||||
func LogsToEthereum(logs []*Log) []*ethtypes.Log {
|
||||
var ethLogs []*ethtypes.Log // nolint: prealloc
|
||||
|
||||
@@ -113,6 +113,7 @@ func (msg *MsgEthereumTx) FromEthereumTx(tx *ethtypes.Transaction) {
|
||||
}
|
||||
|
||||
msg.Size_ = float64(tx.Size())
|
||||
msg.Hash = tx.Hash().Hex()
|
||||
}
|
||||
|
||||
// Route returns the route value of an MsgEthereumTx.
|
||||
|
||||
+74
-818
File diff suppressed because it is too large
Load Diff
@@ -377,78 +377,6 @@ func local_request_Query_TxLogs_0(ctx context.Context, marshaler runtime.Marshal
|
||||
|
||||
}
|
||||
|
||||
func request_Query_TxReceipt_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryTxReceiptRequest
|
||||
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)
|
||||
}
|
||||
|
||||
msg, err := client.TxReceipt(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_TxReceipt_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryTxReceiptRequest
|
||||
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)
|
||||
}
|
||||
|
||||
msg, err := server.TxReceipt(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func request_Query_TxReceiptsByBlockHeight_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryTxReceiptsByBlockHeightRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
msg, err := client.TxReceiptsByBlockHeight(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_TxReceiptsByBlockHeight_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryTxReceiptsByBlockHeightRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
msg, err := server.TxReceiptsByBlockHeight(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}}
|
||||
)
|
||||
@@ -719,46 +647,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_TxReceipt_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_TxReceipt_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_TxReceipt_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_TxReceiptsByBlockHeight_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_TxReceiptsByBlockHeight_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_TxReceiptsByBlockHeight_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()
|
||||
@@ -1000,46 +888,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_TxReceipt_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_TxReceipt_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_TxReceipt_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_TxReceiptsByBlockHeight_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_TxReceiptsByBlockHeight_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_TxReceiptsByBlockHeight_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()
|
||||
@@ -1136,10 +984,6 @@ var (
|
||||
|
||||
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", "v1alpha1", "tx_logs", "hash"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_Query_TxReceipt_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"ethermint", "evm", "v1alpha1", "tx_receipt", "hash"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_Query_TxReceiptsByBlockHeight_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"ethermint", "evm", "v1alpha1", "tx_receipts_block"}, "", 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", "v1alpha1", "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", "v1alpha1", "block_bloom"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
@@ -1162,10 +1006,6 @@ var (
|
||||
|
||||
forward_Query_TxLogs_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_TxReceipt_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_TxReceiptsByBlockHeight_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_BlockLogs_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_BlockBloom_0 = runtime.ForwardResponseMessage
|
||||
|
||||
@@ -242,12 +242,8 @@ func (st *StateTransition) TransitionDb(ctx sdk.Context, config ChainConfig) (re
|
||||
// Resets nonce to value pre state transition
|
||||
csdb.SetNonce(st.Message.From(), currentNonce)
|
||||
|
||||
// Generate bloom filter to be saved in tx receipt data
|
||||
bloomInt := big.NewInt(0)
|
||||
|
||||
var (
|
||||
bloomFilter ethtypes.Bloom
|
||||
logs []*ethtypes.Log
|
||||
logs []*ethtypes.Log
|
||||
)
|
||||
|
||||
if st.TxHash != nil && !st.Simulate {
|
||||
@@ -256,9 +252,6 @@ func (st *StateTransition) TransitionDb(ctx sdk.Context, config ChainConfig) (re
|
||||
err = errors.Wrap(err, "failed to get logs")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
bloomInt = big.NewInt(0).SetBytes(ethtypes.LogsBloom(logs))
|
||||
bloomFilter = ethtypes.BytesToBloom(bloomInt.Bytes())
|
||||
}
|
||||
|
||||
if !st.Simulate {
|
||||
@@ -270,15 +263,9 @@ func (st *StateTransition) TransitionDb(ctx sdk.Context, config ChainConfig) (re
|
||||
}
|
||||
|
||||
resp.Logs = logs
|
||||
resp.Bloom = bloomInt
|
||||
resp.Response = &MsgEthereumTxResponse{
|
||||
Bloom: bloomFilter.Bytes(),
|
||||
TxLogs: NewTransactionLogsFromEth(*st.TxHash, logs),
|
||||
Ret: ret,
|
||||
}
|
||||
|
||||
if contractCreation {
|
||||
resp.Response.ContractAddress = contractAddress.String()
|
||||
Logs: NewLogsFromEth(logs),
|
||||
Ret: ret,
|
||||
}
|
||||
|
||||
// TODO: Refund unused gas here, if intended in future
|
||||
|
||||
+66
-109
@@ -150,19 +150,16 @@ var xxx_messageInfo_ExtensionOptionsWeb3Tx proto.InternalMessageInfo
|
||||
|
||||
// MsgEthereumTxResponse defines the Msg/EthereumTx response type.
|
||||
type MsgEthereumTxResponse struct {
|
||||
// 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.
|
||||
ContractAddress string `protobuf:"bytes,1,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty" yaml:"contract_address"`
|
||||
// bloom represents the bloom filter bytes
|
||||
Bloom []byte `protobuf:"bytes,2,opt,name=bloom,proto3" json:"bloom,omitempty"`
|
||||
// tx_logs contains the transaction hash and the proto-compatible ethereum
|
||||
// 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
|
||||
Hash string `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"`
|
||||
// logs contains the transaction hash and the proto-compatible ethereum
|
||||
// logs.
|
||||
TxLogs TransactionLogs `protobuf:"bytes,3,opt,name=tx_logs,json=txLogs,proto3" json:"tx_logs" yaml:"tx_logs"`
|
||||
// ret defines the bytes from the execution.
|
||||
Ret []byte `protobuf:"bytes,4,opt,name=ret,proto3" json:"ret,omitempty"`
|
||||
Logs []*Log `protobuf:"bytes,2,rep,name=logs,proto3" json:"logs,omitempty"`
|
||||
// returned data from evm function (result or data supplied with revert opcode)
|
||||
Ret []byte `protobuf:"bytes,3,opt,name=ret,proto3" json:"ret,omitempty"`
|
||||
// reverted flag is set to true when the call has been reverted
|
||||
Reverted bool `protobuf:"varint,5,opt,name=reverted,proto3" json:"reverted,omitempty"`
|
||||
Reverted bool `protobuf:"varint,4,opt,name=reverted,proto3" json:"reverted,omitempty"`
|
||||
}
|
||||
|
||||
func (m *MsgEthereumTxResponse) Reset() { *m = MsgEthereumTxResponse{} }
|
||||
@@ -208,37 +205,33 @@ func init() {
|
||||
func init() { proto.RegisterFile("ethermint/evm/v1alpha1/tx.proto", fileDescriptor_6a305e80b084ab0e) }
|
||||
|
||||
var fileDescriptor_6a305e80b084ab0e = []byte{
|
||||
// 476 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0x3f, 0x6f, 0xd3, 0x40,
|
||||
0x18, 0xc6, 0x7d, 0x8d, 0xd3, 0x3f, 0x97, 0x02, 0xd5, 0xa9, 0x04, 0x63, 0x24, 0xdb, 0xb2, 0x84,
|
||||
0x9a, 0x25, 0xb6, 0x9a, 0x6e, 0xd9, 0x6a, 0x51, 0x26, 0x2a, 0xa4, 0x53, 0x25, 0x10, 0x4b, 0x75,
|
||||
0x76, 0x0e, 0xdb, 0x92, 0xed, 0xb3, 0xee, 0xae, 0x91, 0xcb, 0xca, 0xc2, 0xc8, 0xca, 0xc6, 0xc7,
|
||||
0xe9, 0xd8, 0x91, 0xc9, 0x42, 0xc9, 0xc6, 0x98, 0x4f, 0x80, 0x7c, 0x6e, 0x52, 0x1a, 0x11, 0xa9,
|
||||
0xdb, 0x7b, 0xef, 0xfb, 0xf3, 0xf9, 0x79, 0x9e, 0x7b, 0xa1, 0x4d, 0x65, 0x42, 0x79, 0x9e, 0x16,
|
||||
0xd2, 0xa7, 0xd3, 0xdc, 0x9f, 0x1e, 0x93, 0xac, 0x4c, 0xc8, 0xb1, 0x2f, 0x2b, 0xaf, 0xe4, 0x4c,
|
||||
0x32, 0xd4, 0x5f, 0x01, 0x1e, 0x9d, 0xe6, 0xde, 0x12, 0x30, 0x0f, 0x63, 0x16, 0x33, 0x85, 0xf8,
|
||||
0x4d, 0xd5, 0xd2, 0xa6, 0xb3, 0xe1, 0xba, 0xe6, 0x53, 0x45, 0xb8, 0x3f, 0x00, 0x7c, 0x72, 0x2e,
|
||||
0xe2, 0xb3, 0x86, 0xa3, 0x57, 0xf9, 0x45, 0x85, 0x46, 0x50, 0x9f, 0x10, 0x49, 0x0c, 0xe0, 0x80,
|
||||
0x41, 0x6f, 0x64, 0x79, 0xff, 0xff, 0xa1, 0x77, 0x51, 0xbd, 0x21, 0x92, 0x60, 0xc5, 0xa2, 0x97,
|
||||
0x50, 0x17, 0xe9, 0x17, 0x6a, 0x6c, 0x39, 0x60, 0x00, 0x82, 0xee, 0x9f, 0xda, 0x06, 0x43, 0xac,
|
||||
0x5a, 0xc8, 0x86, 0x7a, 0x42, 0x44, 0x62, 0x74, 0x1c, 0x30, 0xd8, 0x0b, 0x7a, 0x8b, 0xda, 0xde,
|
||||
0xe1, 0x59, 0x39, 0x76, 0x87, 0x2e, 0x56, 0x03, 0x84, 0xa0, 0xfe, 0x99, 0xb3, 0xdc, 0xd0, 0x1b,
|
||||
0x00, 0xab, 0x7a, 0xac, 0x7f, 0xfb, 0x69, 0x6b, 0xae, 0x0b, 0xcd, 0xb3, 0x4a, 0xd2, 0x42, 0xa4,
|
||||
0xac, 0x78, 0x5f, 0xca, 0x94, 0x15, 0xe2, 0x5e, 0xe7, 0x1d, 0x63, 0xc1, 0xfe, 0x3a, 0xf3, 0x81,
|
||||
0x86, 0x27, 0xab, 0xf9, 0xd7, 0x2d, 0xf8, 0xfc, 0x81, 0x3f, 0x4c, 0x45, 0xc9, 0x0a, 0x41, 0xd1,
|
||||
0x5b, 0x78, 0x10, 0xb1, 0x42, 0x72, 0x12, 0xc9, 0x4b, 0x32, 0x99, 0x70, 0x2a, 0x84, 0xf2, 0xbc,
|
||||
0x17, 0xbc, 0x5a, 0xd4, 0xf6, 0x8b, 0x6b, 0x92, 0x67, 0x63, 0x77, 0x9d, 0x70, 0xf1, 0xb3, 0x65,
|
||||
0xeb, 0xb4, 0xed, 0xa0, 0x43, 0xd8, 0x0d, 0x33, 0xc6, 0x72, 0x65, 0x7e, 0x1f, 0xb7, 0x07, 0xf4,
|
||||
0x11, 0xee, 0xc8, 0xea, 0x32, 0x63, 0xb1, 0x50, 0xce, 0x7b, 0xa3, 0xa3, 0x8d, 0x41, 0x72, 0x52,
|
||||
0x08, 0x12, 0x35, 0xd2, 0xdf, 0xb1, 0x58, 0x04, 0xfd, 0x9b, 0xda, 0xd6, 0x16, 0xb5, 0xfd, 0xb4,
|
||||
0x55, 0x70, 0x77, 0x8b, 0x8b, 0xb7, 0x65, 0xd5, 0xcc, 0xd1, 0x01, 0xec, 0x70, 0x2a, 0x55, 0x5c,
|
||||
0xfb, 0xb8, 0x29, 0x91, 0x09, 0x77, 0x39, 0x9d, 0x52, 0x2e, 0xe9, 0xc4, 0xe8, 0x3a, 0x60, 0xb0,
|
||||
0x8b, 0x57, 0xe7, 0x36, 0x85, 0x51, 0x0a, 0x3b, 0xe7, 0x22, 0x46, 0x21, 0x84, 0xff, 0x3c, 0xf4,
|
||||
0xeb, 0x4d, 0x8a, 0x1e, 0xe4, 0x65, 0x0e, 0x1f, 0x85, 0x2d, 0x63, 0x0d, 0x4e, 0x6f, 0x66, 0x16,
|
||||
0xb8, 0x9d, 0x59, 0xe0, 0xf7, 0xcc, 0x02, 0xdf, 0xe7, 0x96, 0x76, 0x3b, 0xb7, 0xb4, 0x5f, 0x73,
|
||||
0x4b, 0xfb, 0x74, 0x14, 0xa7, 0x32, 0xb9, 0x0a, 0xbd, 0x88, 0xe5, 0x7e, 0xc4, 0x44, 0xce, 0x84,
|
||||
0x7f, 0xbf, 0x9e, 0x95, 0x5a, 0x50, 0x79, 0x5d, 0x52, 0x11, 0x6e, 0xab, 0xd5, 0x3c, 0xf9, 0x1b,
|
||||
0x00, 0x00, 0xff, 0xff, 0x74, 0xe0, 0xdf, 0x68, 0x0d, 0x03, 0x00, 0x00,
|
||||
// 404 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0x31, 0x6b, 0xdb, 0x40,
|
||||
0x1c, 0xc5, 0x75, 0x96, 0xda, 0xba, 0xe7, 0x16, 0xca, 0xd1, 0x1a, 0x55, 0x85, 0x93, 0x10, 0x94,
|
||||
0x6a, 0xb1, 0x84, 0xe5, 0xcd, 0x5b, 0x4d, 0xbd, 0xd5, 0x14, 0x0e, 0x43, 0xa1, 0x9b, 0x64, 0x5f,
|
||||
0x25, 0x81, 0xa5, 0x13, 0xba, 0xb3, 0x50, 0xf2, 0x09, 0x32, 0x7a, 0xcd, 0x96, 0x8f, 0x93, 0xd1,
|
||||
0x63, 0x26, 0x13, 0xec, 0x2d, 0x63, 0x3e, 0x41, 0xd0, 0x39, 0xb6, 0xe3, 0x10, 0x43, 0xb6, 0xbf,
|
||||
0xf4, 0xff, 0xdd, 0xbd, 0xf7, 0x8e, 0x07, 0x4d, 0x2a, 0x62, 0x5a, 0xa4, 0x49, 0x26, 0x3c, 0x5a,
|
||||
0xa6, 0x5e, 0xd9, 0x0d, 0x66, 0x79, 0x1c, 0x74, 0x3d, 0x51, 0xb9, 0x79, 0xc1, 0x04, 0x43, 0xed,
|
||||
0x3d, 0xe0, 0xd2, 0x32, 0x75, 0x77, 0x80, 0xf1, 0x39, 0x62, 0x11, 0x93, 0x88, 0x57, 0x4f, 0x5b,
|
||||
0xda, 0xb0, 0x4e, 0x5c, 0x57, 0x1f, 0x95, 0x84, 0x7d, 0x09, 0xe0, 0xc7, 0x11, 0x8f, 0x86, 0x35,
|
||||
0x47, 0xe7, 0xe9, 0xb8, 0x42, 0x3e, 0xd4, 0xa6, 0x81, 0x08, 0x74, 0x60, 0x01, 0xa7, 0xe5, 0x63,
|
||||
0xf7, 0x65, 0x41, 0x77, 0x5c, 0xfd, 0x0a, 0x44, 0x40, 0x24, 0x8b, 0xbe, 0x42, 0x8d, 0x27, 0xe7,
|
||||
0x54, 0x6f, 0x58, 0xc0, 0x01, 0x83, 0x37, 0x77, 0x2b, 0x13, 0x74, 0x88, 0xfc, 0x85, 0x4c, 0xa8,
|
||||
0xc5, 0x01, 0x8f, 0x75, 0xd5, 0x02, 0xce, 0xfb, 0x41, 0xeb, 0x7e, 0x65, 0xbe, 0x2b, 0x66, 0x79,
|
||||
0xdf, 0xee, 0xd8, 0x44, 0x2e, 0x10, 0x82, 0xda, 0xff, 0x82, 0xa5, 0xba, 0x56, 0x03, 0x44, 0xce,
|
||||
0x7d, 0xed, 0xe2, 0xca, 0x54, 0x6c, 0x1b, 0x1a, 0xc3, 0x4a, 0xd0, 0x8c, 0x27, 0x2c, 0xfb, 0x93,
|
||||
0x8b, 0x84, 0x65, 0xfc, 0xe0, 0xf3, 0x91, 0xc1, 0xb0, 0xfd, 0x9c, 0xf9, 0x4b, 0xc3, 0xde, 0x7e,
|
||||
0xbf, 0x00, 0xf0, 0xcb, 0x51, 0x3e, 0x42, 0x79, 0xce, 0x32, 0x4e, 0x6b, 0x5d, 0x69, 0x0c, 0x6c,
|
||||
0x75, 0xa5, 0x17, 0x0f, 0x6a, 0x33, 0x16, 0x71, 0xbd, 0x61, 0xa9, 0x4e, 0xcb, 0xff, 0x76, 0x2a,
|
||||
0xfb, 0x6f, 0x16, 0x11, 0x09, 0xa2, 0x4f, 0x50, 0x2d, 0xa8, 0x90, 0xe1, 0x3e, 0x90, 0x7a, 0x44,
|
||||
0x06, 0x6c, 0x16, 0xb4, 0xa4, 0x85, 0xa0, 0x53, 0x19, 0xa9, 0x49, 0xf6, 0xdf, 0x5b, 0x4b, 0x7e,
|
||||
0x02, 0xd5, 0x11, 0x8f, 0x50, 0x08, 0xe1, 0x93, 0x57, 0xff, 0x7e, 0x4a, 0xeb, 0xc8, 0xbc, 0xd1,
|
||||
0x79, 0x15, 0xb6, 0xcb, 0x38, 0xf8, 0x79, 0xbd, 0xc6, 0x60, 0xb9, 0xc6, 0xe0, 0x76, 0x8d, 0xc1,
|
||||
0x62, 0x83, 0x95, 0xe5, 0x06, 0x2b, 0x37, 0x1b, 0xac, 0xfc, 0xfb, 0x11, 0x25, 0x22, 0x9e, 0x87,
|
||||
0xee, 0x84, 0xa5, 0xde, 0x84, 0xf1, 0x94, 0x71, 0xef, 0xd0, 0x95, 0x4a, 0xb6, 0x45, 0x9c, 0xe5,
|
||||
0x94, 0x87, 0x6f, 0x65, 0x4f, 0x7a, 0x0f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x9c, 0x61, 0x2c, 0xf2,
|
||||
0x9a, 0x02, 0x00, 0x00,
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
@@ -452,36 +445,33 @@ func (m *MsgEthereumTxResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
dAtA[i] = 0
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x28
|
||||
dAtA[i] = 0x20
|
||||
}
|
||||
if len(m.Ret) > 0 {
|
||||
i -= len(m.Ret)
|
||||
copy(dAtA[i:], m.Ret)
|
||||
i = encodeVarintTx(dAtA, i, uint64(len(m.Ret)))
|
||||
i--
|
||||
dAtA[i] = 0x22
|
||||
dAtA[i] = 0x1a
|
||||
}
|
||||
{
|
||||
size, err := m.TxLogs.MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
if len(m.Logs) > 0 {
|
||||
for iNdEx := len(m.Logs) - 1; iNdEx >= 0; iNdEx-- {
|
||||
{
|
||||
size, err := m.Logs[iNdEx].MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintTx(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintTx(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x1a
|
||||
if len(m.Bloom) > 0 {
|
||||
i -= len(m.Bloom)
|
||||
copy(dAtA[i:], m.Bloom)
|
||||
i = encodeVarintTx(dAtA, i, uint64(len(m.Bloom)))
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
if len(m.ContractAddress) > 0 {
|
||||
i -= len(m.ContractAddress)
|
||||
copy(dAtA[i:], m.ContractAddress)
|
||||
i = encodeVarintTx(dAtA, i, uint64(len(m.ContractAddress)))
|
||||
if len(m.Hash) > 0 {
|
||||
i -= len(m.Hash)
|
||||
copy(dAtA[i:], m.Hash)
|
||||
i = encodeVarintTx(dAtA, i, uint64(len(m.Hash)))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
@@ -547,16 +537,16 @@ func (m *MsgEthereumTxResponse) Size() (n int) {
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = len(m.ContractAddress)
|
||||
l = len(m.Hash)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovTx(uint64(l))
|
||||
}
|
||||
l = len(m.Bloom)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovTx(uint64(l))
|
||||
if len(m.Logs) > 0 {
|
||||
for _, e := range m.Logs {
|
||||
l = e.Size()
|
||||
n += 1 + l + sovTx(uint64(l))
|
||||
}
|
||||
}
|
||||
l = m.TxLogs.Size()
|
||||
n += 1 + l + sovTx(uint64(l))
|
||||
l = len(m.Ret)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovTx(uint64(l))
|
||||
@@ -874,7 +864,7 @@ func (m *MsgEthereumTxResponse) Unmarshal(dAtA []byte) error {
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field ContractAddress", wireType)
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
@@ -902,45 +892,11 @@ func (m *MsgEthereumTxResponse) Unmarshal(dAtA []byte) error {
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.ContractAddress = string(dAtA[iNdEx:postIndex])
|
||||
m.Hash = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Bloom", wireType)
|
||||
}
|
||||
var byteLen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTx
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
byteLen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if byteLen < 0 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
postIndex := iNdEx + byteLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Bloom = append(m.Bloom[:0], dAtA[iNdEx:postIndex]...)
|
||||
if m.Bloom == nil {
|
||||
m.Bloom = []byte{}
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 3:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field TxLogs", wireType)
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Logs", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
@@ -967,11 +923,12 @@ func (m *MsgEthereumTxResponse) Unmarshal(dAtA []byte) error {
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if err := m.TxLogs.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
m.Logs = append(m.Logs, &Log{})
|
||||
if err := m.Logs[len(m.Logs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 4:
|
||||
case 3:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Ret", wireType)
|
||||
}
|
||||
@@ -1005,7 +962,7 @@ func (m *MsgEthereumTxResponse) Unmarshal(dAtA []byte) error {
|
||||
m.Ret = []byte{}
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 5:
|
||||
case 4:
|
||||
if wireType != 0 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Reverted", wireType)
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
ethcmn "github.com/ethereum/go-ethereum/common"
|
||||
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
||||
ethcrypto "github.com/ethereum/go-ethereum/crypto"
|
||||
)
|
||||
|
||||
@@ -23,20 +22,13 @@ func GenerateEthAddress() ethcmn.Address {
|
||||
}
|
||||
|
||||
func TestEvmDataEncoding(t *testing.T) {
|
||||
addr := "0x5dE8a020088a2D6d0a23c204FFbeD02790466B49"
|
||||
bloom := ethtypes.BytesToBloom([]byte{0x1, 0x3})
|
||||
ret := []byte{0x5, 0x8}
|
||||
|
||||
data := &MsgEthereumTxResponse{
|
||||
ContractAddress: addr,
|
||||
Bloom: bloom.Bytes(),
|
||||
TxLogs: TransactionLogs{
|
||||
Hash: ethcmn.BytesToHash([]byte{1, 2, 3, 4}).String(),
|
||||
Logs: []*Log{{
|
||||
Data: []byte{1, 2, 3, 4},
|
||||
BlockNumber: 17,
|
||||
}},
|
||||
},
|
||||
Logs: []*Log{{
|
||||
Data: []byte{1, 2, 3, 4},
|
||||
BlockNumber: 17,
|
||||
}},
|
||||
Ret: ret,
|
||||
}
|
||||
|
||||
@@ -46,8 +38,6 @@ func TestEvmDataEncoding(t *testing.T) {
|
||||
res, err := DecodeTxResponse(enc)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, res)
|
||||
require.Equal(t, addr, res.ContractAddress)
|
||||
require.Equal(t, bloom.Bytes(), res.Bloom)
|
||||
require.Equal(t, data.TxLogs, res.TxLogs)
|
||||
require.Equal(t, data.Logs, res.Logs)
|
||||
require.Equal(t, ret, res.Ret)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user