smartbft

package
v0.0.0-...-f69b815 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: Apache-2.0, Apache-2.0 Imports: 46 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CommitMsgSeeds []*protos.Message
View Source
var HeartBeatResponseSeeds []*protos.Message
View Source
var HeartBeatSeeds []*protos.Message
View Source
var NewViewSeeds []*protos.Message
View Source
var PrePareMsgSeeds []*protos.Message
View Source
var PrePrePareMsgSeeds []*protos.Message

for fuzz seeds

View Source
var StateTransferRequestSeeds []*protos.Message
View Source
var StateTransferResponseSeeds []*protos.Message
View Source
var ViewChangeSeeds []*protos.Message
View Source
var ViewDataSeeds []*protos.Message

Functions

func AddCommitMsgSeeds

func AddCommitMsgSeeds(m *protos.Message)

func AddHeartBeatResponseSeeds

func AddHeartBeatResponseSeeds(m *protos.Message)

func AddHeartBeatSeeds

func AddHeartBeatSeeds(m *protos.Message)

func AddNewViewSeeds

func AddNewViewSeeds(m *protos.Message)

func AddPrePareMsgSeeds

func AddPrePareMsgSeeds(m *protos.Message)

func AddPrePrePareMsgSeeds

func AddPrePrePareMsgSeeds(m *protos.Message)

func AddStateTransferRequestSeeds

func AddStateTransferRequestSeeds(m *protos.Message)

func AddStateTransferResponseSeeds

func AddStateTransferResponseSeeds(m *protos.Message)

func AddTransactionSeeds

func AddTransactionSeeds(seed []byte)

func AddViewChangeSeeds

func AddViewChangeSeeds(m *protos.Message)

func AddViewDataSeeds

func AddViewDataSeeds(m *protos.Message)

func CommitFuzz

func CommitFuzz(m *protos.Message) *protos.Message

func ConfigurationEnvelop

func ConfigurationEnvelop(configBlock *common.Block) (*common.ConfigEnvelope, error)

ConfigurationEnvelop extract configuration envelop

func ConsensusMessageFuzzed

func ConsensusMessageFuzzed(m *protos.Message)

======================= funcs for Consensus message Fuzzer =======================

func HeartBeatFuzz

func HeartBeatFuzz(m *protos.Message) *protos.Message

func HeartBeatResponseFuzz

func HeartBeatResponseFuzz(m *protos.Message) *protos.Message

func LastBlockFromLedgerOrPanic

func LastBlockFromLedgerOrPanic(ledger Ledger, logger Logger) *common.Block

func LastConfigBlockFromLedgerOrPanic

func LastConfigBlockFromLedgerOrPanic(ledger Ledger, logger Logger) *common.Block

func NewViewFuzz

func NewViewFuzz(m *protos.Message) *protos.Message

func PrePareMsgFuzz

func PrePareMsgFuzz(m *protos.Message) *protos.Message

func PrePrePareMsgFuzz

func PrePrePareMsgFuzz(m *protos.Message) *protos.Message

func PreviousConfigBlockFromLedgerOrPanic

func PreviousConfigBlockFromLedgerOrPanic(ledger Ledger, logger Logger) *common.Block

func ProposalToBlock

func ProposalToBlock(proposal types.Proposal) (*common.Block, error)

func RemoteNodesFromConfigBlock

func RemoteNodesFromConfigBlock(block *common.Block, selfID uint64, logger *flogging.FabricLogger) (*nodeConfig, error)

func StateTransferRequest

func StateTransferRequest(m *protos.Message) *protos.Message

func StateTransferResponse

func StateTransferResponse(m *protos.Message) *protos.Message

func TransactionMessageFuzzed

func TransactionMessageFuzzed(req []byte) []byte

======================= Funcs for Transaction message Fuzzer =======================

func ViewChangeFuzz

func ViewChangeFuzz(m *protos.Message) *protos.Message

func ViewDataFuzz

func ViewDataFuzz(m *protos.Message) *protos.Message

