Skip to content

Commit

Permalink
Release/0.4.11 (lavanet#211)
Browse files Browse the repository at this point in the history
* added upgrade plan

* PRT-228 fixing chain id flag

* PRT-226 fixing up to 1000 concurrent cosnumer session manager

Co-authored-by: Yarom Swisa <[email protected] git config --global user.name Yarom>
  • Loading branch information
ranlavanet and Yarom Swisa authored Dec 28, 2022
1 parent 86f1bd9 commit 677c142
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 13 deletions.
29 changes: 26 additions & 3 deletions cmd/lavad/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,13 @@ func main() {
//
// TODO: there has to be a better way to send txs
// (cosmosclient was a fail)

clientCtx.SkipConfirm = true
txFactory := tx.NewFactoryCLI(clientCtx, cmd.Flags()).WithChainID("lava")
networkChainId, err := cmd.Flags().GetString(flags.FlagChainID)
if err != nil {
return err
}
txFactory := tx.NewFactoryCLI(clientCtx, cmd.Flags()).WithChainID(networkChainId)

port, err := strconv.Atoi(args[1])
if err != nil {
Expand Down Expand Up @@ -116,7 +121,13 @@ func main() {
}
}

relayer.PortalServer(ctx, clientCtx, listenAddr, chainID, apiInterface, cmd.Flags())
networkChainId, err := cmd.Flags().GetString(flags.FlagChainID)
if err != nil {
return err
}
txFactory := tx.NewFactoryCLI(clientCtx, cmd.Flags()).WithChainID(networkChainId)

relayer.PortalServer(ctx, clientCtx, txFactory, listenAddr, chainID, apiInterface, cmd.Flags())

return nil
},
Expand Down Expand Up @@ -152,7 +163,14 @@ func main() {
utils.LavaFormatFatal("failed to read log level flag", err, nil)
}
utils.LoggingLevel(logLevel)
relayer.TestClient(ctx, clientCtx, chainID, apiInterface, duration, cmd.Flags())

networkChainId, err := cmd.Flags().GetString(flags.FlagChainID)
if err != nil {
return err
}
txFactory := tx.NewFactoryCLI(clientCtx, cmd.Flags()).WithChainID(networkChainId)

relayer.TestClient(ctx, txFactory, clientCtx, chainID, apiInterface, duration, cmd.Flags())

return nil
},
Expand All @@ -163,6 +181,11 @@ func main() {
flags.AddTxFlagsToCmd(cmdPortalServer)
cmdPortalServer.MarkFlagRequired(flags.FlagFrom)
flags.AddTxFlagsToCmd(cmdTestClient)

cmdPortalServer.Flags().String(flags.FlagChainID, app.Name, "network chain id")
cmdTestClient.Flags().String(flags.FlagChainID, app.Name, "network chain id")
cmdServer.Flags().String(flags.FlagChainID, app.Name, "network chain id")

cmdTestClient.MarkFlagRequired(flags.FlagFrom)
cmdTestClient.Flags().Bool("secure", false, "secure sends reliability on every message")
cmdPortalServer.Flags().Bool("secure", false, "secure sends reliability on every message")
Expand Down
2 changes: 1 addition & 1 deletion relayer/lavasession/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
const (
MaxConsecutiveConnectionAttempts = 3
TimeoutForEstablishingAConnection = 300 * time.Millisecond
MaxSessionsAllowedPerProvider = 10 // Max number of sessions allowed per provider
MaxSessionsAllowedPerProvider = 1000 // Max number of sessions allowed per provider
MaxAllowedBlockListedSessionPerProvider = 3
MaximumNumberOfFailuresAllowedPerConsumerSession = 3
RelayNumberIncrement = 1
Expand Down
4 changes: 3 additions & 1 deletion relayer/portal_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"time"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/cosmos/cosmos-sdk/version"
"github.com/lavanet/lava/relayer/chainproxy"
"github.com/lavanet/lava/relayer/performance"
Expand All @@ -20,6 +21,7 @@ import (
func PortalServer(
ctx context.Context,
clientCtx client.Context,
txFactory tx.Factory,
listenAddr string,
chainID string,
apiInterface string,
Expand All @@ -33,7 +35,7 @@ func PortalServer(
log.Fatalln("error: GetOrCreateVRFKey", err)
}
// Start sentry
sentry := sentry.NewSentry(clientCtx, chainID, true, nil, nil, apiInterface, sk, flagSet, 0)
sentry := sentry.NewSentry(clientCtx, txFactory, chainID, true, nil, nil, apiInterface, sk, flagSet, 0)
err = sentry.Init(ctx)
if err != nil {
log.Fatalln("error sentry.Init", err)
Expand Down
15 changes: 9 additions & 6 deletions relayer/sentry/sentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ type Sentry struct {
serverID uint64
authorizationCache map[uint64]map[string]*pairingtypes.QueryVerifyPairingResponse
authorizationCacheMutex sync.RWMutex
txFactory tx.Factory
//
// expected payments storage
PaymentsMu sync.RWMutex
Expand Down Expand Up @@ -775,8 +776,8 @@ func (s *Sentry) CompareRelaysAndReportConflict(reply0 *pairingtypes.RelayReply,
}
msg := conflicttypes.NewMsgDetection(s.Acc, nil, &responseConflict, nil)
s.ClientCtx.SkipConfirm = true
txFactory := tx.NewFactoryCLI(s.ClientCtx, s.cmdFlags).WithChainID("lava")
err := SimulateAndBroadCastTx(s.ClientCtx, txFactory, msg)
// txFactory := tx.NewFactoryCLI(s.ClientCtx, s.cmdFlags).WithChainID("lava")
err := SimulateAndBroadCastTx(s.ClientCtx, s.txFactory, msg)
if err != nil {
utils.LavaFormatError("CompareRelaysAndReportConflict - SimulateAndBroadCastTx Failed", err, nil)
}
Expand Down Expand Up @@ -825,8 +826,8 @@ func (s *Sentry) discrepancyChecker(finalizedBlocksA map[int64]string, consensus
// TODO:: Fill msg with incriminating data
msg := conflicttypes.NewMsgDetection(s.Acc, nil, nil, nil)
s.ClientCtx.SkipConfirm = true
txFactory := tx.NewFactoryCLI(s.ClientCtx, s.cmdFlags).WithChainID("lava")
err := SimulateAndBroadCastTx(s.ClientCtx, txFactory, msg)
// txFactory := tx.NewFactoryCLI(s.ClientCtx, s.cmdFlags).WithChainID("lava")
err := SimulateAndBroadCastTx(s.ClientCtx, s.txFactory, msg)
if err != nil {
return false, utils.LavaFormatError("discrepancyChecker - SimulateAndBroadCastTx Failed", err, nil)
}
Expand Down Expand Up @@ -881,8 +882,8 @@ func (s *Sentry) validateProviderReply(finalizedBlocks map[int64]string, latestB
// TODO:: Fill msg with incriminating data
msg := conflicttypes.NewMsgDetection(s.Acc, nil, nil, nil)
s.ClientCtx.SkipConfirm = true
txFactory := tx.NewFactoryCLI(s.ClientCtx, s.cmdFlags).WithChainID("lava")
err := SimulateAndBroadCastTx(s.ClientCtx, txFactory, msg)
// txFactory := tx.NewFactoryCLI(s.ClientCtx, s.cmdFlags).WithChainID("lava")
err := SimulateAndBroadCastTx(s.ClientCtx, s.txFactory, msg)
if err != nil {
return utils.LavaFormatError("validateProviderReply - SimulateAndBroadCastTx Failed", err, nil)
}
Expand Down Expand Up @@ -1438,6 +1439,7 @@ func (s *Sentry) ExpectedBlockHeight() (int64, int) {

func NewSentry(
clientCtx client.Context,
txFactory tx.Factory,
chainID string,
isUser bool,
voteInitiationCb func(ctx context.Context, voteID string, voteDeadline uint64, voteParams *VoteParams),
Expand All @@ -1464,6 +1466,7 @@ func NewSentry(
pairingQueryClient: pairingQueryClient,
epochStorageQueryClient: epochStorageQueryClient,
ChainID: chainID,
txFactory: txFactory,
isUser: isUser,
Acc: acc,
newEpochCb: newEpochCb,
Expand Down
2 changes: 1 addition & 1 deletion relayer/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,7 @@ func Server(
//

// Start newSentry
newSentry := sentry.NewSentry(clientCtx, chainID, false, voteEventHandler, askForRewards, apiInterface, nil, nil, g_serverID)
newSentry := sentry.NewSentry(clientCtx, txFactory, chainID, false, voteEventHandler, askForRewards, apiInterface, nil, nil, g_serverID)
err := newSentry.Init(ctx)
if err != nil {
utils.LavaFormatError("sentry init failure to initialize", err, &map[string]string{"apiInterface": apiInterface, "ChainID": chainID})
Expand Down
4 changes: 3 additions & 1 deletion relayer/test_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"time"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/lavanet/lava/relayer/chainproxy"
"github.com/lavanet/lava/relayer/sentry"
"github.com/lavanet/lava/relayer/sigs"
Expand All @@ -17,6 +18,7 @@ import (

func TestClient(
ctx context.Context,
txFactory tx.Factory,
clientCtx client.Context,
chainID string,
apiInterface string,
Expand All @@ -32,7 +34,7 @@ func TestClient(
log.Fatalln("error: GetOrCreateVRFKey", err)
}
// Start sentry
sentry := sentry.NewSentry(clientCtx, chainID, true, nil, nil, apiInterface, sk, flagSet, 0)
sentry := sentry.NewSentry(clientCtx, txFactory, chainID, true, nil, nil, apiInterface, sk, flagSet, 0)
err = sentry.Init(ctx)
if err != nil {
log.Fatalln("error sentry.Init", err)
Expand Down

0 comments on commit 677c142

Please sign in to comment.