certifiers

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2017 License: Apache-2.0 Imports: 13 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FutureHeight = (math.MaxInt32 - 5)

Functions

func ErrNoPathFound

func ErrNoPathFound() error

func ErrPastTime

func ErrPastTime() error

func ErrSeedNotFound

func ErrSeedNotFound() error

func ErrTooMuchChange

func ErrTooMuchChange() error

func ErrValidatorsChanged

func ErrValidatorsChanged() error

func GenHeader

func GenHeader(chainID string, height int, txs types.Txs,
	vals *types.ValidatorSet, appHash []byte) *types.Header

func IsNoPathFoundErr added in v0.10.0

func IsNoPathFoundErr(err error) bool

IsNoPathFoundErr checks whether an error is due to no path of validators in provider from where we are to where we want to be

func IsPastTimeErr added in v0.10.0

func IsPastTimeErr(err error) bool

func IsSeedNotFoundErr added in v0.10.0

func IsSeedNotFoundErr(err error) bool

IsSeedNotFoundErr checks whether an error is due to missing data

func IsTooMuchChangeErr added in v0.10.0

func IsTooMuchChangeErr(err error) bool

IsTooMuchChangeErr checks whether and error is due to too much change between these validators sets

func IsValidatorsChangedErr added in v0.10.0

func IsValidatorsChangedErr(err error) bool

IsValidatorsChangedErr checks whether and error is due to a differing validator set

func VerifyCommitAny

func VerifyCommitAny(old, cur *types.ValidatorSet, chainID string,
	blockID types.BlockID, height int, commit *types.Commit) error

VerifyCommitAny will check to see if the set would be valid with a different validator set.

old is the validator set that we know * over 2/3 of the power in old signed this block

cur is the validator set that signed this block

  • only votes from old are sufficient for 2/3 majority in the new set as well

That means that: * 10% of the valset can't just declare themselves kings * If the validator set is 3x old size, we need more proof to trust

*** TODO: move this. It belongs in tendermint/types/validator_set.go: VerifyCommitAny

Types

type CacheProvider

type CacheProvider struct {
	Providers []Provider
}

CacheProvider allows you to place one or more caches in front of a source Provider. It runs through them in order until a match is found. So you can keep a local cache, and check with the network if no data is there.

func NewCacheProvider

func NewCacheProvider(providers ...Provider) CacheProvider

func (CacheProvider) GetByHash

func (c CacheProvider) GetByHash(hash []byte) (s Seed, err error)

func (CacheProvider) GetByHeight

func (c CacheProvider) GetByHeight(h int) (s Seed, err error)

GetByHeight should return the closest possible match from all providers.

The Cache is usually organized in order from cheapest call (memory) to most expensive calls (disk/network). However, since GetByHeight returns a Seed a h' <= h, if the memory has a seed at h-10, but the network would give us the exact match, a naive "stop at first non-error" would hide the actual desired results.

