consensus

package
v0.0.24 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: Apache-2.0 Imports: 52 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateConfigCommonBlock added in v0.0.20

func CreateConfigCommonBlock(blockNum uint64, prevHash []byte, txCount uint64, decisionNum arma_types.DecisionNum, batchCount, batchIndex int, configReq []byte) (*common.Block, error)

func CreateConsensusRulesVerifier added in v0.0.20

func CreateConsensusRulesVerifier(config *config.ConsenterNodeConfig) *requestfilter.RulesVerifier

func CreateDataCommonBlock added in v0.0.20

func CreateDataCommonBlock(blockNum uint64, prevHash []byte, batchID arma_types.BatchID, txCount uint64, decisionNum arma_types.DecisionNum, batchCount, batchIndex int, lastConfigBlockNum uint64) (*common.Block, error)

func VerifyConfigCommonBlock added in v0.0.20

func VerifyConfigCommonBlock(configBlock *common.Block, blockNum uint64, prevHash []byte, dataHash []byte, txCount uint64, decisionNum arma_types.DecisionNum, batchCount, batchIndex int) error

func VerifyDataCommonBlock added in v0.0.20

func VerifyDataCommonBlock(block *common.Block, blockNum uint64, prevHash []byte, batchID arma_types.BatchID, txCount uint64, decisionNum arma_types.DecisionNum, batchCount, batchIndex int, lastConfigBlockNum uint64) error

Types

type Arma

type Arma interface {
	SimulateStateTransition(prevState *state.State, configSeq arma_types.ConfigSequence, events [][]byte) (*state.State, [][]arma_types.BatchAttestationFragment, []*state.ConfigRequest)
	Index([][]byte)
}

type BFT

type BFT interface {
	SubmitRequest(req []byte) error
	Start() error
	HandleMessage(targetID uint64, m *smartbftprotos.Message)
	HandleRequest(targetID uint64, request []byte)
	Stop()
}

type BatchAttestationDB added in v0.0.18

type BatchAttestationDB interface {
	Exists(digest []byte) bool
	Put(digest [][]byte, epoch []uint64) // TODO remove epochs from BADB
	Clean(epoch uint64)                  // TODO remove clean by epoch
}

type ConfigApplier added in v0.0.21

type ConfigApplier interface {
	// ApplyConfigToState update the current state based on the config request
	ApplyConfigToState(state *state.State, configRequest *state.ConfigRequest) (*state.State, error)
	// ExtractSmartBFTConfigFromBlock extracts the smartBFT config from a config block
	ExtractSmartBFTConfigFromBlock(configBlock *common.Block, selfID arma_types.PartyID) ([]uint64, smartbft_types.Configuration, error)
}

type Consensus

type Consensus struct {
	delivery.DeliverService
	*comm.ClusterService
	Net          NetStopper
	Config       *config.ConsenterNodeConfig
	SigVerifier  SigVerifier
	Signer       Signer
	CurrentNodes []uint64
	BFTConfig    smartbft_types.Configuration
	BFT          *consensus.Consensus
	Storage      Storage
	BADB         *badb.BatchAttestationDB
	Arma         Arma

	State *state.State

	Logger                 *flogging.FabricLogger
	Synchronizer           SynchronizerStopper
	Metrics                *ConsensusMetrics
	RequestVerifier        *requestfilter.RulesVerifier
	ConfigUpdateProposer   policy.ConfigUpdateProposer
	ConfigApplier          ConfigApplier
	ConfigRequestValidator configrequest.ConfigRequestValidator
	ConfigRulesVerifier    verify.OrdererRules
	// contains filtered or unexported fields
}

func CreateConsensus

func CreateConsensus(conf *config.ConsenterNodeConfig, net NetStopper, lastConfigBlock *common.Block, logger *flogging.FabricLogger, signer Signer, configUpdateProposer policy.ConfigUpdateProposer) *Consensus

func (*Consensus) AssembleProposal

func (c *Consensus) AssembleProposal(metadata []byte, requests [][]byte) smartbft_types.Proposal

AssembleProposal creates a proposal which includes the given requests (when permitting) and metadata (from SmartBFT API)

func (*Consensus) AuxiliaryData

func (c *Consensus) AuxiliaryData(i []byte) []byte

AuxiliaryData extracts the auxiliary data from a signature's message (from SmartBFT API)

func (*Consensus) Deliver

Deliver delivers the given proposal and signatures. After the call returns we assume that this proposal is stored in persistent memory. It returns whether this proposal was a reconfiguration and the current config. (from SmartBFT API)

func (*Consensus) NotifyEvent

func (c *Consensus) NotifyEvent(stream protos.Consensus_NotifyEventServer) error

func (*Consensus) OnConsensus

func (c *Consensus) OnConsensus(channel string, sender uint64, request *orderer.ConsensusRequest) error

func (*Consensus) OnSubmit

func (c *Consensus) OnSubmit(channel string, sender uint64, req *orderer.SubmitRequest) error

func (*Consensus) RequestID

func (c *Consensus) RequestID(req []byte) smartbft_types.RequestInfo

RequestID returns info about the given request (from SmartBFT API)

func (*Consensus) RequestsFromProposal

func (c *Consensus) RequestsFromProposal(proposal smartbft_types.Proposal) []smartbft_types.RequestInfo

RequestsFromProposal returns from the given proposal the included requests' info (from SmartBFT API)

func (*Consensus) Sign

func (c *Consensus) Sign(msg []byte) []byte

Sign signs on the given data and returns the signature (from SmartBFT API)

func (*Consensus) SignProposal

func (c *Consensus) SignProposal(proposal smartbft_types.Proposal, _ []byte) *smartbft_types.Signature

SignProposal signs on the given proposal and returns a composite Signature (from SmartBFT API)

func (*Consensus) SoftStop added in v0.0.20

func (c *Consensus) SoftStop()

func (*Consensus) Start

func (c *Consensus) Start() error

func (*Consensus) Stop

func (c *Consensus) Stop()

func (*Consensus) SubmitConfig added in v0.0.20

func (c *Consensus) SubmitConfig(ctx context.Context, request *protos.Request) (*protos.SubmitResponse, error)

SubmitConfig is used to submit a config request from the router in the consenter's party.

func (*Consensus) SubmitRequest

func (c *Consensus) SubmitRequest(req []byte) error

func (*Consensus) VerificationSequence

func (c *Consensus) VerificationSequence() uint64

VerificationSequence returns the current verification sequence (from SmartBFT API)

func (*Consensus) VerifyConsenterSig

func (c *Consensus) VerifyConsenterSig(signature smartbft_types.Signature, prop smartbft_types.Proposal) ([]byte, error)

VerifyConsenterSig verifies the signature for the given proposal It returns the auxiliary data in the signature (from SmartBFT API)

func (*Consensus) VerifyProposal

func (c *Consensus) VerifyProposal(proposal smartbft_types.Proposal) ([]smartbft_types.RequestInfo, error)

VerifyProposal verifies the given proposal and returns the included requests' info (from SmartBFT API)

func (*Consensus) VerifyRequest

func (c *Consensus) VerifyRequest(req []byte) (smartbft_types.RequestInfo, error)

VerifyRequest verifies the given request and returns its info (from SmartBFT API)

func (*Consensus) VerifySignature

func (c *Consensus) VerifySignature(signature smartbft_types.Signature) error

VerifySignature verifies the signature (from SmartBFT API)

type ConsensusMetrics added in v0.0.20

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

func NewConsensusMetrics added in v0.0.20

func NewConsensusMetrics(consenterNodeConfig *config.ConsenterNodeConfig, decisions uint64, txCount uint64, logger *flogging.FabricLogger) *ConsensusMetrics

func (*ConsensusMetrics) Start added in v0.0.20

func (m *ConsensusMetrics) Start()

func (*ConsensusMetrics) Stop added in v0.0.20

func (m *ConsensusMetrics) Stop()

type Consenter added in v0.0.18

type Consenter struct {
	Logger          *flogging.FabricLogger
	DB              BatchAttestationDB
	BAFDeserializer state.BAFDeserializer
}

func (*Consenter) Index added in v0.0.22

func (c *Consenter) Index(digests [][]byte)

Index indexes BAs (digests). Note that this must hold: Index(digests) with the same digests is idempotent. TODO revise the recovery from failure or shutdown, specifically the order of Index and Append.

func (*Consenter) SimulateStateTransition added in v0.0.18

func (c *Consenter) SimulateStateTransition(prevState *state.State, configSeq types.ConfigSequence, requests [][]byte) (*state.State, [][]types.BatchAttestationFragment, []*state.ConfigRequest)

type DefaultConfigApplier added in v0.0.21

type DefaultConfigApplier struct{}

func (*DefaultConfigApplier) ApplyConfigToState added in v0.0.21

func (ca *DefaultConfigApplier) ApplyConfigToState(state *state.State, configRequest *state.ConfigRequest) (*state.State, error)

func (*DefaultConfigApplier) ExtractSmartBFTConfigFromBlock added in v0.0.22

func (ca *DefaultConfigApplier) ExtractSmartBFTConfigFromBlock(configBlock *common.Block, selfID arma_types.PartyID) ([]uint64, smartbft_types.Configuration, error)

type NetStopper added in v0.0.20

type NetStopper interface {
	Stop()
}

type SigVerifier

type SigVerifier interface {
	VerifySignature(id arma_types.PartyID, shardID arma_types.ShardID, msg, sig []byte) error
}

type Signer

type Signer interface {
	Sign(message []byte) ([]byte, error)
	Serialize() ([]byte, error)
}

type Storage

type Storage interface {
	Append([]byte)
	Close()
}

type SynchronizerStopper added in v0.0.20

type SynchronizerStopper interface {
	Stop()
}

type TotalOrder added in v0.0.18

type TotalOrder interface {
	SubmitRequest(req []byte) error
}

Directories

Path Synopsis
mocks
Code generated by counterfeiter.
Code generated by counterfeiter.
Code generated by counterfeiter.
Code generated by counterfeiter.
mocks
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