forked from cerc-io/laconicd-deprecated
fix(evm,rpc): coinbase should not be the current one in traceTransaction execution (#1392)
* add proposer address * make proto-all * update nix * fix test * keep default proposerAddress * add change doc * refine GetProposerAddress with test * include ProposerAddress for trace api * fix eth call req * wrap proposerAddress for eth call * allow proto translates to sdk.ConsAddress * Update rpc/backend/call_tx.go Co-authored-by: Freddy Caceres <facs95@gmail.com> Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
This commit is contained in:
co-authored by
Freddy Caceres
Federico Kunze Küllmer
parent
f04b289e75
commit
295a8862db
+16
-9
@@ -8,6 +8,7 @@ import (
|
||||
"math/big"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
@@ -298,17 +299,18 @@ func (b *Backend) EstimateGas(args evmtypes.TransactionArgs, blockNrOptional *rp
|
||||
return 0, err
|
||||
}
|
||||
|
||||
req := evmtypes.EthCallRequest{
|
||||
Args: bz,
|
||||
GasCap: b.RPCGasCap(),
|
||||
}
|
||||
|
||||
_, err = b.TendermintBlockByNumber(blockNr)
|
||||
header, err := b.TendermintBlockByNumber(blockNr)
|
||||
if err != nil {
|
||||
// the error message imitates geth behavior
|
||||
return 0, errors.New("header not found")
|
||||
}
|
||||
|
||||
req := evmtypes.EthCallRequest{
|
||||
Args: bz,
|
||||
GasCap: b.RPCGasCap(),
|
||||
ProposerAddress: sdk.ConsAddress(header.Block.ProposerAddress),
|
||||
}
|
||||
|
||||
// From ContextWithHeight: if the provided height is 0,
|
||||
// it will return an empty context and the gRPC query will use
|
||||
// the latest block height for querying.
|
||||
@@ -328,10 +330,15 @@ func (b *Backend) DoCall(
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
header, err := b.TendermintBlockByNumber(blockNr)
|
||||
if err != nil {
|
||||
// the error message imitates geth behavior
|
||||
return nil, errors.New("header not found")
|
||||
}
|
||||
req := evmtypes.EthCallRequest{
|
||||
Args: bz,
|
||||
GasCap: b.RPCGasCap(),
|
||||
Args: bz,
|
||||
GasCap: b.RPCGasCap(),
|
||||
ProposerAddress: sdk.ConsAddress(header.Block.ProposerAddress),
|
||||
}
|
||||
|
||||
// From ContextWithHeight: if the provided height is 0,
|
||||
|
||||
+13
-10
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
rpctypes "github.com/evmos/ethermint/rpc/types"
|
||||
evmtypes "github.com/evmos/ethermint/x/evm/types"
|
||||
@@ -77,11 +78,12 @@ func (b *Backend) TraceTransaction(hash common.Hash, config *evmtypes.TraceConfi
|
||||
}
|
||||
|
||||
traceTxRequest := evmtypes.QueryTraceTxRequest{
|
||||
Msg: ethMessage,
|
||||
Predecessors: predecessors,
|
||||
BlockNumber: blk.Block.Height,
|
||||
BlockTime: blk.Block.Time,
|
||||
BlockHash: common.Bytes2Hex(blk.BlockID.Hash),
|
||||
Msg: ethMessage,
|
||||
Predecessors: predecessors,
|
||||
BlockNumber: blk.Block.Height,
|
||||
BlockTime: blk.Block.Time,
|
||||
BlockHash: common.Bytes2Hex(blk.BlockID.Hash),
|
||||
ProposerAddress: sdk.ConsAddress(blk.Block.ProposerAddress),
|
||||
}
|
||||
|
||||
if config != nil {
|
||||
@@ -154,11 +156,12 @@ func (b *Backend) TraceBlock(height rpctypes.BlockNumber,
|
||||
ctxWithHeight := rpctypes.ContextWithHeight(int64(contextHeight))
|
||||
|
||||
traceBlockRequest := &evmtypes.QueryTraceBlockRequest{
|
||||
Txs: txsMessages,
|
||||
TraceConfig: config,
|
||||
BlockNumber: block.Block.Height,
|
||||
BlockTime: block.Block.Time,
|
||||
BlockHash: common.Bytes2Hex(block.BlockID.Hash),
|
||||
Txs: txsMessages,
|
||||
TraceConfig: config,
|
||||
BlockNumber: block.Block.Height,
|
||||
BlockTime: block.Block.Time,
|
||||
BlockHash: common.Bytes2Hex(block.BlockID.Hash),
|
||||
ProposerAddress: sdk.ConsAddress(block.Block.ProposerAddress),
|
||||
}
|
||||
|
||||
res, err := b.queryClient.TraceBlock(ctxWithHeight, traceBlockRequest)
|
||||
|
||||
Reference in New Issue
Block a user