Documentation ¶
Overview ¶
Package activation is responsible for creating activation transactions and running the mining flow, coordinating Post building, sending proofs to PoET and building NIPost structs.
Index ¶
- Constants
- Variables
- func ExtractPublicKey(signedAtx *types.ActivationTx) (*signing.PublicKey, error)
- func NewNIPostWithChallenge(challenge *types.Hash32, poetRef []byte) *types.NIPost
- func SignAtx(signer signer, atx *types.ActivationTx) error
- type AtxCache
- type AtxMemDB
- func (mem *AtxMemDB) GetAllItems() []*types.ActivationTx
- func (mem *AtxMemDB) GetEpochAtxs(epochID types.EpochID) (atxs []types.ATXID)
- func (mem *AtxMemDB) GetFullAtx(id types.ATXID) (*types.ActivationTx, error)
- func (mem *AtxMemDB) Invalidate(id types.ATXID)
- func (mem *AtxMemDB) ProcessAtx(atx *types.ActivationTx) error
- func (mem *AtxMemDB) Put(atx *types.ActivationTx)
- type Builder
- func (b *Builder) Coinbase() types.Address
- func (b *Builder) GetPositioningAtxInfo() (types.ATXID, types.LayerID, uint64, error)
- func (b *Builder) GetPrevAtx(node types.NodeID) (*types.ActivationTxHeader, error)
- func (b *Builder) MinGas() uint64
- func (b *Builder) PublishActivationTx(ctx context.Context) error
- func (b *Builder) SetCoinbase(rewardAddress types.Address)
- func (b *Builder) SetMinGas(value uint64)
- func (b *Builder) SignAtx(atx *types.ActivationTx) error
- func (b *Builder) SmesherID() types.NodeID
- func (b *Builder) Smeshing() bool
- func (b *Builder) StartSmeshing(coinbase types.Address, opts PostSetupOpts) error
- func (b *Builder) StopSmeshing(deleteFiles bool) error
- func (b *Builder) UpdatePoETServer(ctx context.Context, target string) error
- type BuilderOption
- type Config
- type DB
- func (db *DB) AwaitAtx(id types.ATXID) chan struct{}
- func (db *DB) ContextuallyValidateAtx(atx *types.ActivationTxHeader) error
- func (db *DB) FetchAtxReferences(ctx context.Context, atx *types.ActivationTx) error
- func (db *DB) GetAtxHeader(id types.ATXID) (*types.ActivationTxHeader, error)
- func (db *DB) GetAtxTimestamp(atxid types.ATXID) (time.Time, error)
- func (db *DB) GetEpochAtxs(epochID types.EpochID) (atxs []types.ATXID, err error)
- func (db *DB) GetEpochWeight(epochID types.EpochID) (uint64, []types.ATXID, error)
- func (db *DB) GetFullAtx(id types.ATXID) (*types.ActivationTx, error)
- func (db *DB) GetMinerWeightsInEpochFromView(targetEpoch types.EpochID, view map[types.BlockID]struct{}) (map[string]uint64, error)
- func (db *DB) GetNodeAtxIDForEpoch(nodeID types.NodeID, publicationEpoch types.EpochID) (types.ATXID, error)
- func (db *DB) GetNodeLastAtxID(nodeID types.NodeID) (types.ATXID, error)
- func (db *DB) GetPosAtxID() (types.ATXID, error)
- func (db *DB) HandleAtxData(ctx context.Context, data []byte) error
- func (db *DB) HandleGossipAtx(ctx context.Context, _ peer.ID, msg []byte) pubsub.ValidationResult
- func (db *DB) ProcessAtx(ctx context.Context, atx *types.ActivationTx) error
- func (db *DB) StoreAtx(ctx context.Context, ech types.EpochID, atx *types.ActivationTx) error
- func (db *DB) SyntacticallyValidateAtx(ctx context.Context, atx *types.ActivationTx) error
- func (db *DB) UnsubscribeAtx(id types.ATXID)
- func (db *DB) ValidateSignedAtx(pubKey signing.PublicKey, signedAtx *types.ActivationTx) error
- type ErrAtxNotFound
- type GetInfoResponse
- type HTTPPoetClient
- type HTTPPoetHarness
- type IdentityStore
- type NIPostBuilder
- type PoETClientInitializer
- 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
- func (db *PoetDb) ValidateAndStoreMsg(data []byte) error
- type PoetListener
- type PoetProvingServiceClient
- type PostConfig
- type PostSetupComputeProvider
- type PostSetupManager
- func (mgr *PostSetupManager) Benchmark(p PostSetupComputeProvider) (int, error)
- func (mgr *PostSetupManager) BestProvider() (*PostSetupComputeProvider, error)
- func (mgr *PostSetupManager) ComputeProviders() []PostSetupComputeProvider
- func (mgr *PostSetupManager) Config() PostConfig
- func (mgr *PostSetupManager) GenerateProof(challenge []byte) (*types.Post, *types.PostMetadata, error)
- func (mgr *PostSetupManager) LastError() error
- func (mgr *PostSetupManager) LastOpts() *PostSetupOpts
- func (mgr *PostSetupManager) StartSession(opts PostSetupOpts) (chan struct{}, error)
- func (mgr *PostSetupManager) Status() *PostSetupStatus
- func (mgr *PostSetupManager) StatusChan() <-chan *PostSetupStatus
- func (mgr *PostSetupManager) StopSession(deleteFiles bool) error
- type PostSetupOpts
- type PostSetupProvider
- type PostSetupStatus
- type SmeshingProvider
- type StartRequest
- type SubmitRequest
- type SubmitResponse
- type Validator
Constants ¶
const AtxProtocol = "AtxGossip"
AtxProtocol is the protocol id for broadcasting atxs over gossip.
const PoetProofProtocol = "PoetProof"
PoetProofProtocol is the name of the PoetProof gossip protocol.
Variables ¶
var ( // ErrStopRequested is returned when builder is stopped. ErrStopRequested = errors.New("builder: stop requested") // ErrATXChallengeExpired is returned when atx missed its publication window and needs to be regenerated. ErrATXChallengeExpired = errors.New("builder: atx expired") // ErrPoetServiceUnstable is returned when poet quality of service is low. ErrPoetServiceUnstable = errors.New("builder: poet service is unstable") )
Functions ¶
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 NewNIPostWithChallenge ¶
NewNIPostWithChallenge is a convenience method FOR TESTS ONLY. TODO: move this out of production code.
func SignAtx ¶
func SignAtx(signer signer, atx *types.ActivationTx) error
SignAtx signs the atx atx with specified signer and assigns the signature into atx.Sig this function returns an error if atx could not be converted to bytes.
Types ¶
type AtxCache ¶
AtxCache holds an lru cache of ActivationTxHeader structs of recent atx used to calculate active set size ideally this cache will hold the atxs created in latest epoch, on which most of active set size calculation will be performed.
func NewAtxCache ¶
NewAtxCache creates a new cache for activation transaction headers.
type AtxMemDB ¶ added in v0.1.15
type AtxMemDB struct {
// contains filtered or unexported fields
}
AtxMemDB is a memory store that holds all received ATXs from gossip network by their ids.
func NewAtxMemPool ¶ added in v0.1.15
func NewAtxMemPool() *AtxMemDB
NewAtxMemPool creates a struct holding atxs by id.
func (*AtxMemDB) GetAllItems ¶ added in v0.1.15
func (mem *AtxMemDB) GetAllItems() []*types.ActivationTx
GetAllItems creates and returns a list of all items found in cache.
func (*AtxMemDB) GetEpochAtxs ¶ added in v0.1.15
GetEpochAtxs returns mock atx list.
func (*AtxMemDB) GetFullAtx ¶ added in v0.1.15
GetFullAtx retrieves the atx by the provided id id, it returns a reference to the found atx struct or an error if not.
func (*AtxMemDB) Invalidate ¶ added in v0.1.15
Invalidate removes the provided atx by its id. it does not return error if id is not found.
func (*AtxMemDB) ProcessAtx ¶ added in v0.1.15
func (mem *AtxMemDB) ProcessAtx(atx *types.ActivationTx) error
ProcessAtx puts an atx into mem pool, this is just for testing.
func (*AtxMemDB) Put ¶ added in v0.1.15
func (mem *AtxMemDB) Put(atx *types.ActivationTx)
Put insets an atx into the mempool.
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder struct is the struct that orchestrates the creation of activation transactions it is responsible for initializing post, receiving poet proof and orchestrating nipst. after which it will calculate total weight and providing relevant view as proof.
func NewBuilder ¶
func NewBuilder(conf Config, nodeID types.NodeID, signer signer, db atxDBProvider, publisher pubsub.Publisher, nipostBuilder nipostBuilder, postSetupProvider PostSetupProvider, layerClock layerClock, syncer syncer, store bytesStore, log log.Log, opts ...BuilderOption) *Builder
NewBuilder returns an atx builder that will start a routine that will attempt to create an atx upon each new layer.
func (*Builder) GetPositioningAtxInfo ¶
GetPositioningAtxInfo return the following details about the latest atx, to be used as a positioning atx:
atxID, pubLayerID, endTick
func (*Builder) GetPrevAtx ¶
GetPrevAtx gets the last atx header of specified node Id, it returns error if no previous atx found or if no AtxHeader struct in db.
func (*Builder) PublishActivationTx ¶
PublishActivationTx attempts to publish an atx, it returns an error if an atx cannot be created.
func (*Builder) SetCoinbase ¶ added in v1.0.0
SetCoinbase sets the address rewardAddress to be the coinbase account written into the activation transaction the rewards for blocks made by this miner will go to this address.
func (*Builder) SignAtx ¶
func (b *Builder) SignAtx(atx *types.ActivationTx) error
SignAtx signs the atx and assigns the signature into atx.Sig this function returns an error if atx could not be converted to bytes.
func (*Builder) SmesherID ¶ added in v1.0.0
SmesherID returns the ID of the smesher that created this activation.
func (*Builder) StartSmeshing ¶ added in v1.0.0
func (b *Builder) StartSmeshing(coinbase types.Address, opts PostSetupOpts) error
StartSmeshing 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. If the post data is incomplete or missing, data creation session will be preceded. Changing of the post potions (e.g., number of labels), after initial setup, is supported.
func (*Builder) StopSmeshing ¶ added in v1.0.0
StopSmeshing stops the atx builder.
type BuilderOption ¶ added in v1.0.0
type BuilderOption func(*Builder)
BuilderOption ...
func WithContext ¶ added in v1.0.0
func WithContext(ctx context.Context) BuilderOption
WithContext modifies parent context for background job.
func WithPoETClientInitializer ¶ added in v1.0.0
func WithPoETClientInitializer(initializer PoETClientInitializer) BuilderOption
WithPoETClientInitializer modifies initialization logic for PoET client. Used during client update.
func WithPoetRetryInterval ¶ added in v1.0.0
func WithPoetRetryInterval(interval time.Duration) BuilderOption
WithPoetRetryInterval modifies time that builder will have to wait before retrying ATX build process if it failed due to issues with PoET server.
type DB ¶ added in v0.1.11
DB hold the atxs received from all nodes and their validity status it also stores identifications for all nodes e.g the coupling between ed id and bls id.
func NewDB ¶ added in v0.1.11
func NewDB(dbStore database.Database, fetcher system.Fetcher, idStore idStore, meshDb *mesh.DB, layersPerEpoch uint32, goldenATXID types.ATXID, nipostValidator nipostValidator, log log.Log) *DB
NewDB creates a new struct of type DB, this struct will hold the atxs received from all nodes and their validity.
func (*DB) AwaitAtx ¶ added in v0.1.11
AwaitAtx returns a channel that will receive notification when the specified atx with id id is received via gossip.
func (*DB) ContextuallyValidateAtx ¶ added in v0.1.11
func (db *DB) 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 (*DB) FetchAtxReferences ¶ added in v0.1.16
FetchAtxReferences fetches positioning and prev atxs from peers if they are not found in db.
func (*DB) GetAtxHeader ¶ added in v0.1.11
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 (*DB) GetAtxTimestamp ¶
GetAtxTimestamp returns ATX timestamp.
func (*DB) GetEpochAtxs ¶ added in v0.1.15
GetEpochAtxs returns all valid ATXs received in the epoch epochID.
func (*DB) GetEpochWeight ¶
GetEpochWeight returns the total weight of ATXs targeting the given epochID.
func (*DB) GetFullAtx ¶ added in v0.1.11
GetFullAtx returns the full atx struct of the given atxId id, it returns an error if the full atx cannot be found in all databases.
func (*DB) GetMinerWeightsInEpochFromView ¶
func (db *DB) GetMinerWeightsInEpochFromView(targetEpoch types.EpochID, view map[types.BlockID]struct{}) (map[string]uint64, error)
GetMinerWeightsInEpochFromView returns a map of miner IDs and each one's weight targeting targetEpoch, by traversing the provided view.
func (*DB) GetNodeAtxIDForEpoch ¶ added in v0.1.11
func (db *DB) GetNodeAtxIDForEpoch(nodeID types.NodeID, publicationEpoch types.EpochID) (types.ATXID, error)
GetNodeAtxIDForEpoch returns an atx published by the provided nodeID for the specified publication epoch. meaning the atx that the requested nodeID has published. it returns an error if no atx was found for provided nodeID.
func (*DB) GetNodeLastAtxID ¶ added in v0.1.11
GetNodeLastAtxID returns the last atx id that was received for node nodeID.
func (*DB) GetPosAtxID ¶ added in v0.1.11
GetPosAtxID returns the best (highest layer id), currently known to this node, pos atx id.
func (*DB) HandleAtxData ¶ added in v0.1.16
HandleAtxData handles atxs received either by gossip or sync.
func (*DB) HandleGossipAtx ¶ added in v0.1.15
HandleGossipAtx handles the atx gossip data channel.
func (*DB) ProcessAtx ¶ added in v0.1.11
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 (*DB) StoreAtx ¶ added in v0.1.11
StoreAtx stores an atx for epoch 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 (*DB) SyntacticallyValidateAtx ¶ added in v0.1.11
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.
- NIPost challenge is a hash of the serialization of the following fields: NodeID, SequenceNumber, PrevATXID, LayerID, StartTick, PositioningATX.
- The NIPost is valid.
- ATX LayerID is NIPostLayerTime or less after the PositioningATX LayerID.
- The ATX view of the previous epoch contains ActiveSetSize activations.
func (*DB) UnsubscribeAtx ¶ added in v0.1.11
UnsubscribeAtx un subscribes the waiting for a specific atx with atx id id to arrive via gossip.
func (*DB) ValidateSignedAtx ¶ added in v0.1.11
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 ErrAtxNotFound ¶
type ErrAtxNotFound error
ErrAtxNotFound is a specific error returned when no atx was found in DB.
type GetInfoResponse ¶
GetInfoResponse is the response object for the get-info endpoint.
type HTTPPoetClient ¶
type HTTPPoetClient struct {
// contains filtered or unexported fields
}
HTTPPoetClient implements PoetProvingServiceClient interface.
func NewHTTPPoetClient ¶
func NewHTTPPoetClient(target string) *HTTPPoetClient
NewHTTPPoetClient returns new instance of HTTPPoetClient for the specified target.
func (*HTTPPoetClient) PoetServiceID ¶ added in v0.1.11
func (c *HTTPPoetClient) PoetServiceID(ctx context.Context) ([]byte, error)
PoetServiceID returns the public key of the PoET proving service.
type HTTPPoetHarness ¶
type HTTPPoetHarness struct { *HTTPPoetClient Stdout io.Reader Stderr io.Reader ErrChan <-chan error 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
}
IdentityStore stores couples of identities and used to retrieve bls identity by provided ed25519 identity.
func NewIdentityStore ¶
func NewIdentityStore(db database.Database) *IdentityStore
NewIdentityStore creates a new identity store.
func (*IdentityStore) GetIdentity ¶
func (s *IdentityStore) GetIdentity(id string) (types.NodeID, error)
GetIdentity gets the identity by the provided ed25519 string id, it returns a NodeID struct or an error if id was not found.
func (*IdentityStore) StoreNodeIdentity ¶
func (s *IdentityStore) StoreNodeIdentity(id types.NodeID) error
StoreNodeIdentity stores a NodeID type, which consists of 2 identities: BLS and ed25519.
type NIPostBuilder ¶ added in v1.0.0
type NIPostBuilder struct {
// contains filtered or unexported fields
}
NIPostBuilder holds the required state and dependencies to create Non-Interactive Proofs of Space-Time (NIPost).
func NewNIPostBuilder ¶ added in v1.0.0
func NewNIPostBuilder( minerID []byte, postSetupProvider PostSetupProvider, poetProver PoetProvingServiceClient, poetDB poetDbAPI, store bytesStore, log log.Log, ) *NIPostBuilder
NewNIPostBuilder returns a NIPostBuilder.
func (*NIPostBuilder) BuildNIPost ¶ added in v1.0.0
func (nb *NIPostBuilder) BuildNIPost(ctx context.Context, challenge *types.Hash32, atxExpired chan struct{}) (*types.NIPost, error)
BuildNIPost uses the given challenge to build a NIPost. "atxExpired" and "stop" are channels for early termination of the building process. The process can take considerable time, because it includes waiting for the poet service to publish a proof - a process that takes about an epoch.
type PoETClientInitializer ¶ added in v1.0.0
type PoETClientInitializer func(string) PoetProvingServiceClient
PoETClientInitializer interfaces for creating PoetProvingServiceClient.
type PoetDb ¶
type PoetDb struct {
// contains filtered or unexported fields
}
PoetDb is a database for PoET proofs.
func (*PoetDb) GetMembershipMap ¶
GetMembershipMap returns the map of memberships in the requested PoET proof.
func (*PoetDb) GetProofMessage ¶
GetProofMessage returns the originally received PoET proof message.
func (*PoetDb) HasProof ¶
HasProof returns true if the database contains a proof with the given reference, or false otherwise.
func (*PoetDb) SubscribeToProofRef ¶
SubscribeToProofRef returns a channel that PoET proof ref for the requested PoET ID and round ID will be sent. If the proof is already available it will be sent immediately, otherwise it will be sent when available.
func (*PoetDb) UnsubscribeFromProofRef ¶
UnsubscribeFromProofRef removes all subscriptions from a given poetID and roundID. This method should be used with caution since any subscribers still waiting will now hang forever. TODO: only cancel specific subscription.
func (*PoetDb) Validate ¶
func (db *PoetDb) Validate(proof types.PoetProof, poetID []byte, roundID string, signature []byte) error
Validate validates a new PoET proof.
func (*PoetDb) ValidateAndStore ¶
func (db *PoetDb) ValidateAndStore(proofMessage *types.PoetProofMessage) error
ValidateAndStore validates and stores a new PoET proof.
func (*PoetDb) ValidateAndStoreMsg ¶ added in v0.1.16
ValidateAndStoreMsg validates and stores a new PoET proof.
type PoetListener ¶
PoetListener handles PoET gossip messages.
func NewPoetListener ¶
func NewPoetListener(poetDb poetValidatorPersistor, logger log.Log) *PoetListener
NewPoetListener returns a new PoetListener.
func (*PoetListener) HandlePoetProofMessage ¶
func (l *PoetListener) HandlePoetProofMessage(ctx context.Context, _ peer.ID, msg []byte) pubsub.ValidationResult
HandlePoetProofMessage is a receiver for broadcast messages.
type PoetProvingServiceClient ¶
type PoetProvingServiceClient interface { // Submit registers a challenge in the proving service current open round. Submit(ctx context.Context, challenge types.Hash32) (*types.PoetRound, error) // PoetServiceID returns the public key of the PoET proving service. PoetServiceID(context.Context) ([]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 PostConfig ¶ added in v1.0.0
type PostConfig struct { BitsPerLabel uint `mapstructure:"post-bits-per-label"` LabelsPerUnit uint `mapstructure:"post-labels-per-unit"` MinNumUnits uint `mapstructure:"post-min-numunits"` MaxNumUnits uint `mapstructure:"post-max-numunits"` K1 uint `mapstructure:"post-k1"` K2 uint `mapstructure:"post-k2"` }
PostConfig is the configuration of the Post protocol, used for data creation, proofs generation and validation.
func DefaultPostConfig ¶ added in v1.0.0
func DefaultPostConfig() PostConfig
DefaultPostConfig defines the default configuration for Post.
type PostSetupComputeProvider ¶
type PostSetupComputeProvider initialization.ComputeProvider
PostSetupComputeProvider represent a compute provider for Post setup data creation.
type PostSetupManager ¶ added in v1.0.0
type PostSetupManager struct {
// contains filtered or unexported fields
}
PostSetupManager implements the PostProvider interface.
func NewPostSetupManager ¶ added in v1.0.0
func NewPostSetupManager(id []byte, cfg PostConfig, logger log.Log) (*PostSetupManager, error)
NewPostSetupManager creates a new instance of PostSetupManager.
func (*PostSetupManager) Benchmark ¶ added in v1.0.0
func (mgr *PostSetupManager) Benchmark(p PostSetupComputeProvider) (int, error)
Benchmark runs a short benchmarking session for a given provider to evaluate its performance.
func (*PostSetupManager) BestProvider ¶ added in v1.0.0
func (mgr *PostSetupManager) BestProvider() (*PostSetupComputeProvider, error)
BestProvider returns the most performant compute provider based on a short benchmarking session.
func (*PostSetupManager) ComputeProviders ¶
func (mgr *PostSetupManager) ComputeProviders() []PostSetupComputeProvider
ComputeProviders returns a list of available compute providers for Post setup.
func (*PostSetupManager) Config ¶ added in v1.0.0
func (mgr *PostSetupManager) Config() PostConfig
Config returns the Post protocol config.
func (*PostSetupManager) GenerateProof ¶ added in v1.0.0
func (mgr *PostSetupManager) GenerateProof(challenge []byte) (*types.Post, *types.PostMetadata, error)
GenerateProof generates a new Post.
func (*PostSetupManager) LastError ¶
func (mgr *PostSetupManager) LastError() error
LastError returns the Post setup last error.
func (*PostSetupManager) LastOpts ¶ added in v1.0.0
func (mgr *PostSetupManager) LastOpts() *PostSetupOpts
LastOpts returns the Post setup last session options.
func (*PostSetupManager) StartSession ¶ added in v1.0.0
func (mgr *PostSetupManager) StartSession(opts PostSetupOpts) (chan struct{}, error)
StartSession starts (or continues) a data creation session. It supports resuming a previously started session, as well as changing the Post setup options (e.g., number of units) after initial setup.
func (*PostSetupManager) Status ¶ added in v1.0.0
func (mgr *PostSetupManager) Status() *PostSetupStatus
Status returns the setup current status.
func (*PostSetupManager) StatusChan ¶
func (mgr *PostSetupManager) StatusChan() <-chan *PostSetupStatus
StatusChan returns a channel with status updates of the setup current or the upcoming session.
func (*PostSetupManager) StopSession ¶
func (mgr *PostSetupManager) StopSession(deleteFiles bool) error
StopSession stops the current Post setup data creation session and optionally attempts to delete the data file(s).
type PostSetupOpts ¶ added in v1.0.0
type PostSetupOpts struct { DataDir string `mapstructure:"smeshing-opts-datadir"` NumUnits uint `mapstructure:"smeshing-opts-numunits"` NumFiles uint `mapstructure:"smeshing-opts-numfiles"` ComputeProviderID int `mapstructure:"smeshing-opts-provider"` Throttle bool `mapstructure:"smeshing-opts-throttle"` }
PostSetupOpts are the options used to initiate a Post setup data creation session, either via the public smesher API, or on node launch (via cmd args).
func DefaultPostSetupOpts ¶ added in v1.0.0
func DefaultPostSetupOpts() PostSetupOpts
DefaultPostSetupOpts defines the default options for Post setup.
type PostSetupProvider ¶ added in v1.0.0
type PostSetupProvider interface { Status() *PostSetupStatus StatusChan() <-chan *PostSetupStatus ComputeProviders() []PostSetupComputeProvider Benchmark(p PostSetupComputeProvider) (int, error) StartSession(opts PostSetupOpts) (chan struct{}, error) StopSession(deleteFiles bool) error GenerateProof(challenge []byte) (*types.Post, *types.PostMetadata, error) LastError() error LastOpts() *PostSetupOpts Config() PostConfig }
PostSetupProvider defines the functionality required for Post setup.
type PostSetupStatus ¶ added in v1.0.0
type PostSetupStatus struct { State postSetupState NumLabelsWritten uint64 LastOpts *PostSetupOpts LastError error }
PostSetupStatus represents a status snapshot of the Post setup.
type SmeshingProvider ¶ added in v1.0.0
type SmeshingProvider interface { Smeshing() bool StartSmeshing(types.Address, PostSetupOpts) error StopSmeshing(bool) error SmesherID() types.NodeID Coinbase() types.Address SetCoinbase(coinbase types.Address) MinGas() uint64 SetMinGas(value uint64) }
SmeshingProvider defines the functionality required for the node's Smesher API.
type StartRequest ¶
type StartRequest struct { GatewayAddresses []string `json:"gatewayAddresses,omitempty"` DisableBroadcast bool `json:"disableBroadcast,omitempty"` ConnAcksThreshold int `json:"connAcksThreshold,omitempty"` BroadcastAcksThreshold int `json:"broadcastAcksThreshold,omitempty"` }
StartRequest is the request object for the start endpoint.
type SubmitRequest ¶
type SubmitRequest struct {
Challenge []byte `json:"challenge,omitempty"`
}
SubmitRequest is the request object for the submit endpoint.
type SubmitResponse ¶
type SubmitResponse struct {
RoundID string
}
SubmitResponse is the response object for the submit endpoint.
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator contains the dependencies required to validate NIPosts.
func NewValidator ¶
func NewValidator(poetDb poetDbAPI, cfg PostConfig) *Validator
NewValidator returns a new NIPost validator.
func (*Validator) Validate ¶
func (v *Validator) Validate(minerID signing.PublicKey, nipost *types.NIPost, expectedChallenge types.Hash32, numUnits uint) error
Validate validates a NIPost, given a miner id and expected challenge. It returns an error if an issue is found or nil if the NIPost is valid. Some of the Post metadata fields validation values is ought to eventually be derived from consensus instead of local configuration. If so, their validation should be removed to contextual validation, while still syntactically-validate them here according to locally configured min/max values.
func (*Validator) ValidatePost ¶
func (v *Validator) ValidatePost(id []byte, PoST *types.Post, PostMetadata *types.PostMetadata, numUnits uint) error
ValidatePost validates a Proof of Space-Time (PoST). It returns nil if validation passed or an error indicating why validation failed.