policy

package
v2.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package policy ports contracts/solana/reporter/policy.ts: it decides which sink messages the reporter sends.

Index

Constants

View Source
const (
	AlertFabricatedSlot   = "Akash reports a Solana slot beyond any plausible finalized slot"
	AlertNoStatus         = "Akash reports an outcome without a finalized Solana status"
	AlertContradiction    = "Akash settlement contradicts finalized Solana outcome"
	AlertGovernanceReview = "Transfer requires governance review"
)

Variables

This section is empty.

Functions

func ChallengeSeconds

func ChallengeSeconds(settlement sinkv1.SettlementData) (int64, error)

ChallengeSeconds returns the end of the challenge window in Unix seconds.

func CompareOutcome

func CompareOutcome(transfer sinkv1.TransferState, outcome sinkv1.Outcome) (contradicts, terminalMatches bool)

CompareOutcome tells how a finalized Solana outcome relates to the Akash settlement and its reported observations.

func MinimumSlot

func MinimumSlot(transfer sinkv1.TransferState, slotLimit *uint64) uint64

MinimumSlot returns the highest reported slot, ignoring slots above slotLimit when one is given.

func ReportedObservations

func ReportedObservations(transfer sinkv1.TransferState) []sinkv1.Observation

ReportedObservations returns the governance observation, then the observation of every vote.

func ReporterThreshold

func ReporterThreshold(ratio sdkmath.LegacyDec, members int) (int, error)

ReporterThreshold returns ceil(ratio × members), which must exceed two thirds of the members unless there are none.

func SettledConsistently

func SettledConsistently(transfer sinkv1.TransferState, outcome sinkv1.Outcome) bool

SettledConsistently reports a terminal, unheld settlement that agrees with the finalized outcome and every report. PlanOutcome would return no message and no alert for it.

Types

type Key

type Key struct {
	ID            string
	Kind          MsgKind
	Outcome       sinkv1.Outcome
	Round         uint64
	PolicyVersion uint64
}

Key identifies a message for the purpose of executing it at most once. A vote is keyed by outcome, round and policy version. A veto and a refund are keyed by the transfer alone: MsgVetoVoid carries no round, so a veto planned in one round and one planned after a governance resolution share a key.

func KeyOf

func KeyOf(id sinkid.ID, msg sdk.Msg) Key

KeyOf returns the key of a message the policy plans for the transfer. A message of any other type gets a key with kind zero.

type Kind

type Kind int

Kind tells whether Solana finalized a status for a transfer.

const (
	KindAbsent Kind = iota + 1
	KindResolved
)

type MsgKind

type MsgKind uint8

MsgKind identifies the kind of a sink message. The values are the kind bytes of the nonce slot hash.

const (
	MsgVote   MsgKind = 1
	MsgVeto   MsgKind = 2
	MsgRefund MsgKind = 3
)

type Observed

type Observed struct {
	Kind        Kind
	ContextSlot uint64
	SlotLimit   *uint64
	Observation sinkv1.Observation
}

Observed is what a node saw on Solana. Observation is set for KindResolved only. SlotLimit, when set, is the highest slot that any node could have finalized at ContextSlot.

type Plan

type Plan struct {
	Messages []sdk.Msg
	Alerts   []string
}

Plan is the messages to send and the alerts to raise for one transfer.

func PlanOutcome

func PlanOutcome(reporter string, s Snapshot, o Observed) (Plan, error)

PlanOutcome is the pure policy. The chain remains authoritative for membership, rounds, caps, challenge deadlines and exact-once payment when the planned messages execute.

type Planned

type Planned struct {
	ID  sinkid.ID
	Msg sdk.Msg
	Key Key
	// PlanHeight and PlanTime are the height and block time of the snapshot the message was planned from.
	PlanHeight int64
	PlanTime   time.Time
}

Planned is a message the policy planned from one snapshot.

type Snapshot

type Snapshot struct {
	Params      sinkv1.Params
	Policy      sinkv1.ReporterPolicy
	RefundUsage sinkv1.EpochUsage
	Epoch       uint64
	Time        int64
	RefundHead  *sinkid.ID
	Transfer    sinkv1.TransferState
}

Snapshot is the chain state a decision is made from. Time is the block time in Unix seconds. RefundHead is the head of the refund queue: x/sink pays refunds oldest first.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL