forked from cerc-io/laconicd-deprecated
tests: integration tests with JSON-RPC client (#704)
* tests: integration tests with JSON-RPC client * fix package * tests: networking configuration fixed (#706) * update testnet hdPath, fixes #688 * lint * header * e2e wip * fix getBlock response * enable personal API * changelog Co-authored-by: Guillermo Paoletti <guillermo.paoletti@gmail.com> Co-authored-by: Freddy Caceres <freddy.caceres@crypto.com>
This commit is contained in:
co-authored by
Guillermo Paoletti
Freddy Caceres
parent
481e3b82ce
commit
32c905ab87
@@ -239,8 +239,7 @@ func (e *EVMBackend) EthBlockFromTm(block *tmtypes.Block) (*ethtypes.Block, erro
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ethHeader := types.EthHeaderFromTendermint(block.Header, baseFee)
|
||||
ethHeader.Bloom = bloom
|
||||
ethHeader := types.EthHeaderFromTendermint(block.Header, bloom, baseFee)
|
||||
|
||||
var txs []*ethtypes.Transaction
|
||||
for _, txBz := range block.Txs {
|
||||
@@ -490,8 +489,7 @@ func (e *EVMBackend) HeaderByNumber(blockNum types.BlockNumber) (*ethtypes.Heade
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ethHeader := types.EthHeaderFromTendermint(resBlock.Block.Header, baseFee)
|
||||
ethHeader.Bloom = bloom
|
||||
ethHeader := types.EthHeaderFromTendermint(resBlock.Block.Header, bloom, baseFee)
|
||||
return ethHeader, nil
|
||||
}
|
||||
|
||||
@@ -518,8 +516,7 @@ func (e *EVMBackend) HeaderByHash(blockHash common.Hash) (*ethtypes.Header, erro
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ethHeader := types.EthHeaderFromTendermint(resBlock.Block.Header, baseFee)
|
||||
ethHeader.Bloom = bloom
|
||||
ethHeader := types.EthHeaderFromTendermint(resBlock.Block.Header, bloom, baseFee)
|
||||
return ethHeader, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -271,7 +271,7 @@ func (a *API) BlockProfile(file string, nsec uint) error {
|
||||
|
||||
// CpuProfile turns on CPU profiling for nsec seconds and writes
|
||||
// profile data to file.
|
||||
func (a *API) CpuProfile(file string, nsec uint) error { // nolint: golint, stylecheck
|
||||
func (a *API) CpuProfile(file string, nsec uint) error { // nolint: golint, stylecheck, revive
|
||||
a.logger.Debug("debug_cpuProfile", "file", file, "nsec", nsec)
|
||||
if err := a.StartCPUProfile(file); err != nil {
|
||||
return err
|
||||
|
||||
@@ -260,7 +260,7 @@ func (api *PublicFilterAPI) NewBlockFilter() rpc.ID {
|
||||
|
||||
baseFee := types.BaseFeeFromEvents(data.ResultEndBlock.Events)
|
||||
|
||||
header := types.EthHeaderFromTendermint(data.Header, baseFee)
|
||||
header := types.EthHeaderFromTendermint(data.Header, ethtypes.Bloom{}, baseFee)
|
||||
api.filtersMu.Lock()
|
||||
if f, found := api.filters[headerSub.ID()]; found {
|
||||
f.hashes = append(f.hashes, header.Hash())
|
||||
@@ -312,7 +312,8 @@ func (api *PublicFilterAPI) NewHeads(ctx context.Context) (*rpc.Subscription, er
|
||||
|
||||
baseFee := types.BaseFeeFromEvents(data.ResultEndBlock.Events)
|
||||
|
||||
header := types.EthHeaderFromTendermint(data.Header, baseFee)
|
||||
// TODO: fetch bloom from events
|
||||
header := types.EthHeaderFromTendermint(data.Header, ethtypes.Bloom{}, baseFee)
|
||||
err = notifier.Notify(rpcSub.ID, header)
|
||||
if err != nil {
|
||||
headersSub.err <- err
|
||||
|
||||
@@ -112,9 +112,6 @@ func (bn BlockNumber) Int64() int64 {
|
||||
func (bn BlockNumber) TmHeight() *int64 {
|
||||
if bn < 0 {
|
||||
return nil
|
||||
} else if bn == EthEarliestBlockNumber {
|
||||
var firstHeight int64 = 0
|
||||
return &firstHeight
|
||||
}
|
||||
|
||||
height := bn.Int64()
|
||||
|
||||
+13
-12
@@ -8,15 +8,13 @@ import (
|
||||
"math/big"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
feemarkettypes "github.com/tharsis/ethermint/x/feemarket/types"
|
||||
|
||||
tmbytes "github.com/tendermint/tendermint/libs/bytes"
|
||||
tmtypes "github.com/tendermint/tendermint/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
|
||||
evmtypes "github.com/tharsis/ethermint/x/evm/types"
|
||||
feemarkettypes "github.com/tharsis/ethermint/x/feemarket/types"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
@@ -40,7 +38,7 @@ func RawTxToEthTx(clientCtx client.Context, txBz tmtypes.Tx) (*evmtypes.MsgEther
|
||||
|
||||
// EthHeaderFromTendermint is an util function that returns an Ethereum Header
|
||||
// from a tendermint Header.
|
||||
func EthHeaderFromTendermint(header tmtypes.Header, baseFee *big.Int) *ethtypes.Header {
|
||||
func EthHeaderFromTendermint(header tmtypes.Header, bloom ethtypes.Bloom, baseFee *big.Int) *ethtypes.Header {
|
||||
txHash := ethtypes.EmptyRootHash
|
||||
if len(header.DataHash) == 0 {
|
||||
txHash = common.BytesToHash(header.DataHash)
|
||||
@@ -49,17 +47,17 @@ func EthHeaderFromTendermint(header tmtypes.Header, baseFee *big.Int) *ethtypes.
|
||||
return ðtypes.Header{
|
||||
ParentHash: common.BytesToHash(header.LastBlockID.Hash.Bytes()),
|
||||
UncleHash: ethtypes.EmptyUncleHash,
|
||||
Coinbase: common.Address{},
|
||||
Coinbase: common.BytesToAddress(header.ProposerAddress),
|
||||
Root: common.BytesToHash(header.AppHash),
|
||||
TxHash: txHash,
|
||||
ReceiptHash: ethtypes.EmptyRootHash,
|
||||
Bloom: ethtypes.Bloom{},
|
||||
Bloom: bloom,
|
||||
Difficulty: big.NewInt(0),
|
||||
Number: big.NewInt(header.Height),
|
||||
GasLimit: 0,
|
||||
GasUsed: 0,
|
||||
Time: uint64(header.Time.Unix()),
|
||||
Extra: nil,
|
||||
Time: uint64(header.Time.UTC().Unix()),
|
||||
Extra: []byte{},
|
||||
MixDigest: common.Hash{},
|
||||
Nonce: ethtypes.BlockNonce{},
|
||||
BaseFee: baseFee,
|
||||
@@ -88,11 +86,14 @@ func BlockMaxGasFromConsensusParams(ctx context.Context, clientCtx client.Contex
|
||||
// transactions.
|
||||
func FormatBlock(
|
||||
header tmtypes.Header, size int, gasLimit int64,
|
||||
gasUsed *big.Int, transactions interface{}, bloom ethtypes.Bloom,
|
||||
gasUsed *big.Int, transactions []interface{}, bloom ethtypes.Bloom,
|
||||
validatorAddr common.Address, baseFee *big.Int,
|
||||
) map[string]interface{} {
|
||||
if len(header.DataHash) == 0 {
|
||||
header.DataHash = tmbytes.HexBytes(common.Hash{}.Bytes())
|
||||
var transactionsRoot common.Hash
|
||||
if len(transactions) == 0 {
|
||||
transactionsRoot = ethtypes.EmptyRootHash
|
||||
} else {
|
||||
transactionsRoot = common.BytesToHash(header.DataHash)
|
||||
}
|
||||
|
||||
return map[string]interface{}{
|
||||
@@ -111,7 +112,7 @@ func FormatBlock(
|
||||
"gasLimit": hexutil.Uint64(gasLimit), // Static gas limit
|
||||
"gasUsed": (*hexutil.Big)(gasUsed),
|
||||
"timestamp": hexutil.Uint64(header.Time.Unix()),
|
||||
"transactionsRoot": hexutil.Bytes(header.DataHash),
|
||||
"transactionsRoot": transactionsRoot,
|
||||
"receiptsRoot": ethtypes.EmptyRootHash,
|
||||
"baseFeePerGas": (*hexutil.Big)(baseFee),
|
||||
|
||||
|
||||
+2
-1
@@ -16,6 +16,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/eth/filters"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
@@ -381,7 +382,7 @@ func (api *pubSubAPI) subscribeNewHeads(wsConn *wsConn) (rpc.ID, error) {
|
||||
continue
|
||||
}
|
||||
|
||||
header := types.EthHeaderFromTendermint(data.Header, baseFee)
|
||||
header := types.EthHeaderFromTendermint(data.Header, ethtypes.Bloom{}, baseFee)
|
||||
|
||||
api.filtersMu.RLock()
|
||||
for subID, wsSub := range api.filters {
|
||||
|
||||
Reference in New Issue
Block a user