resolutions

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2024 License: Apache-2.0 Imports: 6 Imported by: 4

Documentation

Overview

package resolutions contains the interface and registration for resolution types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListResolutions

func ListResolutions() []string

ListResolutions returns a list of all registered resolutions.

func RegisterResolution

func RegisterResolution(name string, mod ModOperation, resolution ResolutionConfig) error

RegisterResolution registers a resolution with the Kwil network.

Types

type ModOperation added in v0.8.1

type ModOperation int8

ModOperation is the type used to enumerate different resolution modifications

const (
	ModRemove ModOperation = iota - 1
	ModUpdate
	ModAdd
)

Resolutions may be removed, updated, or added.

type Resolution

type Resolution struct {
	// ID is the unique identifier for the resolution. It is a UUID
	// that is deterministically generated from the body of the
	// resolution.
	ID *types.UUID
	// Body is the content of the resolution. It can hold any
	// arbitrary data that is relevant to the resolution.
	Body []byte
	// Type is the type of the resolution. It is used to determine
	// the logic for the resolution.
	Type string
	// ExpirationHeight is the block height at which the resolution
	// is set to expire, if it has not received the required number
	// of votes.
	ExpirationHeight int64
	// ApprovedPower is the total power of the voters that have
	// approved the resolution.
	ApprovedPower int64
	// Voters is a list of voters that have voted on the resolution.
	// This includes the proposer of the resolution.
	Voters []*types.Validator
	// Proposer is the voter that proposed the resolution body.
	// The power of the proposer can be found in the Voters list.
	Proposer []byte
}

Resolution contains information for a resolution that can be voted on.

type ResolutionConfig

type ResolutionConfig struct {
	// RefundThreshold is the required vote percentage threshold for
	// all voters on a resolution to be refunded the gas costs
	// associated with voting. This allows for resolutions that have
	// not received enough votes to pass to refund gas to the voters
	// that have voted on the resolution. For a 1/3rds threshold,
	// >=1/3rds of the voters must vote for the resolution for
	// refunds to occur. If this threshold is not met, voters will
	// not be refunded when the resolution expires. The number must
	// be a fraction between 0 and 1. If this field is nil, it will
	// default to only refunding voters when the resolution is confirmed.
	RefundThreshold *big.Rat
	// ConfirmationThreshold is the required vote percentage
	// threshold for whether a resolution is confirmed. In a 2/3rds
	// threshold, >=2/3rds of the voters must vote for the resolution
	// for it to be confirmed. Voters will also be refunded if this
	// threshold is met, regardless of the refund threshold. The
	// number must be a fraction between 0 and 1. If this field is
	// nil, it will default to 2/3.
	ConfirmationThreshold *big.Rat
	// ExpirationPeriod is the amount of blocks that the resolution
	// will be valid for before it expires. It is applied additively
	// to the current block height when the resolution is proposed;
	// if the current block height is 10 and the expiration height is
	// 5, the resolution will expire at block 15. If this field is
	// <1, it will default to 14400, which is approximately 1 day
	// assuming 6 second blocks.
	ExpirationPeriod int64
	// ResolveFunc is a function that is called once a resolution has
	// received a required number of votes, as defined by the
	// ConfirmationThreshold. It is given a readwrite database
	// connection and the information for the resolution that has
	// been confirmed. All nodes will call this function as a part of
	// block execution. It is therefore expected that the function is
	// deterministic, regardless of a node's local configuration.
	ResolveFunc func(ctx context.Context, app *common.App, resolution *Resolution) error
}

ResolutionConfig is a configuration for a type of resolution. It can be used to define resolutions that a Kwil network can vote on, and define the resulting logic if the resolution receives the required number of votes.

func GetResolution

func GetResolution(name string) (ResolutionConfig, error)

GetResolution returns a resolution by its name.

Directories

Path Synopsis
package credit implements a credit resolution, allowing accounts to be credited with a given amount.
package credit implements a credit resolution, allowing accounts to be credited with a given amount.

Jump to

Keyboard shortcuts

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