Skip to content

Commit

Permalink
PRT-318 adding print when max cu reached + adjusting tests (#245)
Browse files Browse the repository at this point in the history
* PRT-318 adding print when max cu reached + adjusting tests

* PRT-318 adding cu to error message
  • Loading branch information
ranlavanet authored Jan 22, 2023
1 parent 8ff862b commit e0ec4f1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down
1 change: 1 addition & 0 deletions relayer/lavasession/consumer_session_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 12 additions & 0 deletions relayer/lavasession/consumer_session_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion relayer/lavasession/consumer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit e0ec4f1

Please sign in to comment.