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: CUDOS Extract address info cmd [1] #397

Merged
merged 7 commits into from
Oct 18, 2024

Conversation

MissingNO57
Copy link
Contributor

Proposed Changes

[describe the changes here...]

Linked Issues

[if applicable, add links to issues resolved by this PR]

Types of changes

What type of change does this pull request make (put an x in the boxes that apply)?

  • Bug fix (non-breaking change that fixes an issue).
  • New feature added (non-breaking change that adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to stop working as expected).
  • Documentation update.
  • Something else (e.g., tests, scripts, example, deployment, infrastructure).

Checklist

Put an x in the boxes that apply:

  • I have read the CONTRIBUTING guide
  • Checks and tests pass locally

If applicable

  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that code coverage does not decrease
  • I have added/updated the documentation

Further comments

[if this is a relatively large or complex change, kick off a discussion by explaining why you chose the solution you did, what alternatives you considered, etc...]

Comment on lines 627 to 633
} else {
// Store delegation to delegated map
resolvedDelegatorMap, _ := unbondingDelegatedBalanceMap.GetOrSetDefault(resolvedDelegatorAddress, NewOrderedMap[string, sdk.Int]())
resolvedDelegator, _ := resolvedDelegatorMap.GetOrSetDefault(validatorOperatorAddress, sdk.NewInt(0))
resolvedDelegatorMap.Set(validatorOperatorAddress, resolvedDelegator.Add(delegatorTokens))
unbondingDelegatedBalanceMap.Set(resolvedDelegatorAddress, resolvedDelegatorMap)
}
Copy link
Collaborator

@pbukva pbukva Oct 15, 2024

Choose a reason for hiding this comment

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

Shouldn't we have another if-else branch + map for handling unbonded (BOND_STATUS_UNBONDED) delegations.
👉 I understand that we consider BOND_STATUS_UNBONDED delegations as liquid balance, just wondering if it would make sense to have them stored in dedicated map, so we could potentially save them as list (per delegator account) in to the manifest file.
👉 Potentiall the same could apply for more esoteric BOND_STATUS_UNSPECIFIED delegation state (though I'm not entirely sure, whether this bond state actualy applies exclusivelly for validator state, though something tells me that if validator is in the BOND_STATUS_UNSPECIFIED state, all delegations on that validator will be in that state as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Each delegator has list of Delegations and UnbondingDelegations but also each validator can have state bonded, unboned, etc.

Right now we split GenesisData.Validators.Delegations to Bonded GenesisData.Delegations, and GenesisData.UnbondedDelegations
And GenesisData.Validators.UnbondingDelegations map is used for GenesisData.UnbondingDelegations

There can actually be multiple different combinations like:
bonded delegation to bonded validator
unbonding delegation to bonded validator
bonded delegation to unbonding validator
...

I am not sure how to handle this.

What we currently do is that we withdraw all delegations and we recreate only bonded delegations to bonded validators.

app/upgrade_cudos.go Outdated Show resolved Hide resolved
OperatorAddress string
ConsensusPubkey cryptotypes.PubKey
Delegations *OrderedMap[string, *DelegationInfo]
UnbondingDelegations *OrderedMap[string, *UnbondingDelegationInfo]
Copy link
Collaborator

Choose a reason for hiding this comment

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

It feels like that ValidatorInfo struct should contain also the UndondedDelegations and Rewards maps.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This map mimics the structure of genesis json.

I've moved rewards to distibution info where they are calculated.

@MissingNO57 MissingNO57 changed the title [WiP] Extract address info Extract address info Oct 17, 2024
@MissingNO57 MissingNO57 changed the title Extract address info feat: CUDOS Extract address info cmd Oct 17, 2024
@MissingNO57 MissingNO57 changed the title feat: CUDOS Extract address info cmd feat: CUDOS Extract address info cmd [1] Oct 17, 2024
Copy link
Collaborator

@pbukva pbukva left a comment

Choose a reason for hiding this comment

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

LGTM

@MissingNO57 MissingNO57 merged commit 28af5cf into feat/cudos_merge Oct 18, 2024
1 check passed
@MissingNO57 MissingNO57 deleted the feat/extract_address_info branch October 18, 2024 15:04
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.

2 participants