statebased

package
v2.1.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2020 License: Apache-2.0 Imports: 12 Imported by: 296

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewV13Evaluator

func NewV13Evaluator(policySupport validation.PolicyEvaluator, vpmgr KeyLevelValidationParameterManager) *policyCheckerFactoryV13

NewV13Evaluator returns a policy evaluator that checks 2 kinds of policies: 1) chaincode endorsement policies; 2) state-based endorsement policies.

func NewV20Evaluator

func NewV20Evaluator(
	vpmgr KeyLevelValidationParameterManager,
	policySupport validation.PolicyEvaluator,
	collRes CollectionResources,
	StateFetcher s.StateFetcher,
) *policyCheckerFactoryV20

NewV20Evaluator returns a policy evaluator that checks 3 kinds of policies: 1) chaincode endorsement policies; 2) state-based endorsement policies; 3) collection-level endorsement policies.

Types

type CollectionResources

type CollectionResources interface {
	// CollectionValidationInfo returns collection-level endorsement policy for the supplied chaincode.
	// The function returns two types of errors, unexpected errors and validation errors. The
	// reason for this is that this function is to be called from the validation code, which
	// needs to tell apart the two types of error to halt processing on the channel if the
	// unexpected error is not nil and mark the transaction as invalid if the validation error
	// is not nil.
	CollectionValidationInfo(chaincodeName, collectionName string, state s.State) (args []byte, unexpectedErr error, validationErr error)
}

CollectionResources provides access to collection artefacts

type KeyLevelValidationParameterManager

type KeyLevelValidationParameterManager interface {
	// GetValidationParameterForKey returns the validation parameter for the
	// supplied KVS key identified by (cc, coll, key) at the specified block
	// height h. The function returns the validation parameter and no error in case of
	// success, or nil and an error otherwise. One particular error that may be
	// returned is ValidationParameterUpdatedErr, which is returned in case the
	// validation parameters for the given KVS key have been changed by a transaction
	// with txNum smaller than the one supplied by the caller. This protects from a
	// scenario where a transaction changing validation parameters is marked as valid
	// by VSCC and is later invalidated by the committer for other reasons (e.g. MVCC
	// conflicts).  This function may be blocking until sufficient information has
	// been passed (by calling ApplyRWSetUpdates and ApplyValidatedRWSetUpdates) for
	// all txes with txNum smaller than the one supplied by the caller.
	GetValidationParameterForKey(cc, coll, key string, blockNum, txNum uint64) ([]byte, error)

	// ExtractValidationParameterDependency is used to determine which validation parameters are
	// updated by transaction at height `blockNum, txNum`. This is needed
	// to determine which txes have dependencies for specific validation parameters and will
	// determine whether GetValidationParameterForKey may block.
	ExtractValidationParameterDependency(blockNum, txNum uint64, rwset []byte)

	// SetTxValidationResult sets the validation result for transaction at height
	// `blockNum, txNum` for the specified chaincode `cc`.
	// This is used to determine whether the dependencies set by
	// ExtractValidationParameterDependency matter or not.
	SetTxValidationResult(cc string, blockNum, txNum uint64, err error)
}

KeyLevelValidationParameterManager is used by validation plugins in order to retrieve validation parameters for individual KVS keys. The functions are supposed to be called in the following order:

  1. the validation plugin called to validate a certain tx calls ExtractValidationParameterDependency in order for the manager to be able to determine whether validation parameters from the ledger can be used or whether they are being updated by a transaction in this block.
  2. the validation plugin issues 0 or more calls to GetValidationParameterForKey.
  3. the validation plugin determines the validation code for the tx and calls SetTxValidationCode.

type KeyLevelValidationParameterManagerImpl added in v1.3.0

type KeyLevelValidationParameterManagerImpl struct {
	StateFetcher validation.StateFetcher

	PolicyTranslator PolicyTranslator
	// contains filtered or unexported fields
}

func (*KeyLevelValidationParameterManagerImpl) ExtractValidationParameterDependency added in v1.3.0

func (m *KeyLevelValidationParameterManagerImpl) ExtractValidationParameterDependency(blockNum, txNum uint64, rwsetBytes []byte)

ExtractValidationParameterDependency implements the method of the same name of the KeyLevelValidationParameterManager interface Note that this function doesn't take any namespace argument. This is because we want to inspect all namespaces for which this transaction modifies metadata.

func (*KeyLevelValidationParameterManagerImpl) GetValidationParameterForKey added in v1.3.0

func (m *KeyLevelValidationParameterManagerImpl) GetValidationParameterForKey(cc, coll, key string, blockNum, txNum uint64) ([]byte, error)

GetValidationParameterForKey implements the method of the same name of the KeyLevelValidationParameterManager interface

func (*KeyLevelValidationParameterManagerImpl) SetTxValidationResult added in v1.3.0

func (m *KeyLevelValidationParameterManagerImpl) SetTxValidationResult(ns string, blockNum, txNum uint64, err error)

SetTxValidationCode implements the method of the same name of the KeyLevelValidationParameterManager interface. Note that this function receives a namespace argument so that it records the validation result for this transaction and for this chaincode.

type KeyLevelValidator added in v1.3.0

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

KeyLevelValidator implements per-key level ep validation

func NewKeyLevelValidator added in v1.3.0

func (*KeyLevelValidator) PostValidate added in v1.3.0

func (klv *KeyLevelValidator) PostValidate(cc string, blockNum, txNum uint64, err error)

PostValidate implements the function of the StateBasedValidator interface

func (*KeyLevelValidator) PreValidate added in v1.3.0

func (klv *KeyLevelValidator) PreValidate(txNum uint64, block *common.Block)

PreValidate implements the function of the StateBasedValidator interface

func (*KeyLevelValidator) Validate added in v1.3.0

func (klv *KeyLevelValidator) Validate(cc string, blockNum, txNum uint64, rwsetBytes, prp, ccEP []byte, endorsements []*peer.Endorsement) commonerrors.TxValidationError

Validate implements the function of the StateBasedValidator interface

type PolicyTranslator

type PolicyTranslator interface {
	// Translate performs the translation of the
	// supplied bytes, returning the translated
	// version or an error if one occurred
	Translate([]byte) ([]byte, error)
}

PolicyTranslator translates marshaled policies into different protobuf representations

type RWSetPolicyEvaluator

type RWSetPolicyEvaluator interface {
	Evaluate(blockNum, txNum uint64, NsRwSets []*rwsetutil.NsRwSet, ns string, sd []*protoutil.SignedData) commonerrors.TxValidationError
}

RWSetPolicyEvaluator provides means to evaluate transaction artefacts

type RWSetPolicyEvaluatorFactory

type RWSetPolicyEvaluatorFactory interface {
	// Evaluator returns a new policy evaluator
	// given the supplied chaincode endorsement policy
	Evaluator(ccEP []byte) RWSetPolicyEvaluator
}

RWSetPolicyEvaluatorFactory is a factory for policy evaluators

type ValidationParameterUpdatedError added in v1.3.0

type ValidationParameterUpdatedError struct {
	CC     string
	Coll   string
	Key    string
	Height uint64
	Txnum  uint64
}

ValidationParameterUpdatedErr is returned whenever Validation Parameters for a key could not be supplied because they are being updated

func (*ValidationParameterUpdatedError) Error added in v1.3.0

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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