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

feat: periodic pledging implementation #191

Merged
merged 30 commits into from
Jul 23, 2024
Merged

Conversation

arnabghose997
Copy link
Collaborator

@arnabghose997 arnabghose997 commented Jul 11, 2024

This PR intends to replace current PoW approach with Periodic Pledging. As opposed to the current approach, tokens will now be pledged for a duration of 7 days, post which token unpledging can happen. If a Trans token is in custody of owner for more than Pledge period (7 days) or if it has been transferred before the pledging period, the quorums will be able to unpledge their pledge tokens through a CLI/API call.

Since, pledged tokens are unpledged after 7 day period. a self-transfer CLI/API call is provided for node to essentially perform a psuedo state change, which will invite quorums to again pledge for the trans token.

It has been tested locally with a temporary pledged duration value of 100 seconds with both RBT transfers and Smart contract deployment and execution.

Unpledge CLI

./rubixgoplatform run-unpledge -port 20005

It goes through all the records present in the unpledgeQueue table and performs the unpledging process for all transactions, if any

Self Transfer CLI

./rubixgoplatform self-transfer-rbt -senderAddr bafybmidm7my4wuhqmcwwkkbrem6ytn3vrt3vpnocvjn5r3a4pyp5drc3iq -transType 2 -port 20016

Similar to general RBT transfer, we only pass the sender's address and the transaction type for Self Transfer.

@arnabghose997 arnabghose997 self-assigned this Jul 11, 2024
@arnabghose997 arnabghose997 marked this pull request as ready for review July 11, 2024 12:56
@arnabghose997 arnabghose997 requested a review from thewebchap July 11, 2024 12:56
@arnabghose997 arnabghose997 linked an issue Jul 11, 2024 that may be closed by this pull request
@arnabghose997 arnabghose997 force-pushed the arnab/periodic-pledging branch from 362f46c to ef02ead Compare July 11, 2024 13:36
@Allen-Cherian
Copy link
Contributor

Allen-Cherian commented Jul 12, 2024

Test Results

  1. Unpledge-cli :
  • When a transfer occurs, the transaction details—transaction ID, pledged token, epoch, and quorum DID—are added to the unpledgequeue table.
  • Upon calling the unpledge command, the transaction details are removed from the unpledgequeue table. Concurrently, credit details are added to the credit table, and the pledged tokens are unpledged.
  1. Self Transfer Cli :
  • Self transfer working fine. The transaction details is getting added in the Transaction history table and the transaction id is getting updated in the TokensTable.

@thewebchap
Copy link
Member

Working as expected . We can merge once backward compatibility is added.

@arnabghose997
Copy link
Collaborator Author

A new command unpledge-pow-pledge-tokens has been added, as part of the migration for older nodes (v0.0.17 and prior), to migrate from PoW based pledging to Periodic Pledging. This command will check if there are any tokens present in the unpledgequeue table. If so, then the tokens will force unpledged and the unpledgequeue table will be dropped. The information about pledge tokens, after the Periodic Pledging upgrade, will become part of the UnpledgeSequence table. Following is the syntax of the command:

./rubixgoplatform unpledge-pow-pledge-tokens --port <quorum node's server port>

A fix has also been administered that affected old nodes migrating to Period Pledging. The format for storing quorum address in quorummanager table in older versions were <node_peer_id>.<quorum_did> format. However, in the current implementation, we expect their format to be <quorum_did>. Especially while populating the ql attribute of QuorumManager struct, the values from the address column of quorummanager table are directly appended to it. This causes issues when invoking getPeer method in later stages of the code.

To mitigate this, we have added a check in the NewQuorumManager function, where we check if the address from quorummanager table is in <node_peer_id>.<quorum_did> format. If so, then we update it to <quorum_did> format before appending to ql attribute of QuorumManager struct.

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.

Migrate from PoW unpledging to Proof of Periodic Pledging
4 participants