Documentation ¶
Index ¶
- Constants
- func DefaultConfig() config.Config
- func ExtractPublicKey(signedAtx *types.ActivationTx) (*signing.PublicKey, error)
- func NewNIPSTWithChallenge(challenge *types.Hash32, poetRef []byte) *types.NIPST
- func SignAtx(signer Signer, atx *types.ActivationTx) error
- type ATXDBProvider
- type ActivationDb
- func (db *ActivationDb) AwaitAtx(id types.AtxId) chan struct{}
- func (db *ActivationDb) CalcActiveSetFromView(view []types.BlockID, pubEpoch types.EpochId) (uint32, error)
- func (db *ActivationDb) CalcActiveSetSize(epoch types.EpochId, blocks map[types.BlockID]struct{}) (map[string]struct{}, error)
- func (db *ActivationDb) ContextuallyValidateAtx(atx *types.ActivationTxHeader) error
- func (db *ActivationDb) GetAtxHeader(id types.AtxId) (*types.ActivationTxHeader, error)
- func (db *ActivationDb) GetFullAtx(id types.AtxId) (*types.ActivationTx, error)
- func (db *ActivationDb) GetNodeAtxIdForEpoch(nodeId types.NodeId, targetEpoch types.EpochId) (types.AtxId, error)
- func (db *ActivationDb) GetNodeLastAtxId(nodeId types.NodeId) (types.AtxId, error)
- func (db *ActivationDb) GetPosAtxId() (types.AtxId, error)
- func (db *ActivationDb) ProcessAtx(atx *types.ActivationTx) error
- func (db *ActivationDb) ProcessAtxs(atxs []*types.ActivationTx) error
- func (db *ActivationDb) StoreAtx(ech types.EpochId, atx *types.ActivationTx) error
- func (db *ActivationDb) SyntacticallyValidateAtx(atx *types.ActivationTx) error
- func (db *ActivationDb) UnsubscribeAtx(id types.AtxId)
- func (db *ActivationDb) ValidateSignedAtx(pubKey signing.PublicKey, signedAtx *types.ActivationTx) error
- type ActivesetCache
- type AtxCache
- type Broadcaster
- type Builder
- func (b *Builder) GetPositioningAtx() (*types.ActivationTxHeader, error)
- func (b *Builder) GetPrevAtx(node types.NodeId) (*types.ActivationTxHeader, error)
- func (b *Builder) MiningStats() (int, uint64, string, string)
- func (b *Builder) PublishActivationTx() error
- func (b *Builder) SetCoinbaseAccount(rewardAddress types.Address)
- func (b Builder) SignAtx(atx *types.ActivationTx) error
- func (b *Builder) Start()
- func (b *Builder) StartPost(rewardAddress types.Address, dataDir string, space uint64) error
- func (b *Builder) Stop()
- type BytesStore
- type EpochProvider
- type ErrAtxNotFound
- type GetInfoResponse
- type HTTPPoetClient
- type HTTPPoetHarness
- type IdStore
- type IdentityStore
- type LayerClock
- type MeshProvider
- type NIPSTBuilder
- type NipstBuilder
- type NipstValidator
- type PoETNumberOfTickProvider
- type PoetDb
- func (db *PoetDb) GetMembershipMap(proofRef []byte) (map[types.Hash32]bool, error)
- func (db *PoetDb) GetProofMessage(proofRef []byte) ([]byte, error)
- func (db *PoetDb) HasProof(proofRef []byte) bool
- func (db *PoetDb) SubscribeToProofRef(poetId []byte, roundId string) chan []byte
- func (db *PoetDb) UnsubscribeFromProofRef(poetId []byte, roundId string)
- func (db *PoetDb) Validate(proof types.PoetProof, poetId []byte, roundId string, signature []byte) error
- func (db *PoetDb) ValidateAndStore(proofMessage *types.PoetProofMessage) error
- type PoetDbApi
- type PoetListener
- type PoetProvingServiceClient
- type PoetValidatorPersistor
- type PostClient
- func (c *PostClient) Cfg() *config.Config
- func (c *PostClient) Execute(challenge []byte) (*types.PostProof, error)
- func (c *PostClient) Initialize() (commitment *types.PostProof, err error)
- func (c *PostClient) IsInitialized() (bool, uint64, error)
- func (c *PostClient) Reset() error
- func (c *PostClient) SetLogger(logger shared.Logger)
- func (c *PostClient) SetParams(dataDir string, space uint64) error
- func (c *PostClient) VerifyInitAllowed() error
- type PostProverClient
- type Signer
- type StartRequest
- type StopRequestedError
- type SubmitRequest
- type SubmitResponse
- type Syncer
- type Validator
Constants ¶
const ( InitIdle = 1 + iota InitInProgress InitDone )
const AtxProtocol = "AtxGossip"
const PoetProofProtocol = "PoetProof"
Variables ¶
This section is empty.
Functions ¶
func DefaultConfig ¶
func ExtractPublicKey ¶
func ExtractPublicKey(signedAtx *types.ActivationTx) (*signing.PublicKey, error)
ExtractPublicKey extracts public key from message and verifies public key exists in IdStore, this is how we validate ATX signature. If this is the first ATX it is considered valid anyways and ATX syntactic validation will determine ATX validity
func NewNIPSTWithChallenge ¶
Types ¶
type ATXDBProvider ¶
type ATXDBProvider interface { GetAtxHeader(id types.AtxId) (*types.ActivationTxHeader, error) CalcActiveSetFromView(view []types.BlockID, pubEpoch types.EpochId) (uint32, error) GetNodeLastAtxId(nodeId types.NodeId) (types.AtxId, error) GetPosAtxId() (types.AtxId, error) AwaitAtx(id types.AtxId) chan struct{} UnsubscribeAtx(id types.AtxId) }
type ActivationDb ¶
type ActivationDb struct { sync.RWMutex //todo: think about whether we need one db or several IdStore LayersPerEpoch uint16 // contains filtered or unexported fields }
func NewActivationDb ¶
func NewActivationDb(dbstore database.Database, idstore IdStore, meshDb *mesh.MeshDB, layersPerEpoch uint16, nipstValidator NipstValidator, log log.Log) *ActivationDb
func (*ActivationDb) AwaitAtx ¶
func (db *ActivationDb) AwaitAtx(id types.AtxId) chan struct{}
func (*ActivationDb) CalcActiveSetFromView ¶
func (db *ActivationDb) CalcActiveSetFromView(view []types.BlockID, pubEpoch types.EpochId) (uint32, error)
CalcActiveSetFromView traverses the view found in a - the activation tx and counts number of active ids published in the epoch prior to the epoch that a was published at, this number is the number of active ids in the next epoch the function returns error if the view is not found
func (*ActivationDb) CalcActiveSetSize ¶
func (db *ActivationDb) CalcActiveSetSize(epoch types.EpochId, blocks map[types.BlockID]struct{}) (map[string]struct{}, error)
CalcActiveSetSize - returns the active set size that matches the view of the contextually valid blocks in the provided layer
func (*ActivationDb) ContextuallyValidateAtx ¶
func (db *ActivationDb) ContextuallyValidateAtx(atx *types.ActivationTxHeader) error
ContextuallyValidateAtx ensures that the previous ATX referenced is the last known ATX for the referenced miner ID. If a previous ATX is not referenced, it validates that indeed there's no previous known ATX for that miner ID.
func (*ActivationDb) GetAtxHeader ¶
func (db *ActivationDb) GetAtxHeader(id types.AtxId) (*types.ActivationTxHeader, error)
GetAtxHeader returns the ATX header by the given ID. This function is thread safe and will return an error if the ID is not found in the ATX DB.
func (*ActivationDb) GetFullAtx ¶
func (db *ActivationDb) GetFullAtx(id types.AtxId) (*types.ActivationTx, error)
func (*ActivationDb) GetNodeAtxIdForEpoch ¶
func (*ActivationDb) GetNodeLastAtxId ¶
GetNodeLastAtxId returns the last atx id that was received for node nodeId
func (*ActivationDb) GetPosAtxId ¶
func (db *ActivationDb) GetPosAtxId() (types.AtxId, error)
GetPosAtxId returns the best (highest layer id), currently known to this node, pos atx id
func (*ActivationDb) ProcessAtx ¶
func (db *ActivationDb) ProcessAtx(atx *types.ActivationTx) error
ProcessAtx validates the active set size declared in the atx, and contextually validates the atx according to atx validation rules it then stores the atx with flag set to validity of the atx.
ATXs received as input must be already syntactically valid. Only contextual validation is performed.
func (*ActivationDb) ProcessAtxs ¶
func (db *ActivationDb) ProcessAtxs(atxs []*types.ActivationTx) error
func (*ActivationDb) StoreAtx ¶
func (db *ActivationDb) StoreAtx(ech types.EpochId, atx *types.ActivationTx) error
StoreAtx stores an atx for epoh ech, it stores atx for the current epoch and adds the atx for the nodeid that created it in a sorted manner by the sequence id. this function does not validate the atx and assumes all data is correct and that all associated atx exist in the db. will return error if writing to db failed
func (*ActivationDb) SyntacticallyValidateAtx ¶
func (db *ActivationDb) SyntacticallyValidateAtx(atx *types.ActivationTx) error
SyntacticallyValidateAtx ensures the following conditions apply, otherwise it returns an error.
- If the sequence number is non-zero: PrevATX points to a syntactically valid ATX whose sequence number is one less than the current ATX's sequence number.
- If the sequence number is zero: PrevATX is empty.
- Positioning ATX points to a syntactically valid ATX.
- NIPST challenge is a hash of the serialization of the following fields: NodeID, SequenceNumber, PrevATXID, LayerID, StartTick, PositioningATX.
- The NIPST is valid.
- ATX LayerID is NipstLayerTime or less after the PositioningATX LayerID.
- The ATX view of the previous epoch contains ActiveSetSize activations.
func (*ActivationDb) UnsubscribeAtx ¶
func (db *ActivationDb) UnsubscribeAtx(id types.AtxId)
func (*ActivationDb) ValidateSignedAtx ¶
func (db *ActivationDb) ValidateSignedAtx(pubKey signing.PublicKey, signedAtx *types.ActivationTx) error
ValidateSignedAtx extracts public key from message and verifies public key exists in IdStore, this is how we validate ATX signature. If this is the first ATX it is considered valid anyways and ATX syntactic validation will determine ATX validity
type ActivesetCache ¶
type ActivesetCache struct {
*lru.Cache
}
func NewActivesetCache ¶
func NewActivesetCache(size int) ActivesetCache
type Broadcaster ¶
type Builder ¶
type Builder struct { Signer // contains filtered or unexported fields }
func NewBuilder ¶
func NewBuilder(nodeId types.NodeId, coinbaseAccount types.Address, signer Signer, db ATXDBProvider, net Broadcaster, mesh MeshProvider, layersPerEpoch uint16, nipstBuilder NipstBuilder, postProver PostProverClient, layerClock LayerClock, syncer Syncer, store BytesStore, log log.Log) *Builder
NewBuilder returns an atx builder that will start a routine that will attempt to create an atx upon each new layer.
func (*Builder) GetPositioningAtx ¶
func (b *Builder) GetPositioningAtx() (*types.ActivationTxHeader, error)
GetPositioningAtx return the latest atx to be used as a positioning atx
func (*Builder) GetPrevAtx ¶
func (*Builder) MiningStats ¶
MiningStats returns state of post init, coinbase reward account and data directory path for post commitment
func (*Builder) PublishActivationTx ¶
PublishActivationTx attempts to publish an atx, it returns an error if an atx cannot be created.
func (*Builder) SetCoinbaseAccount ¶
func (*Builder) Start ¶
func (b *Builder) Start()
Start is the main entry point of the atx builder. it runs the main loop of the builder and shouldn't be called more than once
type BytesStore ¶
type ErrAtxNotFound ¶
type ErrAtxNotFound error
type GetInfoResponse ¶
type HTTPPoetClient ¶
type HTTPPoetClient struct {
// contains filtered or unexported fields
}
HTTPPoetClient implements PoetProvingServiceClient interface.
func NewHTTPPoetClient ¶
func NewHTTPPoetClient(target string, ctx context.Context) *HTTPPoetClient
NewHTTPPoetClient returns new instance of HTTPPoetClient for the specified target.
func (*HTTPPoetClient) PoetServiceId ¶
func (c *HTTPPoetClient) PoetServiceId() ([]byte, error)
func (*HTTPPoetClient) Start ¶
func (c *HTTPPoetClient) Start(gatewayAddresses []string) error
type HTTPPoetHarness ¶
type HTTPPoetHarness struct { *HTTPPoetClient Teardown func(cleanup bool) error // contains filtered or unexported fields }
HTTPPoetHarness utilizes a local self-contained poet server instance targeted by an HTTP client, in order to exercise functionality.
func NewHTTPPoetHarness ¶
func NewHTTPPoetHarness(disableBroadcast bool) (*HTTPPoetHarness, error)
NewHTTPPoetHarness returns a new instance of HTTPPoetHarness.
type IdentityStore ¶
type IdentityStore struct {
// contains filtered or unexported fields
}
func NewIdentityStore ¶
func NewIdentityStore(db database.Database) *IdentityStore
func (*IdentityStore) GetIdentity ¶
func (s *IdentityStore) GetIdentity(id string) (types.NodeId, error)
func (*IdentityStore) StoreNodeIdentity ¶
func (s *IdentityStore) StoreNodeIdentity(id types.NodeId) error
type LayerClock ¶
type MeshProvider ¶
type NIPSTBuilder ¶
type NIPSTBuilder struct {
// contains filtered or unexported fields
}
func NewNIPSTBuilder ¶
func NewNIPSTBuilder(id []byte, postProver PostProverClient, poetProver PoetProvingServiceClient, poetDb PoetDbApi, store BytesStore, log log.Log) *NIPSTBuilder
func (*NIPSTBuilder) BuildNIPST ¶
type NipstBuilder ¶
type NipstValidator ¶
type PoETNumberOfTickProvider ¶
type PoETNumberOfTickProvider struct { }
func (*PoETNumberOfTickProvider) NumOfTicks ¶
func (provider *PoETNumberOfTickProvider) NumOfTicks() uint64
type PoetDb ¶
type PoetDb struct {
// contains filtered or unexported fields
}
func (*PoetDb) GetMembershipMap ¶
func (*PoetDb) SubscribeToProofRef ¶
func (*PoetDb) UnsubscribeFromProofRef ¶
func (*PoetDb) ValidateAndStore ¶
func (db *PoetDb) ValidateAndStore(proofMessage *types.PoetProofMessage) error
type PoetListener ¶
func NewPoetListener ¶
func NewPoetListener(net service.Service, poetDb PoetValidatorPersistor, logger log.Log) *PoetListener
func (*PoetListener) Close ¶
func (l *PoetListener) Close()
func (*PoetListener) Start ¶
func (l *PoetListener) Start()
type PoetProvingServiceClient ¶
type PoetProvingServiceClient interface { // Submit registers a challenge in the proving service current open round. Submit(challenge types.Hash32) (*types.PoetRound, error) PoetServiceId() ([]byte, error) }
PoetProvingServiceClient provides a gateway to a trust-less public proving service, which may serve many PoET proving clients, and thus enormously reduce the cost-per-proof for PoET since each additional proof adds only a small number of hash evaluations to the total cost.
type PoetValidatorPersistor ¶
type PostClient ¶
func NewPostClient ¶
func NewPostClient(cfg *config.Config, id []byte) (*PostClient, error)
func (*PostClient) Cfg ¶
func (c *PostClient) Cfg() *config.Config
func (*PostClient) Execute ¶
func (c *PostClient) Execute(challenge []byte) (*types.PostProof, error)
func (*PostClient) Initialize ¶
func (c *PostClient) Initialize() (commitment *types.PostProof, err error)
func (*PostClient) IsInitialized ¶
func (c *PostClient) IsInitialized() (bool, uint64, error)
func (*PostClient) Reset ¶
func (c *PostClient) Reset() error
func (*PostClient) SetLogger ¶
func (c *PostClient) SetLogger(logger shared.Logger)
func (*PostClient) VerifyInitAllowed ¶
func (c *PostClient) VerifyInitAllowed() error
type PostProverClient ¶
type PostProverClient interface { // initialize is the process in which the prover commits // to store some data, by having its storage being filled with // pseudo-random data with respect to a specific id. // This data is the result of a computationally-expensive operation. Initialize() (commitment *types.PostProof, err error) // Execute is the phase in which the prover received a challenge, // and proves that his data is still stored (or was recomputed). // This phase can be repeated arbitrarily many times without repeating initialization; // thus despite the initialization essentially serving as a proof-of-work, // the amortized computational complexity can be made arbitrarily small. Execute(challenge []byte) (proof *types.PostProof, err error) // Reset removes the initialization phase files. Reset() error // IsInitialized indicates whether the initialization phase has been completed. IsInitialized() (initComplete bool, remainingBytes uint64, err error) // VerifyInitAllowed indicates whether the preconditions for starting // the initialization phase are met. VerifyInitAllowed() error // SetParams updates the datadir and space params in the client config, to be used in the initialization // and the execution phases. It overrides the config which the client was instantiated with. SetParams(datadir string, space uint64) error // SetLogger sets a logger for the client. SetLogger(logger shared.Logger) // Cfg returns the the client latest config. Cfg() *config.Config }
PostProverClient provides proving functionality for PoST.
type StartRequest ¶
type StopRequestedError ¶
type StopRequestedError struct{}
func (StopRequestedError) Error ¶
func (s StopRequestedError) Error() string
type SubmitRequest ¶
type SubmitRequest struct {
Challenge []byte `json:"challenge,omitempty"`
}
type SubmitResponse ¶
type SubmitResponse struct {
RoundId string
}