core

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2020 License: GPL-3.0, GPL-3.0 Imports: 27 Imported by: 0

Documentation

Overview

Package core is a generated GoMock package.

Index

Constants

View Source
const (
	MaxRound = 99 // consequence of backlog priority
)
View Source
const MaxSizeBacklogUnchecked = 1000

Variables

View Source
var ErrEmptyCommitteeSet = errors.New("committee set can't be empty")
View Source
var (
	ErrUnauthorizedAddress = errors.New("unauthorized address")
)

Functions

func Encode

func Encode(val interface{}) ([]byte, error)

func New

func New(backend Backend, config *config.Config) *core

New creates an Tendermint consensus core

func NewRoundMessages added in v0.4.0

func NewRoundMessages() *roundMessages

NewRoundMessages creates a new messages instance with the given view and validatorSet we need to keep a reference of proposal in order to propose locked proposal when there is a lock and itself is the proposer

func PrepareCommittedSeal

func PrepareCommittedSeal(hash common.Hash, round int64, height *big.Int) []byte

PrepareCommittedSeal returns a committed seal for the given hash

Types

type Backend added in v0.1.6

type Backend interface {
	Address() common.Address

	AddSeal(block *types.Block) (*types.Block, error)

	AskSync(header *types.Header)

	// Broadcast sends a message to all validators (include self)
	Broadcast(ctx context.Context, committee types.Committee, payload []byte) error

	// Commit delivers an approved proposal to backend.
	// The delivered proposal will be put into blockchain.
	Commit(proposalBlock *types.Block, round int64, seals [][]byte) error

	GetContractABI() string

	// Gossip sends a message to all validators (exclude self)
	Gossip(ctx context.Context, committee types.Committee, payload []byte)

	KnownMsgHash() []common.Hash

	HandleUnhandledMsgs(ctx context.Context)

	// LastCommittedProposal retrieves latest committed proposal and the address of proposer
	LastCommittedProposal() (*types.Block, common.Address)

	Post(ev interface{})

	// Setter for proposed block hash
	SetProposedBlockHash(hash common.Hash)

	// Sign signs input data with the backend's private key
	Sign([]byte) ([]byte, error)

	Subscribe(types ...interface{}) *event.TypeMuxSubscription

	SyncPeer(address common.Address)

	// VerifyProposal verifies the proposal. If a consensus.ErrFutureBlock error is returned,
	// the time difference of the proposal and current time is also returned.
	VerifyProposal(types.Block) (time.Duration, error)

	WhiteList() []string

	BlockChain() *ethcore.BlockChain

	//Used to set the blockchain on this
	SetBlockchain(bc *ethcore.BlockChain)

	// RemoveMessageFromLocalCache removes a local message from the known messages cache.
	// It is called by core when some unprocessed messages are removed from the untrusted backlog buffer.
	RemoveMessageFromLocalCache(payload []byte)
}

Backend provides application specific functions for Istanbul core

type ConsensusMsg added in v0.4.0

type ConsensusMsg interface {
	GetRound() int64
	GetHeight() *big.Int
}

type Message added in v0.1.6

type Message struct {
	Code          uint64
	Msg           []byte
	Address       common.Address
	Signature     []byte
	CommittedSeal []byte
	// contains filtered or unexported fields
}

func (*Message) Decode added in v0.1.6

func (m *Message) Decode(val interface{}) error

func (*Message) DecodeRLP added in v0.1.6

func (m *Message) DecodeRLP(s *rlp.Stream) error

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

func (*Message) EncodeRLP added in v0.1.6

func (m *Message) EncodeRLP(w io.Writer) error

EncodeRLP serializes m into the Ethereum RLP format.

func (*Message) FromPayload added in v0.1.6

func (m *Message) FromPayload(b []byte) error

func (*Message) GetCode added in v0.1.6

func (m *Message) GetCode() uint64

func (*Message) GetPower added in v0.4.0

func (m *Message) GetPower() uint64

func (*Message) GetSignature added in v0.1.6

func (m *Message) GetSignature() []byte

func (*Message) Height added in v0.4.0

func (m *Message) Height() (*big.Int, error)

func (*Message) Payload added in v0.1.6

func (m *Message) Payload() []byte

func (*Message) PayloadNoSig added in v0.1.6

func (m *Message) PayloadNoSig() ([]byte, error)

func (*Message) Round added in v0.4.0

func (m *Message) Round() (int64, error)

func (*Message) String added in v0.1.6

func (m *Message) String() string

func (*Message) Validate added in v0.7.0

func (m *Message) Validate(validateFn func(*types.Header, []byte, []byte) (common.Address, error), previousHeader *types.Header) (*types.CommitteeMember, error)

type MockBackend added in v0.1.6

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

MockBackend is a mock of Backend interface

func NewMockBackend added in v0.1.6

func NewMockBackend(ctrl *gomock.Controller) *MockBackend

NewMockBackend creates a new mock instance

func (*MockBackend) AddSeal added in v0.4.0

func (m *MockBackend) AddSeal(block *types.Block) (*types.Block, error)

AddSeal mocks base method

func (*MockBackend) Address added in v0.1.6

func (m *MockBackend) Address() common.Address

Address mocks base method

func (*MockBackend) AskSync added in v0.3.0

func (m *MockBackend) AskSync(header *types.Header)

AskSync mocks base method

func (*MockBackend) BlockChain added in v0.5.0

func (m *MockBackend) BlockChain() *ethcore.BlockChain

BlockChain mocks base method

func (*MockBackend) Broadcast added in v0.1.6

func (m *MockBackend) Broadcast(ctx context.Context, committee types.Committee, payload []byte) error

Broadcast mocks base method

func (*MockBackend) Commit added in v0.1.6

func (m *MockBackend) Commit(proposalBlock *types.Block, round int64, seals [][]byte) error

Commit mocks base method

func (*MockBackend) EXPECT added in v0.1.6

func (m *MockBackend) EXPECT() *MockBackendMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockBackend) GetContractABI added in v0.3.0

func (m *MockBackend) GetContractABI() string

GetContractABI mocks base method

func (*MockBackend) Gossip added in v0.1.6

func (m *MockBackend) Gossip(ctx context.Context, committee types.Committee, payload []byte)

Gossip mocks base method

func (*MockBackend) HandleUnhandledMsgs added in v0.3.0

func (m *MockBackend) HandleUnhandledMsgs(ctx context.Context)

HandleUnhandledMsgs mocks base method

func (*MockBackend) KnownMsgHash added in v0.7.0

func (m *MockBackend) KnownMsgHash() []common.Hash

KnownMsgHash mocks base method

func (*MockBackend) LastCommittedProposal added in v0.1.6

func (m *MockBackend) LastCommittedProposal() (*types.Block, common.Address)

LastCommittedProposal mocks base method

func (*MockBackend) Post added in v0.1.6

func (m *MockBackend) Post(ev interface{})

Post mocks base method

func (*MockBackend) RemoveMessageFromLocalCache added in v0.7.0

func (m *MockBackend) RemoveMessageFromLocalCache(payload []byte)

RemoveMessageFromLocalCache mocks base method

func (*MockBackend) SetBlockchain added in v0.5.0

func (m *MockBackend) SetBlockchain(bc *ethcore.BlockChain)

SetBlockchain mocks base method

func (*MockBackend) SetProposedBlockHash added in v0.1.6

func (m *MockBackend) SetProposedBlockHash(hash common.Hash)

SetProposedBlockHash mocks base method

func (*MockBackend) Sign added in v0.1.6

func (m *MockBackend) Sign(arg0 []byte) ([]byte, error)

Sign mocks base method

func (*MockBackend) Subscribe added in v0.1.6

func (m *MockBackend) Subscribe(types ...interface{}) *event.TypeMuxSubscription

Subscribe mocks base method

func (*MockBackend) SyncPeer added in v0.1.6

func (m *MockBackend) SyncPeer(address common.Address)

SyncPeer mocks base method

func (*MockBackend) VerifyProposal added in v0.1.6

func (m *MockBackend) VerifyProposal(arg0 types.Block) (time.Duration, error)

VerifyProposal mocks base method

func (*MockBackend) WhiteList added in v0.3.0

func (m *MockBackend) WhiteList() []string

WhiteList mocks base method

type MockBackendMockRecorder added in v0.1.6

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

MockBackendMockRecorder is the mock recorder for MockBackend

func (*MockBackendMockRecorder) AddSeal added in v0.4.0

func (mr *MockBackendMockRecorder) AddSeal(block interface{}) *gomock.Call

AddSeal indicates an expected call of AddSeal

func (*MockBackendMockRecorder) Address added in v0.1.6

func (mr *MockBackendMockRecorder) Address() *gomock.Call

Address indicates an expected call of Address

func (*MockBackendMockRecorder) AskSync added in v0.3.0

func (mr *MockBackendMockRecorder) AskSync(header interface{}) *gomock.Call

AskSync indicates an expected call of AskSync

func (*MockBackendMockRecorder) BlockChain added in v0.5.0

func (mr *MockBackendMockRecorder) BlockChain() *gomock.Call

BlockChain indicates an expected call of BlockChain

func (*MockBackendMockRecorder) Broadcast added in v0.1.6

func (mr *MockBackendMockRecorder) Broadcast(ctx, committee, payload interface{}) *gomock.Call

