Skip to content

Commit

Permalink
Merge branch 'main' of github.com:lavanet/lava into eth_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kajeagentspi committed Aug 14, 2022
2 parents f970921 + 439d3e7 commit 76dd1a8
Show file tree
Hide file tree
Showing 12 changed files with 422 additions and 222 deletions.
5 changes: 5 additions & 0 deletions cmd/lavad/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"strconv"
"strings"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
Expand All @@ -13,6 +14,7 @@ import (
"github.com/ignite-hq/cli/ignite/pkg/cosmoscmd"
"github.com/lavanet/lava/app"
"github.com/lavanet/lava/relayer"
"github.com/lavanet/lava/utils"
"github.com/spf13/cobra"
)

Expand All @@ -33,6 +35,7 @@ func main() {
Long: `server`,
Args: cobra.ExactArgs(5),
RunE: func(cmd *cobra.Command, args []string) error {
utils.LavaFormatInfo("Provider process started", nil, &map[string]string{"args": strings.Join(args, ",")})
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
Expand Down Expand Up @@ -67,6 +70,7 @@ func main() {
Long: `portal server`,
Args: cobra.ExactArgs(4),
RunE: func(cmd *cobra.Command, args []string) error {
utils.LavaFormatInfo("Gateway Proxy process started", nil, &map[string]string{"args": strings.Join(args, ",")})
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
Expand Down Expand Up @@ -94,6 +98,7 @@ func main() {
Long: `test client`,
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
utils.LavaFormatInfo("Test consumer process started", nil, &map[string]string{"args": strings.Join(args, ",")})
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
Expand Down
6 changes: 6 additions & 0 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51832,6 +51832,9 @@ definitions:
sig:
type: string
format: byte
epoch:
type: string
format: uint64
QoSReport:
type: object
properties:
Expand Down Expand Up @@ -51866,6 +51869,9 @@ definitions:
sig:
type: string
format: byte
epoch:
type: string
format: uint64
lavanet.lava.epochstorage.Endpoint:
type: object
properties:
Expand Down
9 changes: 5 additions & 4 deletions relayer/chainproxy/chainproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ func SendRelay(
return nil, nil, err
}

blockHeight = cp.GetSentry().GetBlockHeight()
blockHeight = int64(clientSession.Client.GetPairingEpoch()) // epochs heights only

relayRequest := &pairingtypes.RelayRequest{
Provider: clientSession.Client.Acc,
ConnectionType: connectionType,
Expand Down Expand Up @@ -158,13 +159,13 @@ func SendRelay(
}

expectedBH, numOfProviders := cp.GetSentry().ExpecedBlockHeight()
clientSession.CalculateQoS(nodeMsg.GetServiceApi().ComputeUnits, currentLatency, expectedBH-reply.LatestBlock, numOfProviders, cp.GetSentry().GetServicersToPairCount())
clientSession.CalculateQoS(nodeMsg.GetServiceApi().ComputeUnits, currentLatency, expectedBH-reply.LatestBlock, numOfProviders, int64(cp.GetSentry().GetProvidersCount()))

return reply, relayRequest, nil
}
callback_send_reliability := func(clientSession *sentry.ClientSession, dataReliability *pairingtypes.VRFData) (*pairingtypes.RelayReply, *pairingtypes.RelayRequest, 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")
}
Expand All @@ -174,7 +175,7 @@ func SendRelay(
ApiUrl: url,
Data: []byte(req),
SessionId: uint64(0), //sessionID for reliability is 0
ChainID: cp.GetSentry().ChainID,
ChainID: sentry.ChainID,
CuSum: clientSession.CuSum,
BlockHeight: blockHeight,
RelayNum: clientSession.RelayNum,
Expand Down
4 changes: 2 additions & 2 deletions relayer/chainsentry/chainsentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (cs *ChainSentry) SetLatestBlockNum(value int64) {
atomic.StoreInt64(&cs.latestBlockNum, value)
}

func (cs *ChainSentry) GetLatestBlockData() (int64, map[int64]interface{}, error) {
func (cs *ChainSentry) GetLatestBlockData() (int64, map[int64]interface{}) {
cs.blockQueueMu.Lock()
defer cs.blockQueueMu.Unlock()

Expand All @@ -50,7 +50,7 @@ func (cs *ChainSentry) GetLatestBlockData() (int64, map[int64]interface{}, error
blockNum := latestBlockNum - int64(cs.finalizedBlockDistance) - int64(cs.numFinalBlocks) + int64(i+1)
hashes[blockNum] = cs.blocksQueue[i]
}
return latestBlockNum, hashes, nil
return latestBlockNum, hashes
}

func (cs *ChainSentry) fetchLatestBlockNum(ctx context.Context) (int64, error) {
Expand Down
3 changes: 1 addition & 2 deletions relayer/portal_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package relayer

import (
context "context"
"fmt"
"log"
"time"

Expand Down Expand Up @@ -49,7 +48,7 @@ func PortalServer(

//
// Set up a connection to the server.
log.Println(fmt.Sprintf("PortalServer %s", apiInterface))
log.Printf("PortalServer %s\n", apiInterface)
keyName, err := sigs.GetKeyName(clientCtx)
if err != nil {
log.Fatalln("error: getKeyName", err)
Expand Down
Loading

0 comments on commit 76dd1a8

Please sign in to comment.