types

package
v0.0.0-...-5d85a61 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2023 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventDataTypeNewBlock       = byte(0x01)
	EventDataTypeFork           = byte(0x02)
	EventDataTypeTx             = byte(0x03)
	EventDataTypeNewBlockHeader = byte(0x04)

	EventDataTypeRoundState    = byte(0x11)
	EventDataTypeVote          = byte(0x12)
	EventDataTypeSignAggr      = byte(0x13)
	EventDataTypeVote2Proposer = byte(0x14)

	EventDataTypeRequest        = byte(0x21)
	EventDataTypeMessage        = byte(0x22)
	EventDataTypeFinalCommitted = byte(0x23)
)
View Source
const (
	VoteTypePrevote   = byte(0x01)
	VoteTypePrecommit = byte(0x02)
)

Types of votes TODO Make a new type "VoteType"

View Source
const HalfLooseRound = 15
View Source
const LooseRound = 30
View Source
const MaxBlockSize = 22020096
View Source
const MaxSignAggrSize = 22020096

Variables

View Source
var (
	PeerStateKey     = "ConsensusReactor.peerState"
	PeerMempoolChKey = "MempoolReactor.peerMempoolCh"
)
View Source
var (
	ErrPartSetUnexpectedIndex = errors.New("Error part set unexpected index")
	ErrPartSetInvalidProof    = errors.New("Error part set invalid proof")
)
View Source
var (
	ErrInvalidBlockPartSignature = errors.New("Error invalid block part signature")
	ErrInvalidBlockPartHash      = errors.New("Error invalid block part hash")
)
View Source
var (
	ErrVoteUnexpectedStep          = errors.New("Unexpected step")
	ErrVoteInvalidValidatorIndex   = errors.New("Invalid round vote validator index")
	ErrVoteInvalidValidatorAddress = errors.New("Invalid round vote validator address")
	ErrVoteInvalidSignature        = errors.New("Invalid round vote signature")
	ErrVoteInvalidBlockHash        = errors.New("Invalid block hash")
)
View Source
var CONSENSUS_POS string = "pos"
View Source
var CONSENSUS_POW string = "pow"
View Source
var CONSENSUS_Tendermint string = "tendermint"
View Source
var GenDocKey = []byte("GenDocKey")
View Source
var MainnetGenesisJSON string = `` /* 1066-byte string literal not displayed */
View Source
var TestnetGenesisJSON string = `` /* 885-byte string literal not displayed */
View Source
var ValidatorCodec = validatorCodec{}

Functions

func AddListenerForEvent

func AddListenerForEvent(evsw EventSwitch, id, event string, cb func(data TMEventData))

func EventStringBlockPart

func EventStringBlockPart() string

func EventStringBond

func EventStringBond() string

func EventStringCompleteProposal

func EventStringCompleteProposal() string

func EventStringDupeout

func EventStringDupeout() string

func EventStringFinalCommitted

func EventStringFinalCommitted() string

func EventStringFork

func EventStringFork() string

func EventStringLock

func EventStringLock() string

func EventStringMessage

func EventStringMessage() string

func EventStringNewBlock

func EventStringNewBlock() string

func EventStringNewBlockHeader

func EventStringNewBlockHeader() string

func EventStringNewRound

func EventStringNewRound() string

func EventStringNewRoundStep

func EventStringNewRoundStep() string

func EventStringPolka

func EventStringPolka() string

func EventStringProposal

func EventStringProposal() string

func EventStringProposalBlockParts

func EventStringProposalBlockParts() string

func EventStringRebond

func EventStringRebond() string

func EventStringRelock

func EventStringRelock() string

func EventStringRequest

func EventStringRequest() string

func EventStringSignAggr

func EventStringSignAggr() string

func EventStringTimeoutPropose

func EventStringTimeoutPropose() string

func EventStringTimeoutWait

func EventStringTimeoutWait() string

func EventStringTx

func EventStringTx(tx Tx) string

func EventStringUnbond

func EventStringUnbond() string

func EventStringUnlock

func EventStringUnlock() string

func EventStringVote

func EventStringVote() string

func EventStringVote2Proposer

func EventStringVote2Proposer() string

func FireEventCompleteProposal

func FireEventCompleteProposal(fireable events.Fireable, rs EventDataRoundState)

func FireEventFinalCommitted

func FireEventFinalCommitted(fireable events.Fireable, rs EventDataFinalCommitted)

func FireEventLock

func FireEventLock(fireable events.Fireable, rs EventDataRoundState)

func FireEventMessage

func FireEventMessage(fireable events.Fireable, rs EventDataMessage)

func FireEventNewBlock

func FireEventNewBlock(fireable events.Fireable, block EventDataNewBlock)

func FireEventNewBlockHeader

func FireEventNewBlockHeader(fireable events.Fireable, header EventDataNewBlockHeader)

func FireEventNewRound

func FireEventNewRound(fireable events.Fireable, rs EventDataRoundState)

func FireEventNewRoundStep

func FireEventNewRoundStep(fireable events.Fireable, rs EventDataRoundState)

func FireEventPolka

func FireEventPolka(fireable events.Fireable, rs EventDataRoundState)

func FireEventRelock

func FireEventRelock(fireable events.Fireable, rs EventDataRoundState)

func FireEventRequest

func FireEventRequest(fireable events.Fireable, rs EventDataRequest)

func FireEventSignAggr

func FireEventSignAggr(fireable events.Fireable, sign EventDataSignAggr)

func FireEventTimeoutPropose

func FireEventTimeoutPropose(fireable events.Fireable, rs EventDataRoundState)

