Documentation
¶
Index ¶
- Variables
- func NewMinedRelaysWriteAheadLog(logFilePath string, logger polylog.Logger) (*minedRelaysWriteAheadLog, error)
- func NewRelayerSessions(deps depinject.Config, opts ...relayer.RelayerSessionsManagerOption) (_ relayer.RelayerSessionsManager, err error)
- func NewSessionTree(logger polylog.Logger, sessionHeader *sessiontypes.SessionHeader, ...) (relayer.SessionTree, error)
- func ReconstructSMTFromMinedRelaysLog(minedRelaysLogFilePath string, treeStore kvstore.MapStore, ...) (*smt.SMST, error)
- func WithDisableSMTPersistence(smtPersistenceDisabled bool) relayer.RelayerSessionsManagerOption
- func WithStoresDirectoryPath(storesDirectoryPath string) relayer.RelayerSessionsManagerOption
- type SessionsTreesMap
Constants ¶
This section is empty.
Variables ¶
var ( ErrSessionTreeClosed = sdkerrors.Register(codespace, 1, "session tree already closed") ErrSessionTreeNotClosed = sdkerrors.Register(codespace, 2, "session tree not closed") ErrSessionTreeStorePathExists = sdkerrors.Register(codespace, 3, "session tree store path already exists") ErrSessionTreeProofPathMismatch = sdkerrors.Register(codespace, 4, "session tree proof path mismatch") ErrSessionTreeUndefinedStoresDirectoryPath = sdkerrors.Register(codespace, 5, "session tree key-value store directory undefined for where they will be saved on disk") ErrSessionTreeAlreadyMarkedAsClaimed = sdkerrors.Register(codespace, 6, "session tree already marked as claimed") ErrSessionSupplierClientNotFound = sdkerrors.Register(codespace, 7, "supplier client not found") ErrSessionUpdatingTree = sdkerrors.Register(codespace, 8, "error updating session SMST") ErrSessionRelayMetaHasNoServiceID = sdkerrors.Register(codespace, 9, "service ID not specified in relay metadata") ErrSessionRelayMetaHasInvalidServiceID = sdkerrors.Register(codespace, 10, "service specified in relay metadata not found") ErrSessionTreeInvalidStoresDirectoryPath = sdkerrors.Register(codespace, 11, "session tree invalid stores directory path") ErrSessionTreeWALWriteQueueFull = sdkerrors.Register(codespace, 12, "session tree WAL write queue full") ErrSessionTreeWALClosed = sdkerrors.Register(codespace, 13, "session tree WAL closed") )
Next available error code: 12
var ClaimAndProofGasCost = sdktypes.NewInt64Coin(pocket.DenomuPOKT, 2)
Cumulative (observed) gas fees for creating a single claim and submitting a single proof: - Gas price at time of observance: 0.001uPOKT - Value obtained empirically by observing logs during load testing - Value may change as network parameters change - This value is a function of the claim & proof message sizes
TODO_IMPORTANT(#1507): ClaimAndProofGasCost value should be a function of the biggest Relay (in num of bytes) and tx_size_cost_per_byte auth module param. There should be a two step approach to this: 1. Choose a reasonable (empirically observed) p90 of claim & proof sizes across most chains 2. TODO_FUTURE: Compute the gas cost dynamically based on the size of the branch being proven. TODO_TECHDEBT(@olshansk): Temporarily setting this to 1uPOKT to see more claims & proofs on chain
Functions ¶
func NewMinedRelaysWriteAheadLog ¶ added in v0.1.30
func NewMinedRelaysWriteAheadLog(logFilePath string, logger polylog.Logger) (*minedRelaysWriteAheadLog, error)
NewMinedRelaysWriteAheadLog constructs a new minedRelaysWriteAheadLog, opening (or creating) the underlying append-only file at the given path and starting the periodic flush loop and the dedicated writer goroutine.
Paired with the SessionTree's in-memory SMST: - Call this once per newly created SessionTree to start capturing mined relays - For each mined relay, append to the WAL and also update the in-memory SMST - Keep the returned WAL around for the duration of the session - On clean shutdown, flush; on crash, replay to rebuild the in-memory SMST
Errors indicate we could not open the on-disk log (permissions, full disk, etc.).
func NewRelayerSessions ¶
func NewRelayerSessions( deps depinject.Config, opts ...relayer.RelayerSessionsManagerOption, ) (_ relayer.RelayerSessionsManager, err error)
NewRelayerSessions creates a new relayerSessions.
Required dependencies:
- client.BlockClient
- client.BlockQueryClient
- client.SupplierClientMap
- client.SharedQueryClient
- client.ServiceQueryClient
- client.ProofQueryClient
- client.BankQueryClient
- polylog.Logger
Available options:
- WithStoresDirectoryPath
- WithSigningKeyNames
func NewSessionTree ¶
func NewSessionTree( logger polylog.Logger, sessionHeader *sessiontypes.SessionHeader, supplierOperatorAddress string, storesDirectoryPath string, smtPersistenceDisabled bool, ) (relayer.SessionTree, error)
NewSessionTree creates a new sessionTree from a Session and a storePrefix. It also takes a function removeFromRelayerSessions that removes the sessionTree from the RelayerSessionsManager. It returns an error if the backing store fails to be created.
func ReconstructSMTFromMinedRelaysLog ¶ added in v0.1.30
func ReconstructSMTFromMinedRelaysLog( minedRelaysLogFilePath string, treeStore kvstore.MapStore, logger polylog.Logger, ) (*smt.SMST, error)
ReconstructSMTFromMinedRelaysLog replays the mined relays write-ahead log from disk to reconstruct the SMST representing the session state at crash/restart.
Since the SMST is in-memory by design (for speed), replaying the WAL is how we recover exactly the same state after a crash or restart, avoiding mined relay loss and guaranteeing the same ordering of the inserted relays which is critical for correct proof generation.
Rebuilding an in-memory SMST backup from the WAL involves: - Open the WAL file that contains all previously mined relays - For each relay, read fields in order and feed them into a fresh, in-memory SMST via Update - Stop on clean EOF; any other read error is logged/returned - The resulting trie represents the exact pre-crash state (deterministic replay)
Returns the reconstructed SMST or an error if replay fails
func WithDisableSMTPersistence ¶ added in v0.1.30
func WithDisableSMTPersistence(smtPersistenceDisabled bool) relayer.RelayerSessionsManagerOption
WithDisableSMTPersistence sets whether or not to persist the SMT of work sessions to disk.
func WithStoresDirectoryPath ¶ added in v0.1.29
func WithStoresDirectoryPath(storesDirectoryPath string) relayer.RelayerSessionsManagerOption
WithStoresDirectoryPath sets the path on disk where KVStore data files used to store SMST of work sessions are created.
Types ¶
type SessionsTreesMap ¶ added in v0.1.2
type SessionsTreesMap = map[string]map[int64]map[string]relayer.SessionTree
SessionTreesMap is an alias type for a map of supplierOperatorAddress -> sessionEndHeight -> sessionId -> SessionTree.
It keeps track of the sessions created by RelayMiner in memory. The sessions are group by their end block height, session id and supplier operator address.