slash

package
v0.0.31 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2022 License: LGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsBanned

func IsBanned(wrapper *staking.ValidatorWrapper) bool

IsBanned ..

func Rate

func Rate(votingPower *votepower.Roster, records Records) numeric.Dec

Rate is the slashing % rate

func Verify

func Verify(
	chain CommitteeReader,
	state *state.DB,
	candidate *Record,
) error

Verify checks that the slash is valid

Types

type Application

type Application struct {
	TotalSlashed           *big.Int `json:"total-slashed"`
	TotalBeneficiaryReward *big.Int `json:"total-beneficiary-reward"`
}

Application tracks the slash application to state

func Apply

func Apply(
	chain staking.ValidatorSnapshotReader, state *state.DB,
	slashes Records, rate numeric.Dec, rewardBeneficiary common.Address,
) (*Application, error)

Apply ..

func (*Application) String

func (a *Application) String() string

type CommitteeReader

type CommitteeReader interface {
	Config() *params.ChainConfig
	ReadShardState(epoch *big.Int) (*shard.State, error)
	CurrentBlock() *types.Block
}

CommitteeReader ..

type ConflictingVotes

type ConflictingVotes struct {
	FirstVote  Vote `json:"first-vote"`
	SecondVote Vote `json:"second-vote"`
}

ConflictingVotes ..

type Evidence

type Evidence struct {
	Moment
	ConflictingVotes
	Offender common.Address `json:"offender"`
}

Evidence ..

func (Evidence) MarshalJSON

func (e Evidence) MarshalJSON() ([]byte, error)

MarshalJSON ..

func (Evidence) String

func (e Evidence) String() string

type Moment

type Moment struct {
	Epoch   *big.Int `json:"epoch"`
	ShardID uint32   `json:"shard-id"`
	Height  uint64   `json:"height"`
	ViewID  uint64   `json:"view-id"`
}

Moment ..

type Record

type Record struct {
	// the reporter who will get rewarded
	Evidence Evidence       `json:"evidence"`
	Reporter common.Address `json:"reporter"`
}

Record is an proof of a slashing made by a witness of a double-signing event

func (Record) Hash

func (r Record) Hash() common.Hash

Hash is a New256 hash of an RLP encoded Record

func (Record) MarshalJSON

func (r Record) MarshalJSON() ([]byte, error)

MarshalJSON ..

func (Record) String

func (r Record) String() string

type Records

type Records []Record

Records ..

func (Records) SetDifference

func (r Records) SetDifference(ys Records) Records

SetDifference returns all the records that are in ys but not in r

func (Records) String

func (r Records) String() string

type Vote

type Vote struct {
	SignerPubKeys   []bls.SerializedPublicKey `json:"bls-public-keys"`
	BlockHeaderHash common.Hash               `json:"block-header-hash"`
	Signature       []byte                    `json:"bls-signature"`
}

Vote is the vote of the double signer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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