Thus, we query each provider in order until we find an exact match or we finished querying them all. If at least one returned a non-error, then this returns the best match (minimum h-h').

func (CacheProvider) StoreSeed

func (c CacheProvider) StoreSeed(seed Seed) (err error)

StoreSeed tries to add the seed to all providers.

Aborts on first error it encounters (closest provider)

type DynamicCertifier

type DynamicCertifier struct {
	Cert       *StaticCertifier
	LastHeight int
}

DynamicCertifier uses a StaticCertifier to evaluate the checkpoint but allows for a change, if we present enough proof

TODO: do we keep a long history so we can use our memory to validate checkpoints from previously valid validator sets????

func NewDynamic

func NewDynamic(chainID string, vals *types.ValidatorSet) *DynamicCertifier

func (*DynamicCertifier) Certify

func (c *DynamicCertifier) Certify(check lc.Checkpoint) error

Certify handles this with

func (*DynamicCertifier) Update

func (c *DynamicCertifier) Update(check lc.Checkpoint, vset *types.ValidatorSet) error

Update will verify if this is a valid change and update the certifying validator set if safe to do so.

Returns an error if update is impossible (invalid proof or IsTooMuchChangeErr)

type InquiringCertifier

type InquiringCertifier struct {
	Cert         *DynamicCertifier
	TrustedSeeds Provider // These are only properly validated data, from local system
	SeedSource   Provider // This is a source of new info, like a node rpc, or other import method
}

func NewInquiring

func NewInquiring(chainID string, vals *types.ValidatorSet, trusted Provider, source Provider) *InquiringCertifier

func (*InquiringCertifier) Certify

func (c *InquiringCertifier) Certify(check lc.Checkpoint) error

func (*InquiringCertifier) ChainID

func (c *InquiringCertifier) ChainID() string

func (*InquiringCertifier) Update

func (c *InquiringCertifier) Update(check lc.Checkpoint, vals *types.ValidatorSet) error

type MemStoreProvider

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

func NewMemStoreProvider

func NewMemStoreProvider() *MemStoreProvider

func (*MemStoreProvider) GetByHash

func (m *MemStoreProvider) GetByHash(hash []byte) (Seed, error)

func (*MemStoreProvider) GetByHeight

func (m *MemStoreProvider) GetByHeight(h int) (Seed, error)

func (*MemStoreProvider) StoreSeed

func (m *MemStoreProvider) StoreSeed(seed Seed) error

type MissingProvider

type MissingProvider struct{}

MissingProvider doens't store anything, always a miss Designed as a mock for testing

func NewMissingProvider

func NewMissingProvider() MissingProvider

func (MissingProvider) GetByHash

func (_ MissingProvider) GetByHash(_ []byte) (Seed, error)

func (MissingProvider) GetByHeight

func (_ MissingProvider) GetByHeight(_ int) (Seed, error)

func (MissingProvider) StoreSeed

func (_ MissingProvider) StoreSeed(_ Seed) error

type Provider

type Provider interface {
	StoreSeed(seed Seed) error
	// GetByHeight returns the closest seed at with height <= h
	GetByHeight(h int) (Seed, error)
	// GetByHash returns a seed exactly matching this validator hash
	GetByHash(hash []byte) (Seed, error)
}

Provider is used to get more validators by other means

TODO: Also FileStoreProvider, NodeProvider, ...

type Seed

type Seed struct {
	lc.Checkpoint `json:"checkpoint"`
	Validators    *types.ValidatorSet `json:"validator_set"`
}

Seed is a checkpoint and the actual validator set, the base info you need to update to a given point, assuming knowledge of some previous validator set

func LatestSeed

func LatestSeed(p Provider) (Seed, error)

func LoadSeed

func LoadSeed(path string) (seed Seed, err error)

func (Seed) Hash

func (s Seed) Hash() []byte

func (Seed) Height

func (s Seed) Height() int

func (Seed) Write

func (s Seed) Write(path string) (err error)

type Seeds

type Seeds []Seed

func (Seeds) Len

func (s Seeds) Len() int

func (Seeds) Less

func (s Seeds) Less(i, j int) bool

func (Seeds) Swap

func (s Seeds) Swap(i, j int)

type StaticCertifier

type StaticCertifier struct {
	ChainID string
	VSet    *types.ValidatorSet
	// contains filtered or unexported fields
}

StaticCertifier assumes a static set of validators, set on initilization and checks against them.

Good for testing or really simple chains. You will want a better implementation when the validator set can actually change.

func NewStatic

func NewStatic(chainID string, vals *types.ValidatorSet) *StaticCertifier

func (*StaticCertifier) Certify

func (c *StaticCertifier) Certify(check lc.Checkpoint) error

func (*StaticCertifier) Hash

func (c *StaticCertifier) Hash() []byte

type ValKeys

type ValKeys []crypto.PrivKey

Test Helper: ValKeys lets us simulate signing with many keys

func GenSecValKeys

func GenSecValKeys(n int) ValKeys

GenSecValKeys produces an array of secp256k1 private keys to generate commits

func GenValKeys

func GenValKeys(n int) ValKeys

GenValKeys produces an array of private keys to generate commits

func (ValKeys) Change

func (v ValKeys) Change(i int) ValKeys

Change replaces the key at index i

func (ValKeys) Extend

func (v ValKeys) Extend(n int) ValKeys

Extend adds n more keys (to remove, just take a slice)

func (ValKeys) ExtendSec

func (v ValKeys) ExtendSec(n int) ValKeys

Extend adds n more secp256k1 keys (to remove, just take a slice)

func (ValKeys) GenCheckpoint

func (v ValKeys) GenCheckpoint(chainID string, height int, txs types.Txs,
	vals *types.ValidatorSet, appHash []byte, first, last int) lc.Checkpoint

GenCheckpoint calls GenHeader and SignHeader and combines them into a Checkpoint

func (ValKeys) SignHeader

func (v ValKeys) SignHeader(header *types.Header, first, last int) *types.Commit

SignHeader properly signs the header with all keys from first to last exclusive

func (ValKeys) ToValidators

func (v ValKeys) ToValidators(init, inc int64) *types.ValidatorSet

ToValidators produces a list of validators from the set of keys The first key has weight `init` and it increases by `inc` every step so we can have all the same weight, or a simple linear distribution (should be enough for testing)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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