evidence

package
v0.17.2 Latest Latest
Warning

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

Go to latest
Published: May 11, 2021 License: Apache-2.0 Imports: 14 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

Index

Constants

View Source
const (
	VOTING   int8 = 0x1
	INNOCENT int8 = 0x2
	GUILTY   int8 = 0x3

	YES int8 = 0x1
	NO  int8 = 0x2
)
View Source
const (
	MISSED_REQUIRED_VOTES int8 = 0x01
	BYZANTINE_FAULT       int8 = 0x02
)

Variables

View Source
var (
	ErrCreateAllegationFailed = codes.ProtocolError{codes.TxErrEvidenceError, "failed to create allegation request"}
	ErrHandleReleaseFailed    = codes.ProtocolError{codes.TxErrEvidenceError, "failed to handle release"}
	ErrFrozenValidator        = codes.ProtocolError{codes.TxErrEvidenceError, "error frozen validator"}
	ErrNonFrozenValidator     = codes.ProtocolError{codes.TxErrEvidenceError, "error non frozen validator"}
	ErrNonActiveValidator     = codes.ProtocolError{codes.TxErrEvidenceError, "non active validator"}
	ErrInvalidHeight          = codes.ProtocolError{codes.TxErrEvidenceError, "error invalid height"}
	ErrRequestAlreadyExists   = codes.ProtocolError{codes.TxErrEvidenceError, "allegation request already exists against this address"}
)

Functions

func ChoiceStrToInt8 added in v0.16.1

func ChoiceStrToInt8(choice string) int8

func VoteToString added in v0.16.1

func VoteToString(status int8) string

Types

type AllegationRequest added in v0.16.1

type AllegationRequest struct {
	ID               string
	ReporterAddress  keys.Address
	MaliciousAddress keys.Address
	BlockHeight      int64
	ProofMsg         string
	Status           int8
	Votes            []*AllegationVote
}

func NewAllegationRequest added in v0.16.1

func NewAllegationRequest(ID string, reporterAddress keys.Address, maliciousAddress keys.Address, blockHeight int64, proofMsg string) *AllegationRequest

func (*AllegationRequest) Bytes added in v0.16.1

func (ar *AllegationRequest) Bytes() ([]byte, error)

func (*AllegationRequest) FromBytes added in v0.16.1

func (ar *AllegationRequest) FromBytes(msg []byte) (*AllegationRequest, error)

func (*AllegationRequest) String added in v0.16.1

func (ar *AllegationRequest) String() string

type AllegationTracker added in v0.16.1

type AllegationTracker struct {
	Requests map[string]bool
}

type AllegationVote added in v0.16.1

type AllegationVote struct {
	Address keys.Address
	Choice  int8
}

type CumulativeVote added in v0.16.1

type CumulativeVote struct {
	Addresses map[string]int64
}

type EvidenceState added in v0.17.0

type EvidenceState struct {
	Allegations          []*AllegationRequest    `json:"allegations"`
	SuspiciousValidators []*LastValidatorHistory `json:"suspiciousValidators"`
}

-----------------------------Dump/Load chain state

func NewEvidenceState added in v0.17.0

func NewEvidenceState() *EvidenceState

type EvidenceStore added in v0.16.1

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

func NewEvidenceStore added in v0.16.1

func NewEvidenceStore(prefix string, state *storage.State) *EvidenceStore

func (*EvidenceStore) CheckRequestExists added in v0.16.1

func (es *EvidenceStore) CheckRequestExists(new keys.Address) bool

func (*EvidenceStore) CleanTracker added in v0.16.1

func (es *EvidenceStore) CleanTracker()

func (*EvidenceStore) CreateSuspiciousValidator added in v0.16.1

func (es *EvidenceStore) CreateSuspiciousValidator(validatorAddress keys.Address, status int8, height int64, createdAt *time.Time) (*LastValidatorHistory, error)

func (*EvidenceStore) DeleteAllegationRequest added in v0.16.1

func (es *EvidenceStore) DeleteAllegationRequest(ID string) (bool, error)

func (*EvidenceStore) DumpState added in v0.17.0

func (es *EvidenceStore) DumpState() (state *EvidenceState, succeed bool)

