validator

package
v0.0.0-...-91a82d4 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2019 License: LGPL-3.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrKnownBlock is returned when a block to import is already known locally.
	ErrKnownBlock = errors.New("block already known")
	// ErrPrunedAncestor is returned when validating a block requires an ancestor
	// that is known, but the state of which is not available.
	ErrPrunedAncestor = errors.New("pruned ancestor")
	// ErrUnknownAncestor is returned when validating a block requires an ancestor
	// that is unknown.
	ErrUnknownAncestor = errors.New("unknown ancestor")
	// ErrBlockTime timestamp less than or equal to parent's
	ErrBlockTime = errors.New("timestamp less than or equal to parent's")
	// ErrInvalidNumber is returned if a block's number doesn't equal it's parent's
	// plus one.
	ErrInvalidNumber = errors.New("invalid block number")
	// ErrFutureBlock is returned when a block's timestamp is in the future according
	// to the current node.
	ErrFutureBlock = errors.New("block in the future")
	// ErrExtraDataTooLong is returned when extra-data too long
	ErrExtraDataTooLong = func(actual, expected uint64) error {
		return fmt.Errorf("extra-data too long: %d > %d", actual, expected)
	}
	// ErrDifficulty is returned invalid difficulty
	ErrDifficulty = func(actual, expected *big.Int) error {
		return fmt.Errorf("invalid difficulty: have %v, want %v", actual, expected)
	}
	// ErrGasLimitTooBig is returned invalid gasLimit,the gas limit is > 2^63-1
	ErrGasLimitTooBig = func(actual, expected uint64) error {
		return fmt.Errorf("invalid max gaslimit: have %v, max %v", actual, expected)
	}
	// ErrGasUsed is returned invalid gasUsed
	ErrGasUsed = func(actual, expected uint64) error {
		return fmt.Errorf("invalid gasUsed: have %d, gasLimit %d", actual, expected)
	}
	// ErrGasLimit is returned invalid gaslimit
	ErrGasLimit = func(actual, expected, extra uint64) error {
		return fmt.Errorf("invalid gaslimit: have %d, want %d += %d", actual, expected, extra)
	}
	// ErrTxsRootHash is returned invalid txs root hash
	ErrTxsRootHash = func(actual, expected utils.Hash) error {
		return fmt.Errorf("transaction txs root hash mismatch: have %x, want %x", actual, expected)
	}

	// ErrReceiptRootHash is returned invalid receiptroot hash
	ErrReceiptRootHash = func(actual, expected utils.Hash) error {
		return fmt.Errorf("invalid receipt root hash (remote: %x local: %x)", actual, expected)
	}
	// ErrStateRootHash is returned invalid stateroot hash
	ErrStateRootHash = func(actual, expected utils.Hash) error {
		return fmt.Errorf("transaction state root hash mismatch: have %x, want %x", actual, expected)
	}
	// ErrDposRootHash is returned invalid stateroot hash
	ErrDposRootHash = func(actual, expected utils.Hash) error {
		return fmt.Errorf("dpos state root hash mismatch: have %s, want %s", actual.String(), expected.String())
	}
	// ErrLogsBloom is returned invalid logs bloom
	ErrLogsBloom = func(actual, expected bloom.Bloom) error {
		return fmt.Errorf("invalid logs bloom (remote: %x  local: %x)", actual, expected)
	}
	// ErrLocalGasUsed is returned invalid local gas used
	ErrLocalGasUsed = func(actual, expected uint64) error {
		return fmt.Errorf("invalid gas used (remote: %d local: %d)", actual, expected)
	}
)

Functions

This section is empty.

Types

type Validator

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

Validator responsible for validating block headers, blocks and processed state.

func New

func New(ledger *ledger.Ledger, engine consensus.Engine) *Validator

New returns a new block validator

func (*Validator) ValidateHeader

func (v *Validator) ValidateHeader(chain consensus.IChainReader, header *types.BlockHeader, seal bool) error

ValidateHeader verifies the the block header

func (*Validator) ValidateState

func (v *Validator) ValidateState(
	block, parent *types.Block,
	statedb *state.StateDB,
	receipts types.Receipts,
	deleteEmptyObjects bool,
	usedGas uint64) error

ValidateState validates the various changes that happen after a state transition, such as amount of used gas, the receipt roots and the state root itself.

func (*Validator) ValidateTxs

func (v *Validator) ValidateTxs(block *types.Block) error

ValidateTxs verifies the the block header's transaction root before already validated header

Jump to

Keyboard shortcuts

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