func FireEventTimeoutWait

func FireEventTimeoutWait(fireable events.Fireable, rs EventDataRoundState)

func FireEventTx

func FireEventTx(fireable events.Fireable, tx EventDataTx)

func FireEventUnlock

func FireEventUnlock(fireable events.Fireable, rs EventDataRoundState)

func FireEventVote

func FireEventVote(fireable events.Fireable, vote EventDataVote)

func FireEventVote2Proposer

func FireEventVote2Proposer(fireable events.Fireable, vote EventDataVote2Proposer)

func HashSignBytes

func HashSignBytes(chainID string, o Signable) []byte

func IsVoteTypeValid

func IsVoteTypeValid(type_ byte) bool

func Loose23MajorThreshold

func Loose23MajorThreshold(totalVotingPower *big.Int, round int) *big.Int

max { [(2*LooseRound - round)*totalVotingPower + 3*LooseRound]/(3*LooseRound), totalVotingPower/2 + 1 }

func MakeBlock

func MakeBlock(height uint64, chainID string, commit *Commit,
	block *types.Block, valHash []byte, epochNumber uint64, epochBytes []byte, tx3ProofData []*types.TX3ProofData, partSize int) (*NCBlock, *PartSet)

func SignBytes

func SignBytes(chainID string, o Signable) []byte

Types

type BannedApi

type BannedApi struct {
	BannedList []string `json:"bannedList"`
}

type BlockID

type BlockID struct {
	Hash        []byte        `json:"hash"`
	PartsHeader PartSetHeader `json:"parts"`
}

func (BlockID) Equals

func (blockID BlockID) Equals(other BlockID) bool

func (BlockID) IsZero

func (blockID BlockID) IsZero() bool

func (BlockID) Key

func (blockID BlockID) Key() string

func (BlockID) String

func (blockID BlockID) String() string

func (BlockID) WriteSignBytes

func (blockID BlockID) WriteSignBytes(w io.Writer, n *int, err *error)

type BlockIDApi

type BlockIDApi struct {
	Hash        string           `json:"hash"`
	PartsHeader PartSetHeaderApi `json:"parts"`
}

type CandidateApi

type CandidateApi struct {
	CandidateList []string `json:"candidateList"`
}

type CanonicalJSONBlockID

type CanonicalJSONBlockID struct {
	Hash        []byte                     `json:"hash,omitempty"`
	PartsHeader CanonicalJSONPartSetHeader `json:"parts,omitempty"`
}

func CanonicalBlockID

func CanonicalBlockID(blockID BlockID) CanonicalJSONBlockID

type CanonicalJSONOnceProposal

type CanonicalJSONOnceProposal struct {
	ChainID  string                `json:"chain_id"`
	Proposal CanonicalJSONProposal `json:"proposal"`
}

type CanonicalJSONOnceSignAggr

type CanonicalJSONOnceSignAggr struct {
	ChainID  string                `json:"chain_id"`
	SignAggr CanonicalJSONSignAggr `json:"sign_aggr"`
}

type CanonicalJSONOnceValidatorMsg

type CanonicalJSONOnceValidatorMsg struct {
	ChainID      string                    `json:"chain_id"`
	ValidatorMsg CanonicalJSONValidatorMsg `json:"validator_msg"`
}

type CanonicalJSONOnceVote

type CanonicalJSONOnceVote struct {
	ChainID string            `json:"chain_id"`
	Vote    CanonicalJSONVote `json:"vote"`
}

type CanonicalJSONPartSetHeader

type CanonicalJSONPartSetHeader struct {
	Hash  []byte `json:"hash"`
	Total uint64 `json:"total"`
}

func CanonicalPartSetHeader

func CanonicalPartSetHeader(psh PartSetHeader) CanonicalJSONPartSetHeader

type CanonicalJSONProposal

type CanonicalJSONProposal struct {
	BlockPartsHeader CanonicalJSONPartSetHeader `json:"block_parts_header"`
	Height           uint64                     `json:"height"`
	POLBlockID       CanonicalJSONBlockID       `json:"pol_block_id"`
	POLRound         int                        `json:"pol_round"`
	Round            int                        `json:"round"`
	Hash             []byte                     `json:"hash"`
}

func CanonicalProposal

func CanonicalProposal(proposal *Proposal) CanonicalJSONProposal

type CanonicalJSONSignAggr

type CanonicalJSONSignAggr struct {
	Height        uint64               `json:"height"`
	Round         int                  `json:"round"`
	Type          byte                 `json:"type"`
	NumValidators int                  `json:"NumValidators"`
	BlockID       CanonicalJSONBlockID `json:"block_id"`
	Maj23         CanonicalJSONBlockID `json:"maj23"`
	Sum           int64                `json:"sum"`
}

func CanonicalSignAggr

func CanonicalSignAggr(signAggr *SignAggr) CanonicalJSONSignAggr

type CanonicalJSONValidatorMsg

type CanonicalJSONValidatorMsg struct {
	From           string        `json:"from"`
	Epoch          int           `json:"epoch"`
	ValidatorIndex int           `json:"validator_index"`
	Key            string        `json:"key"`
	PubKey         crypto.PubKey `json:"pub_key"`
	Power          uint64        `json:"power"`
	Action         string        `json:"action"`
	Target         string        `json:"target"`
}

type CanonicalJSONVote

type CanonicalJSONVote struct {
	BlockID CanonicalJSONBlockID `json:"block_id"`
	Height  uint64               `json:"height"`
	Round   uint64               `json:"round"`
	Type    byte                 `json:"type"`
}

func CanonicalVote