func (*EvidenceStore) GenerateRequestID added in v0.16.1

func (es *EvidenceStore) GenerateRequestID() (string, error)

func (*EvidenceStore) Get added in v0.16.1

func (es *EvidenceStore) Get(key []byte) ([]byte, error)

func (*EvidenceStore) GetAllegationRequest added in v0.16.1

func (es *EvidenceStore) GetAllegationRequest(ID string) (*AllegationRequest, error)

func (*EvidenceStore) GetAllegationTracker added in v0.16.1

func (es *EvidenceStore) GetAllegationTracker() (*AllegationTracker, error)

func (*EvidenceStore) GetCumulativeVote added in v0.16.1

func (es *EvidenceStore) GetCumulativeVote() (*CumulativeVote, error)

func (*EvidenceStore) GetFrozenMap added in v0.16.1

func (es *EvidenceStore) GetFrozenMap() map[string]bool

func (*EvidenceStore) GetSuspiciousValidator added in v0.16.1

func (es *EvidenceStore) GetSuspiciousValidator(validatorAddress keys.Address, height int64, diff int64) (*LastValidatorHistory, error)

func (*EvidenceStore) GetValidatorMap added in v0.16.1

func (es *EvidenceStore) GetValidatorMap() map[string]bool

func (*EvidenceStore) GetValidatorStatus added in v0.16.1

func (es *EvidenceStore) GetValidatorStatus(addr keys.Address) (*ValidatorStatus, error)

func (*EvidenceStore) GetVersioned added in v0.16.1

func (es *EvidenceStore) GetVersioned(key []byte, height int64, diff int64) []byte

func (*EvidenceStore) GetVoteBlock added in v0.16.1

func (es *EvidenceStore) GetVoteBlock(height int64) (*VoteBlock, error)

func (*EvidenceStore) HandleRelease added in v0.16.1

func (es *EvidenceStore) HandleRelease(options *Options, validatorAddress keys.Address, blockHeight int64, blockCreatedAt time.Time) error

func (*EvidenceStore) IsActiveValidator added in v0.16.1

func (es *EvidenceStore) IsActiveValidator(addr keys.Address) bool

func (*EvidenceStore) IsFrozenValidator added in v0.16.1

func (es *EvidenceStore) IsFrozenValidator(validatorAddress keys.Address) bool

func (*EvidenceStore) IsRequestIDBusy added in v0.16.1

func (es *EvidenceStore) IsRequestIDBusy(ID string) bool

func (*EvidenceStore) IterateRequests added in v0.16.1

func (es *EvidenceStore) IterateRequests(fn func(ar *AllegationRequest) bool) (stopped bool)

func (*EvidenceStore) IterateSuspiciousValidators added in v0.16.1

func (es *EvidenceStore) IterateSuspiciousValidators(fn func(lvh *LastValidatorHistory) bool) (stopped bool)

func (*EvidenceStore) IterateValidatorStatuses added in v0.16.1

func (es *EvidenceStore) IterateValidatorStatuses(fn func(vs *ValidatorStatus) bool) (stopped bool)

func (*EvidenceStore) LoadState added in v0.17.0

func (es *EvidenceStore) LoadState(state *EvidenceState) (err error)

func (*EvidenceStore) PerformAllegation added in v0.16.1

func (es *EvidenceStore) PerformAllegation(validatorAddress keys.Address, maliciousAddress keys.Address, ID string, blockHeight int64, proofMsg string) error

func (*EvidenceStore) Set added in v0.16.1

func (es *EvidenceStore) Set(key []byte, value []byte) error

func (*EvidenceStore) SetAllegationRequest added in v0.16.1

func (es *EvidenceStore) SetAllegationRequest(ar *AllegationRequest) error

func (*EvidenceStore) SetAllegationTracker added in v0.16.1

func (es *EvidenceStore) SetAllegationTracker(at *AllegationTracker) error

func (*EvidenceStore) SetCumulativeVote added in v0.16.1

func (es *EvidenceStore) SetCumulativeVote(cv *CumulativeVote, currentHeight int64, yHeight int64) error

func (*EvidenceStore) SetValidatorStatus added in v0.16.1

