diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 5e4f715e3e..8f2870411d 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -29843,6 +29843,8 @@ paths: type: string vrfpk: type: string + moniker: + type: string pagination: type: object properties: @@ -30007,6 +30009,8 @@ paths: type: string vrfpk: type: string + moniker: + type: string default: description: An unexpected error response. schema: @@ -30086,6 +30090,8 @@ paths: type: string vrfpk: type: string + moniker: + type: string output: type: string default: @@ -30382,6 +30388,8 @@ paths: type: string vrfpk: type: string + moniker: + type: string default: description: An unexpected error response. schema: @@ -30732,6 +30740,8 @@ paths: type: string vrfpk: type: string + moniker: + type: string output: type: string default: @@ -30984,6 +30994,8 @@ paths: type: string vrfpk: type: string + moniker: + type: string maxCU: type: string format: uint64 @@ -53085,6 +53097,8 @@ definitions: type: string vrfpk: type: string + moniker: + type: string pagination: type: object properties: @@ -53193,6 +53207,8 @@ definitions: type: string vrfpk: type: string + moniker: + type: string lavanet.lava.epochstorage.QueryParamsResponse: type: object properties: @@ -53252,6 +53268,8 @@ definitions: type: string vrfpk: type: string + moniker: + type: string lavanet.lava.epochstorage.StakeStorage: type: object properties: @@ -53301,6 +53319,8 @@ definitions: type: string vrfpk: type: string + moniker: + type: string lavanet.lava.pairing.CacheUsage: type: object properties: @@ -53617,6 +53637,8 @@ definitions: type: string vrfpk: type: string + moniker: + type: string output: type: string lavanet.lava.pairing.QueryGetEpochPaymentsResponse: @@ -53701,6 +53723,8 @@ definitions: type: string vrfpk: type: string + moniker: + type: string lavanet.lava.pairing.QueryGetProviderPaymentStorageResponse: type: object properties: @@ -53827,6 +53851,8 @@ definitions: type: string vrfpk: type: string + moniker: + type: string output: type: string lavanet.lava.pairing.QueryUserEntryResponse: @@ -53874,6 +53900,8 @@ definitions: type: string vrfpk: type: string + moniker: + type: string maxCU: type: string format: uint64 diff --git a/relayer/chainproxy/chainproxy.go b/relayer/chainproxy/chainproxy.go index 68e173afbe..cfef1991c5 100644 --- a/relayer/chainproxy/chainproxy.go +++ b/relayer/chainproxy/chainproxy.go @@ -119,7 +119,7 @@ func SendRelay( } // consumerSession is locked here. - callback_send_relay := func(consumerSession *lavasession.SingleConsumerSession) (*pairingtypes.RelayReply, *pairingtypes.Relayer_RelaySubscribeClient, *pairingtypes.RelayRequest, time.Duration, error) { + callback_send_relay := func(consumerSession *lavasession.SingleConsumerSession) (*pairingtypes.RelayReply, *pairingtypes.Relayer_RelaySubscribeClient, *pairingtypes.RelayRequest, time.Duration, bool, error) { // client session is locked here blockHeight = int64(epoch) // epochs heights only @@ -141,18 +141,18 @@ func SendRelay( } sig, err := sigs.SignRelay(privKey, *relayRequest) if err != nil { - return nil, nil, nil, 0, err + return nil, nil, nil, 0, false, err } relayRequest.Sig = sig c := *consumerSession.Endpoint.Client - relaySentTime := time.Now() connectCtx, cancel := context.WithTimeout(ctx, DefaultTimeout) defer cancel() var replyServer pairingtypes.Relayer_RelaySubscribeClient var reply *pairingtypes.RelayReply + relaySentTime := time.Now() if isSubscription { replyServer, err = c.RelaySubscribe(ctx, relayRequest) } else { @@ -163,11 +163,15 @@ func SendRelay( utils.LavaFormatError("cache not connected", err, nil) } reply, err = c.Relay(connectCtx, relayRequest) + } else { + // Info was fetched from cache, so we need to change the state + // so we can return here, no need to update anything and calculate as this info was fetched from the cache + return reply, nil, relayRequest, 0, true, nil } } currentLatency := time.Since(relaySentTime) if err != nil { - return nil, nil, nil, 0, err + return nil, nil, nil, 0, false, err } if !isSubscription { @@ -176,22 +180,22 @@ func SendRelay( finalized := cp.GetSentry().IsFinalizedBlock(relayRequest.RequestBlock, reply.LatestBlock) err = VerifyRelayReply(reply, relayRequest, providerPublicAddress, cp.GetSentry().GetSpecComparesHashes()) if err != nil { - return nil, nil, nil, 0, err + return nil, nil, nil, 0, false, err } cache := cp.GetCache() // TODO: response sanity, check its under an expected format add that format to spec cache.SetEntry(ctx, relayRequest, cp.GetSentry().ApiInterface, nil, cp.GetSentry().ChainID, dappID, reply, finalized) // caching in the portal doesn't care about hashes - return reply, nil, relayRequest, currentLatency, nil + return reply, nil, relayRequest, currentLatency, false, nil } // isSubscription - return reply, &replyServer, relayRequest, currentLatency, nil + return reply, &replyServer, relayRequest, currentLatency, false, nil } - callback_send_reliability := func(consumerSession *lavasession.SingleConsumerSession, dataReliability *pairingtypes.VRFData, providerAddress string) (*pairingtypes.RelayReply, *pairingtypes.RelayRequest, error) { + callback_send_reliability := func(consumerSession *lavasession.SingleConsumerSession, dataReliability *pairingtypes.VRFData, providerAddress string) (*pairingtypes.RelayReply, *pairingtypes.RelayRequest, time.Duration, error) { // client session is locked here sentry := cp.GetSentry() if blockHeight < 0 { - return nil, nil, fmt.Errorf("expected callback_send_relay to be called first and set blockHeight") + return nil, nil, 0, fmt.Errorf("expected callback_send_relay to be called first and set blockHeight") } relayRequest := &pairingtypes.RelayRequest{ @@ -212,30 +216,31 @@ func SendRelay( sig, err := sigs.SignRelay(privKey, *relayRequest) if err != nil { - return nil, nil, err + return nil, nil, 0, err } relayRequest.Sig = sig sig, err = sigs.SignVRFData(privKey, relayRequest.DataReliability) if err != nil { - return nil, nil, err + return nil, nil, 0, err } relayRequest.DataReliability.Sig = sig c := *consumerSession.Endpoint.Client + relaySentTime := time.Now() reply, err := c.Relay(ctx, relayRequest) if err != nil { - return nil, nil, err + return nil, nil, 0, err } - + currentLatency := time.Since(relaySentTime) err = VerifyRelayReply(reply, relayRequest, providerAddress, cp.GetSentry().GetSpecComparesHashes()) if err != nil { - return nil, nil, err + return nil, nil, 0, err } - return reply, relayRequest, nil + return reply, relayRequest, currentLatency, nil } - reply, replyServer, relayLatency, firstSessionError := cp.GetSentry().SendRelay(ctx, singleConsumerSession, epoch, providerPublicAddress, callback_send_relay, callback_send_reliability, nodeMsg.GetServiceApi().Category) + reply, replyServer, relayLatency, isCachedResult, firstSessionError := cp.GetSentry().SendRelay(ctx, singleConsumerSession, epoch, providerPublicAddress, callback_send_relay, callback_send_reliability, nodeMsg.GetServiceApi().Category) if firstSessionError != nil { // on session failure here errReport := cp.GetConsumerSessionManager().OnSessionFailure(singleConsumerSession, firstSessionError) @@ -250,7 +255,7 @@ func SendRelay( return nil, nil, utils.LavaFormatError("relay_retry_attempt - Failed to get a second session from a different provider", nil, &map[string]string{"Original Error": firstSessionError.Error(), "GetSessionFromAllExcept Error": err.Error(), "ChainID": cp.GetSentry().ChainID, "Original_Provider_Address": originalProviderAddress}) } var secondSessionError error - reply, replyServer, relayLatency, secondSessionError = cp.GetSentry().SendRelay(ctx, singleConsumerSession, epoch, providerPublicAddress, callback_send_relay, callback_send_reliability, nodeMsg.GetServiceApi().Category) + reply, replyServer, relayLatency, isCachedResult, secondSessionError = cp.GetSentry().SendRelay(ctx, singleConsumerSession, epoch, providerPublicAddress, callback_send_relay, callback_send_reliability, nodeMsg.GetServiceApi().Category) if secondSessionError != nil { errReport = cp.GetConsumerSessionManager().OnSessionFailure(singleConsumerSession, secondSessionError) if errReport != nil { @@ -270,6 +275,10 @@ func SendRelay( } } if !isSubscription { + if isCachedResult { + err = cp.GetConsumerSessionManager().OnSessionUnUsed(singleConsumerSession) + return reply, replyServer, err + } latestBlock := reply.LatestBlock expectedBH, numOfProviders := cp.GetSentry().ExpectedBlockHeight() err = cp.GetConsumerSessionManager().OnSessionDone(singleConsumerSession, epoch, latestBlock, nodeMsg.GetServiceApi().ComputeUnits, relayLatency, expectedBH, numOfProviders, cp.GetSentry().GetProvidersCount()) // session done successfully diff --git a/relayer/lavasession/consumer_session_manager.go b/relayer/lavasession/consumer_session_manager.go index 1bde810464..cccba14c97 100644 --- a/relayer/lavasession/consumer_session_manager.go +++ b/relayer/lavasession/consumer_session_manager.go @@ -265,17 +265,43 @@ func (csm *ConsumerSessionManager) blockProvider(address string, reportProvider return nil } -// Report session failure, mark it as blocked from future usages, report if timeout happened. -func (csm *ConsumerSessionManager) OnSessionFailure(consumerSession *SingleConsumerSession, errorReceived error) error { - // consumerSession must be locked when getting here. +// Verify the consumerSession is locked when getting to this function, if its not locked throw an error +func (csm *ConsumerSessionManager) verifyLock(consumerSession *SingleConsumerSession) error { if consumerSession.lock.TryLock() { // verify. // if we managed to lock throw an error for misuse. defer consumerSession.lock.Unlock() - return sdkerrors.Wrapf(LockMisUseDetectedError, "consumerSession.lock must be locked before accessing this method, additional info:") + return LockMisUseDetectedError + } + return nil +} + +// A Session can be created but unused if consumer found the response in the cache. +// So we need to unlock the session and decrease the cu that were applied +func (csm *ConsumerSessionManager) OnSessionUnUsed(consumerSession *SingleConsumerSession) error { + if err := csm.verifyLock(consumerSession); err != nil { + return sdkerrors.Wrapf(err, "OnSessionUnUsed, consumerSession.lock must be locked before accessing this method, additional info:") + } + cuToDecrease := consumerSession.LatestRelayCu + consumerSession.LatestRelayCu = 0 // making sure no one uses it in a wrong way + parentConsumerSessionsWithProvider := consumerSession.Client // must read this pointer before unlocking + // finished with consumerSession here can unlock. + consumerSession.lock.Unlock() // we unlock before we change anything in the parent ConsumerSessionsWithProvider + err := parentConsumerSessionsWithProvider.decreaseUsedComputeUnits(cuToDecrease) // change the cu in parent + if err != nil { + return err + } + return nil +} + +// Report session failure, mark it as blocked from future usages, report if timeout happened. +func (csm *ConsumerSessionManager) OnSessionFailure(consumerSession *SingleConsumerSession, errorReceived error) error { + // consumerSession must be locked when getting here. + if err := csm.verifyLock(consumerSession); err != nil { + return sdkerrors.Wrapf(err, "OnSessionFailure, consumerSession.lock must be locked before accessing this method, additional info:") } // consumer Session should be locked here. so we can just apply the session failure here. - if consumerSession.Blocklisted { + if consumerSession.BlockListed { // if consumer session is already blocklisted return an error. return sdkerrors.Wrapf(SessionIsAlreadyBlockListedError, "trying to report a session failure of a blocklisted consumer session") } @@ -284,10 +310,8 @@ func (csm *ConsumerSessionManager) OnSessionFailure(consumerSession *SingleConsu consumerSession.ConsecutiveNumberOfFailures += 1 // increase number of failures for this session // if this session failed more than MaximumNumberOfFailuresAllowedPerConsumerSession times we block list it. - if consumerSession.ConsecutiveNumberOfFailures > MaximumNumberOfFailuresAllowedPerConsumerSession { - consumerSession.Blocklisted = true // block this session from future usages - } else if SessionOutOfSyncError.Is(errorReceived) { // this is an error that we must block the session due to. - consumerSession.Blocklisted = true + if consumerSession.ConsecutiveNumberOfFailures > MaximumNumberOfFailuresAllowedPerConsumerSession || SessionOutOfSyncError.Is(errorReceived) { + consumerSession.BlockListed = true // block this session from future usages } cuToDecrease := consumerSession.LatestRelayCu consumerSession.LatestRelayCu = 0 // making sure no one uses it in a wrong way @@ -333,6 +357,26 @@ func (csm *ConsumerSessionManager) GetSessionFromAllExcept(ctx context.Context, } } +// On a successful DataReliability session we don't need to increase and update any field, we just need to unlock the session. +func (csm *ConsumerSessionManager) OnDataReliabilitySessionDone(consumerSession *SingleConsumerSession, + latestServicedBlock int64, + specComputeUnits uint64, + currentLatency time.Duration, + expectedBH int64, + numOfProviders int, + providersCount uint64, +) error { + if err := csm.verifyLock(consumerSession); err != nil { + return sdkerrors.Wrapf(err, "OnDataReliabilitySessionDone, consumerSession.lock must be locked before accessing this method") + } + + defer consumerSession.lock.Unlock() // we need to be locked here, if we didn't get it locked we try lock anyway + consumerSession.ConsecutiveNumberOfFailures = 0 // reset failures. + consumerSession.LatestBlock = latestServicedBlock // update latest serviced block + consumerSession.CalculateQoS(specComputeUnits, currentLatency, expectedBH-latestServicedBlock, numOfProviders, int64(providersCount)) + return nil +} + // On a successful session this function will update all necessary fields in the consumerSession. and unlock it when it finishes func (csm *ConsumerSessionManager) OnSessionDone( consumerSession *SingleConsumerSession, @@ -345,12 +389,11 @@ func (csm *ConsumerSessionManager) OnSessionDone( providersCount uint64, ) error { // release locks, update CU, relaynum etc.. - defer consumerSession.lock.Unlock() // we need to be locked here, if we didn't get it locked we try lock anyway - if consumerSession.lock.TryLock() { // verify consumerSession was locked. - // if we managed to lock throw an error for misuse. - return sdkerrors.Wrapf(LockMisUseDetectedError, "consumerSession.lock must be locked before accessing this method") + if err := csm.verifyLock(consumerSession); err != nil { + return sdkerrors.Wrapf(err, "OnSessionDone, consumerSession.lock must be locked before accessing this method") } + defer consumerSession.lock.Unlock() // we need to be locked here, if we didn't get it locked we try lock anyway consumerSession.CuSum += consumerSession.LatestRelayCu // add CuSum to current cu usage. consumerSession.LatestRelayCu = 0 // reset cu just in case consumerSession.RelayNum += RelayNumberIncrement // increase relayNum @@ -470,24 +513,13 @@ func (csm *ConsumerSessionManager) GetDataReliabilitySession(ctx context.Context return consumerSession, providerAddress, currentEpoch, nil } -// On a successful DataReliability session we don't need to increase and update any field, we just need to unlock the session. -func (csm *ConsumerSessionManager) OnSessionDoneWithoutQoSChanges(consumerSession *SingleConsumerSession) error { - defer consumerSession.lock.Unlock() // we need to be locked here, if we didn't get it locked we try lock anyway - if consumerSession.lock.TryLock() { // verify consumerSession was locked. - // if we managed to lock throw an error for misuse. - return sdkerrors.Wrapf(LockMisUseDetectedError, "consumerSession.lock must be locked before accessing this method") - } - return nil -} - // On a successful Subscribe relay func (csm *ConsumerSessionManager) OnSessionDoneIncreaseRelayAndCu(consumerSession *SingleConsumerSession) error { - defer consumerSession.lock.Unlock() // we need to be locked here, if we didn't get it locked we try lock anyway - if consumerSession.lock.TryLock() { // verify consumerSession was locked. - // if we managed to lock throw an error for misuse. - return sdkerrors.Wrapf(LockMisUseDetectedError, "consumerSession.lock must be locked before accessing this method") + if err := csm.verifyLock(consumerSession); err != nil { + return sdkerrors.Wrapf(err, "OnSessionDoneIncreaseRelayAndCu consumerSession.lock must be locked before accessing this method") } + defer consumerSession.lock.Unlock() // we need to be locked here, if we didn't get it locked we try lock anyway consumerSession.CuSum += consumerSession.LatestRelayCu // add CuSum to current cu usage. consumerSession.LatestRelayCu = 0 // reset cu just in case consumerSession.RelayNum += RelayNumberIncrement // increase relayNum @@ -498,21 +530,22 @@ func (csm *ConsumerSessionManager) OnSessionDoneIncreaseRelayAndCu(consumerSessi // On a failed DataReliability session we don't decrease the cu unlike a normal session, we just unlock and verify if we need to block this session or provider. func (csm *ConsumerSessionManager) OnDataReliabilitySessionFailure(consumerSession *SingleConsumerSession, errorReceived error) error { // consumerSession must be locked when getting here. - if consumerSession.lock.TryLock() { // verify. - // if we managed to lock throw an error for misuse. - defer consumerSession.lock.Unlock() - return sdkerrors.Wrapf(LockMisUseDetectedError, "consumerSession.lock must be locked before accessing this method, additional info:") + if err := csm.verifyLock(consumerSession); err != nil { + return sdkerrors.Wrapf(err, "OnDataReliabilitySessionFailure consumerSession.lock must be locked before accessing this method") } // consumer Session should be locked here. so we can just apply the session failure here. - if consumerSession.Blocklisted { + if consumerSession.BlockListed { // if consumer session is already blocklisted return an error. return sdkerrors.Wrapf(SessionIsAlreadyBlockListedError, "trying to report a session failure of a blocklisted client session") } - + consumerSession.QoSInfo.TotalRelays++ consumerSession.ConsecutiveNumberOfFailures += 1 // increase number of failures for this session + // if this session failed more than MaximumNumberOfFailuresAllowedPerConsumerSession times we block list it. if consumerSession.ConsecutiveNumberOfFailures > MaximumNumberOfFailuresAllowedPerConsumerSession { - consumerSession.Blocklisted = true // block this session from future usages + consumerSession.BlockListed = true // block this session from future usages + } else if SessionOutOfSyncError.Is(errorReceived) { // this is an error that we must block the session due to. + consumerSession.BlockListed = true } var blockProvider, reportProvider bool diff --git a/relayer/lavasession/consumer_types.go b/relayer/lavasession/consumer_types.go index 7463f0c716..bc9cca67a7 100644 --- a/relayer/lavasession/consumer_types.go +++ b/relayer/lavasession/consumer_types.go @@ -40,7 +40,7 @@ type SingleConsumerSession struct { RelayNum uint64 LatestBlock int64 Endpoint *Endpoint - Blocklisted bool // if session lost sync we blacklist it. + BlockListed bool // if session lost sync we blacklist it. ConsecutiveNumberOfFailures uint64 // number of times this session has failed } @@ -168,7 +168,7 @@ func (cswp *ConsumerSessionsWithProvider) getConsumerSessionInstanceFromEndpoint } if session.lock.TryLock() { - if session.Blocklisted { // this session cannot be used. + if session.BlockListed { // this session cannot be used. numberOfBlockedSessions += 1 // increase the number of blocked sessions so we can block this provider is too many are blocklisted session.lock.Unlock() continue diff --git a/relayer/sentry/sentry.go b/relayer/sentry/sentry.go index a692089b22..d88ec4b7ee 100755 --- a/relayer/sentry/sentry.go +++ b/relayer/sentry/sentry.go @@ -950,29 +950,29 @@ func (s *Sentry) SendRelay( consumerSession *lavasession.SingleConsumerSession, sessionEpoch uint64, providerPubAddress string, - cb_send_relay func(consumerSession *lavasession.SingleConsumerSession) (*pairingtypes.RelayReply, *pairingtypes.Relayer_RelaySubscribeClient, *pairingtypes.RelayRequest, time.Duration, error), - cb_send_reliability func(consumerSession *lavasession.SingleConsumerSession, dataReliability *pairingtypes.VRFData, providerAddress string) (*pairingtypes.RelayReply, *pairingtypes.RelayRequest, error), + cb_send_relay func(consumerSession *lavasession.SingleConsumerSession) (*pairingtypes.RelayReply, *pairingtypes.Relayer_RelaySubscribeClient, *pairingtypes.RelayRequest, time.Duration, bool, error), + cb_send_reliability func(consumerSession *lavasession.SingleConsumerSession, dataReliability *pairingtypes.VRFData, providerAddress string) (*pairingtypes.RelayReply, *pairingtypes.RelayRequest, time.Duration, error), specCategory *spectypes.SpecCategory, -) (*pairingtypes.RelayReply, *pairingtypes.Relayer_RelaySubscribeClient, time.Duration, error) { +) (*pairingtypes.RelayReply, *pairingtypes.Relayer_RelaySubscribeClient, time.Duration, bool, error) { // callback user - reply, replyServer, request, latency, err := cb_send_relay(consumerSession) + reply, replyServer, request, latency, fromCache, err := cb_send_relay(consumerSession) // error using this provider if err != nil { - return nil, nil, 0, utils.LavaFormatError("failed sending relay", lavasession.SendRelayError, &map[string]string{"ErrMsg": err.Error()}) + return nil, nil, 0, fromCache, utils.LavaFormatError("failed sending relay", lavasession.SendRelayError, &map[string]string{"ErrMsg": err.Error()}) } - if s.GetSpecComparesHashes() && reply != nil { + if s.GetSpecComparesHashes() && reply != nil && !fromCache { finalizedBlocks := map[int64]string{} // TODO:: define struct in relay response err = json.Unmarshal(reply.FinalizedBlocksHashes, &finalizedBlocks) if err != nil { - return nil, nil, latency, utils.LavaFormatError("failed in unmarshalling finalized blocks data", lavasession.SendRelayError, &map[string]string{"ErrMsg": err.Error()}) + return nil, nil, latency, fromCache, utils.LavaFormatError("failed in unmarshalling finalized blocks data", lavasession.SendRelayError, &map[string]string{"ErrMsg": err.Error()}) } latestBlock := reply.LatestBlock // validate that finalizedBlocks makes sense err = s.validateProviderReply(finalizedBlocks, latestBlock, providerPubAddress, consumerSession) if err != nil { - return nil, nil, latency, utils.LavaFormatError("failed provider reply validation", lavasession.SendRelayError, &map[string]string{"ErrMsg": err.Error()}) + return nil, nil, latency, fromCache, utils.LavaFormatError("failed provider reply validation", lavasession.SendRelayError, &map[string]string{"ErrMsg": err.Error()}) } // // Compare finalized block hashes with previous providers @@ -982,7 +982,7 @@ func (s *Sentry) SendRelay( // check for discrepancy with old epoch _, err := checkFinalizedHashes(s, providerPubAddress, latestBlock, finalizedBlocks, request, reply) if err != nil { - return nil, nil, latency, utils.LavaFormatError("failed to check finalized hashes", lavasession.SendRelayError, &map[string]string{"ErrMsg": err.Error()}) + return nil, nil, latency, fromCache, utils.LavaFormatError("failed to check finalized hashes", lavasession.SendRelayError, &map[string]string{"ErrMsg": err.Error()}) } if specCategory.Deterministic && s.IsFinalizedBlock(request.RequestBlock, reply.LatestBlock) { @@ -1022,6 +1022,7 @@ func (s *Sentry) SendRelay( } sendReliabilityRelay := func(singleConsumerSession *lavasession.SingleConsumerSession, providerAddress string, differentiator bool) (relay_rep *pairingtypes.RelayReply, relay_req *pairingtypes.RelayRequest, err error) { + var dataReliabilityLatency time.Duration s.VrfSkMu.Lock() vrf_res, vrf_proof := utils.ProveVrfOnRelay(request, reply, s.VrfSk, differentiator, sessionEpoch) s.VrfSkMu.Unlock() @@ -1034,7 +1035,7 @@ func (s *Sentry) SendRelay( QueryHash: utils.CalculateQueryHash(*request), // calculated from query body anyway, but we will use this on payment Sig: nil, // calculated in cb_send_reliability } - relay_rep, relay_req, err = cb_send_reliability(singleConsumerSession, dataReliability, providerAddress) + relay_rep, relay_req, dataReliabilityLatency, err = cb_send_reliability(singleConsumerSession, dataReliability, providerAddress) if err != nil { errRet := s.consumerSessionManager.OnDataReliabilitySessionFailure(singleConsumerSession, err) if errRet != nil { @@ -1042,7 +1043,9 @@ func (s *Sentry) SendRelay( } return nil, nil, utils.LavaFormatError("sendReliabilityRelay Could not get reply to reliability relay from provider", err, &map[string]string{"Address": providerAddress}) } - err = s.consumerSessionManager.OnSessionDoneWithoutQoSChanges(singleConsumerSession) + + expectedBH, numOfProviders := s.ExpectedBlockHeight() + err = s.consumerSessionManager.OnDataReliabilitySessionDone(singleConsumerSession, relay_rep.LatestBlock, singleConsumerSession.LatestRelayCu, dataReliabilityLatency, expectedBH, numOfProviders, s.GetProvidersCount()) return relay_rep, relay_req, err } @@ -1077,7 +1080,7 @@ func (s *Sentry) SendRelay( } } - return reply, replyServer, latency, nil + return reply, replyServer, latency, fromCache, nil } // Verify all dataReliabilityVerifications with one another diff --git a/scripts/init_chain_commands.sh b/scripts/init_chain_commands.sh index 594d552c4f..bb58dc6fb3 100755 --- a/scripts/init_chain_commands.sh +++ b/scripts/init_chain_commands.sh @@ -15,19 +15,19 @@ lavad tx gov vote 2 yes -y --from alice --gas-adjustment "1.5" --gas "auto" --ga sleep 4 lavad tx pairing stake-client "ETH1" 200000ulava 1 -y --from user1 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE lavad tx pairing stake-client "GTH1" 200000ulava 1 -y --from user1 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE -lavad tx pairing stake-client "COS3" 200000ulava 1 -y --from user2 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE -lavad tx pairing stake-client "FTM250" 200000ulava 1 -y --from user3 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE -lavad tx pairing stake-client "CELO" 200000ulava 1 -y --from user3 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE -lavad tx pairing stake-client "LAV1" 200000ulava 1 -y --from user4 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE -lavad tx pairing stake-client "COS4" 200000ulava 1 -y --from user2 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE -lavad tx pairing stake-client "ALFAJORES" 200000ulava 1 -y --from user3 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE -lavad tx pairing stake-client "ARB1" 200000ulava 1 -y --from user4 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE -lavad tx pairing stake-client "ARBN" 200000ulava 1 -y --from user4 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE -lavad tx pairing stake-client "APT1" 200000ulava 1 -y --from user4 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE -lavad tx pairing stake-client "STRK" 200000ulava 1 -y --from user4 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE -lavad tx pairing stake-client "JUN1" 200000ulava 1 -y --from user4 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE -lavad tx pairing stake-client "COS5" 200000ulava 1 -y --from user2 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE -lavad tx pairing stake-client "POLYGON1" 200000ulava 1 -y --from user3 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE +lavad tx pairing stake-client "COS3" 200000ulava 1 -y --from user1 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE +lavad tx pairing stake-client "FTM250" 200000ulava 1 -y --from user1 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE +lavad tx pairing stake-client "CELO" 200000ulava 1 -y --from user1 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE +lavad tx pairing stake-client "LAV1" 200000ulava 1 -y --from user1 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE +lavad tx pairing stake-client "COS4" 200000ulava 1 -y --from user1 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE +lavad tx pairing stake-client "ALFAJORES" 200000ulava 1 -y --from user1 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE +lavad tx pairing stake-client "ARB1" 200000ulava 1 -y --from user1 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE +lavad tx pairing stake-client "ARBN" 200000ulava 1 -y --from user1 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE +lavad tx pairing stake-client "APT1" 200000ulava 1 -y --from user1 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE +lavad tx pairing stake-client "STRK" 200000ulava 1 -y --from user1 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE +lavad tx pairing stake-client "JUN1" 200000ulava 1 -y --from user1 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE +lavad tx pairing stake-client "COS5" 200000ulava 1 -y --from user1 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE +lavad tx pairing stake-client "POLYGON1" 200000ulava 1 -y --from user1 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE # Ethereum providers