Documentation ¶
Index ¶
- Variables
- func ErrNoPathFound() error
- func ErrPastTime() error
- func ErrSeedNotFound() error
- func ErrTooMuchChange() error
- func ErrValidatorsChanged() error
- func GenHeader(chainID string, height int, txs types.Txs, vals []*types.Validator, ...) *types.Header
- func NoPathFound(err error) bool
- func PastTime(err error) bool
- func SeedNotFound(err error) bool
- func TooMuchChange(err error) bool
- func ValidatorsChanged(err error) bool
- func VerifyCommitAny(old, cur *types.ValidatorSet, chainID string, blockID types.BlockID, ...) error
- type CacheProvider
- type DynamicCertifier
- type InquiringCertifier
- type MemStoreProvider
- type MissingProvider
- type Provider
- type Seed
- type Seeds
- type StaticCertifier
- type ValKeys
- func (v ValKeys) Change(i int) ValKeys
- func (v ValKeys) Extend(n int) ValKeys
- func (v ValKeys) ExtendSec(n int) ValKeys
- func (v ValKeys) GenCheckpoint(chainID string, height int, txs types.Txs, vals []*types.Validator, ...) lc.Checkpoint
- func (v ValKeys) SignHeader(header *types.Header, first, last int) *types.Commit
- func (v ValKeys) ToValidators(init, inc int64) []*types.Validator
Constants ¶
This section is empty.
Variables ¶
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 NoPathFound ¶
NoPathFound asserts whether an error is due to no path of validators in provider from where we are to where we want to be
func SeedNotFound ¶
SeedNotFound asserts whether an error is due to missing data
func TooMuchChange ¶
TooMuchChange asserts whether and error is due to too much change between these validators sets
func ValidatorsChanged ¶
ValidatorsChanged asserts 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) GetByHeight ¶
func (c CacheProvider) GetByHeight(h int) (s Seed, err error)
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.Validator) *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, vals []*types.Validator) 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 TooMuchChange)
type InquiringCertifier ¶
type InquiringCertifier struct { Cert *DynamicCertifier Provider }
func NewInquiring ¶
func NewInquiring(chainID string, vals []*types.Validator, provider 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.Validator) 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) 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 Validators []*types.Validator }
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 ¶
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 (*StaticCertifier) Certify ¶
func (c *StaticCertifier) Certify(check lc.Checkpoint) error
func (*StaticCertifier) Hash ¶
func (c *StaticCertifier) Hash() []byte
type ValKeys ¶
we use this to simulate signing with many keys
func GenSecValKeys ¶
GenSecValKeys produces an array of secp256k1 private keys to generate commits
func GenValKeys ¶
GenValKeys produces an array of private keys to generate commits
func (ValKeys) GenCheckpoint ¶
func (v ValKeys) GenCheckpoint(chainID string, height int, txs types.Txs, vals []*types.Validator, appHash []byte, first, last int) lc.Checkpoint
GenCheckpoint calls GenHeader and SignHeader and combines them into a Checkpoint
func (ValKeys) SignHeader ¶
SignHeader properly signs the header with all keys from first to last exclusive
func (ValKeys) ToValidators ¶
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)