types

package
v0.3.0-dev.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventTypeTallyCompletion = "tally_completion"

	AttributeDataRequestID = "dr_id"
	AttributeTypeConsensus = "consensus"
	AttributeTallyVMStdOut = "tally_vm_stdout"
	AttributeTallyVMStdErr = "tally_vm_stderr"
	AttributeTallyExitCode = "exit_code"
	AttributeProxyPubKeys  = "proxy_public_keys"
)
View Source
const (
	// ModuleName defines the module name.
	ModuleName = "tally"
)

Variables

View Source
var (
	ErrInvalidFilterType   = errors.Register("tally", 2, "invalid filter type")
	ErrFilterInputTooShort = errors.Register("tally", 3, "filter input length too short")
	ErrInvalidPathLen      = errors.Register("tally", 4, "invalid JSON path length")
	ErrEmptyReveals        = errors.Register("tally", 5, "no reveals given")
	ErrCorruptReveals      = errors.Register("tally", 6, "> 1/3 of reveals are corrupted")
	ErrNoConsensus         = errors.Register("tally", 7, "> 1/3 of reveals do not agree on reveal data")
	ErrNoBasicConsensus    = errors.Register("tally", 8, "> 1/3 of reveals do not agree on (exit_code, proxy_pub_keys)")
	ErrInvalidNumberType   = errors.Register("tally", 9, "invalid number type specified")
	ErrFilterUnexpected    = errors.Register("tally", 10, "unexpected error occurred in filter")
)

Functions

This section is empty.

Types

type DataResult

type DataResult struct {
	Version        string `json:"version"`
	ID             string `json:"dr_id"`
	BlockHeight    uint64 `json:"block_height"`
	ExitCode       byte   `json:"exit_code"`
	GasUsed        string `json:"gas_used"`
	Result         []byte `json:"result"`
	PaybackAddress string `json:"payback_address"` // base64-encoded string
	SedaPayload    string `json:"seda_payload"`
	Consensus      bool   `json:"consensus"`
}

type Filter

type Filter interface {
	// ApplyFilter takes in a list of reveals and returns an outlier
	// list, whose value at index i indicates whether i-th reveal is
	// an outlier. Value of 1 indicates an outlier, and value of 0
	// indicates a non-outlier reveal.
	ApplyFilter(reveals []RevealBody) ([]int, error)
}

type FilterMode

type FilterMode struct {
	// contains filtered or unexported fields
}

func NewFilterMode

func NewFilterMode(input []byte) (FilterMode, error)

NewFilterMode constructs a new FilerMode object given a filter input. Mode filter input looks as follows: 0 1 9 9+data_path_length | filter_type | data_path_length | data_path |

func (FilterMode) ApplyFilter

func (f FilterMode) ApplyFilter(reveals []RevealBody) ([]int, error)

ApplyFilter applies the Mode Filter and returns an outlier list. (i) If more than 1/3 of reveals are corrupted, a corrupt reveals error is returned without an outlier list. (ii) Otherwise, a reveal is declared an outlier if it does not match the mode value. If less than 2/3 of the reveals are non-outliers, "no consensus" error is returned along with an outlier list.

type FilterNone

type FilterNone struct{}

func NewFilterNone

func NewFilterNone(_ []byte) (FilterNone, error)

NewFilterNone constructs a new FilterNone object.

func (FilterNone) ApplyFilter

func (f FilterNone) ApplyFilter(reveals []RevealBody) ([]int, error)

FilterNone declares all reveals as non-outliers, unless reveals are empty or corrupt.

type FilterStdDev

type FilterStdDev struct {
	// contains filtered or unexported fields
}

func NewFilterStdDev

func NewFilterStdDev(input []byte) (FilterStdDev, error)

NewFilterStdDev constructs a new FilterStdDev object given a filter input. Standard deviation filter input looks as follows: 0 1 9 10 18 18+json_path_length | filter_type | max_sigma | number_type | json_path_length | json_path |

func (FilterStdDev) ApplyFilter

func (f FilterStdDev) ApplyFilter(reveals []RevealBody) ([]int, error)

ApplyFilter applies the Standard Deviation Filter and returns an outlier list. (i) If more than 1/3 of reveals are corrupted (i.e. invalid json path, invalid bytes, etc.), a corrupt reveals error is returned without an outlier list. (ii) If the number type is invalid, an error is returned without an outlier list. (iii) Otherwise, an outlier list is returned. A reveal is declared an outlier if it deviates from the median by more than the given max sigma. If less than 2/3 of the reveals are non-outliers, "no consensus" error is returned as well.

type HalfStepInt

type HalfStepInt[T constraints.Integer] struct {
	// contains filtered or unexported fields
}

HalfStepInt is an integer type with half-step increments (0.5).

func (HalfStepInt[T]) IsWithinSigma

func (h HalfStepInt[T]) IsWithinSigma(x T, maxSigma Sigma) bool

IsWithinSigma returns true if and only if the integer x is within the maxSigma range from the halfStepInt h. That is, IsWithinSigma returns true if and only if the absolute difference between x and h is less than or equal to maxSigma.

func (*HalfStepInt[T]) Mid

func (h *HalfStepInt[T]) Mid(x, y T) *HalfStepInt[T]

Mid sets h to the middle point between the two integers x and y and returns h.

type Request

type Request struct {
	DrBinaryID        string                `json:"dr_binary_id"`
	DrInputs          string                `json:"dr_inputs"`
	GasLimit          string                `json:"gas_limit"`
	GasPrice          string                `json:"gas_price"`
	Height            uint64                `json:"height"`
	ID                string                `json:"id"`
	Memo              string                `json:"memo"`
	PaybackAddress    string                `json:"payback_address"`
	ReplicationFactor int64                 `json:"replication_factor"`
	ConsensusFilter   string                `json:"consensus_filter"`
	Reveals           map[string]RevealBody `json:"reveals"`
	SedaPayload       string                `json:"seda_payload"`
	TallyBinaryID     string                `json:"tally_binary_id"`
	TallyInputs       string                `json:"tally_inputs"`
	Version           string                `json:"version"`
}

type RevealBody

type RevealBody struct {
	Salt         []byte   `json:"salt"`
	ExitCode     byte     `json:"exit_code"`
	GasUsed      string   `json:"gas_used"`
	Reveal       string   `json:"reveal"` // base64-encoded string
	ProxyPubKeys []string `json:"proxy_public_keys"`
}

func (*RevealBody) MarshalJSON

func (u *RevealBody) MarshalJSON() ([]byte, error)

type Sigma

type Sigma uint64

Sigma is a 10^6 precision fixed-point unsigned number represented by a uint64, whose last 6 digits represent the fractional part.

func NewSigma

func NewSigma(data []byte) (Sigma, error)

func (Sigma) FractionalPart

func (s Sigma) FractionalPart() uint64

FractionalPart returns Sigma's fractional part as a uint64. For example, the fractional part of Sigma(1_500_000) is 500_000, representing the fraction 500_000 / 1_000_000.

func (Sigma) WholeNumber

func (s Sigma) WholeNumber() uint64

WholeNumber returns Sigma's whole number part. For example, the whole number part of Sigma(1_000_000) is 1.

type Sudo

type Sudo struct {
	ID       string     `json:"dr_id"`
	Result   DataResult `json:"result"`
	ExitCode byte       `json:"exit_code"`
}

type WasmStorageKeeper

type WasmStorageKeeper interface {
	GetCoreContractAddr(ctx context.Context) (sdk.AccAddress, error)
	GetDataRequestWasm(ctx context.Context, hash string) (types.DataRequestWasm, error)
}

Jump to

Keyboard shortcuts

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