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

Validator Querier Precompile #53

Open
ceyonur opened this issue Nov 9, 2023 · 1 comment
Open

Validator Querier Precompile #53

ceyonur opened this issue Nov 9, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@ceyonur
Copy link
Collaborator

ceyonur commented Nov 9, 2023

We currently expose validator sets through AccessibleState.GetSnowContext().ValidatorState in stateful precompile function. Meaning that we can actually perform a query for subnet validators (and even other subnet validators) and provide this functionality to smart contracts. This could be very handy for governance, delegations, rewards and staking operations.

@ceyonur ceyonur added the enhancement New feature or request label Nov 9, 2023
@ceyonur ceyonur self-assigned this Nov 9, 2023
@ceyonur ceyonur added this to EVM Nov 9, 2023
@ceyonur
Copy link
Collaborator Author

ceyonur commented Nov 9, 2023

I sketched an interface:

//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IValidatorQuerier {
  // Returns the validator ID list of the current subnet and the height at which it was fetched.
  // The order of the list is lexicographically sorted by validator ID.
  function getCurrentValidatorList() external view returns (bytes20[] calldata validatorList, uint64 pChainHeight);

  // Returns the validator ID list of the subnet with [subnetID] and the height at [pChainHeight].
  // The order of the list is lexicographically sorted by validator ID.
  function getValidatorListAt(
    bytes32 subnetID,
    uint64 pChainHeight
  ) external view returns (bytes20[] calldata validatorIDs);

  // Returns the stake weight of the validator with [validatorID] in the subnet with [subnetID] at [pChainHeight].
  function getWeight(bytes32 subnetID, bytes20 validatorID, uint64 pChainHeight) external view returns (uint64 weight);

  // Returns the BLS public key of the validator with [validatorID] in the subnet with [subnetID] at [pChainHeight].
  function getBLSPublicKey(
    bytes32 subnetID,
    bytes20 validatorID,
    uint64 pChainHeight
  ) external view returns (bytes calldata blsPublicKey);

  // Returns the subnet ID of the current subnet.
  function getCurrentSubnetID() external view returns (bytes32 subnetID);

  // Returns the current height of the P-Chain.
  function getCurrentPChainHeight() external view returns (uint64 pChainHeight);
}

@ceyonur ceyonur moved this from Backlog 🗄️ to Researching 📚 in Platform Engineering Group Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Researching 📚
Status: No status
Development

No branches or pull requests

1 participant