@@ -176,6 +176,15 @@ public void ForkchoiceUpdated(BlockHeader newHeadHash, Keccak finalizedHash)
176
176
_logger . Trace (
177
177
$ "GetBlockConsensusInfo { header . ToString ( BlockHeader . Format . FullHashAndNumber ) } header.IsPostMerge: { header . IsPostMerge } header.TotalDifficulty { header . TotalDifficulty } header.Difficulty { header . Difficulty } TTD: { _specProvider . TerminalTotalDifficulty } MergeBlockNumber { _specProvider . MergeBlockNumber } , TransitionFinished: { TransitionFinished } ") ;
178
178
179
+ if ( ( header . TotalDifficulty ?? 0 ) != 0 && dontTrustTotalDifficulty && header . IsGenesis == false )
180
+ {
181
+ BlockHeader ? parentHeader = _blockTree . FindParentHeader ( header , BlockTreeLookupOptions . None ) ;
182
+ if ( parentHeader != null && parentHeader . TotalDifficulty != 0 )
183
+ header . TotalDifficulty = parentHeader . TotalDifficulty + header . Difficulty ;
184
+ else
185
+ header . TotalDifficulty = null ;
186
+ }
187
+
179
188
bool isTerminal = false , isPostMerge ;
180
189
if ( header . IsPostMerge ) // block from Engine API, there is no need to check more cases
181
190
{
@@ -206,25 +215,9 @@ public void ForkchoiceUpdated(BlockHeader newHeadHash, Keccak finalizedHash)
206
215
}
207
216
else
208
217
{
209
- if ( header . TotalDifficulty >= _specProvider . TerminalTotalDifficulty && dontTrustTotalDifficulty && header . IsGenesis == false )
210
- {
211
- BlockHeader ? parentHeader = _blockTree . FindParentHeader ( header , BlockTreeLookupOptions . None ) ;
212
- if ( parentHeader != null && parentHeader . TotalDifficulty != 0 )
213
- header . TotalDifficulty = parentHeader . TotalDifficulty + header . Difficulty ;
214
- else
215
- header . TotalDifficulty = null ;
216
- }
217
-
218
- if ( header . TotalDifficulty == null )
219
- {
220
- isPostMerge = header . Difficulty == 0 ;
221
- isTerminal = false ; // we can't say if block isTerminal if we don't have TD
222
- }
223
- else
224
- {
225
- isTerminal = header . IsTerminalBlock ( _specProvider ) ; // we're checking if block is terminal if not it should be PostMerge block
226
- isPostMerge = ! isTerminal ;
227
- }
218
+
219
+ isTerminal = header . IsTerminalBlock ( _specProvider ) ; // we're checking if block is terminal if not it should be PostMerge block
220
+ isPostMerge = ! isTerminal ;
228
221
}
229
222
}
230
223
0 commit comments