Skip to content

Commit

Permalink
PROTO-1328: always default to discovery relay (#8247)
Browse files Browse the repository at this point in the history
  • Loading branch information
alecsavvy committed Apr 30, 2024
1 parent f42c6cd commit 4503cc7
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 38 deletions.
5 changes: 5 additions & 0 deletions .changeset/nervous-rules-shop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@audius/sdk": patch
---

Using discovery relay for ACDC is not the default behavior.
18 changes: 2 additions & 16 deletions packages/common/src/services/audius-backend/AudiusBackend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -677,15 +677,6 @@ export const audiusBackend = ({
monitoringCallbacks.contentNode
)

const useDiscoveryRelay = await getFeatureEnabled(
FeatureFlags.DISCOVERY_RELAY
)

console.info(
{ useDiscoveryRelay },
`discovery relay${useDiscoveryRelay ? ' ' : ' not '}enabled`
)

try {
const newAudiusLibs = new AudiusLibs({
localStorage,
Expand Down Expand Up @@ -734,17 +725,12 @@ export const audiusBackend = ({
preferHigherPatchForSecondaries: await getFeatureEnabled(
FeatureFlags.PREFER_HIGHER_PATCH_FOR_SECONDARIES
),
hedgehogConfig,
useDiscoveryRelay
hedgehogConfig
})
await newAudiusLibs.init()
audiusLibs = newAudiusLibs
onLibsInit(audiusLibs)

if (useDiscoveryRelay) {
// libs not respecting the flag, mod web3 manager manually
audiusLibs.web3Manager.discoveryProvider = audiusLibs.discoveryProvider
}
audiusLibs.web3Manager.discoveryProvider = audiusLibs.discoveryProvider

sanityChecks(audiusLibs)
} catch (err) {
Expand Down
2 changes: 0 additions & 2 deletions packages/common/src/services/remote-config/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export enum FeatureFlags {
USDC_PURCHASES_UPLOAD = 'usdc_purchases_upload',
AUDIO_MATCHING_CHALLENGES = 'audio_matching_challenges',
NEW_PLAYLIST_ROUTES = 'new_playlist_routes',
DISCOVERY_RELAY = 'discovery_relay',
FEATURE_FLAG_ACCESS = 'feature_flag_access',
BUY_USDC_VIA_SOL = 'buy_usdc_via_sol',
IOS_USDC_PURCHASE_ENABLED = 'ios_usdc_purchase_enabled',
Expand Down Expand Up @@ -126,7 +125,6 @@ export const flagDefaults: FlagDefaults = {
[FeatureFlags.USDC_PURCHASES_UPLOAD]: false,
[FeatureFlags.AUDIO_MATCHING_CHALLENGES]: false,
[FeatureFlags.NEW_PLAYLIST_ROUTES]: false,
[FeatureFlags.DISCOVERY_RELAY]: false,
[FeatureFlags.FEATURE_FLAG_ACCESS]: false,
[FeatureFlags.BUY_USDC_VIA_SOL]: false,
[FeatureFlags.IOS_USDC_PURCHASE_ENABLED]: true,
Expand Down
14 changes: 3 additions & 11 deletions packages/libs/src/AudiusLibs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ export class AudiusLibs {
preferHigherPatchForPrimary = true,
preferHigherPatchForSecondaries = true,
localStorage,
useDiscoveryRelay = false
useDiscoveryRelay = true
}: AudiusLibsConfig) {
// set version

Expand Down Expand Up @@ -545,16 +545,8 @@ export class AudiusLibs {
})
await this.discoveryProvider.init()

// set discovery provider in web3 for relay
if (this.web3Config && this.useDiscoveryRelay) {
const web3Manager = this.web3Manager
if (web3Manager === undefined || web3Manager === null) {
console.info(
'useDiscoveryRelay is set to true but web3Manager is not configured'
)
} else {
this.web3Manager?.setDiscoveryProvider(this.discoveryProvider)
}
if (this.web3Manager != null) {
this.web3Manager.discoveryProvider = this.discoveryProvider
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const discoveryNodeSelector = new DiscoveryNodeSelector({

const mswHandlers = [
rest.post(
`${developmentConfig.identityServiceUrl}/relay`,
`${discoveryNode}/relay`,
(_req, res, ctx) => {
return res(
ctx.status(200),
Expand Down Expand Up @@ -192,14 +192,14 @@ describe('EntityManager', () => {
const discoveryRelayUrl = await discoveryEntityManager.getRelayEndpoint()
const identityRelayUrlUndefined =
await relayEntityManagerUndefined.getRelayEndpoint()
const identityRelayUrlFalse =
const identityRelayUrlFalse =
await relayEntityManagerFalse.getRelayEndpoint()

expect(discoveryRelayUrl).toEqual(discoveryNode)
expect(identityRelayUrlUndefined).toEqual(
developmentConfig.identityServiceUrl
discoveryRelayUrl
)
expect(identityRelayUrlUndefined).toEqual(identityRelayUrlFalse)
expect(discoveryRelayUrl).toEqual(identityRelayUrlFalse)
})
})
})
4 changes: 0 additions & 4 deletions packages/libs/src/sdk/services/EntityManager/EntityManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,6 @@ export class EntityManager implements EntityManagerService {
}

public async getRelayEndpoint(): Promise<string> {
const useDiscoveryRelay = this.config.useDiscoveryRelay
if (useDiscoveryRelay === undefined || !useDiscoveryRelay) {
return this.config.identityServiceUrl
}
const discoveryEndpoint =
await this.discoveryNodeSelector.getSelectedEndpoint()
if (discoveryEndpoint === null) {
Expand Down
2 changes: 1 addition & 1 deletion packages/libs/src/sdk/services/EntityManager/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const defaultEntityManagerConfig: EntityManagerConfigInternal = {
contractAddress: productionConfig.entityManagerContractAddress,
web3ProviderUrl: productionConfig.web3ProviderUrl,
identityServiceUrl: productionConfig.identityServiceUrl,
useDiscoveryRelay: false,
useDiscoveryRelay: true,
logger: new Logger()
}

Expand Down

0 comments on commit 4503cc7

Please sign in to comment.