diff --git a/rpc/backend/evm_backend.go b/rpc/backend/evm_backend.go index d5d8a84a86..1f22c20709 100644 --- a/rpc/backend/evm_backend.go +++ b/rpc/backend/evm_backend.go @@ -281,8 +281,13 @@ func (b *Backend) EthBlockFromTendermint( if err != nil { return nil, err } + b.logger.Info("address", "addr", addr) validatorAddr := common.BytesToAddress(addr) + b.logger.Info("validator address", "validatorAddr", validatorAddr) + + headerAddr := common.BytesToAddress(resBlock.Block.Header.ProposerAddress) + b.logger.Info("header address", "headerAddr", headerAddr) gasLimit, err := types.BlockMaxGasFromConsensusParams(ctx, b.clientCtx, block.Height) if err != nil { @@ -299,12 +304,30 @@ func (b *Backend) EthBlockFromTendermint( } gasUsed += uint64(txsResult.GetGasUsed()) } + resBlock.Block.Header.Hash() formattedBlock := types.FormatBlock( block.Header, block.Size(), gasLimit, new(big.Int).SetUint64(gasUsed), ethRPCTxs, bloom, validatorAddr, baseFee, ) + blockJson, err := json.Marshal(formattedBlock) + if err != nil { + return nil, err + } + b.logger.Info("headerJson", "headerJson", string(blockJson)) + var ethHeader ethtypes.Header + err = json.Unmarshal(blockJson, ðHeader) + if err != nil { + return nil, err + } + b.logger.Info("ethHeader", "ethHeader", ethHeader) + + ethHash := ethHeader.Hash() + b.logger.Info("ethHash", "ethHash", ethHash) + + formattedBlock["hash"] = ethHash + return formattedBlock, nil } diff --git a/rpc/namespaces/ethereum/eth/api.go b/rpc/namespaces/ethereum/eth/api.go index 07add625ac..6c38aeb1ed 100644 --- a/rpc/namespaces/ethereum/eth/api.go +++ b/rpc/namespaces/ethereum/eth/api.go @@ -729,7 +729,7 @@ func (e *PublicAPI) EstimateGas(args evmtypes.TransactionArgs, blockNrOptional * // GetBlockByHash returns the block identified by hash. func (e *PublicAPI) GetBlockByHash(hash common.Hash, fullTx bool) (map[string]interface{}, error) { - e.logger.Debug("eth_getBlockByHash", "hash", hash.Hex(), "full", fullTx) + e.logger.Info("eth_getBlockByHash", "hash", hash.Hex(), "full", fullTx) return e.backend.GetBlockByHash(hash, fullTx) } diff --git a/rpc/types/utils.go b/rpc/types/utils.go index e6eaa9154c..270d6a6a46 100644 --- a/rpc/types/utils.go +++ b/rpc/types/utils.go @@ -99,6 +99,9 @@ func FormatBlock( transactionsRoot = common.BytesToHash(header.DataHash) } + ethHeader := EthHeaderFromTendermint(header, bloom, baseFee) + ethHeader.GasLimit = uint64(gasLimit) + ethHeader.GasUsed = gasUsed.Uint64() result := map[string]interface{}{ "number": hexutil.Uint64(header.Height), "hash": hexutil.Bytes(header.Hash()), @@ -123,6 +126,8 @@ func FormatBlock( "totalDifficulty": (*hexutil.Big)(big.NewInt(0)), } + // Can we make a "correct" ethtypes.Header? + if baseFee != nil { result["baseFeePerGas"] = (*hexutil.Big)(baseFee) }