infra

package
v0.0.0-...-a3380f7 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2022 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CH_MAX_CAPACITY = 1e6
)
View Source
const (
	MAX_TRY = 3
)

Variables

View Source
var (
	Metric = NewMetricInstance()
)

Functions

func CreateBroadcastClient

func CreateBroadcastClient(node Node) (orderer.AtomicBroadcast_BroadcastClient, error)

func CreateDeliverFilteredClient

func CreateDeliverFilteredClient() (peer.Deliver_DeliverFilteredClient, error)

func CreateEndorserClient

func CreateEndorserClient(node Node) (peer.EndorserClient, error)

func CreateProposal

func CreateProposal(txid string, channel, ccname, version string, args []string) (*peer.Proposal, string, error)

CreateProposal creates an unsigned proposal based on the given information and returns a proposal and its transaction id

func CreateSignedDeliverNewestEnv

func CreateSignedDeliverNewestEnv() (*common.Envelope, error)

func CreateSignedTx

func CreateSignedTx(proposal *peer.Proposal, responses []*peer.ProposalResponse) (*common.Envelope, error)

CreateSignedTx extract response, then signs and generates an envelope

func DERToPrivateKey

func DERToPrivateKey(der []byte) (key interface{}, err error)

DERToPrivateKey unmarshals a der to private key

func DialConnection

func DialConnection(node Node) (*grpc.ClientConn, error)

func End2End

func End2End()

End2End executes end-to-end benchmark on HLF An Element (i.e. a transaction) will go through the following channels unsignedCh -> signedCh -> endorsedCh -> integratedCh

func GetCertificate

func GetCertificate(f string) (*x509.Certificate, []byte, error)

func GetChaincodeProposalPayload

func GetChaincodeProposalPayload(ccProposalPayloadBytes []byte) (*peer.ChaincodeProposalPayload, error)

func GetPrivateKey

func GetPrivateKey(f string) (*ecdsa.PrivateKey, error)

func GetSignatureHeader

func GetSignatureHeader(signatureHeaderBytes []byte) (*common.SignatureHeader, error)

func GetTLSCACerts

func GetTLSCACerts(file string) ([]byte, error)

func GetVersionInfo

func GetVersionInfo() string

GetVersionInfo return version information

func NewEndorsedChannel

func NewEndorsedChannel() chan *Element

func NewIntegratedChannel

func NewIntegratedChannel() chan *Element

func NewLogChannel

func NewLogChannel() chan string

func NewObserverEndChannel

func NewObserverEndChannel() chan struct{}

func NewReportChannel

func NewReportChannel() chan string

func NewSignedChannel

func NewSignedChannel() []chan *Element

func NewUnsignedChannel

func NewUnsignedChannel() chan *Element

func PEMtoPrivateKey

func PEMtoPrivateKey(raw []byte, pwd []byte) (interface{}, error)

PEMtoPrivateKey unmarshals a pem to private key

func Process

func Process(c *Config, l *log.Logger)

func SignProposal

func SignProposal(prop *peer.Proposal) (*peer.SignedProposal, error)

SignProposal signs an unsigned proposal and attach the signature to the signed proposal

func UnmarshalSignatureHeader

func UnmarshalSignatureHeader(bytes []byte) (*common.SignatureHeader, error)

func WaitObserverEnd

func WaitObserverEnd(startTime time.Time, printWG *sync.WaitGroup)

func WriteLogToFile

func WriteLogToFile(printWG *sync.WaitGroup)

WriteLogToFile receives and write the following types of log to file:

Start: timestamp txid-index txid  endorser-id, connection-id, client-id
Proposal: timestamp txid-index txid  endorser-id, connection-id, client-id
Broadcast: timestamp txid-index txid  broadcaster-id
End: timestamp txid-index txid [VALID/MVCC]
Number of all transactions: total-transaction-num
Number of VALID transactions: valid-transaction-num
Number of ABORTED transactions: aborted-transaction-num
Abort rate: abort-rate
Duration: duration
TPS: throughput

Types

type Broadcaster

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

type Broadcasters

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

func NewBroadcasters

func NewBroadcasters(inCh <-chan *Element) *Broadcasters

func (*Broadcasters) StartAsync

func (bs *Broadcasters) StartAsync()

StartAsync starts a goroutine for every broadcaster

type Config

