types

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2020 License: MIT Imports: 16 Imported by: 5

Documentation

Index

Constants

View Source
const (
	MaxNameLength            = 70
	MaxIdentityLength        = 3000
	MaxWebsiteLength         = 140
	MaxSecurityContactLength = 140
	MaxDetailsLength         = 280
)

Define validator staking related const

Variables

View Source
var (
	// ErrInvalidSig is a bad signature
	ErrInvalidSig = errors.New("invalid transaction v, r, s values")
)
View Source
var (

	// ErrInvalidStakingKind given when caller gives bad staking message kind
	ErrInvalidStakingKind = errors.New("bad staking kind")
)

Functions

func MarshalDelegation

func MarshalDelegation(delegation Delegation) ([]byte, error)

MarshalDelegation return the delegation

func Sender

func Sender(signer Signer, tx *StakingTransaction) (common.Address, error)

Sender returns the address derived from the signature (V, R, S) using secp256k1 elliptic curve and an error if it failed deriving or upon an incorrect signature.

Sender may cache the address, allowing it to be used regardless of signing method. The cache is invalidated if the cached signer does not match the signer used in the current call.

Types

type Commission

type Commission struct {
	CommissionRates `json:"commission_rates" yaml:"commission_rates"`
	UpdateHeight    *big.Int `json:"update_height" yaml:"update_height"` // the block height the commission rate was last changed

}

Commission defines a commission parameters for a given validator.

type CommissionRates

type CommissionRates struct {
	Rate          numeric.Dec `json:"rate" yaml:"rate"`                       // the commission rate charged to delegators, as a fraction
	MaxRate       numeric.Dec `json:"max_rate" yaml:"max_rate"`               // maximum commission rate which validator can ever charge, as a fraction
	MaxChangeRate numeric.Dec `json:"max_change_rate" yaml:"max_change_rate"` // maximum increase of the validator commission every epoch, as a fraction
}

CommissionRates defines the initial commission rates to be used for creating a validator.

type DVPair

type DVPair struct {
	DelegatorAddress common.Address
	ValidatorAddress common.Address
}

DVPair is struct that just has a delegator-validator pair with no other data. It is intended to be used as a marshalable pointer. For example, a DVPair can be used to construct the key to getting an UnbondingDelegation from state.

type DVVTriplet

type DVVTriplet struct {
	DelegatorAddress    common.Address
	ValidatorSrcAddress common.Address
	ValidatorDstAddress common.Address
}

DVVTriplet is struct that just has a delegator-validator-validator triplet with no other data. It is intended to be used as a marshalable pointer. For example, a DVVTriplet can be used to construct the key to getting a Redelegation from state.

type Delegate

type Delegate struct {
	DelegatorAddress common.Address `json:"delegator_address" yaml:"delegator_address"`
	ValidatorAddress common.Address `json:"validator_address" yaml:"validator_address"`
	Amount           *big.Int       `json:"amount" yaml:"amount"`
}

Delegate - type for delegating to a validator

type Delegation

type Delegation struct {
	DelegatorAddress common.Address `json:"delegator_address" yaml:"delegator_address"`
	ValidatorAddress common.Address `json:"validator_address" yaml:"validator_address"`
	Amount           *big.Int       `json:"amount" yaml:"amount"`
}

Delegation represents the bond with tokens held by an account. It is owned by one delegator, and is associated with the voting power of one validator.

func NewDelegation

func NewDelegation(delegatorAddr common.Address, validatorAddr common.Address,
	amount *big.Int) Delegation

NewDelegation creates a new delegation object

func UnmarshalDelegation

func UnmarshalDelegation(by []byte) (*Delegation, error)

UnmarshalDelegation return the delegation

func (Delegation) GetAmount

func (d Delegation) GetAmount() *big.Int

GetAmount returns amount of a delegation

func (Delegation) GetDelegatorAddr

func (d Delegation) GetDelegatorAddr() common.Address

GetDelegatorAddr returns DelegatorAddr

func (Delegation) GetValidatorAddr

func (d Delegation) GetValidatorAddr() common.Address

GetValidatorAddr returns ValidatorAddr

func (Delegation) String

func (d Delegation) String() string

String returns a human readable string representation of a Delegation.

type Delegations

type Delegations []Delegation

Delegations is a collection of delegations

func (Delegations) String

func (d Delegations) String() (out string)

String returns the string representation of a list of delegations

type Description

type Description struct {
	Name            string `json:"name" yaml:"name"`                         // name
	Identity        string `json:"identity" yaml:"identity"`                 // optional identity signature (ex. UPort or Keybase)
	Website         string `json:"website" yaml:"website"`                   // optional website link
	SecurityContact string `json:"security_contact" yaml:"security_contact"` // optional security contact info
	Details         string `json:"details" yaml:"details"`                   // optional details
}

Description - some possible IRL connections

type Directive

type Directive byte

Directive says what kind of payload follows

