Skip to content

Conversation

@camharris
Copy link
Collaborator

What /Why

This PR adds two new metadata fields to P-Chain staking operations to enable historical tracking of validator/delegator stake amounts and commission rates.

Changes

Added two new optional metadata fields to P-Chain staking operations:

  1. validator_weight - The staked amount in nAVAX (1 AVAX = 1,000,000,000 nAVAX)
    -- Exposed on: ADD_VALIDATOR, ADD_PERMISSIONLESS_VALIDATOR, ADD_DELEGATOR, ADD_PERMISSIONLESS_DELEGATOR, REWARD_VALIDATOR
    -- Type: uint64
    -- Source: validator.Weight() / delegator.Weight()

  2. delegation_fee - The validator's commission rate (parts per million)
    -- Exposed on: ADD_VALIDATOR, ADD_PERMISSIONLESS_VALIDATOR, REWARD_VALIDATOR
    -- Type: uint32
    -- Source: DelegationShares field from validator transactions
    -- Format: Parts per million (e.g., 20000 = 2%, 50000 = 5%)
    -- Only included for validator operations (not delegator operations)

Copy link
Collaborator

@rajranjan0608 rajranjan0608 left a comment

Choose a reason for hiding this comment

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

LGTM!

Updated .golangci.yml to be compatible with golangci-lint v1.62+:
- Removed deprecated skip-dirs-use-default field
- Updated forbidigo config to use new structured format (p/msg)
- Changed exclude_godoc_examples to exclude-godoc-examples (hyphenated)

This fixes the CI linting failures without changing any linting rules.
@camharris
Copy link
Collaborator Author

@rajranjan0608 sorry, I missed updating the construction_test.go in my initial pass.

I've also updated the golangci-lint config for v1.62+ compatibility by removing the deprecated skip-dirs-use-default field, and updating the forbidigo config to use the new format. This should resolve the failing checks .

@camharris
Copy link
Collaborator Author

Note on linting failures: The lint check is now properly running (thanks to the .golangci.yml fix), but it's catching pre-existing issues in client/client.go and client/pchainclient.go that are unrelated to this PR's changes.

The files modified in this PR (mapper/pchain/* and service/backend/pchain/*) pass linting cleanly. The client/ package issues appear to be from interface definitions missing methods (BalanceAt, GetAtomicUTXOs) on master.

Happy to fix those in this PR if helpful, or they could be addressed separately.

@camharris
Copy link
Collaborator Author

@rajranjan0608 Update: I can now reproduce the typecheck errors locally with golangci-lint v1.62.2.

After investigation, I've confirmed these are pre-existing issues on master caused by library compatibility between golangci-lint's typecheck and the current avalanchego/coreth versions. I see you're already addressing this in #250 with the dependency upgrades - that should resolve these typecheck errors once merged.

The files modified in this PR (mapper/pchain/* and service/backend/pchain/*) pass all other linters cleanly. For now, I've kept typecheck commented out in .golangci.yml since it can't be disabled and the errors are unrelated to this PR's changes.

Happy to rebase on #250 once it's merged, or merge this as-is if that works better for your workflow!

Signed-off-by: Raj Ranjan <rranjan01234@gmail.com>
@camharris camharris merged commit c4fc1b9 into ava-labs:master Nov 13, 2025
4 checks passed
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