diff --git a/cmd/rpcdaemon/graphql/eip-1767.graphqls.ref b/cmd/rpcdaemon/graphql/eip-1767.graphqls.ref index 58e6368239b..0ba4cb53eb5 100644 --- a/cmd/rpcdaemon/graphql/eip-1767.graphqls.ref +++ b/cmd/rpcdaemon/graphql/eip-1767.graphqls.ref @@ -154,9 +154,6 @@ type Block { mixHash: Bytes32! # Difficulty is a measure of the difficulty of mining this block. difficulty: BigInt! - # TotalDifficulty is the sum of all difficulty values up to and including - # this block. - totalDifficulty: BigInt! # OmmerCount is the number of ommers (AKA uncles) associated with this # block. If ommers are unavailable, this field will be null. ommerCount: Int diff --git a/cmd/rpcdaemon/graphql/geth-schema.graphqls.ref b/cmd/rpcdaemon/graphql/geth-schema.graphqls.ref index c0050476691..3eff936fc88 100644 --- a/cmd/rpcdaemon/graphql/geth-schema.graphqls.ref +++ b/cmd/rpcdaemon/graphql/geth-schema.graphqls.ref @@ -190,9 +190,6 @@ mixHash: Bytes32! # Difficulty is a measure of the difficulty of mining this block. difficulty: BigInt! - # TotalDifficulty is the sum of all difficulty values up to and including - # this block. - totalDifficulty: BigInt! # OmmerCount is the number of ommers (AKA uncles) associated with this # block. If ommers are unavailable, this field will be null. ommerCount: Int diff --git a/cmd/rpcdaemon/graphql/graph/generated.go b/cmd/rpcdaemon/graphql/graph/generated.go index df4ac38da32..33c9fb51c94 100644 --- a/cmd/rpcdaemon/graphql/graph/generated.go +++ b/cmd/rpcdaemon/graphql/graph/generated.go @@ -87,7 +87,6 @@ type ComplexityRoot struct { ReceiptsRoot func(childComplexity int) int StateRoot func(childComplexity int) int Timestamp func(childComplexity int) int - TotalDifficulty func(childComplexity int) int TransactionAt func(childComplexity int, index int) int TransactionCount func(childComplexity int) int Transactions func(childComplexity int) int @@ -476,13 +475,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Block.Timestamp(childComplexity), true - case "Block.totalDifficulty": - if e.complexity.Block.TotalDifficulty == nil { - break - } - - return e.complexity.Block.TotalDifficulty(childComplexity), true - case "Block.transactionAt": if e.complexity.Block.TransactionAt == nil { break @@ -1952,8 +1944,6 @@ func (ec *executionContext) fieldContext_Block_parent(_ context.Context, field g return ec.fieldContext_Block_mixHash(ctx, field) case "difficulty": return ec.fieldContext_Block_difficulty(ctx, field) - case "totalDifficulty": - return ec.fieldContext_Block_totalDifficulty(ctx, field) case "ommerCount": return ec.fieldContext_Block_ommerCount(ctx, field) case "ommers": @@ -2661,50 +2651,6 @@ func (ec *executionContext) fieldContext_Block_difficulty(_ context.Context, fie return fc, nil } -func (ec *executionContext) _Block_totalDifficulty(ctx context.Context, field graphql.CollectedField, obj *model.Block) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Block_totalDifficulty(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.TotalDifficulty, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNBigInt2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Block_totalDifficulty(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Block", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type BigInt does not have child fields") - }, - } - return fc, nil -} - func (ec *executionContext) _Block_ommerCount(ctx context.Context, field graphql.CollectedField, obj *model.Block) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Block_ommerCount(ctx, field) if err != nil { @@ -2818,8 +2764,6 @@ func (ec *executionContext) fieldContext_Block_ommers(_ context.Context, field g return ec.fieldContext_Block_mixHash(ctx, field) case "difficulty": return ec.fieldContext_Block_difficulty(ctx, field) - case "totalDifficulty": - return ec.fieldContext_Block_totalDifficulty(ctx, field) case "ommerCount": return ec.fieldContext_Block_ommerCount(ctx, field) case "ommers": @@ -2925,8 +2869,6 @@ func (ec *executionContext) fieldContext_Block_ommerAt(ctx context.Context, fiel return ec.fieldContext_Block_mixHash(ctx, field) case "difficulty": return ec.fieldContext_Block_difficulty(ctx, field) - case "totalDifficulty": - return ec.fieldContext_Block_totalDifficulty(ctx, field) case "ommerCount": return ec.fieldContext_Block_ommerCount(ctx, field) case "ommers": @@ -4481,8 +4423,6 @@ func (ec *executionContext) fieldContext_Query_block(ctx context.Context, field return ec.fieldContext_Block_mixHash(ctx, field) case "difficulty": return ec.fieldContext_Block_difficulty(ctx, field) - case "totalDifficulty": - return ec.fieldContext_Block_totalDifficulty(ctx, field) case "ommerCount": return ec.fieldContext_Block_ommerCount(ctx, field) case "ommers": @@ -4602,8 +4542,6 @@ func (ec *executionContext) fieldContext_Query_blocks(ctx context.Context, field return ec.fieldContext_Block_mixHash(ctx, field) case "difficulty": return ec.fieldContext_Block_difficulty(ctx, field) - case "totalDifficulty": - return ec.fieldContext_Block_totalDifficulty(ctx, field) case "ommerCount": return ec.fieldContext_Block_ommerCount(ctx, field) case "ommers": @@ -5950,8 +5888,6 @@ func (ec *executionContext) fieldContext_Transaction_block(_ context.Context, fi return ec.fieldContext_Block_mixHash(ctx, field) case "difficulty": return ec.fieldContext_Block_difficulty(ctx, field) - case "totalDifficulty": - return ec.fieldContext_Block_totalDifficulty(ctx, field) case "ommerCount": return ec.fieldContext_Block_ommerCount(ctx, field) case "ommers": @@ -8881,11 +8817,6 @@ func (ec *executionContext) _Block(ctx context.Context, sel ast.SelectionSet, ob if out.Values[i] == graphql.Null { out.Invalids++ } - case "totalDifficulty": - out.Values[i] = ec._Block_totalDifficulty(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } case "ommerCount": out.Values[i] = ec._Block_ommerCount(ctx, field, obj) case "ommers": diff --git a/cmd/rpcdaemon/graphql/graph/model/models_gen.go b/cmd/rpcdaemon/graphql/graph/model/models_gen.go index 043212b5fbe..157a952141a 100644 --- a/cmd/rpcdaemon/graphql/graph/model/models_gen.go +++ b/cmd/rpcdaemon/graphql/graph/model/models_gen.go @@ -34,7 +34,6 @@ type Block struct { LogsBloom string `json:"logsBloom"` MixHash string `json:"mixHash"` Difficulty string `json:"difficulty"` - TotalDifficulty string `json:"totalDifficulty"` OmmerCount *int `json:"ommerCount,omitempty"` Ommers []*Block `json:"ommers,omitempty"` OmmerAt *Block `json:"ommerAt,omitempty"` diff --git a/cmd/rpcdaemon/graphql/graph/schema.graphqls b/cmd/rpcdaemon/graphql/graph/schema.graphqls index 64925dfdc2d..ff0bbb9800c 100644 --- a/cmd/rpcdaemon/graphql/graph/schema.graphqls +++ b/cmd/rpcdaemon/graphql/graph/schema.graphqls @@ -192,9 +192,6 @@ type Block { mixHash: Bytes32! # Difficulty is a measure of the difficulty of mining this block. difficulty: BigInt! - # TotalDifficulty is the sum of all difficulty values up to and including - # this block. - totalDifficulty: BigInt! # OmmerCount is the number of ommers (AKA uncles) associated with this # block. If ommers are unavailable, this field will be null. ommerCount: Int diff --git a/cmd/rpcdaemon/graphql/graph/schema.resolvers.go b/cmd/rpcdaemon/graphql/graph/schema.resolvers.go index 9932c43bd13..030d9b4f6b2 100644 --- a/cmd/rpcdaemon/graphql/graph/schema.resolvers.go +++ b/cmd/rpcdaemon/graphql/graph/schema.resolvers.go @@ -100,7 +100,6 @@ func (r *queryResolver) Block(ctx context.Context, number *string, hash *string) block.Timestamp = *convertDataToStringP(blk, "timestamp") block.TransactionCount = convertDataToIntP(blk, "transactionCount") block.TransactionsRoot = *convertDataToStringP(blk, "transactionsRoot") - block.TotalDifficulty = *convertDataToStringP(blk, "totalDifficulty") block.BaseFeePerGas = convertDataToStringP(blk, "baseFeePerGas") block.Transactions = []*model.Transaction{} diff --git a/cmd/rpcdaemon/graphql/query_block.graphql b/cmd/rpcdaemon/graphql/query_block.graphql index cc9b0e9f50d..a71066f1218 100644 --- a/cmd/rpcdaemon/graphql/query_block.graphql +++ b/cmd/rpcdaemon/graphql/query_block.graphql @@ -25,7 +25,6 @@ stateRoot timestamp transactionsRoot - totalDifficulty transactions { createdContract { address diff --git a/cmd/rpcdaemon/postman/RPC_Testing.json b/cmd/rpcdaemon/postman/RPC_Testing.json index 78d89c9f7a1..6d775bfce63 100644 --- a/cmd/rpcdaemon/postman/RPC_Testing.json +++ b/cmd/rpcdaemon/postman/RPC_Testing.json @@ -290,7 +290,6 @@ " \"size\": \"0x3e1\",", " \"stateRoot\": \"0xb3f9408d80048b6f206951c4e387f8da37fb8510eccc18527865fa746c47bbc5\",", " \"timestamp\": \"0x56bff9bb\",", - " \"totalDifficulty\": \"0x6332227c16fd7c67\",", " \"transactions\": [", " \"0x730724cb08a6eb17bf6b3296359d261570d343ea7944a17a9d7287d77900db08\",", " \"0xef2ea39c20ba09553b2f3cf02380406ac766039ca56612937eed5e7f3503fb3a\",", @@ -336,7 +335,7 @@ "raw": "{{HOST}}", "host": ["{{HOST}}"] }, - "description": "Returns information about a block given the block's number.\r\n\r\n**Parameters**\r\n\r\nTAG - Integer block number or one of \"earliest\", \"latest\" or \"pending\"\r\n\r\nBoolean - If true it returns the full transaction objects, if false only the hashes of the transactions\r\n\r\n**Returns**\r\n\r\nObject - An object of type Block defined as:\r\n\r\nnumber: QUANTITY - The block number or null when pending\r\n\r\nhash: DATA, 32 Bytes - Hash of the block or null when pending\r\n\r\nparentHash: DATA, 32 Bytes - Hash of the parent block\r\n\r\nnonce: DATA, 8 bytes - Hash of the proof of work or null when pending\r\n\r\nsha3Uncles: DATA, 32 Bytes - SHA3 of the uncles data in the block\r\n\r\nlogsBloom: DATA, 256 Bytes - The bloom filter for the block's logs or null when pending\r\n\r\ntransactionsRoot: DATA, 32 Bytes - The root of the transaction trie of the block\r\n\r\nstateRoot: DATA, 32 Bytes - The root of the final state trie of the block\r\n\r\nreceiptsRoot: DATA, 32 Bytes - The root of the receipts trie of the block\r\n\r\nminer: DATA, 20 Bytes - The address of the beneficiary to whom the mining rewards were given\r\n\r\ndifficulty: QUANTITY - Integer of the difficulty for this block\r\n\r\ntotalDifficulty: QUANTITY - Integer of the total difficulty of the chain until this block\r\n\r\nextraData: DATA - The extra data field of this block\r\n\r\nsize: QUANTITY - Integer the size of this block in bytes\r\n\r\ngasLimit: QUANTITY - The maximum gas allowed in this block\r\n\r\ngasUsed: QUANTITY - The total used gas by all transactions in this block\r\n\r\ntimestamp: QUANTITY - The unix timestamp for when the block was collated\r\n\r\ntransactions: ARRAY - Array of transaction objects, or 32 Bytes transaction hashes depending on the last given parameter\r\n\r\nuncles: ARRAY - Array of uncle hashes\r\n\r\n" + "description": "Returns information about a block given the block's number.\r\n\r\n**Parameters**\r\n\r\nTAG - Integer block number or one of \"earliest\", \"latest\" or \"pending\"\r\n\r\nBoolean - If true it returns the full transaction objects, if false only the hashes of the transactions\r\n\r\n**Returns**\r\n\r\nObject - An object of type Block defined as:\r\n\r\nnumber: QUANTITY - The block number or null when pending\r\n\r\nhash: DATA, 32 Bytes - Hash of the block or null when pending\r\n\r\nparentHash: DATA, 32 Bytes - Hash of the parent block\r\n\r\nnonce: DATA, 8 bytes - Hash of the proof of work or null when pending\r\n\r\nsha3Uncles: DATA, 32 Bytes - SHA3 of the uncles data in the block\r\n\r\nlogsBloom: DATA, 256 Bytes - The bloom filter for the block's logs or null when pending\r\n\r\ntransactionsRoot: DATA, 32 Bytes - The root of the transaction trie of the block\r\n\r\nstateRoot: DATA, 32 Bytes - The root of the final state trie of the block\r\n\r\nreceiptsRoot: DATA, 32 Bytes - The root of the receipts trie of the block\r\n\r\nminer: DATA, 20 Bytes - The address of the beneficiary to whom the mining rewards were given\r\n\r\ndifficulty: QUANTITY - Integer of the difficulty for this block\r\n\r\nextraData: DATA - The extra data field of this block\r\n\r\nsize: QUANTITY - Integer the size of this block in bytes\r\n\r\ngasLimit: QUANTITY - The maximum gas allowed in this block\r\n\r\ngasUsed: QUANTITY - The total used gas by all transactions in this block\r\n\r\ntimestamp: QUANTITY - The unix timestamp for when the block was collated\r\n\r\ntransactions: ARRAY - Array of transaction objects, or 32 Bytes transaction hashes depending on the last given parameter\r\n\r\nuncles: ARRAY - Array of uncle hashes\r\n\r\n" }, "response": [] }, @@ -368,7 +367,6 @@ " \"size\": \"0x3e1\",", " \"stateRoot\": \"0xb3f9408d80048b6f206951c4e387f8da37fb8510eccc18527865fa746c47bbc5\",", " \"timestamp\": \"0x56bff9bb\",", - " \"totalDifficulty\": \"0x6332227c16fd7c67\",", " \"transactions\": [", " \"0x730724cb08a6eb17bf6b3296359d261570d343ea7944a17a9d7287d77900db08\",", " \"0xef2ea39c20ba09553b2f3cf02380406ac766039ca56612937eed5e7f3503fb3a\",", @@ -870,7 +868,6 @@ " \"size\": \"0x21a\",", " \"stateRoot\": \"0x1e6e030581fd1873b4784280859cd3b3c04aa85520f08c304cf5ee63d3935add\",", " \"timestamp\": \"0x55ba4242\",", - " \"totalDifficulty\": \"0xffd003ffe\",", " \"transactionsRoot\": \"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",", " \"uncles\": []", " }", @@ -949,7 +946,6 @@ " \"size\": \"0x21a\",", " \"stateRoot\": \"0x1e6e030581fd1873b4784280859cd3b3c04aa85520f08c304cf5ee63d3935add\",", " \"timestamp\": \"0x55ba4242\",", - " \"totalDifficulty\": \"0xffd003ffe\",", " \"transactionsRoot\": \"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",", " \"uncles\": []", " }", diff --git a/cmd/rpctest/rpctest/type.go b/cmd/rpctest/rpctest/type.go index 765171adebb..e967564cb6c 100644 --- a/cmd/rpctest/rpctest/type.go +++ b/cmd/rpctest/rpctest/type.go @@ -326,7 +326,6 @@ type OtsFullBlock struct { StateRoot string `json:"stateRoot"` Timestamp string `json:"timestamp"` - TotalDifficulty hexutil.Big `json:"totalDifficulty"` TransactionCount uint64 `json:"transactionCount"` Transactions []OtsTransaction `json:"transactions"` TxRoot libcommon.Hash `json:"transactionsRoot"` diff --git a/docs/readthedocs/source/rpc/index.rst b/docs/readthedocs/source/rpc/index.rst index ad14711db43..aa9a2ff3fa2 100644 --- a/docs/readthedocs/source/rpc/index.rst +++ b/docs/readthedocs/source/rpc/index.rst @@ -265,9 +265,6 @@ Object - An object of type Block defined as: * - ``QUANTITY`` - ``difficulty`` - Integer of the difficulty for this block - * - ``QUANTITY`` - - ``totalDifficulty`` - - Integer of the total difficulty of the chain until this block * - ``DATA`` - ``extraData`` - The extra data field of this block diff --git a/erigon-lib/common/dbg/experiments.go b/erigon-lib/common/dbg/experiments.go index e2bd92ff76f..744e0c8e753 100644 --- a/erigon-lib/common/dbg/experiments.go +++ b/erigon-lib/common/dbg/experiments.go @@ -49,7 +49,7 @@ var ( noMerge = EnvBool("NO_MERGE", false) discardHistory = EnvBool("DISCARD_HISTORY", false) discardCommitment = EnvBool("DISCARD_COMMITMENT", false) - pruneTotalDifficulty = EnvBool("PRUNE_TOTAL_DIFFICULTY", false) + pruneTotalDifficulty = EnvBool("PRUNE_TOTAL_DIFFICULTY", true) // force skipping of any non-Erigon2 .torrent files DownloaderOnlyBlocks = EnvBool("DOWNLOADER_ONLY_BLOCKS", false) diff --git a/eth/stagedsync/stage_snapshots.go b/eth/stagedsync/stage_snapshots.go index 094e537a914..5f0870502d2 100644 --- a/eth/stagedsync/stage_snapshots.go +++ b/eth/stagedsync/stage_snapshots.go @@ -541,6 +541,7 @@ func pruneCanonicalMarkers(ctx context.Context, tx kv.RwTx, blockReader services return err } defer c.Close() + var tdKey [40]byte for k, v, err := c.First(); k != nil && err == nil; k, v, err = c.Next() { blockNum := binary.BigEndian.Uint64(k) if blockNum == 0 { // Do not prune genesis marker @@ -552,6 +553,13 @@ func pruneCanonicalMarkers(ctx context.Context, tx kv.RwTx, blockReader services if err := tx.Delete(kv.HeaderNumber, v); err != nil { return err } + if dbg.PruneTotalDifficulty() { + copy(tdKey[:], k) + copy(tdKey[8:], v) + if err := tx.Delete(kv.HeaderTD, tdKey[:]); err != nil { + return err + } + } if err := c.DeleteCurrent(); err != nil { return err } diff --git a/turbo/adapter/ethapi/api.go b/turbo/adapter/ethapi/api.go index 1ed331b3d0f..3f3b699f797 100644 --- a/turbo/adapter/ethapi/api.go +++ b/turbo/adapter/ethapi/api.go @@ -374,30 +374,6 @@ func RPCMarshalBlockExDeprecated(block *types.Block, inclTx bool, fullTx bool, b return fields, nil } -/* - -// rpcMarshalHeader uses the generalized output filler, then adds the total difficulty field, which requires -// a `PublicBlockchainAPI`. -func (s *PublicBlockChainAPI) rpcMarshalHeader(ctx context.Context, header *types.Header) map[string]interface{} { - fields := RPCMarshalHeader(header) - fields["totalDifficulty"] = (*hexutil.Big)(s.b.GetTd(ctx, header.Hash())) - return fields -} - -// rpcMarshalBlock uses the generalized output filler, then adds the total difficulty field, which requires -// a `PublicBlockchainAPI`. -func (s *PublicBlockChainAPI) rpcMarshalBlock(ctx context.Context, b *types.Block, inclTx bool, fullTx bool) (map[string]interface{}, error) { - fields, err := RPCMarshalBlock(b, inclTx, fullTx) - if err != nil { - return nil, err - } - if inclTx { - fields["totalDifficulty"] = (*hexutil.Big)(s.b.GetTd(ctx, b.Hash())) - } - return fields, err -} -*/ - // RPCTransaction represents a transaction that will serialize to the RPC representation of a transaction type RPCTransaction struct { BlockHash *libcommon.Hash `json:"blockHash"` diff --git a/turbo/jsonrpc/erigon_block.go b/turbo/jsonrpc/erigon_block.go index ff9a34a4aa1..1d49f4a66c3 100644 --- a/turbo/jsonrpc/erigon_block.go +++ b/turbo/jsonrpc/erigon_block.go @@ -197,13 +197,6 @@ func buildBlockResponse(ctx context.Context, br services.FullBlockReader, db kv. } additionalFields := make(map[string]interface{}) - td, err := rawdb.ReadTd(db, header.Hash(), header.Number.Uint64()) - if err != nil { - return nil, err - } - if td != nil { - additionalFields["totalDifficulty"] = (*hexutil.Big)(td) - } response, err := ethapi.RPCMarshalBlockEx(block, true, fullTx, nil, common.Hash{}, additionalFields) diff --git a/turbo/jsonrpc/eth_block.go b/turbo/jsonrpc/eth_block.go index fdaea006cc7..64321722071 100644 --- a/turbo/jsonrpc/eth_block.go +++ b/turbo/jsonrpc/eth_block.go @@ -228,13 +228,6 @@ func (api *APIImpl) GetBlockByNumber(ctx context.Context, number rpc.BlockNumber return nil, nil } additionalFields := make(map[string]interface{}) - 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 { @@ -289,12 +282,6 @@ func (api *APIImpl) GetBlockByHash(ctx context.Context, numberOrHash rpc.BlockNu } number := block.NumberU64() - td, err := rawdb.ReadTd(tx, hash, number) - if err != nil { - return nil, err - } - additionalFields["totalDifficulty"] = (*hexutil.Big)(td) - chainConfig, err := api.chainConfig(ctx, tx) if err != nil { return nil, err diff --git a/turbo/jsonrpc/eth_uncles.go b/turbo/jsonrpc/eth_uncles.go index edccf0dbe44..c2772bd8ff0 100644 --- a/turbo/jsonrpc/eth_uncles.go +++ b/turbo/jsonrpc/eth_uncles.go @@ -24,7 +24,6 @@ import ( "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon/core/rawdb" "github.com/erigontech/erigon/core/types" "github.com/erigontech/erigon/rpc" "github.com/erigontech/erigon/turbo/adapter/ethapi" @@ -51,11 +50,6 @@ func (api *APIImpl) GetUncleByBlockNumberAndIndex(ctx context.Context, number rp return nil, nil // not error, see https://github.com/erigontech/erigon/issues/1645 } additionalFields := make(map[string]interface{}) - td, err := rawdb.ReadTd(tx, block.Hash(), blockNum) - if err != nil { - return nil, err - } - additionalFields["totalDifficulty"] = (*hexutil.Big)(td) uncles := block.Uncles() if index >= hexutil.Uint(len(uncles)) { @@ -81,13 +75,7 @@ func (api *APIImpl) GetUncleByBlockHashAndIndex(ctx context.Context, hash common if block == nil { return nil, nil // not error, see https://github.com/erigontech/erigon/issues/1645 } - number := block.NumberU64() additionalFields := make(map[string]interface{}) - td, err := rawdb.ReadTd(tx, hash, number) - if err != nil { - return nil, err - } - additionalFields["totalDifficulty"] = (*hexutil.Big)(td) uncles := block.Uncles() if index >= hexutil.Uint(len(uncles)) { diff --git a/turbo/jsonrpc/graphql_api.go b/turbo/jsonrpc/graphql_api.go index 5a04960c7c0..341a4bb293e 100644 --- a/turbo/jsonrpc/graphql_api.go +++ b/turbo/jsonrpc/graphql_api.go @@ -25,7 +25,6 @@ import ( "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/kv" - "github.com/erigontech/erigon/core/rawdb" "github.com/erigontech/erigon/core/types" "github.com/erigontech/erigon/eth/ethutils" "github.com/erigontech/erigon/rpc" @@ -149,16 +148,11 @@ func (api *GraphQLAPIImpl) getBlockWithSenders(ctx context.Context, number rpc.B } func (api *GraphQLAPIImpl) delegateGetBlockByNumber(tx kv.Tx, b *types.Block, number rpc.BlockNumber, inclTx bool) (map[string]interface{}, error) { - td, err := rawdb.ReadTd(tx, b.Hash(), b.NumberU64()) - if err != nil { - return nil, err - } additionalFields := make(map[string]interface{}) response, err := ethapi.RPCMarshalBlock(b, inclTx, inclTx, additionalFields) if !inclTx { delete(response, "transactions") // workaround for https://github.com/erigontech/erigon/issues/4989#issuecomment-1218415666 } - response["totalDifficulty"] = (*hexutil.Big)(td) response["transactionCount"] = b.Transactions().Len() if err == nil && number == rpc.PendingBlockNumber { diff --git a/turbo/jsonrpc/otterscan_api.go b/turbo/jsonrpc/otterscan_api.go index a69885bb0e1..535f848f6ed 100644 --- a/turbo/jsonrpc/otterscan_api.go +++ b/turbo/jsonrpc/otterscan_api.go @@ -33,7 +33,6 @@ import ( "github.com/erigontech/erigon/consensus" "github.com/erigontech/erigon/core" - "github.com/erigontech/erigon/core/rawdb" "github.com/erigontech/erigon/core/types" "github.com/erigontech/erigon/core/vm" "github.com/erigontech/erigon/core/vm/evmtypes" @@ -269,16 +268,11 @@ func (api *OtterscanAPIImpl) traceBlocks(ctx context.Context, addr common.Addres } func delegateGetBlockByNumber(tx kv.Tx, b *types.Block, number rpc.BlockNumber, inclTx bool) (map[string]interface{}, error) { - td, err := rawdb.ReadTd(tx, b.Hash(), b.NumberU64()) - if err != nil { - return nil, err - } additionalFields := make(map[string]interface{}) response, err := ethapi.RPCMarshalBlock(b, inclTx, inclTx, additionalFields) if !inclTx { delete(response, "transactions") // workaround for https://github.com/erigontech/erigon/issues/4989#issuecomment-1218415666 } - response["totalDifficulty"] = (*hexutil2.Big)(td) response["transactionCount"] = b.Transactions().Len() if err == nil && number == rpc.PendingBlockNumber {