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.ValidatorSet, ...) *types.Header
- func IsNoPathFoundErr(err error) bool
- func IsPastTimeErr(err error) bool
- func IsSeedNotFoundErr(err error) bool
- func IsTooMuchChangeErr(err error) bool
- func IsValidatorsChangedErr(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.ValidatorSet, ...) lc.Checkpoint
- func (v ValKeys) SignHeader(header *types.Header, first, last int) *types.Commit
- func (v ValKeys) ToValidators(init, inc int64) *types.ValidatorSet
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 IsNoPathFoundErr ¶ added in v0.10.0
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 IsSeedNotFoundErr ¶ added in v0.10.0
IsSeedNotFoundErr checks whether an error is due to missing data
func IsTooMuchChangeErr ¶ added in v0.10.0
IsTooMuchChangeErr checks whether and error is due to too much change between these validators sets
func IsValidatorsChangedErr ¶ added in v0.10.0
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) 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) 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 ¶
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 ¶
Test Helper: ValKeys lets us 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.ValidatorSet, 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 ¶
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)