DimensionDev / Maskbook-Talks

Where talks of Maskbook happen.
7 stars 1 forks source link

Discussion: Backup Import Conflict Resolving Strategy #29

Open neruthes opened 4 years ago

neruthes commented 4 years ago

We are hereby holding a discussion on how should we design the conflict resolving strategy for importing database backup files.

septs commented 4 years ago

known issue:

  1. Wallet merge logic - undefined behavior
neruthes commented 4 years ago

List of certainly mutable data classes

List of supposedly immutable data classes

neruthes commented 4 years ago

Case-By-Case Study: Persona-Profile Pair

Background

Persona-Profile Pairs may be categorized as:

For each pair, Maskbook should record the update time and the witness time. If the type is Claimed Pair, the witness time and the update time should be the time when the user created the claim.

Real Conflict

Suppose that Alice has multiple SNS-Specific Profiles (SSP) and 2 devices, and the databases on the 2 devices are identical at the initial condition.

When Alice disconnects Alice_SSP_1 and connects Alice_SSP_2 at SNS_1 on Device_1, the old record will be deleted, and the new record will be added. When merging the backup of Device_1 to Device_2, there will be a real conflict. Alice_P (the Persona of Alice) now has a different SSP for the given SNS.

In this case, we need a conflict resolving strategy which can be:

Specifically, when the private key of the Persona does not exist in either database, it would be dangerous to ask for user confirmation, because there can be too many of them.

Fake Conflict

Suppose that Alice has multiple SNS-Specific Profiles (SSP) and 2 devices, and the databases on the 2 devices are identical at the initial condition.

Alice disconnects Alice_SSP_1 and reconnects Alice_SSP_1 at SNS_1 on Device_1, or Alice connects Alice_SSP_3 at SNS_2.

When merging the backup of Device_1 to Device_2, there will be a fake conflict. Alice_P remains the same although certain timestamps are different.

In this case, no conflict happens; Maskbook should use the version whose witnessedAt is later.

Notes