...

Package txvalidator

import "github.com/hyperledger/fabric/core/committer/txvalidator"
Overview
Index
Subdirectories

Overview ▾

Index ▾

type Context
    func (c Context) String() string
type MapBasedPluginMapper
    func (m MapBasedPluginMapper) PluginFactoryByName(name PluginName) validation.PluginFactory
type PluginMapper
type PluginName
type PluginValidator
    func NewPluginValidator(pm PluginMapper, qec QueryExecutorCreator, deserializer msp.IdentityDeserializer, capabilities Capabilities) *PluginValidator
    func (pv *PluginValidator) ValidateWithPlugin(ctx *Context) error
type PolicyEvaluator
    func (id *PolicyEvaluator) DeserializeIdentity(serializedIdentity []byte) (Identity, error)
    func (id *PolicyEvaluator) Evaluate(policyBytes []byte, signatureSet []*common.SignedData) error
type QueryExecutorCreator
type ResultsIteratorImpl
    func (it *ResultsIteratorImpl) Next() (QueryResult, error)
type SerializedPolicy
    func (sp SerializedPolicy) Bytes() []byte
type StateFetcherImpl
    func (sf *StateFetcherImpl) FetchState() (State, error)
type StateImpl
    func (s *StateImpl) GetStateRangeScanIterator(namespace string, startKey string, endKey string) (ResultsIterator, error)
type Support
type TxValidator
    func NewTxValidator(chainID string, support Support, sccp sysccprovider.SystemChaincodeProvider, pm PluginMapper) *TxValidator
    func (v *TxValidator) Validate(block *common.Block) error
type Validator
type VsccValidatorImpl
    func (v *VsccValidatorImpl) GetInfoForValidate(chdr *common.ChannelHeader, ccID string) (*sysccprovider.ChaincodeInstance, *sysccprovider.ChaincodeInstance, []byte, error)
    func (v *VsccValidatorImpl) VSCCValidateTx(seq int, payload *common.Payload, envBytes []byte, block *common.Block) (error, peer.TxValidationCode)
    func (v *VsccValidatorImpl) VSCCValidateTxForCC(ctx *Context) error

Package files

plugin_validator.go validator.go vscc_validator.go

type Context

Context defines information about a transaction that is being validated

type Context struct {
    Seq       int
    Envelope  []byte
    TxID      string
    Channel   string
    VSCCName  string
    Policy    []byte
    Namespace string
    Block     *common.Block
}

func (Context) String

func (c Context) String() string

String returns a string representation of this Context

type MapBasedPluginMapper

MapBasedPluginMapper maps plugin names to their corresponding factories

type MapBasedPluginMapper map[string]validation.PluginFactory

func (MapBasedPluginMapper) PluginFactoryByName

func (m MapBasedPluginMapper) PluginFactoryByName(name PluginName) validation.PluginFactory

PluginFactoryByName returns a plugin factory for the given plugin name, or nil if not found

type PluginMapper

PluginMapper maps plugin names to their corresponding factory instance. Returns nil if the name isn't associated to any plugin.

type PluginMapper interface {
    PluginFactoryByName(name PluginName) validation.PluginFactory
}

type PluginName

PluginName defines the name of the plugin as it appears in the configuration

type PluginName string

type PluginValidator

PluginValidator values transactions with validation plugins

type PluginValidator struct {
    sync.Mutex

    PluginMapper
    QueryExecutorCreator
    msp.IdentityDeserializer
    // contains filtered or unexported fields
}

func NewPluginValidator

func NewPluginValidator(pm PluginMapper, qec QueryExecutorCreator, deserializer msp.IdentityDeserializer, capabilities Capabilities) *PluginValidator

NewPluginValidator creates a new PluginValidator

func (*PluginValidator) ValidateWithPlugin

func (pv *PluginValidator) ValidateWithPlugin(ctx *Context) error

type PolicyEvaluator

type PolicyEvaluator struct {
    msp.IdentityDeserializer
}

func (*PolicyEvaluator) DeserializeIdentity

func (id *PolicyEvaluator) DeserializeIdentity(serializedIdentity []byte) (Identity, error)

DeserializeIdentity unmarshals the given identity to msp.Identity

func (*PolicyEvaluator) Evaluate

func (id *PolicyEvaluator) Evaluate(policyBytes []byte, signatureSet []*common.SignedData) error

Evaluate takes a set of SignedData and evaluates whether this set of signatures satisfies the policy

type QueryExecutorCreator

QueryExecutorCreator creates new query executors

type QueryExecutorCreator interface {
    NewQueryExecutor() (ledger.QueryExecutor, error)
}

type ResultsIteratorImpl

type ResultsIteratorImpl struct {
    ledger2.ResultsIterator
}

func (*ResultsIteratorImpl) Next

func (it *ResultsIteratorImpl) Next() (QueryResult, error)

type SerializedPolicy

SerializedPolicy defines a marshaled policy

type SerializedPolicy []byte

func (SerializedPolicy) Bytes

func (sp SerializedPolicy) Bytes() []byte

Bytes returns te bytes of the SerializedPolicy

type StateFetcherImpl

type StateFetcherImpl struct {
    QueryExecutorCreator
}

func (*StateFetcherImpl) FetchState

func (sf *StateFetcherImpl) FetchState() (State, error)

type StateImpl

type StateImpl struct {
    ledger.QueryExecutor
}

func (*StateImpl) GetStateRangeScanIterator

func (s *StateImpl) GetStateRangeScanIterator(namespace string, startKey string, endKey string) (ResultsIterator, error)

type Support

Support provides all of the needed to evaluate the VSCC

type Support interface {
    // Acquire implements semaphore-like acquire semantics
    Acquire(ctx context.Context, n int64) error

    // Release implements semaphore-like release semantics
    Release(n int64)

    // Ledger returns the ledger associated with this validator
    Ledger() ledger.PeerLedger

    // MSPManager returns the MSP manager for this channel
    MSPManager() msp.MSPManager

    // Apply attempts to apply a configtx to become the new config
    Apply(configtx *common.ConfigEnvelope) error

    // GetMSPIDs returns the IDs for the application MSPs
    // that have been defined in the channel
    GetMSPIDs(cid string) []string

    // Capabilities defines the capabilities for the application portion of this channel
    Capabilities() channelconfig.ApplicationCapabilities
}

type TxValidator

implementation of Validator interface, keeps reference to the ledger to enable tx simulation and execution of vscc

type TxValidator struct {
    ChainID string
    Support Support
    Vscc    vsccValidator
}

func NewTxValidator

func NewTxValidator(chainID string, support Support, sccp sysccprovider.SystemChaincodeProvider, pm PluginMapper) *TxValidator

NewTxValidator creates new transactions validator

func (*TxValidator) Validate

func (v *TxValidator) Validate(block *common.Block) error

Validate performs the validation of a block. The validation of each transaction in the block is performed in parallel. The approach is as follows: the committer thread starts the tx validation function in a goroutine (using a semaphore to cap the number of concurrent validating goroutines). The committer thread then reads results of validation (in orderer of completion of the goroutines) from the results channel. The goroutines perform the validation of the txs in the block and enqueue the validation result in the results channel. A few note-worthy facts: 1) to keep the approach simple, the committer thread enqueues

all transactions in the block and then moves on to reading the
results.

2) for parallel validation to work, it is important that the

validation function does not change the state of the system.
Otherwise the order in which validation is perform matters
and we have to resort to sequential validation (or some locking).
This is currently true, because the only function that affects
state is when a config transaction is received, but they are
guaranteed to be alone in the block. If/when this assumption
is violated, this code must be changed.

type Validator

Validator interface which defines API to validate block transactions and return the bit array mask indicating invalid transactions which didn't pass validation.

type Validator interface {
    Validate(block *common.Block) error
}

type VsccValidatorImpl

VsccValidatorImpl is the implementation used to call the vscc chaincode and validate block transactions

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

func (*VsccValidatorImpl) GetInfoForValidate

func (v *VsccValidatorImpl) GetInfoForValidate(chdr *common.ChannelHeader, ccID string) (*sysccprovider.ChaincodeInstance, *sysccprovider.ChaincodeInstance, []byte, error)

GetInfoForValidate gets the ChaincodeInstance(with latest version) of tx, vscc and policy from lscc

func (*VsccValidatorImpl) VSCCValidateTx

func (v *VsccValidatorImpl) VSCCValidateTx(seq int, payload *common.Payload, envBytes []byte, block *common.Block) (error, peer.TxValidationCode)

VSCCValidateTx executes vscc validation for transaction

func (*VsccValidatorImpl) VSCCValidateTxForCC

func (v *VsccValidatorImpl) VSCCValidateTxForCC(ctx *Context) error

Subdirectories

Name Synopsis
..
mocks Code generated by mockery v1.0.0.