lavaprotocol

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

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")
	ConsistencyError                             = sdkerrors.New("Consistency Error", 3368, "does not meet consistency requirements")
	UnhandledRelayReceiverError                  = sdkerrors.New("UnhandledRelayReceiver Error", 3369, "provider does not handle requested api interface and spec")
	DisabledRelayReceiverError                   = sdkerrors.New("DisabledRelayReceiverError Error", 3370, "provider does not pass verification and disabled this interface and spec")
)

Functions

func ConstructRelayRequest

func ConstructRelayRequest(ctx context.Context, privKey *btcec.PrivateKey, lavaChainID, chainID string, relayRequestData *pairingtypes.RelayPrivateData, providerPublicAddress string, consumerSession *lavasession.SingleConsumerSession, epoch int64, reportedProviders []*pairingtypes.ReportedProvider) (*pairingtypes.RelayRequest, error)

func ConstructRelaySession

func ConstructRelaySession(lavaChainID string, relayRequestData *pairingtypes.RelayPrivateData, chainID, providerPublicAddress string, singleConsumerSession *lavasession.SingleConsumerSession, epoch int64, reportedProviders []*pairingtypes.ReportedProvider) *pairingtypes.RelaySession

func GetLatestFinalizedBlock

func GetLatestFinalizedBlock(latestBlock, blockDistanceForFinalizedData int64) int64

func GetSalt

func GetSalt(requestData *pairingtypes.RelayPrivateData) uint64

func InterpolateBlocks

func InterpolateBlocks(timeNow, latestBlockTime time.Time, averageBlockTime time.Duration) int64

func NewRelayData

func NewRelayData(ctx context.Context, connectionType, apiUrl string, data []byte, seenBlock int64, requestBlock int64, apiInterface string, metadata []pairingtypes.Metadata, addon string, extensions []string) *pairingtypes.RelayPrivateData

func ReplaceRequestedBlock

func ReplaceRequestedBlock(requestedBlock, latestBlock int64) int64

func SetRequestedBlockNotApplicable

func SetRequestedBlockNotApplicable(request *pairingtypes.RelayPrivateData)

currently used when cache hits. we don't want DR.

func SetSalt

func SetSalt(requestData *pairingtypes.RelayPrivateData, value uint64)

func SignRelayResponse

func SignRelayResponse(consumerAddress sdk.AccAddress, request pairingtypes.RelayRequest, pkey *btcSecp256k1.PrivateKey, reply *pairingtypes.RelayReply, signDataReliability bool) (*pairingtypes.RelayReply, error)

func UpdateRequestedBlock

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

func VerifyFinalizationData

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

func VerifyRelayReply

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

func VerifyReliabilityResults

func VerifyReliabilityResults(ctx context.Context, originalResult, dataReliabilityResult *common.RelayResult, apiCollection *spectypes.ApiCollection, headerFilterer HeaderFilterer) (conflicts *conflicttypes.ResponseConflict)

Types

type FinalizationConsensus

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

func NewFinalizationConsensus

func NewFinalizationConsensus(specId string) *FinalizationConsensus

func (*FinalizationConsensus) ExpectedBlockHeight

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

returns the expected latest block to be at based on the current finalization data, and the number of providers we have information for does the calculation on finalized entries then extrapolates the ending based on blockDistance

func (*FinalizationConsensus) GetExpectedBlockHeights

func (fc *FinalizationConsensus) GetExpectedBlockHeights(averageBlockTime_ms time.Duration) map[string]int64

func (*FinalizationConsensus) LatestBlock

func (fc *FinalizationConsensus) LatestBlock() uint64

func (*FinalizationConsensus) NewEpoch

func (fc *FinalizationConsensus) NewEpoch(epoch uint64)

func (*FinalizationConsensus) String

func (fc *FinalizationConsensus) String() string

print the current status

func (*FinalizationConsensus) UpdateFinalizedHashes

func (fc *FinalizationConsensus) UpdateFinalizedHashes(blockDistanceForFinalizedData int64, providerAddress string, finalizedBlocks map[int64]string, req *pairingtypes.RelaySession, 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 HeaderFilterer

type HeaderFilterer interface {
	HandleHeaders(metadata []pairingtypes.Metadata, apiCollection *spectypes.ApiCollection, headersDirection spectypes.Header_HeaderType) (filtered []pairingtypes.Metadata, overwriteReqBlock string, ignoredMetadata []pairingtypes.Metadata)
}

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,4,opt,name=data,proto3" json:"data,omitempty"`
	RequestBlock   int64  `protobuf:"varint,5,opt,name=request_block,json=requestBlock,proto3" json:"request_block,omitempty"`
	ApiInterface   string `protobuf:"bytes,6,opt,name=apiInterface,proto3" json:"apiInterface,omitempty"`
}

Jump to

Keyboard shortcuts

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