const (
	// DirectiveNewValidator ...
	DirectiveNewValidator Directive = iota
	// DirectiveEditValidator ...
	DirectiveEditValidator
	// DirectiveDelegate ...
	DirectiveDelegate
	// DirectiveRedelegate ...
	DirectiveRedelegate
	// DirectiveUndelegate ...
	DirectiveUndelegate
)

func (Directive) String

func (d Directive) String() string

type EIP155Signer

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

EIP155Signer implements Signer using the EIP155 rules.

func NewEIP155Signer

func NewEIP155Signer(chainID *big.Int) EIP155Signer

NewEIP155Signer creates a EIP155Signer given chainID.

func (EIP155Signer) Equal

func (s EIP155Signer) Equal(s2 Signer) bool

Equal checks if the given EIP155Signer is equal to another Signer.

func (EIP155Signer) Hash

Hash returns the hash to be signed by the sender. It does not uniquely identify the transaction.

func (EIP155Signer) Sender

Sender returns the sender address of the given signer.

func (EIP155Signer) SignatureValues

func (s EIP155Signer) SignatureValues(
	tx *StakingTransaction, sig []byte,
) (R, S, V *big.Int, err error)

SignatureValues returns signature values. This signature needs to be in the [R || S || V] format where V is 0 or 1.

type EditValidator

type EditValidator struct {
	Description
	StakingAddress    common.Address `json:"staking_address" yaml:"staking_address"`
	CommissionRate    numeric.Dec    `json:"commission_rate" yaml:"commission_rate"`
	MinSelfDelegation *big.Int       `json:"min_self_delegation" yaml:"min_self_delegation"`
}

EditValidator - type for edit existing validator

type NewValidator

type NewValidator struct {
	Description       `json:"description" yaml:"description"`
	CommissionRates   `json:"commission" yaml:"commission"`
	MinSelfDelegation *big.Int           `json:"min_self_delegation" yaml:"min_self_delegation"`
	StakingAddress    common.Address     `json:"staking_address" yaml:"staking_address"`
	PubKey            shard.BlsPublicKey `json:"validating_pub_key" yaml:"validating_pub_key"`
	Amount            *big.Int           `json:"amount" yaml:"amount"`
}

NewValidator - type for creating a new validator

type Redelegate

type Redelegate struct {
	DelegatorAddress    common.Address `json:"delegator_address" yaml:"delegator_address"`
	ValidatorSrcAddress common.Address `json:"validator_src_address" yaml:"validator_src_address"`
	ValidatorDstAddress common.Address `json:"validator_dst_address" yaml:"validator_dst_address"`
	Amount              *big.Int       `json:"amount" yaml:"amount"`
}

Redelegate - type for reassigning delegation

type Redelegation

type Redelegation struct {
	DelegatorAddress    common.Address      `json:"delegator_address" yaml:"delegator_address"`         // delegator
	ValidatorSrcAddress common.Address      `json:"validator_src_address" yaml:"validator_src_address"` // validator redelegation source operator addr
	ValidatorDstAddress common.Address      `json:"validator_dst_address" yaml:"validator_dst_address"` // validator redelegation destination operator addr
	Entries             []RedelegationEntry `json:"entries" yaml:"entries"`                             // redelegation entries
}

Redelegation contains the list of a particular delegator's redelegating bonds from a particular source validator to a particular destination validator

func NewRedelegation

func NewRedelegation(delegatorAddr common.Address, validatorSrcAddr,
	validatorDstAddr common.Address, epoch *big.Int, amt *big.Int) Redelegation

NewRedelegation - create a new redelegation object

func (*Redelegation) AddEntry

func (d *Redelegation) AddEntry(epoch *big.Int, amt *big.Int)

AddEntry - append entry to the unbonding delegation Merge if has same epoch field

func (Redelegation) String

func (d Redelegation) String() string

String returns a human readable string representation of a Redelegation.

type RedelegationEntry

type RedelegationEntry struct {
	Epoch  *big.Int `json:"epoch" yaml:"epoch"`   // epoch at which the redelegation took place
	Amount *big.Int `json:"amount" yaml:"amount"` // amount of destination-validator tokens created by redelegation
}

RedelegationEntry - entry to a Redelegation

func NewRedelegationEntry

func NewRedelegationEntry(epoch *big.Int, amt *big.Int) RedelegationEntry

NewRedelegationEntry - create a new redelegation object

type Redelegations

type Redelegations []Redelegation

Redelegations are a collection of Redelegation

func (Redelegations) String

func (d Redelegations) String() (out string)

type Signer

type Signer interface {
	// Sender returns the sender address of the transaction.
	Sender(tx *StakingTransaction) (common.Address, error)
	// SignatureValues returns the raw R, S, V values corresponding to the
	// given signature.
	SignatureValues(tx *StakingTransaction, sig []byte) (r, s, v *big.Int, err error)
	// Hash returns the hash to be signed.
	Hash(tx *StakingTransaction) common.Hash
	// Equal returns true if the given signer is the same as the receiver.
	Equal(s Signer) bool
}