func CanonicalVote(vote *Vote) CanonicalJSONVote

type Commit

type Commit struct {
	BlockID BlockID `json:"blockID"`
	Height  uint64  `json:"height"`
	Round   int     `json:"round"`

	SignAggr crypto.BLSSignature `json:"SignAggr"`
	BitArray *BitArray
	// contains filtered or unexported fields
}

func (*Commit) Hash

func (commit *Commit) Hash() []byte

func (*Commit) NumCommits

func (commit *Commit) NumCommits() int

func (*Commit) Size

func (commit *Commit) Size() int

func (*Commit) StringIndented

func (commit *Commit) StringIndented(indent string) string

func (*Commit) Type

func (commit *Commit) Type() byte

func (*Commit) ValidateBasic

func (commit *Commit) ValidateBasic() error

type CommitApi

type CommitApi struct {
	BlockID BlockIDApi     `json:"blockID"`
	Height  hexutil.Uint64 `json:"height"`
	Round   int            `json:"round"`

	SignAggr crypto.BLSSignature `json:"signAggr"`
	BitArray *BitArray           `json:"bitArray"`
}

type ConsensusAggr

type ConsensusAggr struct {
	PublicKeys []string         `json:"publicKey"`
	Addresses  []common.Address `json:"address"`
}

type DefaultSigner

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

func NewDefaultSigner

func NewDefaultSigner(priv crypto.PrivKey) *DefaultSigner

func (*DefaultSigner) Sign

func (ds *DefaultSigner) Sign(msg []byte) crypto.Signature

type EpochApi

type EpochApi struct {
	Number         hexutil.Uint64    `json:"number"`
	RewardPerBlock *hexutil.Big      `json:"rewardPerBlock"`
	StartBlock     hexutil.Uint64    `json:"startBlock"`
	EndBlock       hexutil.Uint64    `json:"endBlock"`
	StartTime      time.Time         `json:"startTime"`
	EndTime        time.Time         `json:"endEime"`
	Validators     []*EpochValidator `json:"validators"`
}

type EpochApiForConsole

type EpochApiForConsole struct {
	Number         hexutil.Uint64              `json:"number"`
	RewardPerBlock *hexutil.Big                `json:"rewardPerBlock"`
	StartBlock     hexutil.Uint64              `json:"startBlock"`
	EndBlock       hexutil.Uint64              `json:"endBlock"`
	StartTime      time.Time                   `json:"startTime"`
	EndTime        time.Time                   `json:"endTime"`
	Validators     []*EpochValidatorForConsole `json:"validators"`
}

type EpochValidator

type EpochValidator struct {
	Address        common.Address `json:"address"`
	PubKey         string         `json:"publicKey"`
	Amount         *hexutil.Big   `json:"votingPower"`
	RemainingEpoch hexutil.Uint64 `json:"remainEpoch"`
}

type EpochValidatorForConsole

type EpochValidatorForConsole struct {
	Address        string         `json:"address"`
	PubKey         string         `json:"publicKey"`
	Amount         *hexutil.Big   `json:"votingPower"`
	RemainingEpoch hexutil.Uint64 `json:"remainEpoch"`
}

type EpochValidatorVoteApi

type EpochValidatorVoteApi struct {
	EpochValidator
	Salt     string      `json:"salt"`
	VoteHash common.Hash `json:"voteHash"`
	TxHash   common.Hash `json:"txHash"`
}

type EpochValidatorVoteApiForConsole

type EpochValidatorVoteApiForConsole struct {
	EpochValidatorForConsole
	Salt     string      `json:"salt"`
	VoteHash common.Hash `json:"voteHash"`
	TxHash   common.Hash `json:"txHash"`
}

type EpochVotesApi

type EpochVotesApi struct {
	EpochNumber hexutil.Uint64           `json:"voteForEpoch"`
	StartBlock  hexutil.Uint64           `json:"startBlock"`
	EndBlock    hexutil.Uint64           `json:"endBlock"`
	Votes       []*EpochValidatorVoteApi `json:"votes"`
}

type EpochVotesApiForConsole

type EpochVotesApiForConsole struct {
	EpochNumber hexutil.Uint64                     `json:"voteForEpoch"`
	StartBlock  hexutil.Uint64                     `json:"startBlock"`
	EndBlock    hexutil.Uint64                     `json:"endBlock"`
	Votes       []*EpochValidatorVoteApiForConsole `json:"votes"`
}

type ErrVoteConflictingVotes

type ErrVoteConflictingVotes struct {
	VoteA *Vote
	VoteB *Vote
}

func (*ErrVoteConflictingVotes) Error

func (err *ErrVoteConflictingVotes) Error() string

type EventCache

type EventCache interface {
	Fireable
	Flush()
}

func NewEventCache

func NewEventCache(evsw EventSwitch) EventCache

type EventDataFinalCommitted

type EventDataFinalCommitted struct {
	BlockNumber uint64
}

func (EventDataFinalCommitted) AssertIsTMEventData

func (_ EventDataFinalCommitted) AssertIsTMEventData()

type EventDataMessage

type EventDataMessage struct {
	Payload []byte `json:"payload"`
}

func (EventDataMessage) AssertIsTMEventData

func (_ EventDataMessage) AssertIsTMEventData()

type EventDataNewBlock

type EventDataNewBlock struct {
	Block *NCBlock `json:"block"`
}

func (EventDataNewBlock) AssertIsTMEventData

func (_ EventDataNewBlock) AssertIsTMEventData()

type EventDataNewBlockHeader

type EventDataNewBlockHeader struct {
	Height int `json:"height"`
}

func (EventDataNewBlockHeader) AssertIsTMEventData

func (_ EventDataNewBlockHeader) AssertIsTMEventData()

type EventDataRequest

type EventDataRequest struct {
	Proposal *ligoTypes.Block `json:"proposal"`
}

func (EventDataRequest) AssertIsTMEventData

func (_ EventDataRequest) AssertIsTMEventData()

type EventDataRoundState

type EventDataRoundState struct {
	Height uint64 `json:"height"`
	Round  int    `json:"round"`
	Step   string `json:"step"`

	RoundState interface{} `json:"-"`
}

func (EventDataRoundState) AssertIsTMEventData

func (_ EventDataRoundState) AssertIsTMEventData()

type EventDataSignAggr

type EventDataSignAggr struct {
	SignAggr *SignAggr
}

func (EventDataSignAggr) AssertIsTMEventData

func (_ EventDataSignAggr) AssertIsTMEventData()

type EventDataTx

type EventDataTx struct {
	Height int    `json:"height"`
	Tx     Tx     `json:"tx"`
	Data   []byte `json:"data"`
	Log    string `json:"log"`
	Error  string `json:"error"`
}

func (EventDataTx) AssertIsTMEventData

func (_ EventDataTx) AssertIsTMEventData()

type EventDataVote

type EventDataVote struct {
	Vote *Vote
}

func (EventDataVote) AssertIsTMEventData

func (_ EventDataVote) AssertIsTMEventData()

type EventDataVote2Proposer

type EventDataVote2Proposer struct {
	Vote        *Vote
	ProposerKey string
}

func (EventDataVote2Proposer) AssertIsTMEventData

func (_ EventDataVote2Proposer) AssertIsTMEventData()

type EventSwitch

type EventSwitch interface {
	events.EventSwitch
}

func NewEventSwitch

func NewEventSwitch() EventSwitch

type Eventable

type Eventable interface {
	SetEventSwitch(EventSwitch)
}

type Fireable

type Fireable interface {
	events.Fireable
}

type GenesisDoc

type GenesisDoc struct {
	ChainID      string          `json:"chain_id"`
	Consensus    string          `json:"consensus"`
	GenesisTime  time.Time       `json:"genesis_time"`
	RewardScheme RewardSchemeDoc `json:"reward_scheme"`
	CurrentEpoch OneEpochDoc     `json:"current_epoch"`
}

func GenesisDocFromJSON

func GenesisDocFromJSON(jsonBlob []byte) (genDoc *GenesisDoc, err error)

func (*GenesisDoc) SaveAs

func (genDoc *GenesisDoc) SaveAs(file string) error

type GenesisDocWrite

type GenesisDocWrite struct {
	ChainID      string           `json:"chain_id"`
	Consensus    string           `json:"consensus"`
	GenesisTime  time.Time        `json:"genesis_time"`
	RewardScheme RewardSchemeDoc  `json:"reward_scheme"`
	CurrentEpoch OneEpochDocWrite `json:"current_epoch"`
}

type GenesisValidator

type GenesisValidator struct {
	EthAccount     common.Address `json:"address"`
	PubKey         crypto.PubKey  `json:"pub_key"`
	Amount         *big.Int       `json:"amount"`
	Name           string         `json:"name"`
	RemainingEpoch uint64         `json:"epoch"`
}

func (GenesisValidator) MarshalJSON

func (gv GenesisValidator) MarshalJSON() ([]byte, error)

func (*GenesisValidator) UnmarshalJSON

func (gv *GenesisValidator) UnmarshalJSON(input []byte) error

type GenesisValidatorWrite

type GenesisValidatorWrite struct {
	EthAccount     string        `json:"address"`
	PubKey         crypto.PubKey `json:"pub_key"`
	Amount         *big.Int      `json:"amount"`
	Name           string        `json:"name"`
	RemainingEpoch uint64        `json:"epoch"`
}

func (GenesisValidatorWrite) MarshalJSON

func (gv GenesisValidatorWrite) MarshalJSON() ([]byte, error)

func (*GenesisValidatorWrite) UnmarshalJSON

func (gv *GenesisValidatorWrite) UnmarshalJSON(input []byte) error

type IntermediateBlockResult

type IntermediateBlockResult struct {
	Block    *types.Block
	State    *state.StateDB
	Receipts types.Receipts
	Ops      *types.PendingOps
}

type NCBlock

type NCBlock struct {
	Block              *types.Block             `json:"block"`
	NTCExtra           *TendermintExtra         `json:"ntcexdata"`
	TX3ProofData       []*types.TX3ProofData    `json:"tx3proofdata"`
	IntermediateResult *IntermediateBlockResult `json:"-"`
}

func (*NCBlock) FillSeenCommitHash

func (b *NCBlock) FillSeenCommitHash()

func (*NCBlock) FromBytes

func (b *NCBlock) FromBytes(reader io.Reader) (*NCBlock, error)

func (*NCBlock) Hash

func (b *NCBlock) Hash() []byte

func (*NCBlock) HashesTo

func (b *NCBlock) HashesTo(hash []byte) bool

func (*NCBlock) MakePartSet

func (b *NCBlock) MakePartSet(partSize int) *PartSet

func (*NCBlock) String

func (b *NCBlock) String() string

func (*NCBlock) StringIndented

func (b *NCBlock) StringIndented(indent string) string

func (*NCBlock) StringShort

func (b *NCBlock) StringShort() string

func (*NCBlock) ToBytes

func (b *NCBlock) ToBytes() []byte

func (*NCBlock) ValidateBasic

func (b *NCBlock) ValidateBasic(ncExtra *TendermintExtra) error

type OneEpochDoc

type OneEpochDoc struct {
	Number         uint64             `json:"number"`
	RewardPerBlock *big.Int           `json:"reward_per_block"`
	StartBlock     uint64             `json:"start_block"`
	EndBlock       uint64             `json:"end_block"`
	Status         int                `json:"status"`
	Validators     []GenesisValidator `json:"validators"`
}

func (OneEpochDoc) MarshalJSON

func (ep OneEpochDoc) MarshalJSON() ([]byte, error)

func (*OneEpochDoc) UnmarshalJSON

func (ep *OneEpochDoc) UnmarshalJSON(input []byte) error

type OneEpochDocWrite

type OneEpochDocWrite struct {
	Number         uint64                  `json:"number"`
	RewardPerBlock *big.Int                `json:"reward_per_block"`
	StartBlock     uint64                  `json:"start_block"`
	EndBlock       uint64                  `json:"end_block"`
	Status         int                     `json:"status"`
	Validators     []GenesisValidatorWrite `json:"validators"`
}

func (OneEpochDocWrite) MarshalJSON

func (ep OneEpochDocWrite) MarshalJSON() ([]byte, error)

func (*OneEpochDocWrite) UnmarshalJSON

func (ep *OneEpochDocWrite) UnmarshalJSON(input []byte) error

type Part

type Part struct {
	Index int                `json:"index"`
	Bytes []byte             `json:"bytes"`
	Proof merkle.SimpleProof `json:"proof"`
	// contains filtered or unexported fields
}

func (*Part) Hash

func (part *Part) Hash() []byte

func (*Part) String

func (part *Part) String() string

func (*Part) StringIndented

func (part *Part) StringIndented(indent string) string

type PartSet

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

func NewPartSetFromData

func NewPartSetFromData(data []byte, partSize int) *PartSet

func NewPartSetFromHeader

func NewPartSetFromHeader(header PartSetHeader) *PartSet

func (*PartSet) AddPart

func (ps *PartSet) AddPart(part *Part, verify bool) (bool, error)

func (*PartSet) BitArray

func (ps *PartSet) BitArray() *BitArray

func (*PartSet) Count

func (ps *PartSet) Count() int

func (*PartSet) GetPart

func (ps *PartSet) GetPart(index int) *Part

func (*PartSet) GetReader

func (ps *PartSet) GetReader() io.Reader

func (*PartSet) HasHeader

func (ps *PartSet) HasHeader(header PartSetHeader) bool

func (*PartSet) Hash

func (ps *PartSet) Hash() []byte

func (*PartSet) HashesTo

func (ps *PartSet) HashesTo(hash []byte) bool

func (*PartSet) Header

func (ps *PartSet) Header() PartSetHeader

func (*PartSet) IsComplete

func (ps *PartSet) IsComplete() bool

func (*PartSet) StringShort

func (ps *PartSet) StringShort() string

func (*PartSet) Total

func (ps *PartSet) Total() int

type PartSetHeader

type PartSetHeader struct {
	Total uint64 `json:"total"`
	Hash  []byte `json:"hash"`
}

func (PartSetHeader) Equals

func (psh PartSetHeader) Equals(other PartSetHeader) bool

func (PartSetHeader) IsZero

func (psh PartSetHeader) IsZero() bool

func (PartSetHeader) String

func (psh PartSetHeader) String() string

func (PartSetHeader) WriteSignBytes

func (psh PartSetHeader) WriteSignBytes(w io.Writer, n *int, err *error)

type PartSetHeaderApi

type PartSetHeaderApi struct {
	Total hexutil.Uint64 `json:"total"`
	Hash  string         `json:"hash"`
}

type PartSetReader

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

func NewPartSetReader

func NewPartSetReader(parts []*Part) *PartSetReader

func (*PartSetReader) Read

func (psr *PartSetReader) Read(p []byte) (n int, err error)

type PrivV

type PrivV struct {
	Address string         `json:"address"`
	PubKey  crypto.PubKey  `json:"consensus_pub_key"`
	PrivKey crypto.PrivKey `json:"consensus_priv_key"`

	Signer `json:"-"`
	// contains filtered or unexported fields
}

type PrivValidator

type PrivValidator struct {
	Address common.Address `json:"address"`
	PubKey  crypto.PubKey  `json:"consensus_pub_key"`
	PrivKey crypto.PrivKey `json:"consensus_priv_key"`

	Signer `json:"-"`
	// contains filtered or unexported fields
}

func GenPrivValidatorKey

func GenPrivValidatorKey(address common.Address) *PrivValidator

func LoadPrivValidator

func LoadPrivValidator(filePath string) *PrivValidator

func (*PrivValidator) GetAddress

func (pv *PrivValidator) GetAddress() []byte

func (*PrivValidator) GetPubKey

func (pv *PrivValidator) GetPubKey() crypto.PubKey

func (*PrivValidator) Save

func (pv *PrivValidator) Save()

func (*PrivValidator) SetFile

func (pv *PrivValidator) SetFile(filePath string)

func (*PrivValidator) SignProposal

func (pv *PrivValidator) SignProposal(chainID string, proposal *Proposal) error

func (*PrivValidator) SignVote

func (pv *PrivValidator) SignVote(chainID string, vote *Vote) error

func (*PrivValidator) String

func (pv *PrivValidator) String() string

type PrivValidatorsByAddress

type PrivValidatorsByAddress []*PrivValidator

func (PrivValidatorsByAddress) Len

func (pvs PrivValidatorsByAddress) Len() int

func (PrivValidatorsByAddress) Less

func (pvs PrivValidatorsByAddress) Less(i, j int) bool

func (PrivValidatorsByAddress) Swap

func (pvs PrivValidatorsByAddress) Swap(i, j int)

type Proposal

type Proposal struct {
	NodeID           string           `json:"node_id"`
	Height           uint64           `json:"height"`
	Round            int              `json:"round"`
	Hash             []byte           `json:"hash"`
	BlockPartsHeader PartSetHeader    `json:"block_parts_header"`
	POLRound         int              `json:"pol_round"`
	POLBlockID       BlockID          `json:"pol_block_id"`
	ProposerNetAddr  string           `json:"proposer_net_addr"`
	ProposerPeerKey  string           `json:"proposer_peer_key"`
	Signature        crypto.Signature `json:"signature"`
}

func NewProposal

func NewProposal(height uint64, round int, hash []byte, blockPartsHeader PartSetHeader, polRound int, polBlockID BlockID, peerKey string) *Proposal

func (*Proposal) BlockHash

func (p *Proposal) BlockHash() []byte

func (*Proposal) BlockHeaderHash

func (p *Proposal) BlockHeaderHash() []byte

func (*Proposal) String

func (p *Proposal) String() string

func (*Proposal) WriteSignBytes

func (p *Proposal) WriteSignBytes(chainID string, w io.Writer, n *int, err *error)

type RefundValidatorAmount

type RefundValidatorAmount struct {
	Address common.Address
	Amount  *big.Int
	Voteout bool
}

type RewardSchemeDoc

type RewardSchemeDoc struct {
	TotalReward        *big.Int `json:"total_reward"`
	RewardFirstYear    *big.Int `json:"reward_first_year"`
	EpochNumberPerYear uint64   `json:"epoch_no_per_year"`
	TotalYear          uint64   `json:"total_year"`
}

func (RewardSchemeDoc) MarshalJSON

func (rs RewardSchemeDoc) MarshalJSON() ([]byte, error)

func (*RewardSchemeDoc) UnmarshalJSON

func (rs *RewardSchemeDoc) UnmarshalJSON(input []byte) error

type SignAggr

type SignAggr struct {
	ChainID       string
	Height        uint64    `json:"height"`
	Round         int       `json:"round"`
	Type          byte      `json:"type"`
	NumValidators int       `json:"numValidators"`
	BlockID       BlockID   `json:"blockid"`
	Maj23         BlockID   `json:"maj23"`
	BitArray      *BitArray `json:"bitarray"`
	Sum           int64     `json:"sum"`

	SignatureAggr crypto.BLSSignature `json:"SignatureAggr"`
	SignBytes     []byte              `json:"sign_bytes"`
}

func MakeSignAggr

func MakeSignAggr(height uint64, round int, mtype byte, numValidators int, blockID BlockID, chainID string, bitArray *BitArray, signAggr crypto.BLSSignature) *SignAggr

func (*SignAggr) HasAll

func (sa *SignAggr) HasAll(valSet *ValidatorSet) bool

func (*SignAggr) HasTwoThirdsMajority

func (sa *SignAggr) HasTwoThirdsMajority(valSet *ValidatorSet) bool

func (*SignAggr) IsCommit

func (sa *SignAggr) IsCommit() bool

func (*SignAggr) MakeCommit

func (sa *SignAggr) MakeCommit() *Commit

func (*SignAggr) SetBitArray

func (sa *SignAggr) SetBitArray(newBitArray *BitArray)

func (*SignAggr) SetMaj23

func (sa *SignAggr) SetMaj23(blockID BlockID)

func (*SignAggr) SignAggr

func (sa *SignAggr) SignAggr() crypto.BLSSignature

func (*SignAggr) SignAggrVerify

func (sa *SignAggr) SignAggrVerify(msg []byte, valSet *ValidatorSet) bool

func (*SignAggr) SignRound

func (sa *SignAggr) SignRound() int

func (*SignAggr) Size

func (sa *SignAggr) Size() int

func (*SignAggr) String

func (va *SignAggr) String() string

func (*SignAggr) StringIndented

func (va *SignAggr) StringIndented(indent string) string

func (*SignAggr) StringShort

func (va *SignAggr) StringShort() string

func (*SignAggr) TwoThirdsMajority

func (sa *SignAggr) TwoThirdsMajority() (blockID BlockID, ok bool)

func (*SignAggr) WriteSignBytes

func (sa *SignAggr) WriteSignBytes(chainID string, w io.Writer, n *int, err *error)

type Signable

type Signable interface {
	WriteSignBytes(chainID string, w io.Writer, n *int, err *error)
}

type Signer

type Signer interface {
	Sign(msg []byte) crypto.Signature
}

type SwitchEpochOp

type SwitchEpochOp struct {
	ChainId       string
	NewValidators *ValidatorSet
}

func (*SwitchEpochOp) Conflict

func (op *SwitchEpochOp) Conflict(op1 ligoTypes.PendingOp) bool

func (*SwitchEpochOp) String

func (op *SwitchEpochOp) String() string

type TMEventData

type TMEventData interface {
	events.EventData
	AssertIsTMEventData()
}

type TendermintExtra

type TendermintExtra struct {
	ChainID         string    `json:"chain_id"`
	Height          uint64    `json:"height"`
	Time            time.Time `json:"time"`
	NeedToSave      bool      `json:"need_to_save"`
	NeedToBroadcast bool      `json:"need_to_broadcast"`
	EpochNumber     uint64    `json:"epoch_number"`
	SeenCommitHash  []byte    `json:"last_commit_hash"`
	ValidatorsHash  []byte    `json:"validators_hash"`
	SeenCommit      *Commit   `json:"seen_commit"`
	EpochBytes      []byte    `json:"epoch_bytes"`
}

func DecodeExtraData

func DecodeExtraData(extra string) (ncExtra *TendermintExtra, err error)

func ExtractTendermintExtra

func ExtractTendermintExtra(h *ligoTypes.Header) (*TendermintExtra, error)

func (*TendermintExtra) Copy

func (te *TendermintExtra) Copy() *TendermintExtra

func (*TendermintExtra) Hash

func (te *TendermintExtra) Hash() []byte

func (*TendermintExtra) String

func (te *TendermintExtra) String() string

type TendermintExtraApi

type TendermintExtraApi struct {
	ChainID         string         `json:"chainId"`
	Height          hexutil.Uint64 `json:"height"`
	Time            time.Time      `json:"time"`
	NeedToSave      bool           `json:"needToSave"`
	NeedToBroadcast bool           `json:"needToBroadcast"`
	EpochNumber     hexutil.Uint64 `json:"epochNumber"`
	SeenCommitHash  string         `json:"lastCommitHash"`
	ValidatorsHash  string         `json:"validatorsHash"`
	SeenCommit      *CommitApi     `json:"seenCommit"`
	EpochBytes      []byte         `json:"epochBytes"`
}

type Tx

type Tx []byte

func (Tx) Hash

func (tx Tx) Hash() []byte

type TxProof

type TxProof struct {
	Index, Total int
	RootHash     []byte
	Data         Tx
	Proof        merkle.SimpleProof
}

func (TxProof) LeafHash

func (tp TxProof) LeafHash() []byte

func (TxProof) Validate

func (tp TxProof) Validate(dataHash []byte) error

type Txs

type Txs []Tx

func (Txs) Hash

func (txs Txs) Hash() []byte

func (Txs) Index

func (txs Txs) Index(tx Tx) int

func (Txs) IndexByHash

func (txs Txs) IndexByHash(hash []byte) int

func (Txs) Proof

func (txs Txs) Proof(i int) TxProof

type Validator

type Validator struct {
	Address        []byte        `json:"address"`
	PubKey         crypto.PubKey `json:"pub_key"`
	VotingPower    *big.Int      `json:"voting_power"`
	RemainingEpoch uint64        `json:"remain_epoch"`
}

func NewValidator

func NewValidator(address []byte, pubKey crypto.PubKey, votingPower *big.Int) *Validator

func (*Validator) Copy

func (v *Validator) Copy() *Validator

func (*Validator) Equals

func (v *Validator) Equals(other *Validator) bool

func (*Validator) Hash

func (v *Validator) Hash() []byte

func (*Validator) String

func (v *Validator) String() string

type ValidatorSet

type ValidatorSet struct {
	// NOTE: persisted via reflect, must be exported.
	Validators []*Validator `json:"validators"`
	// contains filtered or unexported fields
}

ValidatorSet represent a set of *Validator at a given height. The validators can be fetched by address or index. The index is in order of .Address, so the indices are fixed for all rounds of a given blockchain height. On the other hand, the .AccumPower of each validator and the designated .GetProposer() of a set changes every round, upon calling .IncrementAccum(). NOTE: Not goroutine-safe. NOTE: All get/set to validators should copy the value for safety. TODO: consider validator Accum overflow TODO: move valset into an iavl tree where key is 'blockbonded|pubkey'

func NewValidatorSet

func NewValidatorSet(vals []*Validator) *ValidatorSet

func (*ValidatorSet) Add

func (valSet *ValidatorSet) Add(val *Validator) (added bool)

func (*ValidatorSet) AggrPubKey

func (valSet *ValidatorSet) AggrPubKey(bitMap *cmn.BitArray) crypto.PubKey

func (*ValidatorSet) Copy

func (valSet *ValidatorSet) Copy() *ValidatorSet

func (*ValidatorSet) Equals

func (valSet *ValidatorSet) Equals(other *ValidatorSet) bool

func (*ValidatorSet) GetAggrPubKeyAndAddress

func (valSet *ValidatorSet) GetAggrPubKeyAndAddress(bitMap *cmn.BitArray) (*ConsensusAggr, error)

func (*ValidatorSet) GetByAddress

func (valSet *ValidatorSet) GetByAddress(address []byte) (index int, val *Validator)

func (*ValidatorSet) GetByIndex

func (valSet *ValidatorSet) GetByIndex(index int) (address []byte, val *Validator)

func (*ValidatorSet) HasAddress

func (valSet *ValidatorSet) HasAddress(address []byte) bool

HasAddress returns true if address given is in the validator set, false - otherwise.

func (*ValidatorSet) Hash

func (valSet *ValidatorSet) Hash() []byte

func (*ValidatorSet) Iterate

func (valSet *ValidatorSet) Iterate(fn func(index int, val *Validator) bool)

func (*ValidatorSet) Remove

func (valSet *ValidatorSet) Remove(address []byte) (val *Validator, removed bool)

func (*ValidatorSet) Size

func (valSet *ValidatorSet) Size() int

func (*ValidatorSet) String

func (valSet *ValidatorSet) String() string

func (*ValidatorSet) StringIndented

func (valSet *ValidatorSet) StringIndented(indent string) string

func (*ValidatorSet) TalliedVotingPower

func (valSet *ValidatorSet) TalliedVotingPower(bitMap *cmn.BitArray) (*big.Int, *big.Int, *big.Int, error)