func (es *EvidenceStore) SetValidatorStatus(addr keys.Address, isActive bool, height int64) error

func (*EvidenceStore) SetVoteBlock added in v0.16.1

func (es *EvidenceStore) SetVoteBlock(height int64, votes []types.VoteInfo) error

func (*EvidenceStore) UpdateSuspiciousValidator added in v0.16.1

func (es *EvidenceStore) UpdateSuspiciousValidator(lvh *LastValidatorHistory) error

func (*EvidenceStore) Vote added in v0.16.1

func (es *EvidenceStore) Vote(requestID string, voteAddress keys.Address, choice int8) error

func (*EvidenceStore) WithState added in v0.16.1

func (es *EvidenceStore) WithState(state *storage.State) *EvidenceStore

type LastValidatorHistory added in v0.16.1

type LastValidatorHistory struct {
	Address       keys.Address
	Status        int8
	FrozenHeight  int64
	FrozenAt      *time.Time
	ReleaseHeight int64
	ReleaseAt     *time.Time
}

func NewLastValidatorHistory added in v0.16.1

func NewLastValidatorHistory(validatorAddress keys.Address, status int8, height int64, createdAt *time.Time) *LastValidatorHistory

func (*LastValidatorHistory) Bytes added in v0.16.1

func (lvh *LastValidatorHistory) Bytes() ([]byte, error)

func (*LastValidatorHistory) FromBytes added in v0.16.1

func (lvh *LastValidatorHistory) FromBytes(msg []byte) (*LastValidatorHistory, error)

func (*LastValidatorHistory) IsFrozen added in v0.16.1

func (lvh *LastValidatorHistory) IsFrozen() bool

func (*LastValidatorHistory) ReleaseReady added in v0.16.1

func (lvh *LastValidatorHistory) ReleaseReady(options *Options, blockCreatedAt time.Time) (bool, error)

type MaliciousValidators added in v0.16.1

type MaliciousValidators struct {
	Addresses []string
}

type Options

type Options struct {
	// votes count required
	MinVotesRequired int64 `json:"minVotesRequired"`
	// votes boundaries H : H - VotesBlockDiff
	BlockVotesDiff int64 `json:"blockVotesDiff"`

	// penalty 1st iteration
	PenaltyBasePercentage int64 `json:"penaltyBasePercentage"`
	// penalty divisability factor
	PenaltyBaseDecimals int64 `json:"penaltyBaseDecimals"`

	// penalty cut for bounty (as example 13.43 %, stored as 1343)
	PenaltyBountyPercentage int64 `json:"penaltyBountyPercentage"`
	// penalty cut decimals
	PenaltyBountyDecimals int64 `json:"penaltyBountyDecimals"`

	// penalty cut for burn
	PenaltyBurnPercentage int64 `json:"penaltyBurnPercentage"`
	// penalty cut decimals
	PenaltyBurnDecimals int64 `json:"penaltyBurnDecimals"`

	// time to unfreeze validator (number of days) - for 2 scenario
	ValidatorReleaseTime int64 `json:"validatorReleaseTime"`
	// required validator votes
	ValidatorVotePercentage int64 `json:"validatorVotePercentage"`
	// required validator decimals
	ValidatorVoteDecimals int64 `json:"validatorVoteDecimals"`

	// allegation persent
	AllegationPercentage int64 `json:"allegationPercentage"`
	// allegation cut decimals
	AllegationDecimals int64 `json:"allegationDecimals"`
}

type ValidatorStatus added in v0.16.1

type ValidatorStatus struct {
	Address  keys.Address `json:"address"`
	IsActive bool         `json:"isActive"`
	Height   int64        `json:"height"`
}

func (*ValidatorStatus) Bytes added in v0.16.1

func (vs *ValidatorStatus) Bytes() []byte

func (*ValidatorStatus) FromBytes added in v0.16.1

func (vs *ValidatorStatus) FromBytes(msg []byte) (*ValidatorStatus, error)

type VoteBlock added in v0.16.1

type VoteBlock struct {
	Height    int64
	Addresses []keys.Address
}

Jump to

Keyboard shortcuts

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