PathrockNetwork Gno Explorer
HomeBlocksTransactionsTokensRealmsPackagesValidatorsAnalytics

PathrockNetwork Gno Explorer — an independent explorer for Gno.land Mainnet (gnoland-1), operated by PathrockNetwork. Not an official Gno.land service.

gnowebarchive RPC

gno.land/p/nt/poa/v0

Package
Open in gnoweb ↗

Overview

Kind
Pure package
Name
v0
Namespace
nt / poa
Files
6 (README)(gnomod.toml)
Exported functions
n/a — not supported for pure packages by the node (vm/qfuncs)
Module
gno.land/p/nt/poa/v0
gno
0.9

Files (6)

  • README.mdmarkdown
  • gnomod.tomltoml
  • doc.gnogno
  • option.gnogno
  • poa.gnogno
  • poa_test.gnogno
README.mdPreviewRaw
> **v0 - Unaudited**
> This is an initial version of this package that has not yet been formally audited.
> A fully audited version will be published as a subsequent release.
> Use in production at your own risk.

# `poa` - Proof of Authority validator set

Stateful Proof of Authority validator set with simple add/remove constraints. This is a low-level building block intended to be embedded by chain-level governance code (e.g. a GovDAO bridge to `gno.land/p/sys/validators/v0`), not a typical realm utility.

Constraints:
- **Add**: validator must not be in the set already and voting power must be `> 0`.
- **Remove**: validator must be in the set.

## Usage

```go
import (
    "gno.land/p/nt/poa/v0"
    "gno.land/p/sys/validators/v0"
)

// Start with a pre-seeded validator set.
set := poa.NewPoA(poa.WithInitialSet([]validators.Validator{
    {Address: "g1...", PubKey: "gpub1...", VotingPower: 10},
}))

// Add a validator.
v, err := set.AddValidator("g1xyz...", "gpub1xyz...", 5)
if err != nil {
    panic(err)
}

// Inspect membership.
if set.IsValidator("g1xyz...") {
    // ...
}

// List the full current set.
all := set.GetValidators()

// Remove a validator.
removed, err := set.RemoveValidator(v.Address)
```

## API

```go
type PoA struct { /* ... */ }

// Construct an empty set; options seed initial validators.
func NewPoA(opts ...Option) *PoA

// WithInitialSet seeds the validator set at construction time.
func WithInitialSet(vs []validators.Validator) Option

func (p *PoA) AddValidator(addr address, pubKey string, power uint64) (validators.Validator, error)
func (p *PoA) RemoveValidator(addr address) (validators.Validator, error)
func (p *PoA) IsValidator(addr address) bool
func (p *PoA) GetValidator(addr address) (validators.Validator, error)
func (p *PoA) GetValidators() []validators.Validator
```

Validators are stored and returned as `validators.Validator` from `gno.land/p/sys/validators/v0`.

## Errors

- `ErrInvalidVotingPower` — `AddValidator` called with `power == 0`.
- `validators.ErrValidatorExists` — adding an address already in the set.
- `validators.ErrValidatorMissing` — removing or fetching an address that is not in the set.

## Notes

- Public keys are stored as-is — there is no on-chain verification yet (`TODO` in source).
- The package is intentionally narrow: it only manages the in-memory set. Consensus-layer wiring (proposing/applying changes to the actual validator set) is the caller's responsibility.

Functions

not supported for pure packages by the node (vm/qfuncs)

Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.