Documentation
¶
Index ¶
- func OnBEFP(ctx context.Context, s Subscriber, stop func(context.Context) error)
- type BadEncodingProof
- func (p *BadEncodingProof) HeaderHash() []byte
- func (p *BadEncodingProof) Height() uint64
- func (p *BadEncodingProof) MarshalBinary() ([]byte, error)
- func (p *BadEncodingProof) Type() ProofType
- func (p *BadEncodingProof) UnmarshalBinary(data []byte) error
- func (p *BadEncodingProof) Validate(header *header.ExtendedHeader) error
- type Broadcaster
- type DummyService
- func (d *DummyService) Broadcast(context.Context, Proof) error
- func (d *DummyService) RegisterUnmarshaler(ProofType, ProofUnmarshaler) error
- func (d *DummyService) Start(context.Context) error
- func (d *DummyService) Stop(context.Context) error
- func (d *DummyService) Subscribe(ProofType) (Subscription, error)
- func (d *DummyService) UnregisterUnmarshaler(ProofType) error
- type Proof
- type ProofType
- type ProofUnmarshaler
- type Service
- type Subscriber
- type Subscription
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BadEncodingProof ¶
type BadEncodingProof struct {
BlockHeight uint64
// Shares that did not pass verification in rmst2d will be nil.
// For non-nil shares MerkleProofs are computed.
Shares []*ipld.ShareWithProof
// Index represents the row/col index where ErrByzantineRow/ErrByzantineColl occurred.
Index uint32
// contains filtered or unexported fields
}
func (*BadEncodingProof) HeaderHash ¶
func (p *BadEncodingProof) HeaderHash() []byte
HeaderHash returns block hash.
func (*BadEncodingProof) Height ¶
func (p *BadEncodingProof) Height() uint64
Height returns block height.
func (*BadEncodingProof) MarshalBinary ¶
func (p *BadEncodingProof) MarshalBinary() ([]byte, error)
MarshalBinary converts BadEncodingProof to binary.
func (*BadEncodingProof) Type ¶
func (p *BadEncodingProof) Type() ProofType
Type returns type of fraud proof.
func (*BadEncodingProof) UnmarshalBinary ¶
func (p *BadEncodingProof) UnmarshalBinary(data []byte) error
UnmarshalBinary converts binary to BadEncodingProof.
func (*BadEncodingProof) Validate ¶
func (p *BadEncodingProof) Validate(header *header.ExtendedHeader) error
Validate ensures that fraud proof is correct. Validate checks that provided Merkle Proofs correspond to the shares, rebuilds bad row or col from received shares, computes Merkle Root and compares it with block's Merkle Root.
type Broadcaster ¶
type Broadcaster interface {
// Broadcast takes a fraud `Proof` data structure that implements standard BinaryMarshal
// interface and broadcasts it to all subscribed peers.
Broadcast(context.Context, Proof) error
}
Broadcaster is a generic interface that sends a `Proof` to all nodes subscribed on the Broadcaster's topic.
type DummyService ¶
type DummyService struct {
}
func (*DummyService) RegisterUnmarshaler ¶
func (d *DummyService) RegisterUnmarshaler(ProofType, ProofUnmarshaler) error
func (*DummyService) Subscribe ¶
func (d *DummyService) Subscribe(ProofType) (Subscription, error)
func (*DummyService) UnregisterUnmarshaler ¶
func (d *DummyService) UnregisterUnmarshaler(ProofType) error
type Proof ¶
type Proof interface {
// Type returns the exact type of fraud proof.
Type() ProofType
// HeaderHash returns the block hash.
HeaderHash() []byte
// Height returns the block height corresponding to the Proof.
Height() uint64
// Validate check the validity of fraud proof.
// Validate throws an error if some conditions don't pass and thus fraud proof is not valid.
// NOTE: header.ExtendedHeader should pass basic validation otherwise it will panic if it's malformed.
Validate(*header.ExtendedHeader) error
encoding.BinaryMarshaler
encoding.BinaryUnmarshaler
}
Proof is a generic interface that will be used for all types of fraud proofs in the network.
func CreateBadEncodingProof ¶
func CreateBadEncodingProof( hash []byte, height uint64, errByzantine *ipld.ErrByzantine, ) Proof
CreateBadEncodingProof creates a new Bad Encoding Fraud Proof that should be propagated through network. The fraud proof will contain shares that did not pass verification and their relevant Merkle proofs.
func UnmarshalBEFP ¶
UnmarshalBEFP converts given data to BadEncodingProof.
type ProofUnmarshaler ¶
ProofUnmarshaler aliases a function that parses data to `Proof`.
type Service ¶
type Service interface {
Subscriber
Broadcaster
}
Service encompasses the behavior necessary to subscribe and broadcast Fraud Proofs within the network.
func NewService ¶
type Subscriber ¶
type Subscriber interface {
// Subscribe allows to subscribe on a Proof pub sub topic by its type.
Subscribe(ProofType) (Subscription, error)
// RegisterUnmarshaler registers unmarshaler for the given ProofType.
// If there is no unmarshaler for `ProofType`, then `Subscribe` returns an error.
RegisterUnmarshaler(ProofType, ProofUnmarshaler) error
// UnregisterUnmarshaler removes unmarshaler for the given ProofType.
// If there is no unmarshaler for `ProofType`, then it returns an error.
UnregisterUnmarshaler(ProofType) error
}
Subscriber encompasses the behavior necessary to subscribe/unsubscribe from new FraudProof events from the network.