Broadcast indicates an expected call of Broadcast

func (*MockBackendMockRecorder) Commit added in v0.1.6

func (mr *MockBackendMockRecorder) Commit(proposalBlock, round, seals interface{}) *gomock.Call

Commit indicates an expected call of Commit

func (*MockBackendMockRecorder) GetContractABI added in v0.3.0

func (mr *MockBackendMockRecorder) GetContractABI() *gomock.Call

GetContractABI indicates an expected call of GetContractABI

func (*MockBackendMockRecorder) Gossip added in v0.1.6

func (mr *MockBackendMockRecorder) Gossip(ctx, committee, payload interface{}) *gomock.Call

Gossip indicates an expected call of Gossip

func (*MockBackendMockRecorder) HandleUnhandledMsgs added in v0.3.0

func (mr *MockBackendMockRecorder) HandleUnhandledMsgs(ctx interface{}) *gomock.Call

HandleUnhandledMsgs indicates an expected call of HandleUnhandledMsgs

func (*MockBackendMockRecorder) KnownMsgHash added in v0.7.0

func (mr *MockBackendMockRecorder) KnownMsgHash() *gomock.Call

KnownMsgHash indicates an expected call of KnownMsgHash

func (*MockBackendMockRecorder) LastCommittedProposal added in v0.1.6

func (mr *MockBackendMockRecorder) LastCommittedProposal() *gomock.Call

LastCommittedProposal indicates an expected call of LastCommittedProposal

func (*MockBackendMockRecorder) Post added in v0.1.6

func (mr *MockBackendMockRecorder) Post(ev interface{}) *gomock.Call

Post indicates an expected call of Post

func (*MockBackendMockRecorder) RemoveMessageFromLocalCache added in v0.7.0

func (mr *MockBackendMockRecorder) RemoveMessageFromLocalCache(payload interface{}) *gomock.Call

RemoveMessageFromLocalCache indicates an expected call of RemoveMessageFromLocalCache

func (*MockBackendMockRecorder) SetBlockchain added in v0.5.0

func (mr *MockBackendMockRecorder) SetBlockchain(bc interface{}) *gomock.Call

SetBlockchain indicates an expected call of SetBlockchain

func (*MockBackendMockRecorder) SetProposedBlockHash added in v0.1.6

func (mr *MockBackendMockRecorder) SetProposedBlockHash(hash interface{}) *gomock.Call

SetProposedBlockHash indicates an expected call of SetProposedBlockHash

func (*MockBackendMockRecorder) Sign added in v0.1.6

func (mr *MockBackendMockRecorder) Sign(arg0 interface{}) *gomock.Call

Sign indicates an expected call of Sign

func (*MockBackendMockRecorder) Subscribe added in v0.1.6

func (mr *MockBackendMockRecorder) Subscribe(types ...interface{}) *gomock.Call

Subscribe indicates an expected call of Subscribe

func (*MockBackendMockRecorder) SyncPeer added in v0.1.6

func (mr *MockBackendMockRecorder) SyncPeer(address interface{}) *gomock.Call

SyncPeer indicates an expected call of SyncPeer

func (*MockBackendMockRecorder) VerifyProposal added in v0.1.6

func (mr *MockBackendMockRecorder) VerifyProposal(arg0 interface{}) *gomock.Call

VerifyProposal indicates an expected call of VerifyProposal

func (*MockBackendMockRecorder) WhiteList added in v0.3.0

func (mr *MockBackendMockRecorder) WhiteList() *gomock.Call

WhiteList indicates an expected call of WhiteList

type MockTendermint added in v0.5.0

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

MockTendermint is a mock of Tendermint interface

func NewMockTendermint added in v0.5.0

func NewMockTendermint(ctrl *gomock.Controller) *MockTendermint

NewMockTendermint creates a new mock instance

func (*MockTendermint) CoreState added in v0.7.0

func (m *MockTendermint) CoreState() TendermintState

CoreState mocks base method

func (*MockTendermint) EXPECT added in v0.5.0

EXPECT returns an object that allows the caller to indicate expected use

func (*MockTendermint) GetCurrentHeightMessages added in v0.5.0

func (m *MockTendermint) GetCurrentHeightMessages() []*Message

GetCurrentHeightMessages mocks base method

func (*MockTendermint) Start added in v0.5.0

func (m *MockTendermint) Start(ctx context.Context, contract *autonity.Contract)

Start mocks base method

func (*MockTendermint) Stop added in v0.5.0

func (m *MockTendermint) Stop()

Stop mocks base method

type MockTendermintMockRecorder added in v0.5.0

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

MockTendermintMockRecorder is the mock recorder for MockTendermint

