rubixchain / rubixgoplatform

GNU General Public License v3.0
8 stars 17 forks source link

Node Backup: added CLI/API endpoint to perform extraction of token information of a DID from quorum node #150

Closed arnabghose997 closed 1 month ago

arnabghose997 commented 4 months ago

Description

This PR intendeds to add a CLI/API endpoint that would sync with Quorum node fetch the latest token information for a DID and update the TokensTable and sync the Token chain accordingly. Since this is focused on Type 2 quorums for now, the assumption is that the first quorum (0th index) will always be the pledging quorum.

Following is the command to sync tokens for a DID:

./rubixgoplatform nodeSync -did <DID> -port <Node Server Port>

Following is the API endpoint for the Node Sync:

POST: /api/node-sync

Request JSON Body:

{
  "did" : "<DID for which node sync should be done>"
}

Tests Scenarios

The featured was successfully tested on the following Test Scenarios:

Scenario 1

Balance: X -> 0 ; Y -> 0

  1. Generate 1 whole RBT for X
  2. Transfer 0.3 RBT from X to Y.
  3. Take Backup of X (1 whole RBT is burnt; 0.3 RBT is transferred; 0.7 RBT is with X)
  4. Transfer 0.3 RBT from Y to X
  5. Delete X's node directory and use the backup of A and run the node sync command. It is expected that status of 0.3 RBT should change from 4 to 0

Balance: X -> 1 ; Y -> 0

Scenario 2

Balance: X -> 1 ; Y -> 0

  1. Generate 3 whole RBT for X
  2. Transfer 3 RBT from X to Y
  3. Take Backup of X (3 whole RBT is transferred)
  4. Transfer 3 RBT from Y to X
  5. Delete X's node directory and use the backup of X and run the node sync command. It is exepected that the status of all 3 whole tokens will change from 4 to 0.

Balance: X -> 4 ; Y -> 0

Scenario 3

Balance: X -> 4 ; Y -> 0

  1. Take backup of X

  2. Generate 2 RBT for Y and transfer it to X.

  3. Delete X's node directory and use the backup of X and run the node sync command. It is expected that TokensTable of X will have the entries of 2 whole generated token.

Balance: X -> 6 ; Y -> 0

Scenario 4

Balance: X -> 6 ; Y -> 0

  1. Take backup of X
  2. Generate 1 RBT for X
  3. Delete X's node directory and use the backup of A and run the node sync command. It is expected that we wouldn't be able to recover this generated whole token, because we neither have the information about it in the TokensTable, nor its information is with Quorum.

Balance: X -> 6 ; Y -> 0

gklps commented 1 month ago

Closing the PR as this feature was enhanced in PR #189