Documentation
¶
Index ¶
- func OnProof(ctx context.Context, subscriber Subscriber, p ProofType, ...)
- func Register(proofType ProofType, unmarshaler ProofUnmarshaler)
- 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
- type ErrFraudExists
- type Getter
- type Proof
- type ProofType
- type ProofUnmarshaler
- type Service
- type Subscriber
- type Subscription
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OnProof ¶
func OnProof(ctx context.Context, subscriber Subscriber, p ProofType, handle func(proof Proof))
OnProof subscribes to the given Fraud Proof topic via the given Subscriber. In case a Fraud Proof is received, then the given handle function will be invoked.
func Register ¶
func Register(proofType ProofType, unmarshaler ProofUnmarshaler)
Register sets unmarshaler in map by provided ProofType.
Types ¶
type BadEncodingProof ¶
type BadEncodingProof struct {
BlockHeight uint64
// Shares that did not pass verification in rsmt2d 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
// Axis represents the axis that verification failed on.
Axis rsmt2d.Axis
// 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) Subscribe ¶
func (d *DummyService) Subscribe(ProofType) (Subscription, error)
type ErrFraudExists ¶
type ErrFraudExists struct {
Proof []Proof
}
func (*ErrFraudExists) Error ¶
func (e *ErrFraudExists) Error() string
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
}
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
Getter
}
Service encompasses the behavior necessary to subscribe and broadcast Fraud Proofs within the network.
type Subscriber ¶
type Subscriber interface {
// Subscribe allows to subscribe on a Proof pub sub topic by its type.
Subscribe(ProofType) (Subscription, error)
}
Subscriber encompasses the behavior necessary to subscribe/unsubscribe from new FraudProof events from the network.