dedis / cothority

Scalable collective authority
Other
425 stars 106 forks source link

syncChain does not refresh forward links #1244

Closed jeffallen closed 6 years ago

jeffallen commented 6 years ago

Imainge that a node has blocks with indexes: 0 -> <- 1. It is asked to make a forward link to block 3. It calls syncChain to find block 2, and integrates it into it's DB. It now has:

0 -> <- 1 <- 2

This issue is to fix that so that once 2 is fetched, the forward link on 1 will be also updated.

jeffallen commented 6 years ago

Some more/related problems:

  1. the input from getBlocks must always be verified before it is used, it is untrusted data. (there is one in StoreSkipBlock, where we are making the backlinks)
  2. separate calls to s.db.Store which are transactionally related (i.e. I store 2 and then store a new copy of 0 because 2 has a back link to 0 and I need to get the new forward link to 2) need to be done inside of one BoltDB transaction, so that the database is always consistent.

It looks like we need some kind of function called "verifyStoreAndUpdateForwardLinks" which encapsulates all of that into one function.

On consistent vs. complete. Linus and I think that the promise skipchain makes to local apps (i.e. verifiers for evoting) is that the blocks stored in the local DB have consistent links to each other, but that there might be holes in the chain, so that we can get the benefits of the skipchain.

But: making the rule that all backlinks of all newly discovered blocks are traversed in order to preserve consistency means we'll always fetch to completeness, because we will fetch back link 0 of each newly discovered block, marching all the way back until the last block that we have in our DB.

Still got to think about this some.

ineiti commented 6 years ago

I think this issue is closed with the latest changes to the skipchain:

Does that make sense?