Skip to content

Commit

Permalink
jsonrpc: Add totalDifficulty back as interim hive fix (#12469)
Browse files Browse the repository at this point in the history
Until hive implements
ethereum/execution-apis#570

Partial revert of https://github.com/erigontech/erigon/pull/11809/files

The reason this would still work with or without the snapshot files
change:
- RPC tests don't have to know about this PR, since it's based on a
state with assumed nil for the `totalDifficulty` field.
- Hive tests don't progress till pruning, nor do they start with any
snapshots (unless this changes somehow)
  • Loading branch information
somnathb1 authored Oct 28, 2024
1 parent 916e84a commit 04aa6bb
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions turbo/jsonrpc/eth_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,16 @@ func (api *APIImpl) GetBlockByNumber(ctx context.Context, number rpc.BlockNumber
}
additionalFields := make(map[string]interface{})

// =============================
// TODO - remove this after https://github.com/ethereum/execution-apis/pull/570 is implemented by Hive and rest of the community
td, err := rawdb.ReadTd(tx, b.Hash(), b.NumberU64())
if err != nil {
return nil, err
}
if td != nil {
additionalFields["totalDifficulty"] = (*hexutil.Big)(td)
}
// =================================
chainConfig, err := api.chainConfig(ctx, tx)
if err != nil {
return nil, err
Expand Down Expand Up @@ -282,6 +292,17 @@ func (api *APIImpl) GetBlockByHash(ctx context.Context, numberOrHash rpc.BlockNu
}
number := block.NumberU64()

// =============================
// TODO - remove this after https://github.com/ethereum/execution-apis/pull/570 is implemented by Hive and rest of the community
td, err := rawdb.ReadTd(tx, hash, number)
if err != nil {
return nil, err
}
if td != nil {
additionalFields["totalDifficulty"] = (*hexutil.Big)(td)
}
// ==============================

chainConfig, err := api.chainConfig(ctx, tx)
if err != nil {
return nil, err
Expand Down

0 comments on commit 04aa6bb

Please sign in to comment.