-
Notifications
You must be signed in to change notification settings - Fork 312
Chain reorganization discussion #337
Comments
There has been quite a lot of problems detected recently caused by various use of ConcurrentChain. The problem is that things like In general, I'd suggest to create a better implementation of the chain in a way that each code has to open a session, in which its copy of the chain is guaranteed to be immutable. Therefore all such problems would disappear. The session should also provide an easy method on how to check if its copy of the chain is subchain of the best chain. Maybe the caller could open a session with some flags, such as - to guard against chain advancing (i.e. protect the tip), or to guard against reorgs (local copy is subchain of best chain) - and if any such thing would be violated, exception would be thrown. And methods to check for those things should be implemented. |
Little simpler concept would be to introduce a public lock into concurrent chain, which would allowed you to prevent changes in the chain for a short period of time. For example #22 could be implemented like this:
however, currently this is not correct as the chain can change between the first and the second call to chain.Contains. If we did have such a lock, we could do:
and it would be correct because the lock would guarantee the chain won't change. Such a lock is not as good solution as having the chain session completely immutable as suggested in previous comment, but at least it would allow us to write correct code, which is now rather impossible. The current solution for #22 would probably use an approach like this:
which is highly inefficient due to poor implementation of FindAncestorOrSelf. |
As I specified in a previous comment the initial plan is to bringing ConcurrentChain in to the fullnode and making modifications to it that better fit the node requirements. |
I agree, there are several ways and introducing such functions like ContainsAll is another one. There is a whole spectrum of solutions, starting from the public lock (super easy to implement, quick fix, but not elegant) and ending with the immutable session chain system as described earlier (most complicated and probably most elegant). And there are these ContainsAll solutions somewhere in the middle. And yes, bring it in, so we can touch it conveniently. |
@Aprogiena @dangershony found the thread discussing the chain redesign! |
i know about this one, it is on our list |
Fixed with activation merge. |
[Channels] Add API to return network json
tbd
i want to talk about reorgs and current code - ConcurrentChain and discuss a wild idea of getting rid of it (or upgrading it). i will provide more info later, no time now
The text was updated successfully, but these errors were encountered: