forked from cerc-io/laconicd-deprecated
rpc: fix BlockBloom not found in header (#258)
* fix context index * return default bloom if cannot be found * fix blockbloom error * fix setting blockbloom transient in ctx * clean comments * remove unused method * update changelog * Update CHANGELOG.md Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
This commit is contained in:
co-authored by
Federico Kunze Küllmer
parent
e09bf23bd0
commit
aab793e7f4
@@ -248,14 +248,14 @@ func (e *EVMBackend) HeaderByNumber(blockNum types.BlockNumber) (*ethtypes.Heade
|
||||
|
||||
req := &evmtypes.QueryBlockBloomRequest{}
|
||||
|
||||
res, err := e.queryClient.BlockBloom(types.ContextWithHeight(resBlock.Block.Height), req)
|
||||
blockBloomResp, err := e.queryClient.BlockBloom(types.ContextWithHeight(resBlock.Block.Height), req)
|
||||
if err != nil {
|
||||
e.logger.Debug("HeaderByNumber BlockBloom failed", "height", resBlock.Block.Height)
|
||||
return nil, err
|
||||
blockBloomResp = &evmtypes.QueryBlockBloomResponse{Bloom: ethtypes.Bloom{}.Bytes()}
|
||||
}
|
||||
|
||||
ethHeader := types.EthHeaderFromTendermint(resBlock.Block.Header)
|
||||
ethHeader.Bloom = ethtypes.BytesToBloom(res.Bloom)
|
||||
ethHeader.Bloom = ethtypes.BytesToBloom(blockBloomResp.Bloom)
|
||||
return ethHeader, nil
|
||||
}
|
||||
|
||||
@@ -269,14 +269,14 @@ func (e *EVMBackend) HeaderByHash(blockHash common.Hash) (*ethtypes.Header, erro
|
||||
|
||||
req := &evmtypes.QueryBlockBloomRequest{}
|
||||
|
||||
res, err := e.queryClient.BlockBloom(types.ContextWithHeight(resBlock.Block.Height), req)
|
||||
blockBloomResp, err := e.queryClient.BlockBloom(types.ContextWithHeight(resBlock.Block.Height), req)
|
||||
if err != nil {
|
||||
e.logger.Debug("HeaderByHash BlockBloom failed", "height", resBlock.Block.Height)
|
||||
return nil, err
|
||||
blockBloomResp = &evmtypes.QueryBlockBloomResponse{Bloom: ethtypes.Bloom{}.Bytes()}
|
||||
}
|
||||
|
||||
ethHeader := types.EthHeaderFromTendermint(resBlock.Block.Header)
|
||||
ethHeader.Bloom = ethtypes.BytesToBloom(res.Bloom)
|
||||
ethHeader.Bloom = ethtypes.BytesToBloom(blockBloomResp.Bloom)
|
||||
return ethHeader, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -33,30 +33,6 @@ func RawTxToEthTx(clientCtx client.Context, txBz tmtypes.Tx) (*evmtypes.MsgEther
|
||||
return ethTx, nil
|
||||
}
|
||||
|
||||
// EthBlockFromTendermint returns a JSON-RPC compatible Ethereum blockfrom a given Tendermint block.
|
||||
func EthBlockFromTendermint(clientCtx client.Context, queryClient *QueryClient, block *tmtypes.Block) (map[string]interface{}, error) {
|
||||
gasLimit, err := BlockMaxGasFromConsensusParams(context.Background(), clientCtx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
transactions, gasUsed, err := EthTransactionsFromTendermint(clientCtx, block.Txs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req := &evmtypes.QueryBlockBloomRequest{}
|
||||
|
||||
res, err := queryClient.BlockBloom(ContextWithHeight(block.Height), req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
bloom := ethtypes.BytesToBloom(res.Bloom)
|
||||
|
||||
return FormatBlock(block.Header, block.Size(), gasLimit, gasUsed, transactions, bloom), nil
|
||||
}
|
||||
|
||||
// NewTransaction returns a transaction that will serialize to the RPC
|
||||
// representation, with the given location metadata set (if available).
|
||||
func NewTransaction(tx *ethtypes.Transaction, blockHash common.Hash, blockNumber uint64, index uint64) *RPCTransaction {
|
||||
|
||||
Reference in New Issue
Block a user