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

Problem: Missing validator delegation in validator projection #161

Open
calvinaco opened this issue Nov 29, 2020 · 7 comments
Open

Problem: Missing validator delegation in validator projection #161

calvinaco opened this issue Nov 29, 2020 · 7 comments
Assignees

Comments

@calvinaco
Copy link
Collaborator

No description provided.

@calvinaco calvinaco changed the title Problem: Missing validator delegation list projection Problem: Missing validator delegation is validator projection Nov 29, 2021
@ysong42
Copy link
Contributor

ysong42 commented Dec 13, 2021

After reading CosmosSDK document and diving into their codebase, I had some findings.

Here are my notes:
https://github.com/crypto-com/chain-indexing/wiki/Staking-Notes
https://github.com/crypto-com/chain-indexing/wiki/Slashing-Notes

@ysong42
Copy link
Contributor

ysong42 commented Dec 13, 2021

Three things to follow up:

  1. How to get the delegations amount on each validator?
  2. How to add new events on CosmosSDK?
  3. Arrange a follow-up discussion meeting on this Wednesday or Thursday.

@ysong42 ysong42 changed the title Problem: Missing validator delegation is validator projection Problem: Missing validator delegation in validator projection Dec 13, 2021
@ysong42
Copy link
Contributor

ysong42 commented Dec 15, 2021

For getting delegations list on each validator, I could think of two ways to do this:

  • Add new events on CosmosSDK side, whenever a delegation changes (Delegation.Shares.Sub or Delegation.Shares.Add).
  • Not adding new events on CosmosSDK side. Keep track of Validator, Delegation, Redelegation entries on our own indexing server.

@ysong42
Copy link
Contributor

ysong42 commented Dec 15, 2021

One serious problem for adding new events on CosmosSDK is that, even if these events are added to a new version of CosmosSDK, the old blocks won't emit the newly added events.

As the old blocks need to be synced with the old binaries, which are using old version CosmosSDK.

@ysong42
Copy link
Contributor

ysong42 commented Dec 29, 2021

cosmos/cosmos-sdk#10799

According to the discussion in the above thread. We will need to setup multiple archive nodes that stop at different upgrade height, using different versions of binaries.

So that we could query historical states from this set of nodes.

This has not been tested on crypto.org mainnet yet. (We haven't got the new archive nodes yet)

But Validators, Validator and ValidatorDelegations gRPC endpoints works well on croeseid-4 node. croeseid-4 is at about height 2,000,000. I am able to query historical states with the endpoints at around latest, 1,000,000 and 50,000.

@ysong42
Copy link
Contributor

ysong42 commented Dec 29, 2021

In the next step, we will try to port the logic from CosmosSDK to our repo.

Mainly for the following reasons:

  1. Historical states are very important and useful to users. It will be great if the indexing server could provide it natively and not just proxy the requests to blockchain nodes.
  2. When users' chain has upgrade(s) (using x/upgrade module), it will be difficult for them to set up multiple archive nodes.
  3. Even if users could set up archive nodes, they will still need to pull the historical states to the indexing server. As when more requests come in, the underlying nodes may not be able to handle that.

@ysong42
Copy link
Contributor

ysong42 commented Dec 29, 2021

This will be a huge task. I plan to introduce a new projection and then let the projection support each message one by one.

The target of the new projection:

  • Store Validator states in all height
  • Store Validator Delegations states in all height
  • Store Validator UnbindingDelegations states in all height
  • Store Validator Redelegations states in all height

Steps:
- [ ] Problem: New validator projection. Handle MsgCreateValidator.
- [ ] Problem: New validator projection. Handle MsgDelegate.
- [ ] Problem: New validator projection. Handle MsgUndelegate.
- [ ] Problem: New validator projection. Handle MsgRedelegate.
- [ ] Problem: New validator projection. Handle slash event.

  • Problem: New validator projection. Port main logic.
  • Problem: New validator projection. Implement migration scripts and views.
  • Problem: New validator projection. Result verification script.
  • Problem: New validator projection. Missing unit tests.

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

No branches or pull requests

3 participants