Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature : Pinning as a service and Recover Token [Tokenchain] #189

Merged
merged 17 commits into from
Jul 25, 2024

Conversation

Allen-Cherian
Copy link
Contributor

@Allen-Cherian Allen-Cherian commented Jul 10, 2024

The pinning service allows token owners to pin their tokens on a pinning node on their behalf. The token's ownership remains unchanged; the pinning node will have all the information about the pinned token and token chain. The recover token feature allows us to retrieve the token and tokenchain from the pinning node.

Commands added :

  1. pinrbt : The command to initiate a pinning transfer to the pinning node from a sender node.
    Eg: ./rubixgoplatform pinToken -port 20013 -senderAddr bafybmibw7lvjidvlohhdsdshbj4bcly7y6zwanlwcloj5puaizzstyfbhi -pinningAddress bafybmihs3hniinkuk3nh2bo4geyljevyjjyixtnrn3tdqe3yecqrzv22qq -rbtAmount 1 -transComment "Test Pinning As a service " -transType 2
  2. recovertoken : The command to retrieve the token and tokenchain from the pinned node.
    Eg:./rubixgoplatform recoverToken -port 20015 -senderAddr bafybmibw7lvjidvlohhdsdshbj4bcly7y6zwanlwcloj5puaizzstyfbhi -pinningAddress bafybmihs3hniinkuk3nh2bo4geyljevyjjyixtnrn3tdqe3yecqrzv22qq

APIs added :

  1. /api/initiate-pin-token
    Request Structure :
{
    "pinningNode": "bafybmiavcsudhxw4ecj2yduqms5nioekbts7ovowtldcrprstwnnkhu7ua",
    "sender": "bafybmiec5fxospbacox536gcybwpqlu7nnqvtto32ud3pjp5eaojf76lxi",
    "tokenCOunt": 3,
    "comment": "Pinning Test Latest",
    "type": 2
}

  1. /api/recover-token
    Request Structure :
{
   "pinningNode": "bafybmidpuc3vcegwxjrr6xnvvwvt3txmhkjnvdgb2kbyvemilw4lptxlvm",
   "sender":"bafybmid23tc2ddfsmxbb5h26cyiljkylbp7fjsgpbucxlm43vzbm5p2b7y"
}

Test Results :

  1. Successfully pinned a token when the balance was 1.
  2. Transferred the pinned token to a different receiver from the sender node :
    - The status in the sender node changed to 4 (TokenisTransferred)
    - In the pining node the status is still 15 (TokenIsPinnedAsService)
  3. Transfer from the pinning service node failed:
    - The error is insufficient balance, the reason is that, when we fetch the balance from the db, we are searching the token table with the did value, in the tokentable of the pinned node, the did value will be of the sender node, basically the owner node. Also even if that is changed in that particular part, in the latest tokenchain block when the ownership is checked the tokenownership check will fail and the pinning node won’t be able to transfer this token.
  4. Previously transferred token in the pinning node's database was recovered but failed to transfer:
    - When an already transferred token which was existing in the pinning nodes db was recovered and transferred, the transaction didn’t go through. Consensus failed and the tokenstatus in the recovered node’s db was changed to 12(Tokenchainsyncissue). Basically the node was not able to sync the tokenchain. In the quorum part the log showed the tokenstate was already pinned.
  5. Pinning of part token successful. A whole token in the sender node was split and was able to pin the token on a pinning service node.
  6. Recovery of Part Token successful.
  7. Transfer of all the recovered token were successful.

@gklps
Copy link
Member

gklps commented Jul 11, 2024

Suggestion for Enhanced Flexibility:

To improve the generalizability and future-proofing of the command interface, consider the following changes:

Command Renaming:
    ./rubixgoplatform pinrbt --> ./rubixgoplatform pinToken
    ./rubixgoplatform recovertokens --> ./rubixgoplatform recoverToken
API Endpoint Updates:
    /api/initiate-pin-rbt --> /api/initiate-pin-token
    /api/recover-rbt --> /api/recover-token

This approach makes the commands and endpoints less tied to a specific token type ("rbt"), allowing for easier adaptation for other token types that are introduced later.

Copy link
Collaborator

@arnabghose997 arnabghose997 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unpledging of tokens and Self Transfer working as expected

@Allen-Cherian Allen-Cherian merged commit fea068a into development Jul 25, 2024
3 checks passed
@Allen-Cherian Allen-Cherian mentioned this pull request Jul 25, 2024
3 tasks
@Allen-Cherian Allen-Cherian deleted the feat/allen/pinning-service branch July 25, 2024 05:42
arnabghose997 added a commit that referenced this pull request Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants