Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
chore: add feature flags to matrix connection retries (#301)
Browse files Browse the repository at this point in the history
* chore: some hotfixes

* fix

* disable friends UI together with FF

* coso

* fix linter

* simplify feature flags
  • Loading branch information
menduz authored May 13, 2022
1 parent 7c28adc commit 025a967
Show file tree
Hide file tree
Showing 14 changed files with 178 additions and 237 deletions.
111 changes: 35 additions & 76 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"@dcl/catalyst-peer": "^1.0.4",
"@dcl/ecs-math": "^1.0.1",
"@dcl/ecs-quests": "^1.3.1",
"@dcl/feature-flags": "^1.0.1",
"@dcl/hashing": "^1.1.0",
"@dcl/kernel-interface": "^2.0.0-20210922153939.commit-017905d",
"@dcl/legacy-ecs": "^6.10.1-2191620277.commit-7b74643",
Expand Down
4 changes: 0 additions & 4 deletions packages/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,12 @@ export function getServerConfigurations(network: ETHEREUM_NETWORK) {
const tld = network === ETHEREUM_NETWORK.MAINNET ? 'org' : 'zone'

const metaConfigBaseUrl = META_CONFIG_URL || `https://config.decentraland.${tld}/explorer.json`
const metaFeatureFlagsBaseUrl = PREVIEW
? `${rootURLPreviewMode()}/feature-flags/explorer.json`
: `https://feature-flags.decentraland.${tld}/explorer.json`

const questsUrl =
ensureSingleString(qs.get('QUESTS_SERVER_URL')) ?? `https://quests-api.decentraland.${network ? 'org' : 'io'}`

return {
explorerConfiguration: `${metaConfigBaseUrl}?t=${new Date().getTime()}`,
explorerFeatureFlags: `${metaFeatureFlagsBaseUrl}?t=${new Date().getTime()}`,
questsUrl
}
}
Expand Down
18 changes: 8 additions & 10 deletions packages/entryPoints/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import { foregroundChangeObservable, isForeground } from 'shared/world/worldStat
import { getCurrentIdentity } from 'shared/session/selectors'
import { realmInitialized } from 'shared/dao'
import { ensureMetaConfigurationInitialized } from 'shared/meta'
import { FeatureFlags, WorldConfig } from 'shared/meta/types'
import { getFeatureFlags, getWorldConfig, isFeatureEnabled } from 'shared/meta/selectors'
import { WorldConfig } from 'shared/meta/types'
import { getFeatureFlagEnabled, getFeatureFlags, getWorldConfig } from 'shared/meta/selectors'
import { kernelConfigForRenderer } from '../unity-interface/kernelConfigForRenderer'
import { ensureUnityInterface } from 'shared/renderer'
import { globalObservable } from 'shared/observables'
Expand Down Expand Up @@ -162,13 +162,13 @@ async function loadWebsiteSystems(options: KernelOptions['kernelOptions']) {
// For example disable AssetBundles needs a system from FeatureFlag
i.SetFeatureFlagsConfiguration(getFeatureFlags(store.getState()))

const questEnabled = isFeatureEnabled(store.getState(), FeatureFlags.QUESTS, false)
const questEnabled = getFeatureFlagEnabled(store.getState(), 'quests')
const worldConfig: WorldConfig | undefined = getWorldConfig(store.getState())
const renderProfile = worldConfig ? worldConfig.renderProfile ?? RenderProfile.DEFAULT : RenderProfile.DEFAULT
i.SetRenderProfile(renderProfile)

// killswitch, disable asset bundles
if (!isFeatureEnabled(store.getState(), FeatureFlags.ASSET_BUNDLES, false)) {
if (!getFeatureFlagEnabled(store.getState(), 'asset_bundles')) {
i.SetDisableAssetBundles()
}

Expand Down Expand Up @@ -196,10 +196,7 @@ async function loadWebsiteSystems(options: KernelOptions['kernelOptions']) {
i.ConfigureHUDElement(
HUDElementID.TASKBAR,
{ active: true, visible: true },
{
enableVoiceChat: true,
enableQuestPanel: isFeatureEnabled(store.getState(), FeatureFlags.QUESTS, false)
}
{ enableVoiceChat: true, enableQuestPanel: questEnabled }
)
i.ConfigureHUDElement(HUDElementID.WORLD_CHAT_WINDOW, { active: true, visible: false })
i.ConfigureHUDElement(HUDElementID.CONTROLS_HUD, { active: true, visible: false })
Expand Down Expand Up @@ -233,10 +230,11 @@ async function loadWebsiteSystems(options: KernelOptions['kernelOptions']) {
i.ConfigureTutorial(profile.tutorialStep, tutorialConfig)

const isGuest = !identity.hasConnectedWeb3
const BUILDER_IN_WORLD_ENABLED = !isGuest && isFeatureEnabled(store.getState(), FeatureFlags.BUILDER_IN_WORLD, false)
const friendsActivated = !isGuest && !getFeatureFlagEnabled(store.getState(), 'matrix_disabled')
const BUILDER_IN_WORLD_ENABLED = !isGuest && getFeatureFlagEnabled(store.getState(), 'builder_in_world')

i.ConfigureHUDElement(HUDElementID.BUILDER_PROJECTS_PANEL, { active: BUILDER_IN_WORLD_ENABLED, visible: false })
i.ConfigureHUDElement(HUDElementID.FRIENDS, { active: !isGuest, visible: false })
i.ConfigureHUDElement(HUDElementID.FRIENDS, { active: friendsActivated, visible: false })

await realmInitialized()

Expand Down
5 changes: 2 additions & 3 deletions packages/shared/apis/EnvironmentAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import { getServerConfigurations, PREVIEW, RENDERER_WS } from 'config'
import { store } from 'shared/store/isolatedStore'
import { getCommsIsland, getRealm } from 'shared/comms/selectors'
import { Realm } from 'shared/dao/types'
import { isFeatureEnabled } from 'shared/meta/selectors'
import { FeatureFlags } from 'shared/meta/types'
import { getFeatureFlagEnabled } from 'shared/meta/selectors'
import { EnvironmentRealm, ExplorerConfiguration, IEnvironmentAPI, Platform } from './IEnvironmentAPI'

type DecentralandTimeData = {
Expand Down Expand Up @@ -56,7 +55,7 @@ export class EnvironmentAPI extends ExposableAPI implements IEnvironmentAPI {
*/
@exposeMethod
async areUnsafeRequestAllowed(): Promise<boolean> {
return isFeatureEnabled(store.getState(), FeatureFlags.UNSAFE_FETCH_AND_WEBSOCKET, false)
return getFeatureFlagEnabled(store.getState(), 'unsafe-request')
}

/**
Expand Down
1 change: 1 addition & 0 deletions packages/shared/comms/v1/brokerWorldInstanceConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ export class BrokerWorldInstanceConnection implements RoomConnection {

async disconnect() {
if (this.pingInterval) {
this.events.emit('DISCONNECTION')
clearInterval(this.pingInterval)
}
await this.broker.disconnect()
Expand Down
20 changes: 15 additions & 5 deletions packages/shared/dao/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ function* waitForCandidates() {
}
}

function realmFromPinnedCatalyst(): Realm {
return {
protocol: 'v2',
hostname: PIN_CATALYST || 'peer.decentraland.org',
serverName: 'pinned-catalyst'
}
}

function* selectRealm() {
const network: ETHEREUM_NETWORK = yield call(waitForNetworkSelected)

Expand All @@ -147,13 +155,15 @@ function* selectRealm() {
}

const realm: Realm | undefined =
// 1st priority: query param (dao candidates & cached)
// query param (dao candidates & cached)
(yield call(getConfiguredRealm, [...allCandidates, ...cachedCandidates])) ||
// 2nd priority: preview mode
// CATALYST from url parameter
(PIN_CATALYST ? realmFromPinnedCatalyst() : null) ||
// preview mode
(PREVIEW ? PREVIEW_REALM : null) ||
// 3rd priority: cached in local storage
// cached in local storage
(yield call(getRealmFromLocalStorage, network)) ||
// 4th priority: fetch catalysts and select one using the load balancing
// fetch catalysts and select one using the load balancing
(yield call(pickCatalystRealm))

if (!realm) debugger
Expand Down Expand Up @@ -195,7 +205,7 @@ function* initializeCatalystCandidates() {
const catalystsNodesEndpointURL: string | undefined = yield select(getCatalystNodesEndpoint)

const nodes: CatalystNode[] = yield call(fetchCatalystRealms, catalystsNodesEndpointURL)
const added: string[] = PIN_CATALYST ? [] : yield select(getAddedServers)
const added: string[] = yield select(getAddedServers)

const candidates: Candidate[] = yield call(fetchCatalystStatuses, added.map((url) => ({ domain: url })).concat(nodes))

Expand Down
Loading

0 comments on commit 025a967

Please sign in to comment.