Signer encapsulates transaction signature handling. Note that this interface is not a stable API and may change at any time to accommodate new protocol rules.

type StakeMsgFulfiller

type StakeMsgFulfiller func() (Directive, interface{})

StakeMsgFulfiller is signature of callback intended to produce the StakeMsg

type StakingTransaction

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

StakingTransaction is a record captuing all staking operations

func NewStakingTransaction

func NewStakingTransaction(
	nonce, gasLimit uint64, gasPrice *big.Int, f StakeMsgFulfiller,
) (*StakingTransaction, error)

NewStakingTransaction produces a new staking transaction record

func Sign

Sign signs the stake using the given signer and private key

func (*StakingTransaction) ChainID

func (tx *StakingTransaction) ChainID() *big.Int

ChainID is what chain this staking transaction for

func (*StakingTransaction) DecodeRLP

func (tx *StakingTransaction) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder

func (*StakingTransaction) EncodeRLP

func (tx *StakingTransaction) EncodeRLP(w io.Writer) error

EncodeRLP implements rlp.Encoder

func (*StakingTransaction) Gas

func (tx *StakingTransaction) Gas() uint64

Gas returns gas of StakingTransaction.

func (*StakingTransaction) Hash

func (tx *StakingTransaction) Hash() common.Hash

Hash hashes the RLP encoding of tx. It uniquely identifies the transaction.

func (*StakingTransaction) WithSignature

func (tx *StakingTransaction) WithSignature(signer Signer, sig []byte) (*StakingTransaction, error)

WithSignature returns a new transaction with the given signature.

type StakingTransactions

type StakingTransactions []*StakingTransaction

StakingTransactions is a stake slice type for basic sorting.

type UnbondingDelegation

type UnbondingDelegation struct {
	DelegatorAddress common.Address             `json:"delegator_address" yaml:"delegator_address"` // delegator
	ValidatorAddress common.Address             `json:"validator_address" yaml:"validator_address"` // validator unbonding from operator addr
	Entries          []UnbondingDelegationEntry `json:"entries" yaml:"entries"`                     // unbonding delegation entries
}

UnbondingDelegation stores all of a single delegator's unbonding bonds for a single validator in an time-ordered list

func NewUnbondingDelegation

func NewUnbondingDelegation(delegatorAddr common.Address,
	validatorAddr common.Address, epoch *big.Int, amt *big.Int) UnbondingDelegation

NewUnbondingDelegation - create a new unbonding delegation object

func (*UnbondingDelegation) AddEntry

func (d *UnbondingDelegation) AddEntry(epoch *big.Int, amt *big.Int)

AddEntry - append entry to the unbonding delegation if there exists same ExitEpoch entry, merge the amount TODO: check the total amount not exceed the staking amount call this function

func (UnbondingDelegation) String

func (d UnbondingDelegation) String() string

String returns a human readable string representation of an UnbondingDelegation.

type UnbondingDelegationEntry

type UnbondingDelegationEntry struct {
	ExitEpoch *big.Int `json:"exit_epoch" yaml:"exit_epoch"` // epoch which the unbonding begins
	Amount    *big.Int `json:"amount" yaml:"amount"`         // atoms to receive at completion
}

UnbondingDelegationEntry - entry to an UnbondingDelegation

func NewUnbondingDelegationEntry

func NewUnbondingDelegationEntry(epoch *big.Int, amt *big.Int) UnbondingDelegationEntry

NewUnbondingDelegationEntry - create a new unbonding delegation object

type UnbondingDelegations

type UnbondingDelegations []UnbondingDelegation

UnbondingDelegations is a collection of UnbondingDelegation

func (UnbondingDelegations) String

func (ubds UnbondingDelegations) String() (out string)

type Undelegate

type Undelegate struct {
	DelegatorAddress common.Address `json:"delegator_address" yaml:"delegator_address"`
	ValidatorAddress common.Address `json:"validator_address" yaml:"validator_address"`
	Amount           *big.Int       `json:"amount" yaml:"amount"`
}

Undelegate - type for removing delegation responsibility

type Validator

type Validator struct {
	// ECDSA address of the validator
	Address common.Address `json:"address" yaml:"address"`
	// The BLS public key of the validator for consensus
	ValidatingPubKey bls.PublicKey `json:"validating_pub_key" yaml:"validating_pub_key"`
	// The stake put by the validator itself
	Stake *big.Int `json:"stake" yaml:"stake"`
	// if unbonding, height at which this validator has begun unbonding
	UnbondingHeight *big.Int `json:"unbonding_height" yaml:"unbonding_height"`
	// validator's self declared minimum self delegation
	MinSelfDelegation *big.Int `json:"min_self_delegation" yaml:"min_self_delegation"`
	// commission parameters
	Commission `json:"commission" yaml:"commission"`
	// description for the validator
	Description `json:"description" yaml:"description"`
	// Is the validator active in the validating process or not
	Active bool `json:"active" yaml:"active"`
}

Validator - data fields for a validator

Jump to

Keyboard shortcuts

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