Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: PRT Fixing provider client for jsonrpc failing on #1432

Merged
merged 6 commits into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion protocol/chainlib/base_chain_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ func (apip *BaseChainParser) getApiCollection(connectionType, internalPath, addo

// Return an error if spec does not exist
if !ok {
return nil, utils.LavaFormatError("api not supported", nil, utils.Attribute{Key: "connectionType", Value: connectionType})
return nil, utils.LavaFormatWarning("api not supported", common.APINotSupportedError, utils.Attribute{Key: "connectionType", Value: connectionType})
}

// Return an error if api is disabled
Expand Down
2 changes: 1 addition & 1 deletion protocol/chainlib/chainproxy/rpcclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ func (c *Client) CallContext(ctx context.Context, id json.RawMessage, method str
var msg *JsonrpcMessage
var err error
switch p := params.(type) {
case []interface{}:
case []interface{}, string:
msg, err = c.newMessageArrayWithID(method, id, p)
case map[string]interface{}:
msg, err = c.newMessageMapWithID(method, id, p)
Expand Down
15 changes: 10 additions & 5 deletions protocol/lavasession/consumer_session_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,13 @@ func (csm *ConsumerSessionManager) resetValidAddresses(addon string, extensions
csm.lock.Lock() // lock write
defer csm.lock.Unlock()
if len(csm.getValidAddresses(addon, extensions)) == 0 { // re verify it didn't change while waiting for lock.
utils.LavaFormatWarning("Provider pairing list is empty, resetting state.", nil, utils.Attribute{Key: "addon", Value: addon}, utils.Attribute{Key: "extensions", Value: extensions})
csm.setValidAddressesToDefaultValue(addon, extensions)
// only if length is larger than 0 after reset we actually reset. otherwise we don't have any providers for addon or extension
if len(csm.getValidAddresses(addon, extensions)) != 0 {
utils.LavaFormatWarning("Provider pairing list is empty, resetting state.", nil, utils.Attribute{Key: "addon", Value: addon}, utils.Attribute{Key: "extensions", Value: extensions})
} else {
utils.LavaFormatWarning("No providers for asked addon or extension, list is empty after trying to reset", nil, utils.Attribute{Key: "addon", Value: addon}, utils.Attribute{Key: "extensions", Value: extensions})
}
csm.numberOfResets += 1
}
// if len(csm.validAddresses) != 0 meaning we had a reset (or an epoch change), so we need to return the numberOfResets which is currently in csm
Expand Down Expand Up @@ -363,11 +368,11 @@ func (csm *ConsumerSessionManager) getSessionWithProviderOrError(usedProviders U
if errGetRegularProvider != nil {
return nil, err // return original error (getValidConsumerSessionsWithProvider)
}
for _, session := range sessionWithProviderMap {
session.RemoveExtensions = true
for key := range sessionWithProviderMap {
sessionWithProviderMap[key].RemoveExtensions = true
}
// print a warning in case we got a provider who does not support that addon or extension.
utils.LavaFormatWarning("No Providers For Addon Or Extension, using regular provider for relay", errOnRetry, utils.LogAttr("addon", addon), utils.LogAttr("extensions", extensionNames))
utils.LavaFormatWarning("No Providers For Addon Or Extension, using regular provider for relay", errOnRetry, utils.LogAttr("addon", addon), utils.LogAttr("extensions", extensionNames), utils.LogAttr("providers_chosen", sessionWithProviderMap))
} else {
return nil, err // return original error (getValidConsumerSessionsWithProvider)
}
Expand Down Expand Up @@ -421,7 +426,7 @@ func (csm *ConsumerSessionManager) GetSessions(ctx context.Context, cuNeededForS
// we can get here if we wanted 3 archive and got 2 only because one couldn't connect,
// so we tried getting more sessions and got a regular provider due to no pairings available.
// in that case just return the current sessions that we do have.
if sessionWithProvider.RemoveExtensions && len(sessions) > 1 {
if sessionWithProvider.RemoveExtensions && len(sessions) >= 1 {
utils.LavaFormatDebug("Too many sessions when using RemoveAddonAndExtensions session", utils.LogAttr("sessions", sessions), utils.LogAttr("wanted_to_add", sessionWithProvider))
// in that case we just return the sessions we already have.
return sessions, nil
Expand Down
Loading