-
Notifications
You must be signed in to change notification settings - Fork 2.6k
NotInFinalizedChain: trying to revert the same finalized block hash #14347
Comments
Do you have forks? Could it be that you sync some other fork? So let's say you last finalized In general you could also just add a simple:
|
In general this looks like some bug in your code and not in the Substrate code as long as you can not convince me of the opposite ;) |
Thanks @bkchr for the suggestion, Checking However, I think there is still a chance to make Substrate generally more robust as the raised error message is confusing to me. I reproduced this issue locally. To illustrate, K = 3, assuming the blocks are produced as follows, 8 -> 9 > 10a -> 10b -> 11, now block 8 is finalized.
Produce a new block 11b on top of 10a, the chain reorgs from 11a to 11b,
the common block is 9, exacted blocks are [10a, 11b]. When 10a is imported on top of 9 again, it attempts to finalize block 7 (assuming we don't check
substrate/client/service/src/client/client.rs Lines 926 to 937 in 689da49
diff --git a/client/service/src/client/client.rs b/client/service/src/client/client.rs
index 91c59cdbac..ae1f0262cf 100644
--- a/client/service/src/client/client.rs
+++ b/client/service/src/client/client.rs
@@ -927,6 +927,14 @@ where
sp_blockchain::tree_route(self.backend.blockchain(), last_finalized, block)?;
if let Some(retracted) = route_from_finalized.retracted().get(0) {
+ if route_from_finalized.enacted().is_empty() {
+ warn!(
+ "Attempted to re-finalize an older finalized block {block:?}, \
+ last_finalized: {last_finalized}",
+ );
+ return Ok(())
+ }
+
warn!(
"Safety violation: attempted to revert finalized block {:?} which is not in the \
same chain as last finalized {:?}", I can send a PR if it makes sense. |
Improving the error message is fine. However, I'm not sure about not returning an error. I see your reasoning, but we print a message as someone misused the api. So, if we print a message we should also return an error? |
For sure error message could be improved, as it is not super clear. Said that, in theory calling this function against something that has already been finalized (i.e. an ancestor of BUT there are some assumptions around and this modification may have some undesired side effects at the moment. For example here we are setting this block as (actually your code doesn't call In conclusion, I think that an innocent tweak like this is correct but may have repercussions somewhere else and thus you should eventually carefully check it |
Not sure how long it will take to apply this tweak, in order to help the community not be trapped here, we can at least improve the docs to |
I given had a better look and
If we return In both cases we don't push anything new into the BUT In case 1 even if the call is successful this will then fail in the backend when we try to commit the operation ( In case 2 the call ends-up being successful and looks harmless. But, as I said, we have to keep an eye for the places where this call is performed to not disrupt some assumption. For example in substrate/client/consensus/grandpa/src/environment.rs Lines 1422 to 1423 in 297b394
(e.g. update_best_justification just below doesn't look to perform any check and the prev best justification may end up being overwritten)
@andresilva any consideration about this and the proposal of not failing? |
Is there an existing issue?
Experiencing problems? Have you tried our Stack Exchange first?
Description of bug
The error message indicates it was trying to revert the same finalized block which does not make sense to me. Let me know if I can provide more info.
BTW, we finalize the block at K-depth, specifically, when a new block at height N is imported, we attempt to finalize the block at height N-256.
Steps to reproduce
This happens on Subspace gemini-3d testnet, I guess running the fully-synced domain nodes on gemini-3d may reproduce it, but it's not trivial as the testnet is already over 1M blocks :(
The text was updated successfully, but these errors were encountered: