stamp-protocol / tracker

The place for all features, bugs, and discussions
https://stampid.net/
2 stars 0 forks source link

Identity DAG build failure #21

Closed orthecreedence closed 3 years ago

orthecreedence commented 3 years ago

When a DAG has two trees, and one of the trees changes, say, the root key, applying the changes in chronological order fails, because one branch of the tree uses the old root key and the other uses the new key.

Note that we test for this in dag::tests::transactions_merge_reset.

orthecreedence commented 3 years ago

Some possible fixes:

  1. Group transactions by keyset (policy, publish, root) , and apply them in chronological groups instead of in chronological transactions
  2. build identities independantly in their various branches and merge them into one object at the end.
  3. read some actual DAG theory, someone has figured this out.
orthecreedence commented 3 years ago

Had another idea for this.

When building the idntity from the DAG, have a final identity, and a branch-specific identity.

Each time the DAG branches, you create a copy of the pre-fork's branch-specific identity. Then you follow the transactions in that branch, using the branch-specific identity to validate the transactions (and only apply transactions from that branch tot he branch-specific id), but apply all transactions to the final identity on each transaction.

This way, the final ends up getting all the updates in order, but doesn't rely on the primary keys being in order for validation.

This won't fix other conflicts (like setting a name to two different values on different branches) but for those we can use a really naive last-write-wins automated merge until someone bitches about it.