func (*ValidatorSet) TotalVotingPower

func (valSet *ValidatorSet) TotalVotingPower() *big.Int

func (*ValidatorSet) Update

func (valSet *ValidatorSet) Update(val *Validator) (updated bool)

func (*ValidatorSet) VerifyCommit

func (valSet *ValidatorSet) VerifyCommit(chainID string, height uint64, commit *Commit) error

Verify that +2/3 of the set had signed the given signBytes

func (*ValidatorSet) VerifyCommitAny

func (valSet *ValidatorSet) VerifyCommitAny(chainID string, blockID BlockID, height int, commit *Commit) error

Verify that +2/3 of this set had signed the given signBytes. Unlike VerifyCommit(), this function can verify commits with differeent sets.

type ValidatorStatus

type ValidatorStatus struct {
	IsBanned bool `json:"isBanned"`
}

type ValidatorsByAddress

type ValidatorsByAddress []*Validator

func (ValidatorsByAddress) Len

func (vs ValidatorsByAddress) Len() int

func (ValidatorsByAddress) Less

func (vs ValidatorsByAddress) Less(i, j int) bool

func (ValidatorsByAddress) Swap

func (vs ValidatorsByAddress) Swap(i, j int)

type Vote

type Vote struct {
	ValidatorAddress []byte           `json:"validator_address"`
	ValidatorIndex   uint64           `json:"validator_index"`
	Height           uint64           `json:"height"`
	Round            uint64           `json:"round"`
	Type             byte             `json:"type"`
	BlockID          BlockID          `json:"block_id"` // zero if vote is nil.
	Signature        crypto.Signature `json:"signature"`
	SignBytes        []byte           `json:"sign_bytes"`
}

Represents a prevote, precommit, or commit vote from validators for consensus.

func (*Vote) Copy

func (vote *Vote) Copy() *Vote

func (*Vote) DecodeRLP

func (vote *Vote) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder, and load the istanbul fields from a RLP stream.

func (*Vote) EncodeRLP

func (vote *Vote) EncodeRLP(w io.Writer) error

EncodeRLP serializes ist into the Ethereum RLP format.

func (*Vote) String

func (vote *Vote) String() string

func (*Vote) WriteSignBytes

func (vote *Vote) WriteSignBytes(chainID string, w io.Writer, n *int, err *error)

type VoteSet

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

func NewVoteSet

func NewVoteSet(chainID string, height uint64, round int, type_ byte, valSet *ValidatorSet) *VoteSet

Constructs a new VoteSet struct used to accumulate votes for given height/round.

func (*VoteSet) AddVote

func (voteSet *VoteSet) AddVote(vote *Vote) (added bool, err error)

Returns added=true if vote is valid and new. Otherwise returns err=ErrVote[

UnexpectedStep | InvalidIndex | InvalidAddress |
InvalidSignature | InvalidBlockHash | ConflictingVotes ]

Duplicate votes return added=false, err=nil. Conflicting votes return added=*, err=ErrVoteConflictingVotes. NOTE: vote should not be mutated after adding. NOTE: VoteSet must not be nil

func (*VoteSet) BitArray

func (voteSet *VoteSet) BitArray() *BitArray

func (*VoteSet) BitArrayByBlockID

func (voteSet *VoteSet) BitArrayByBlockID(blockID BlockID) *BitArray

func (*VoteSet) ChainID

func (voteSet *VoteSet) ChainID() string

func (*VoteSet) GetByAddress

func (voteSet *VoteSet) GetByAddress(address []byte) *Vote

func (*VoteSet) GetByIndex

func (voteSet *VoteSet) GetByIndex(valIndex int) *Vote

NOTE: if validator has conflicting votes, returns "canonical" vote

func (*VoteSet) HasAll

func (voteSet *VoteSet) HasAll() bool

func (*VoteSet) HasTwoThirdsMajority

func (voteSet *VoteSet) HasTwoThirdsMajority() bool

func (*VoteSet) Height

func (voteSet *VoteSet) Height() uint64

func (*VoteSet) IsCommit

func (voteSet *VoteSet) IsCommit() bool

func (*VoteSet) Round

func (voteSet *VoteSet) Round() int

func (*VoteSet) SetPeerMaj23

func (voteSet *VoteSet) SetPeerMaj23(peerID string, blockID BlockID)

If a peer claims that it has 2/3 majority for given blockKey, call this. NOTE: if there are too many peers, or too much peer churn, this can cause memory issues. TODO: implement ability to remove peers too NOTE: VoteSet must not be nil

func (*VoteSet) Size

func (voteSet *VoteSet) Size() int

func (*VoteSet) String

func (voteSet *VoteSet) String() string

func (*VoteSet) StringIndented

func (voteSet *VoteSet) StringIndented(indent string) string

func (*VoteSet) StringShort

func (voteSet *VoteSet) StringShort() string

func (*VoteSet) TwoThirdsMajority

func (voteSet *VoteSet) TwoThirdsMajority() (blockID BlockID, ok bool)

Returns either a blockhash (or nil) that received +2/3 majority. If there exists no such majority, returns (nil, PartSetHeader{}, false).

func (*VoteSet) Type

func (voteSet *VoteSet) Type() byte

func (*VoteSet) Votes

func (voteSet *VoteSet) Votes() []*Vote

type VoteSetReader

type VoteSetReader interface {
	Height() uint64
	Round() int
	Type() byte
	Size() int
	BitArray() *BitArray
	GetByIndex(int) *Vote
	IsCommit() bool
}

Common interface between *consensus.VoteSet and types.Commit

Jump to

Keyboard shortcuts

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