type Config struct {
	// Network
	Endorsers []Node `yaml:"endorsers"` // peers
	Committer Node   `yaml:"committer"` // the peer chosen to observe blocks from
	Orderer   Node   `yaml:"orderer"`   // orderer
	Channel   string `yaml:"channel"`   // name of the channel to be operated on

	// Chaincode
	Chaincode string   `yaml:"chaincode"` // chaincode name
	Version   string   `yaml:"version"`   // chaincode version
	Args      []string `yaml:"args"`      // chaincode arguments

	// Client identity
	MSPID      string  `yaml:"mspid"`      // the MSP the client belongs
	PrivateKey string  `yaml:"privateKey"` // client's private key
	SignCert   string  `yaml:"signCert"`   // client's certificate
	Identity   *Crypto // client's identity

	End2End bool `yaml:"e2e"` // running mode

	Rate  int `yaml:"rate"`  // average speed of transaction generation
	Burst int `yaml:"burst"` // maximum speed of transaction generation

	TxNum           int     `yaml:"txNum"`           // number of transactions
	TxTime          int     `yaml:"txTime"`          // maximum execution time
	TxType          string  `yaml:"txType"`          // transaction type ['put', 'conflict']
	TxIDStart       int     `yaml:"txIDStart"`       // the start of TX ID
	Session         string  `yaml:"session"`         // session name
	HotAccountRatio float64 `yaml:"hotAccountRatio"` // percentage of hot accounts
	ConflictRatio   float64 `yaml:"conflictRatio"`   // Percentage of conflict

	ConnNum          int `yaml:"connNum"`          // number of connection
	ClientPerConnNum int `yaml:"clientPerConnNum"` // number of client per connection
	IntegratorNum    int `yaml:"integratorNum"`    // number of integrator
	BroadcasterNum   int `yaml:"broadcasterNum"`   // number of orderer client
	EndorserNum      int // number of endorsers

	// If true, let the protoutil generate txid automatically
	// If false, encode the txid by us
	// WARNING: Must modify the code in core/endorser/msgvalidation.go:Validate() and
	// protoutil/proputils.go:ComputeTxID (v2) before compilation
	CheckTxID bool `yaml:"checkTxID"`

	// If true, print the read set and write set to STDOUT
	CheckRWSet bool `yaml:"checkRWSet"`

	LogPath    string `yaml:"logPath"`    // path of the log file
	ReportPath string `yaml:"reportPath"` // path of the report file

	Seed int `yaml:"seed"` // random seed
}

func LoadConfigFromFile

func LoadConfigFromFile(filename string) (*Config, error)

type Crypto

type Crypto struct {
	Creator  []byte
	PrivKey  *ecdsa.PrivateKey
	SignCert *x509.Certificate
}

func (*Crypto) NewSignatureHeader

func (s *Crypto) NewSignatureHeader() (*common.SignatureHeader, error)

func (*Crypto) Serialize

func (s *Crypto) Serialize() ([]byte, error)

func (*Crypto) Sign

func (s *Crypto) Sign(message []byte) ([]byte, error)

Sign signs the digest of a byte array (typically an unsigned proposal)

type CryptoConfig

type CryptoConfig struct {
	MSPID      string
	PrivKey    string
	SignCert   string
	TLSCACerts []string
}

type ECDSASignature

type ECDSASignature struct {
	R, S *big.Int
}

type Element

type Element struct {
	Proposal       *peer.Proposal
	SignedProposal *peer.SignedProposal
	Responses      []*peer.ProposalResponse

	Envelope *common.Envelope
	Txid     string
	// contains filtered or unexported fields
}

Element contains the data for the whole lifecycle of a transaction

type Initiator

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

func NewInitiator

func NewInitiator(outCh chan *Element) *Initiator

func (*Initiator) End

func (it *Initiator) End()

func (*Initiator) StartSync

func (it *Initiator) StartSync()

StartSync sends all unsigned transactions (raw transactions) to the channel 'raw' waiting for subsequent processing

type Integrator

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

func (*Integrator) Integrate

func (it *Integrator) Integrate(e *Element) (*Element, error)

integrate extracts responses and generates an envelope

func (*Integrator) Start

func (it *Integrator) Start()

StartIntegrator tries to extract enough response from endorsed transaction and integrate them into an envelope

type Integrators

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

func NewIntegrators

func NewIntegrators(inCh chan *Element, outCh chan *Element) *Integrators

func (*Integrators) StartAsync

func (its *Integrators) StartAsync()

type MetricInstance

type MetricInstance struct {
	Abort int32
}

func NewMetricInstance

func NewMetricInstance() *MetricInstance

func (*MetricInstance) AddAbort

func (m *MetricInstance) AddAbort()

type Node

type Node struct {
	Address       string `yaml:"address"`
	TLSCACert     string `yaml:"tlsCACert"`
	TLSCAKey      string `yaml:"tlsCAKey"`
	TLSCARoot     string `yaml:"tlsCARoot"`
	TLSCACertByte []byte
	TLSCAKeyByte  []byte
	TLSCARootByte []byte
}

type Observer

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

func NewObserver

func NewObserver() *Observer

func (*Observer) StartAsync

func (o *Observer) StartAsync()

StartAsync starts observing

type Proposer

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

func (*Proposer) Start

func (p *Proposer) Start()

Start serves as the k-th client of the j-th connection to the endorser specified by channel 'signed'. It collects signed proposals and send them to the endorser

type ProposerClient

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

type Proposers

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

func NewProposers

func NewProposers(inChs []chan *Element, outCh chan *Element) *Proposers

func (*Proposers) StartAsync

func (ps *Proposers) StartAsync()

StartAsync starts a goroutine as proposer per client per connection per endorser

type Signer

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

func NewSigner

func NewSigner(inCh chan *Element, outCh []chan *Element) *Signer

func (*Signer) SignElement

func (s *Signer) SignElement(e *Element) error

SignElement signs a transaction with the assembler's identity

func (*Signer) StartSync

func (s *Signer) StartSync()

StartSync collects an unsigned transactions from the 'raw' channel, sign it, then send it to the 'signed' channel of each endorser

type Signers

type Signers struct {
	Signers []*Signer
}

type TimeKeeper

type TimeKeeper struct {
	ProposedTime  int64
	EndorsedTime  int64
	BroadcastTime int64
	ObservedTime  int64
}

type TimeKeepers

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

type WorkloadGenerator

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

func NewWorkloadGenerator

func NewWorkloadGenerator() *WorkloadGenerator

Jump to

Keyboard shortcuts

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