Documentation
¶
Overview ¶
Package observe ports SolanaObserver of contracts/solana/reporter/solana.ts: it turns finalized Solana state into the observation the policy plans from. The owned RPC node is a trust boundary; finalized commitment cannot make an untrusted node truthful.
Index ¶
- type Change
- type Chunk
- type Deployment
- type Finalized
- type MismatchError
- type Observer
- func (o *Observer) Chunk(ctx context.Context, ids []sinkid.ID) (*Chunk, error)
- func (o *Observer) Deployment(ctx context.Context) (Deployment, error)
- func (o *Observer) Finalized(c *Chunk, rec sinkid.Record) (Finalized, error)
- func (o *Observer) Observe(ctx context.Context, c *Chunk, rec sinkid.Record, ...) (policy.Observed, error)
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chunk ¶
type Chunk struct {
// contains filtered or unexported fields
}
Chunk is one finalized snapshot of the deployment accounts and the status accounts of a chunk of transfers.
type Deployment ¶
Deployment is the result of a deployment snapshot without status accounts.
type Finalized ¶
type Finalized struct {
Kind policy.Kind
ContextSlot uint64
Address solana.PublicKey
Status *aktsolana.TransferStatus
Outcome sinkv1.Outcome
Slot uint64
}
Finalized is the finalized status of one transfer. Address, Status, Outcome and Slot are set for KindResolved only.
type MismatchError ¶
MismatchError reports a bridge account that names a light client other than the configured pin.
func (*MismatchError) Error ¶
func (e *MismatchError) Error() string
type Observer ¶
type Observer struct {
// contains filtered or unexported fields
}
Observer reads finalized Solana state for the reporter.
func New ¶
func New(rpc *aktsolana.RPC, idx *aktsolana.EvidenceIndex, o Options, onChange func(Change)) *Observer
New returns an observer. onChange, which may be nil, is called with each change of the followed light client while the follow lock is held. New panics on a mint that is not the program's "mint" PDA or a zero slot lead, which configuration validation rules out.
func (*Observer) Chunk ¶
Chunk takes one snapshot of the deployment accounts and the status accounts of ids. With the four deployment accounts, the RPC's 100-key limit allows 96 IDs.
func (*Observer) Deployment ¶
func (o *Observer) Deployment(ctx context.Context) (Deployment, error)
Deployment takes a snapshot of the deployment accounts. It fails on a light-client pin mismatch.
func (*Observer) Finalized ¶
Finalized checks the finalized status of rec in the chunk snapshot against the Akash record.
func (*Observer) Observe ¶
func (o *Observer) Observe( ctx context.Context, c *Chunk, rec sinkid.Record, reported []sinkv1.Observation, own *sinkv1.Observation, ) (policy.Observed, error)
Observe returns what this node observes for rec in the chunk snapshot. reported holds the Akash votes and the governance observation of the transfer; own, when set, is this reporter's authenticated stored vote. Its evidence is reused after the immutable finalized status is rechecked, so pruned transaction history does not break transfers already observed.
type Options ¶
type Options struct {
GenesisHash string
ProgramID solana.PublicKey
Mint solana.PublicKey
// LightClientPin, when set, fails every snapshot whose bridge names another light client. Unset follows the bridge.
LightClientPin *solana.PublicKey
ChainID string
MaxAge time.Duration
// SlotLead is how far beyond this node's finalized slot another node's finalized slot can plausibly be.
SlotLead uint64
Clock clock.Clock
}
Options configures an Observer.