Skip to content

Missing totalDifficulty in getBlockByNumber #13012

Closed as not planned
Closed as not planned
@tmeinlschmidt

Description

@tmeinlschmidt

System information

Erigon version: 3.00.0-alpha5-78f3647d

OS & Version: Linux

Chain/Network: Polygon Mainnet archive

Expected behaviour

when querying eth_getBlockByNumber, I'd expect to see totalDifficulty in the json (as it does in v2.60.x)

Actual behaviour

this field is completely missing

Steps to reproduce the behaviour

tried both direct rpc to erigon or rpcdaemon, result is the same

curl localhost:8545 -H 'content-type: application/json' -d '{"jsonrpc":"2.0","method":"eth_getBlockByNumber", "params":["65109468", false], "id":"1"}' | jq

in ethstats/ethstats.go (branch v3.0.0-alpha5) I see

  482 // blockStats is the information to report about individual blocks.
  483 type blockStats struct {
  484   Number     *big.Int          `json:"number"`
  485   Hash       libcommon.Hash    `json:"hash"`
  486   ParentHash libcommon.Hash    `json:"parentHash"`
  487   Timestamp  *big.Int          `json:"timestamp"`
  488   Miner      libcommon.Address `json:"miner"`
  489   GasUsed    uint64            `json:"gasUsed"`
  490   GasLimit   uint64            `json:"gasLimit"`
  491   Diff       string            `json:"difficulty"`
  492   TotalDiff  string            `json:"totalDifficulty"`
  493   Txs        []txStats         `json:"transactions"`
  494   TxHash     libcommon.Hash    `json:"transactionsRoot"`
  495   Root       libcommon.Hash    `json:"stateRoot"`
  496   Uncles     uncleStats        `json:"uncles"`
  497 }
...
  531   td, err := rawdb.ReadTd(roTx, block.Hash(), block.NumberU64())
  532   if err != nil {
  533     return err
  534   }
...
  564   return &blockStats{
  565     Number:     block.Header().Number,
  566     Hash:       block.Hash(),
  567     ParentHash: block.Header().ParentHash,
  568     Timestamp:  new(big.Int).SetUint64(block.Header().Time),
  569     Miner:      block.Header().Coinbase,
  570     GasUsed:    block.Header().GasUsed,
  571     GasLimit:   block.Header().GasLimit,
  572     Diff:       block.Header().Difficulty.String(),
  573     TotalDiff:  td.String(),
  574     Txs:        txs,
  575     TxHash:     block.Header().TxHash,
  576     Root:       block.Header().Root,
  577     Uncles:     block.Uncles(),
  578   }
  579 }

so assuing it should be there. But it's not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions