From 245353c8dc3332461c301df5ad27dfd7d6ddcaa6 Mon Sep 17 00:00:00 2001 From: Ran Mishael Date: Thu, 19 Jan 2023 19:56:10 +0100 Subject: [PATCH 1/2] PRT-318 adding print when max cu reached + adjusting tests --- go.mod | 2 -- go.sum | 4 ---- relayer/lavasession/consumer_session_manager.go | 1 + relayer/lavasession/consumer_session_manager_test.go | 12 ++++++++++++ 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 9c80288b3a..df7ffb086a 100644 --- a/go.mod +++ b/go.mod @@ -47,8 +47,6 @@ require ( github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect github.com/ghodss/yaml v1.0.0 // indirect github.com/gogo/googleapis v1.4.0 // indirect - github.com/golang/glog v1.0.0 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0 // indirect github.com/pelletier/go-toml/v2 v2.0.5 // indirect golang.org/x/mod v0.7.0 // indirect golang.org/x/tools v0.2.0 // indirect diff --git a/go.sum b/go.sum index faf7fd1f5b..3950e1518a 100644 --- a/go.sum +++ b/go.sum @@ -654,8 +654,6 @@ github.com/golang-jwt/jwt/v4 v4.3.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzw github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/geo v0.0.0-20190916061304-5b978397cfec/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ= -github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -780,8 +778,6 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0 h1:1JYBfzqrWPcCclBwxFCPAou9n+q86mfnu7NAeHfte7A= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0/go.mod h1:YDZoGHuwE+ov0c8smSH49WLF3F2LaWnYYuDVd+EWrc0= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= diff --git a/relayer/lavasession/consumer_session_manager.go b/relayer/lavasession/consumer_session_manager.go index 70f6df83f9..d96efc33af 100644 --- a/relayer/lavasession/consumer_session_manager.go +++ b/relayer/lavasession/consumer_session_manager.go @@ -138,6 +138,7 @@ func (csm *ConsumerSessionManager) GetSession(ctx context.Context, cuNeededForSe return nil, 0, "", nil, err } else if MaxComputeUnitsExceededError.Is(err) { // This provider doesn't have enough compute units for this session, we block it for this session and continue to another provider. + utils.LavaFormatError("Max Compute Units Exceeded For provider", err, &map[string]string{"providerAddress": providerAddress}) tempIgnoredProviders.providers[providerAddress] = struct{}{} continue } else { diff --git a/relayer/lavasession/consumer_session_manager_test.go b/relayer/lavasession/consumer_session_manager_test.go index 2fa13a9837..78365f1ffc 100644 --- a/relayer/lavasession/consumer_session_manager_test.go +++ b/relayer/lavasession/consumer_session_manager_test.go @@ -168,6 +168,18 @@ func TestPairingResetWithMultipleFailures(t *testing.T) { require.Equal(t, csm.numberOfResets, uint64(numberOfResets+1)) // verify we had one reset only } + cs, epoch, _, _, err := csm.GetSession(ctx, cuForFirstRequest, nil) // get a session + require.Nil(t, err) + require.NotNil(t, cs) + require.Equal(t, epoch, csm.currentEpoch) + require.Equal(t, cs.LatestRelayCu, uint64(cuForFirstRequest)) + err = csm.OnSessionDone(cs, firstEpochHeight, servicedBlockNumber, cuForFirstRequest, time.Duration(time.Millisecond), (servicedBlockNumber - 1), numberOfProviders, numberOfProviders) + require.Nil(t, err) + require.Equal(t, cs.CuSum, cuForFirstRequest) + require.Equal(t, cs.LatestRelayCu, latestRelayCuAfterDone) + require.Equal(t, cs.RelayNum, relayNumberAfterFirstCall) + require.Equal(t, cs.LatestBlock, servicedBlockNumber) + } // Test the basic functionality of the consumerSessionManager From 1ce616ea959e6226e6a1a9d113b23f28648a247e Mon Sep 17 00:00:00 2001 From: Ran Mishael Date: Thu, 19 Jan 2023 21:26:16 +0100 Subject: [PATCH 2/2] PRT-318 adding cu to error message --- relayer/lavasession/consumer_types.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/relayer/lavasession/consumer_types.go b/relayer/lavasession/consumer_types.go index 825ad83780..724bbbfad9 100644 --- a/relayer/lavasession/consumer_types.go +++ b/relayer/lavasession/consumer_types.go @@ -108,7 +108,7 @@ func (cswp *ConsumerSessionsWithProvider) validateComputeUnits(cu uint64) error cswp.Lock.Lock() defer cswp.Lock.Unlock() if (cswp.UsedComputeUnits + cu) > cswp.MaxComputeUnits { - return MaxComputeUnitsExceededError + return utils.LavaFormatError("validateComputeUnits", MaxComputeUnitsExceededError, &map[string]string{"cu": strconv.FormatUint((cswp.UsedComputeUnits + cu), 10), "maxCu": strconv.FormatUint(cswp.MaxComputeUnits, 10)}) } return nil }