func (*MockTendermintMockRecorder) CoreState added in v0.7.0

func (mr *MockTendermintMockRecorder) CoreState() *gomock.Call

CoreState indicates an expected call of CoreState

func (*MockTendermintMockRecorder) GetCurrentHeightMessages added in v0.5.0

func (mr *MockTendermintMockRecorder) GetCurrentHeightMessages() *gomock.Call

GetCurrentHeightMessages indicates an expected call of GetCurrentHeightMessages

func (*MockTendermintMockRecorder) Start added in v0.5.0

func (mr *MockTendermintMockRecorder) Start(ctx, contract interface{}) *gomock.Call

Start indicates an expected call of Start

func (*MockTendermintMockRecorder) Stop added in v0.5.0

Stop indicates an expected call of Stop

type MsgForDump added in v0.7.0

type MsgForDump struct {
	Message
	Hash   common.Hash
	Power  uint64
	Height *big.Int
	Round  int64
}

MsgWithHash save the msg and extra field to be marshal to JSON.

type Proposal added in v0.1.6

type Proposal struct {
	Round         int64
	Height        *big.Int
	ValidRound    int64
	ProposalBlock *types.Block
}

func NewProposal added in v0.1.6

func NewProposal(r int64, h *big.Int, vr int64, p *types.Block) *Proposal

func (*Proposal) DecodeRLP added in v0.1.6

func (p *Proposal) DecodeRLP(s *rlp.Stream) error

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

func (*Proposal) EncodeRLP added in v0.1.6

func (p *Proposal) EncodeRLP(w io.Writer) error

RLP encoding doesn't support negative big.Int, so we have to pass one additionnal field to represents validRound = -1. Note that we could have as well indexed rounds starting by 1, but we want to stay close as possible to the spec.

func (*Proposal) GetHeight added in v0.4.0

func (p *Proposal) GetHeight() *big.Int

func (*Proposal) GetRound added in v0.4.0

func (p *Proposal) GetRound() int64

func (*Proposal) String added in v0.7.0

func (p *Proposal) String() string

type RoundState added in v0.7.0

type RoundState struct {
	Round          int64
	Proposal       common.Hash
	PrevoteState   []VoteState
	PrecommitState []VoteState
}

RoundState save the voting status for a specific round.

type Step

type Step uint64

func (Step) Cmp

func (s Step) Cmp(y Step) int

func (Step) String

func (s Step) String() string

type Tendermint added in v0.5.0

type Tendermint interface {
	Start(ctx context.Context, contract *autonity.Contract)
	Stop()
	GetCurrentHeightMessages() []*Message
	CoreState() TendermintState
}

type TendermintState added in v0.7.0

type TendermintState struct {
	// validator address
	Client common.Address

	// core state of tendermint
	Height      *big.Int
	Round       int64
	Step        uint64
	Proposal    *common.Hash
	LockedValue *common.Hash
	LockedRound int64
	ValidValue  *common.Hash
	ValidRound  int64

	// committee state
	Committee       types.Committee
	Proposer        common.Address
	IsProposer      bool
	QuorumVotePower uint64
	RoundStates     []RoundState
	ProposerPolicy  uint64

	// extra state
	SentProposal          bool
	SentPrevote           bool
	SentPrecommit         bool
	SetValidRoundAndValue bool

	// timer state
	BlockPeriod           uint64
	ProposeTimerStarted   bool
	PrevoteTimerStarted   bool
	PrecommitTimerStarted bool

	// current height messages.
	CurHeightMessages []*MsgForDump
	// backlog msgs
	BacklogMessages []*MsgForDump
	// backlog unchecked msgs.
	UncheckedMsgs []*MsgForDump
	// Known msg of gossip.
	KnownMsgHash []common.Hash
}

TendermintState save an instant status for the tendermint consensus engine.

type TimeoutEvent added in v0.1.6

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

type Vote added in v0.1.6

type Vote struct {
	Round             int64
	Height            *big.Int
	ProposedBlockHash common.Hash
}

func (*Vote) DecodeRLP added in v0.1.6

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

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

func (*Vote) EncodeRLP added in v0.1.6

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

EncodeRLP serializes b into the Ethereum RLP format.

func (*Vote) GetHeight added in v0.4.0

func (sub *Vote) GetHeight() *big.Int

func (*Vote) GetRound added in v0.4.0

func (sub *Vote) GetRound() int64

func (*Vote) String added in v0.1.6

func (sub *Vote) String() string

type VoteState added in v0.7.0

type VoteState struct {
	Value            common.Hash
	ProposalVerified bool
	VotePower        uint64
}

VoteState save the prevote or precommit voting status for a specific value.

Jump to

Keyboard shortcuts

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