Types

type AccessController

type AccessController interface {
	// Evaluate takes a set of SignedData and evaluates whether this set of signatures satisfies the policy
	Evaluate(signatureSet []*common.SignedData) error
}

AccessController is used to determine if a signature of a certain client is valid

type Assembler

type Assembler struct {
	RuntimeConfig   *atomic.Value
	Logger          *flogging.FabricLogger
	VerificationSeq func() uint64
}

func (*Assembler) AssembleProposal

func (a *Assembler) AssembleProposal(metadata []byte, requests [][]byte) (nextProp types.Proposal)

type BFTChain

type BFTChain struct {
	RuntimeConfig    *atomic.Value
	Channel          string
	Config           types.Configuration
	BlockPuller      BlockPuller
	Comm             cluster.Communicator
	SignerSerializer signerSerializer
	PolicyManager    policies.Manager
	Logger           *flogging.FabricLogger
	WALDir           string

	Metrics *Metrics
	// contains filtered or unexported fields
}

BFTChain implements Chain interface to wire with BFT smart library

func NewChain

func NewChain(
	cv ConfigValidator,
	selfID uint64,
	config types.Configuration,
	walDir string,
	blockPuller BlockPuller,
	comm cluster.Communicator,
	signerSerializer signerSerializer,
	policyManager policies.Manager,
	support consensus.ConsenterSupport,
	metrics *Metrics,
) (*BFTChain, error)

NewChain creates new BFT Smart chain

func (*BFTChain) Configure

func (c *BFTChain) Configure(config *common.Envelope, configSeq uint64) error

func (*BFTChain) Deliver

func (c *BFTChain) Deliver(proposal types.Proposal, signatures []types.Signature) types.Reconfig

func (*BFTChain) Errored

func (c *BFTChain) Errored() <-chan struct{}

func (*BFTChain) Halt

func (c *BFTChain) Halt()

func (*BFTChain) HandleMessage

func (c *BFTChain) HandleMessage(sender uint64, m *smartbftprotos.Message)

func (*BFTChain) HandleRequest

func (c *BFTChain) HandleRequest(sender uint64, req []byte)

func (*BFTChain) Order

func (c *BFTChain) Order(env *common.Envelope, configSeq uint64) error

func (*BFTChain) Start

func (c *BFTChain) Start()

func (*BFTChain) WaitReady

func (c *BFTChain) WaitReady() error

type BlockPuller

type BlockPuller interface {
	PullBlock(seq uint64) *common.Block
	HeightsByEndpoints() (map[string]uint64, error)
	Close()
}

BlockPuller is used to pull blocks from other OSN

type Bundle

type Bundle interface {
	channelconfig.Resources
}

type ByteBufferTuple

type ByteBufferTuple struct {
	A []byte
	B []byte
}

func (*ByteBufferTuple) FromBytes

func (bbt *ByteBufferTuple) FromBytes(bytes []byte) error

func (*ByteBufferTuple) ToBytes

func (bbt *ByteBufferTuple) ToBytes() []byte

type ChainGetter

type ChainGetter interface {
	// GetChain obtains the ChainSupport for the given channel.
	// Returns nil, false when the ChainSupport for the given channel
	// isn't found.
	GetChain(chainID string) *multichannel.ChainSupport
}

ChainGetter obtains instances of ChainSupport for the given channel

type ChannelConfigTemplator

type ChannelConfigTemplator interface {
	NewChannelConfig(env *common.Envelope) (channelconfig.Resources, error)
}

type ConfigBlockValidator

type ConfigBlockValidator struct {
	ChannelConfigTemplator ChannelConfigTemplator
	ConfigUpdateProposer   ConfigUpdateProposer
	ValidatingChannel      string
	Filters                Filters
	Logger                 *flogging.FabricLogger
}

func (*ConfigBlockValidator) ValidateConfig

func (cbv *ConfigBlockValidator) ValidateConfig(envelope *common.Envelope) error

type ConfigTxValidator

type ConfigTxValidator interface {
	configtx.Validator
}

type ConfigUpdateProposer

type ConfigUpdateProposer interface {
	ProposeConfigUpdate(channel string, configtx *common.Envelope) (*common.ConfigEnvelope, error)
}

type ConfigValidator

type ConfigValidator interface {
	ValidateConfig(env *common.Envelope) error
}

type Consenter

type Consenter struct {
	CreateChain func(chainName string)
	cluster.InactiveChainRegistry
	GetPolicyManager PolicyManagerRetriever
	Logger           *flogging.FabricLogger
	Cert             []byte
	Comm             *cluster.Comm
	Chains           ChainGetter
	SignerSerializer signerSerializer
	Registrar        *multichannel.Registrar
	WALBaseDir       string
	ClusterDialer    *cluster.PredicateDialer
	Conf             *localconfig.TopLevel
	Metrics          *Metrics
}

Consenter implementation of the BFT smart based consenter

func New

func New(
	icr cluster.InactiveChainRegistry,
	pmr PolicyManagerRetriever,
	signerSerializer signerSerializer,
	clusterDialer *cluster.PredicateDialer,
	conf *localconfig.TopLevel,
	srvConf comm.ServerConfig,
	srv *comm.GRPCServer,
	r *multichannel.Registrar,
	metricsProvider metrics.Provider,
) *Consenter

New creates Consenter of type smart bft

func (*Consenter) HandleChain

func (c *Consenter) HandleChain(support consensus.ConsenterSupport, metadata *common.Metadata) (consensus.Chain, error)

func (*Consenter) ReceiverByChain

func (c *Consenter) ReceiverByChain(channelID string) MessageReceiver

ReceiverByChain returns the MessageReceiver for the given channelID or nil if not found.

func (*Consenter) TargetChannel

func (c *Consenter) TargetChannel(message proto2.Message) string

TargetChannel extracts the channel from the given proto.Message. Returns an empty string on failure.

type ConsenterCertificate

type ConsenterCertificate []byte

ConsenterCertificate denotes a TLS certificate of a consenter

func (ConsenterCertificate) IsConsenterOfChannel

func (conCert ConsenterCertificate) IsConsenterOfChannel(configBlock *common.Block) error

IsConsenterOfChannel returns whether the caller is a consenter of a channel by inspecting the given configuration block. It returns nil if true, else returns an error.

type ConsenterVerifier

type ConsenterVerifier interface {
	// Evaluate takes a set of SignedData and evaluates whether this set of signatures satisfies the policy
	Evaluate(signatureSet []*common.SignedData) error
}

ConsenterVerifier is used to determine whether a signature from one of the consenters is valid

type CreateChainCallback

type CreateChainCallback func()

CreateChainCallback creates a new chain

type Egress

type Egress struct {
	Channel       string
	RPC           RPC
	Logger        Logger
	RuntimeConfig *atomic.Value
}

func (*Egress) Nodes

func (e *Egress) Nodes() []uint64

func (*Egress) SendConsensus

func (e *Egress) SendConsensus(targetID uint64, m *protos.Message)

func (*Egress) SendConsensusFuzz

func (e *Egress) SendConsensusFuzz(targetID uint64, m *protos.Message)

func (*Egress) SendTransaction

func (e *Egress) SendTransaction(targetID uint64, request []byte)

func (*Egress) SendTransactionFuzz

func (e *Egress) SendTransactionFuzz(targetID uint64, request []byte)

type Filters

type Filters interface {
	ApplyFilters(channel string, env *common.Envelope) error
}

type Ingreess

type Ingreess struct {
	Logger        WarningLogger
	ChainSelector ReceiverGetter
}

Ingreess dispatches Submit and Step requests to the designated per chain instances

func (*Ingreess) OnConsensus

func (in *Ingreess) OnConsensus(channel string, sender uint64, request *orderer.ConsensusRequest) error

OnConsensus notifies the Ingreess for a reception of a StepRequest from a given sender on a given channel

func (*Ingreess) OnSubmit

func (in *Ingreess) OnSubmit(channel string, sender uint64, request *orderer.SubmitRequest) error

OnSubmit notifies the Ingreess for a reception of a SubmitRequest from a given sender on a given channel

type Ledger

type Ledger interface {
	// Height returns the number of blocks in the ledger this channel is associated with.
	Height() uint64

	// Block returns a block with the given number,
	// or nil if such a block doesn't exist.
	Block(number uint64) *common.Block
}

type Logger

type Logger interface {
	Warnf(template string, args ...interface{})
	Panicf(template string, args ...interface{})
	Infof(template string, args ...interface{})
}

type MessageReceiver

type MessageReceiver interface {
	HandleMessage(sender uint64, m *protos.Message)
	HandleRequest(sender uint64, req []byte)
}

MessageReceiver receives messages

type MessageType

type MessageType int32
const (
	PrePrePareMsg            MessageType = 0
	PrePareMsg               MessageType = 1
	CommitMsg                MessageType = 2
	ViewChangeMsg            MessageType = 3
	ViewDataMsg              MessageType = 4
	NewViewMsg               MessageType = 5
	HeartBeatMsg             MessageType = 6
	HeartBeatResponseMsg     MessageType = 7
	StateTransferRequestMsg  MessageType = 8
	StateTransferResponseMsg MessageType = 9
)

type Metrics

type Metrics struct {
	ClusterSize          metrics.Gauge
	CommittedBlockNumber metrics.Gauge
	IsLeader             metrics.Gauge
	LeaderID             metrics.Gauge
}

func NewMetrics

func NewMetrics(p metrics.Provider) *Metrics

type NodeIdentitiesByID

type NodeIdentitiesByID map[uint64][]byte

func (NodeIdentitiesByID) IdentityToID

func (nibd NodeIdentitiesByID) IdentityToID(identity []byte) (uint64, bool)

type PolicyManagerRetriever

type PolicyManagerRetriever func(channel string) policies.Manager

type ProtocolFuzzer

type ProtocolFuzzer struct {
	Logger *flogging.FabricLogger
	// contains filtered or unexported fields
}

func NewProtocolFuzzer

func NewProtocolFuzzer(cons *smartbft.Consensus) *ProtocolFuzzer

func (*ProtocolFuzzer) BroadcastConsensusFuzz

func (pf *ProtocolFuzzer) BroadcastConsensusFuzz(msg *protos.Message)

TODO every receiver always get the same message

func (*ProtocolFuzzer) RunFuzz

func (pf *ProtocolFuzzer) RunFuzz()

type RPC

type RPC interface {
	SendConsensus(dest uint64, msg *orderer.ConsensusRequest) error
	SendSubmit(dest uint64, request *orderer.SubmitRequest) error
}

type ReceiverGetter

type ReceiverGetter interface {
	// ReceiverByChain returns the MessageReceiver if it exists, or nil if it doesn't
	ReceiverByChain(channelID string) MessageReceiver
}

ReceiverGetter obtains instances of MessageReceiver given a channel ID

type RequestInspector

type RequestInspector struct {
	ValidateIdentityStructure func(identity *msp.SerializedIdentity) error
}

RequestInspector inspects incomming requests and validates serialized identity

func (*RequestInspector) RequestID

func (ri *RequestInspector) RequestID(rawReq []byte) types.RequestInfo

type RuntimeConfig

type RuntimeConfig struct {
	BFTConfig types.Configuration

	LastCommittedBlockHash string
	RemoteNodes            []cluster.RemoteNode
	ID2Identities          NodeIdentitiesByID
	LastBlock              *common.Block
	LastConfigBlock        *common.Block
	Nodes                  []uint64
	// contains filtered or unexported fields
}

RuntimeConfig defines the configuration of the consensus that is related to runtime.

func (RuntimeConfig) BlockCommitted

func (rtc RuntimeConfig) BlockCommitted(block *common.Block) (RuntimeConfig, error)

type Sequencer

type Sequencer interface {
	Sequence() uint64
}

Sequencer returns sequences

type Signature

type Signature struct {
	Nonce                []byte
	SignatureHeader      []byte
	BlockHeader          []byte
	OrdererBlockMetadata []byte
	AuxiliaryInput       []byte
}

func (Signature) AsBytes

func (sig Signature) AsBytes() []byte

func (*Signature) Marshal

func (sig *Signature) Marshal() []byte

func (*Signature) Unmarshal

func (sig *Signature) Unmarshal(bytes []byte) error

type Signer

type Signer struct {
	ID                 uint64
	SignerSerializer   SignerSerializer
	Logger             Logger
	LastConfigBlockNum func(*common.Block) uint64
}

func (*Signer) Sign

func (s *Signer) Sign(msg []byte) []byte

func (*Signer) SignProposal

func (s *Signer) SignProposal(proposal types.Proposal, auxiliaryInput []byte) *types.Signature

type SignerSerializer

type SignerSerializer interface {
	crypto.Signer
	crypto.IdentitySerializer
}

type Synchronizer

type Synchronizer struct {
	LatestConfig    func() (types.Configuration, []uint64)
	BlockToDecision func(*common.Block) *types.Decision
	OnCommit        func(*common.Block) types.Reconfig
	Support         consensus.ConsenterSupport
	BlockPuller     BlockPuller
	Logger          *flogging.FabricLogger
	// contains filtered or unexported fields
}

func (*Synchronizer) Close

func (s *Synchronizer) Close()

func (*Synchronizer) Sync

func (s *Synchronizer) Sync() types.SyncResponse

type TransactionFuzzer

type TransactionFuzzer struct {
	Logger *flogging.FabricLogger
	// contains filtered or unexported fields
}

func NewTransactionFuzzer

func NewTransactionFuzzer(cons *smartbft.Consensus) *TransactionFuzzer

func (*TransactionFuzzer) BroadcastTransactionsFuzz

func (tf *TransactionFuzzer) BroadcastTransactionsFuzz(req []byte)

func (*TransactionFuzzer) RunTxFuzz

func (tf *TransactionFuzzer) RunTxFuzz()

type Verifier

type Verifier struct {
	RuntimeConfig         *atomic.Value
	ReqInspector          *RequestInspector
	ConsenterVerifier     ConsenterVerifier
	AccessController      AccessController
	VerificationSequencer Sequencer
	Ledger                Ledger
	Logger                *flogging.FabricLogger
	ConfigValidator       ConfigValidator
}

func (*Verifier) AuxiliaryData

func (v *Verifier) AuxiliaryData(msg []byte) []byte

func (*Verifier) RequestsFromProposal

func (v *Verifier) RequestsFromProposal(proposal types.Proposal) []types.RequestInfo

func (*Verifier) VerificationSequence

func (v *Verifier) VerificationSequence() uint64

func (*Verifier) VerifyConsenterSig

func (v *Verifier) VerifyConsenterSig(signature types.Signature, prop types.Proposal) ([]byte, error)

func (*Verifier) VerifyProposal

func (v *Verifier) VerifyProposal(proposal types.Proposal) ([]types.RequestInfo, error)

func (*Verifier) VerifyRequest

func (v *Verifier) VerifyRequest(rawRequest []byte) (types.RequestInfo, error)

func (*Verifier) VerifySignature

func (v *Verifier) VerifySignature(signature types.Signature) error

type WALConfig

type WALConfig struct {
	WALDir            string // WAL data of <my-channel> is stored in WALDir/<my-channel>
	SnapDir           string // Snapshots of <my-channel> are stored in SnapDir/<my-channel>
	EvictionSuspicion string // Duration threshold that the node samples in order to suspect its eviction from the channel.
}

WALConfig consensus specific configuration parameters from orderer.yaml; for SmartBFT only WALDir is relevant.

type WarningLogger

type WarningLogger interface {
	Warningf(template string, args ...interface{})
	Infof(template string, ars ...interface{})
}

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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