DeclareMiningJob stale classification currently treats any validation-context drift as stale (prev_hash, nbits, min_ntime, bip34):
|
} else { |
|
let stale_at_arrival_by_bip34 = declared_bip34_height != latest_bip34_height; |
|
let context_drifted = initial_validation_context.prev_hash |
|
!= latest_validation_context.prev_hash |
|
|| initial_validation_context.nbits != latest_validation_context.nbits |
|
|| initial_validation_context.min_ntime != latest_validation_context.min_ntime |
|
|| initial_bip34_height != latest_bip34_height |
|
|| stale_at_arrival_by_bip34; |
|
|
|
let error_code = if context_drifted { |
|
debug!( |
|
initial_prev_hash = ?initial_validation_context.prev_hash, |
|
initial_nbits = ?initial_validation_context.nbits, |
|
initial_min_ntime = initial_validation_context.min_ntime, |
|
initial_bip34_height, |
|
declared_bip34_height, |
|
latest_prev_hash = ?latest_validation_context.prev_hash, |
|
latest_nbits = ?latest_validation_context.nbits, |
|
latest_min_ntime = latest_validation_context.min_ntime, |
|
latest_bip34_height, |
|
stale_at_arrival_by_bip34, |
|
"Detected stale chain tip during DeclareMiningJob validation; classifying error as stale-chain-tip" |
|
); |
|
ERROR_CODE_DECLARE_MINING_JOB_STALE_CHAIN_TIP |
|
} else { |
|
ERROR_CODE_DECLARE_MINING_JOB_INVALID_JOB |
|
}; |
|
|
|
JdResponse::Error { |
|
error_code, |
|
validation_context: latest_validation_context, |
|
} |
|
}; |
This can misclassify errors:
min_ntime can increase without a tip change
nbits/bip34 comparisons are unnecessary for stale-tip detection in this path
Stale tip classification should be restricted to mismatching prev_hash only.
Finally, there's no need for force_update_mempool_mirror to call createNewBlock().
Calling getTip() should be sufficient.
Note: this should be done on all versions, not only v31x (as could be implied by the code snippet above).
DeclareMiningJobstale classification currently treats any validation-context drift as stale (prev_hash,nbits,min_ntime,bip34):sv2-apps/bitcoin-core-sv2/src/unix_capnp/v31x/job_declaration_protocol/handlers.rs
Lines 289 to 321 in 453e853
This can misclassify errors:
min_ntimecan increase without a tip changenbits/bip34comparisons are unnecessary for stale-tip detection in this pathStale tip classification should be restricted to mismatching
prev_hashonly.Finally, there's no need for
force_update_mempool_mirrorto callcreateNewBlock().Calling
getTip()should be sufficient.Note: this should be done on all versions, not only
v31x(as could be implied by the code snippet above).