lavaprotocol

package
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TimePerCU                      = uint64(100 * time.Millisecond)
	MinimumTimePerRelayDelay       = time.Second
	AverageWorldLatency            = 200 * time.Millisecond
	DataReliabilityTimeoutIncrease = 5 * time.Second
	SupportedNumberOfVRFs          = 2
)

Variables

View Source
var (
	ProviderFinzalizationDataError               = sdkerrors.New("ProviderFinzalizationData Error", 3365, "provider did not sign finalization data correctly")
	ProviderFinzalizationDataAccountabilityError = sdkerrors.New("ProviderFinzalizationDataAccountability Error", 3366, "provider returned invalid finalization data, with accountability")
	HashesConsunsusError                         = sdkerrors.New("HashesConsunsus Error", 3367, "identified finalized responses with conflicting hashes, from two providers")
)

Functions

func ConstructDataReliabilityRelayRequest added in v0.4.5

func ConstructDataReliabilityRelayRequest(ctx context.Context, vrfData *pairingtypes.VRFData, privKey *btcec.PrivateKey, chainID string, relayRequestCommonData *RelayRequestCommonData, providerPublicAddress string, epoch int64, reportedProviders []byte) (*pairingtypes.RelayRequest, error)

func ConstructRelayRequest

func ConstructRelayRequest(ctx context.Context, privKey *btcec.PrivateKey, chainID string, relayRequestCommonData RelayRequestCommonData, providerPublicAddress string, consumerSession *lavasession.SingleConsumerSession, epoch int64, reportedProviders []byte) (*pairingtypes.RelayRequest, error)

func DataReliabilityThresholdToSession added in v0.4.5

func DataReliabilityThresholdToSession(vrfs [][]byte, uniqueIdentifiers []bool, reliabilityThreshold uint32, originalProvidersCount uint32) (indexes map[int64]bool)

func GetLatestFinalizedBlock

func GetLatestFinalizedBlock(latestBlock int64, blockDistanceForFinalizedData int64) int64

func GetTimePerCu added in v0.4.5

func GetTimePerCu(cu uint64) time.Duration

func NewVRFData added in v0.4.5

func NewVRFData(differentiator bool, vrf_res []byte, vrf_proof []byte, request *pairingtypes.RelayRequest, reply *pairingtypes.RelayReply) *pairingtypes.VRFData

func ReplaceRequestedBlock

func ReplaceRequestedBlock(requestedBlock int64, latestBlock int64) int64

func UpdateRequestedBlock

func UpdateRequestedBlock(request *pairingtypes.RelayRequest, response *pairingtypes.RelayReply)

func VerifyFinalizationData

func VerifyFinalizationData(reply *pairingtypes.RelayReply, relayRequest *pairingtypes.RelayRequest, addr string, latestSessionBlock int64, blockDistanceForfinalization uint32) (finalizedBlocks map[int64]string, finalizationConflict *conflicttypes.FinalizationConflict, errRet error)

func VerifyRelayReply

func VerifyRelayReply(reply *pairingtypes.RelayReply, relayRequest *pairingtypes.RelayRequest, addr string) error

func VerifyReliabilityResults

func VerifyReliabilityResults(originalResult *RelayResult, dataReliabilityResults []*RelayResult, totalNumberOfSessions int) (conflict bool, conflicts []*conflicttypes.ResponseConflict)

Types

type FinalizationConsensus

type FinalizationConsensus struct {
	// contains filtered or unexported fields
}

func (*FinalizationConsensus) ExpectedBlockHeight

func (s *FinalizationConsensus) ExpectedBlockHeight(chainParser chainlib.ChainParser) (expectedBlockHeight int64, numOfProviders int)

returns the expected latest block, does the calculation on finalized entries then extrapolates the ending based on blockDistance

func (*FinalizationConsensus) NewEpoch

func (fc *FinalizationConsensus) NewEpoch(epoch uint64)

func (*FinalizationConsensus) UpdateFinalizedHashes

func (fc *FinalizationConsensus) UpdateFinalizedHashes(blockDistanceForFinalizedData int64, providerAddress string, latestBlock int64, finalizedBlocks map[int64]string, req *pairingtypes.RelayRequest, reply *pairingtypes.RelayReply) (finalizationConflict *conflicttypes.FinalizationConflict, err error)

Compare finalized block hashes with previous providers Looks for discrepancy with current epoch providers if no conflicts, insert into consensus and break create new consensus group if no consensus matched check for discrepancy with old epoch checks if there is a consensus mismatch between hashes provided by different providers

type ProviderHashesConsensus

type ProviderHashesConsensus struct {
	FinalizedBlocksHashes map[int64]string
	// contains filtered or unexported fields
}

type RelayRequestCommonData

type RelayRequestCommonData struct {
	ChainID        string `protobuf:"bytes,1,opt,name=chainID,proto3" json:"chainID,omitempty"`
	ConnectionType string `protobuf:"bytes,2,opt,name=connection_type,json=connectionType,proto3" json:"connection_type,omitempty"`
	ApiUrl         string `protobuf:"bytes,3,opt,name=api_url,json=apiUrl,proto3" json:"api_url,omitempty"`
	Data           []byte `protobuf:"bytes,6,opt,name=data,proto3" json:"data,omitempty"`
	RequestBlock   int64  `protobuf:"varint,11,opt,name=request_block,json=requestBlock,proto3" json:"request_block,omitempty"`
}

func NewRelayRequestCommonData added in v0.4.5

func NewRelayRequestCommonData(chainID string, connectionType string, apiUrl string, data []byte, requestBlock int64) RelayRequestCommonData

type RelayResult added in v0.4.5

type RelayResult struct {
	Request         *pairingtypes.RelayRequest
	Reply           *pairingtypes.RelayReply
	ProviderAddress string
	ReplyServer     *pairingtypes.Relayer_RelaySubscribeClient
	Finalized       bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL