First of all, thank you for continuing this thread!
The fix you’re proposing will block any historical claims - that is, pull_threads down the road - which is not the expected behavior. For example, the last entry at position 2047 will be written, and then a new session will be spawned instantly on the smart contract side. At any point in time, whenever validators get to the root, they’ll bump CurrentWeavingSession, and that last record will become unclaimable.
Also, I don’t see the poc_replay_v3 you’re referring to - if possible, could you paste it here? Just to make sure we’re both on the same page.
Actually, I believe the core issue here is that WeavingStates is not cleared on a successful update of the Merkle tree. So what I think you’re getting is:
- Do some number of honest
weave_weftcalls. - Run
on_initialize- it will create aTapestryDrafthere. - On another
on_initialize, it will fall into the first branch here and store the hash intoLoomState. - Then, I assume your test is not doing new
weave_weftcalls and instead runson_initializemultiple times right away. - Because the
WeavingStatesis not cleared or updated, it will re-apply the sort of cached value into a new session.
Can you confirm I’m on the right track with my understanding of what you’re reporting? The issue is that a previously cached WeavingStates value - not cleaned up - automatically falls into the LoomState of a new session thus doing duplication of hash for the next session. Please correct me if I’m wrong.