Skip to content

Commit

Permalink
First iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
dalkia committed Dec 13, 2024
1 parent 0beaaa9 commit 7c4359e
Show file tree
Hide file tree
Showing 21 changed files with 68 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,7 @@ public enum DecentralandUrl
CameraReelUsers,
CameraReelImages,
CameraReelLink,
AssetBundleRegistry

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ private static string RawUrl(DecentralandUrl decentralandUrl) =>
DecentralandUrl.CameraReelUsers => $"https://camera-reel-service.decentraland.{ENV}/api/users",
DecentralandUrl.CameraReelImages => $"https://camera-reel-service.decentraland.{ENV}/api/images",
DecentralandUrl.CameraReelLink => $"https://reels.decentraland.{ENV}",
DecentralandUrl.AssetBundleRegistry => $"https://asset-bundle-registry.decentraland.{ENV}",
_ => throw new ArgumentOutOfRangeException(nameof(decentralandUrl), decentralandUrl, null!)
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using DCL.Browser.DecentralandUrls;
using DCL.Multiplayer.Connections.DecentralandUrls;
using UnityEngine;
using Utility;

Expand Down Expand Up @@ -72,6 +74,7 @@ private SelfProfile CreateProfile()
web3IdentityCache,
IWebRequestController.DEFAULT,
URLDomain.FromString("TestRealm"),
new DecentralandUrlsSource(DecentralandEnvironment.Org),
new ServerAbout(
lambdas: new ContentEndpoint(profileUrl)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"GUID:e169fa6683c924c7e99a85981a91d953",
"GUID:9ca29a7d75ab84bab806a20bbd350fd8",
"GUID:029c1c1b674aaae47a6841a0b89ad80e",
"GUID:e7751264a6735a942a64770d71eb49e0"
"GUID:e7751264a6735a942a64770d71eb49e0",
"GUID:91cf8206af184dac8e30eb46747e9939"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand Down
3 changes: 2 additions & 1 deletion Explorer/Assets/DCL/Ipfs/DCL.Ipfs.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"GUID:f51ebe6a0ceec4240a699833d6309b23",
"GUID:5ab29fa8ae5769b49ab29e390caca7a4",
"GUID:4a12c0b1b77ec6b418a8d7bd5c925be3",
"GUID:166b65e6dfc848bb9fb075f53c293a38"
"GUID:166b65e6dfc848bb9fb075f53c293a38",
"GUID:91cf8206af184dac8e30eb46747e9939"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand Down
1 change: 1 addition & 0 deletions Explorer/Assets/DCL/Ipfs/IIpfsRealm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public interface IIpfsRealm
public URLDomain LambdasBaseUrl { get; }
public IReadOnlyList<string> SceneUrns { get; }
public URLDomain EntitiesActiveEndpoint { get; }
public URLDomain AssetBundleRegistry { get; }

UniTask PublishAsync<T>(EntityDefinitionGeneric<T> entity, CancellationToken ct, IReadOnlyDictionary<string, byte[]>? contentFiles = null);

Expand Down
1 change: 1 addition & 0 deletions Explorer/Assets/DCL/Ipfs/InvalidIpfsRealm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public static InvalidIpfsRealm Instance
public URLDomain LambdasBaseUrl => URLDomain.EMPTY;
public IReadOnlyList<string> SceneUrns { get; } = new List<string>();
public URLDomain EntitiesActiveEndpoint => URLDomain.EMPTY;
public URLDomain AssetBundleRegistry => URLDomain.EMPTY;

public UniTask PublishAsync<T>(EntityDefinitionGeneric<T> entity, CancellationToken ct, IReadOnlyDictionary<string, byte[]>? contentFiles = null) =>
throw new NotSupportedException();
Expand Down
11 changes: 10 additions & 1 deletion Explorer/Assets/DCL/Ipfs/IpfsRealm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Collections.Generic;
using System.Text;
using System.Threading;
using DCL.Multiplayer.Connections.DecentralandUrls;
using UnityEngine;

namespace DCL.Ipfs
Expand All @@ -25,12 +26,15 @@ public class IpfsRealm : IIpfsRealm, IEquatable<IpfsRealm>
public URLDomain ContentBaseUrl { get; }
public URLDomain LambdasBaseUrl { get; }
public URLDomain EntitiesActiveEndpoint { get; }
public URLDomain AssetBundleRegistry { get; }

public IReadOnlyList<string> SceneUrns => sceneUrns;

public IpfsRealm(IWeb3IdentityCache web3IdentityCache,
IWebRequestController webRequestController,
URLDomain realmName, ServerAbout? serverAbout = null)
URLDomain realmName,
IDecentralandUrlsSource urlsSources,
ServerAbout? serverAbout = null)
{
this.web3IdentityCache = web3IdentityCache;
this.webRequestController = webRequestController;
Expand All @@ -48,6 +52,11 @@ public IpfsRealm(IWeb3IdentityCache web3IdentityCache,
//Note: Content url requires the subdirectory content, but the actives endpoint requires the base one.
EntitiesActiveEndpoint = URLBuilder.Combine(ContentBaseUrl, URLSubdirectory.FromString("entities/active"));
ContentBaseUrl = URLBuilder.Combine(ContentBaseUrl, URLSubdirectory.FromString("contents/"));

AssetBundleRegistry =
URLBuilder.Combine(URLDomain.FromString(urlsSources.Url(DecentralandUrl.AssetBundleRegistry)),
URLSubdirectory.FromString("entities/active"));
;
}
else
{
Expand Down
2 changes: 2 additions & 0 deletions Explorer/Assets/DCL/Ipfs/LocalIpfsRealm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ public class LocalIpfsRealm : IIpfsRealm
public URLDomain LambdasBaseUrl { get; }
public IReadOnlyList<string> SceneUrns => Array.Empty<string>();
public URLDomain EntitiesActiveEndpoint => URLDomain.EMPTY;
public URLDomain AssetBundleRegistry { get; }

public LocalIpfsRealm(URLDomain fullPath)
{
CatalystBaseUrl = fullPath;
ContentBaseUrl = fullPath;
AssetBundleRegistry = fullPath;
LambdasBaseUrl = URLDomain.FromString("https://peer.decentraland.org/explorer/");
}

Expand Down
12 changes: 12 additions & 0 deletions Explorer/Assets/DCL/Ipfs/LogIpfsRealm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ public URLDomain EntitiesActiveEndpoint
}
}

public URLDomain AssetBundleRegistry
{
get
{
var result = origin.AssetBundleRegistry;
ReportHub
.WithReport(ReportCategory.REALM)
.Log($"IpfsRealm AssetBundleRegistry requested, result: {result}");
return result;
}
}

public async UniTask PublishAsync<T>(EntityDefinitionGeneric<T> entity, CancellationToken ct, IReadOnlyDictionary<string, byte[]>? contentFiles = null)
{
var sb = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public RetrieveSceneFromVolatileWorld(IRealmData realmData)
pointersList.Value.Add(parcel.ToInt2());

var promise = AssetPromise<SceneDefinitions, GetSceneDefinitionList>.Create(World,
new GetSceneDefinitionList(targetCollection.Value, pointersList.Value, new CommonLoadingArguments(realmIpfs.EntitiesActiveEndpoint)),
new GetSceneDefinitionList(targetCollection.Value, pointersList.Value,
new CommonLoadingArguments(realmIpfs.AssetBundleRegistry)),
PartitionComponent.TOP_PRIORITY);

promise = await promise.ToUniTaskAsync(World, cancellationToken: ct);
Expand Down
3 changes: 2 additions & 1 deletion Explorer/Assets/DCL/Profiles/DCL.Profiles.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"GUID:166b65e6dfc848bb9fb075f53c293a38",
"GUID:3c7b57a14671040bd8c549056adc04f5",
"GUID:ca4e81cdd6a34d1aa54c32ad41fc5b3b",
"GUID:543b8f091a5947a3880b7f2bca2358bd"
"GUID:543b8f091a5947a3880b7f2bca2358bd",
"GUID:91cf8206af184dac8e30eb46747e9939"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
using ECS;
using System.Collections.Generic;
using System.Threading;
using DCL.Browser.DecentralandUrls;
using DCL.Multiplayer.Connections.DecentralandUrls;
using UnityEngine;

namespace DCL.Profiles.Self.Playground
Expand Down Expand Up @@ -39,6 +41,7 @@ private async UniTaskVoid ExecuteAsync(CancellationToken ct)
web3IdentityCache,
IWebRequestController.DEFAULT,
URLDomain.FromString(url),
new DecentralandUrlsSource(DecentralandEnvironment.Org),
new ServerAbout(
lambdas: new ContentEndpoint(url)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private void StartLoadingFromVolatilePointers(ref RealmComponent realm, ref Vola
volatileScenePointers.ActivePromise
= AssetPromise<SceneDefinitions, GetSceneDefinitionList>.Create(World,
new GetSceneDefinitionList(volatileScenePointers.RetrievedReusableList, input,
new CommonLoadingArguments(realm.Ipfs.EntitiesActiveEndpoint)),
new CommonLoadingArguments(realm.Ipfs.AssetBundleRegistry)),
volatileScenePointers.ActivePartitionComponent);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private void ResolvePromise(ref RealmComponent realm, ref StaticScenePointers st
// start loading
staticScenePointers.Promise = AssetPromise<SceneDefinitions, GetSceneDefinitionList>.Create(World,
new GetSceneDefinitionList(new List<SceneEntityDefinition>(staticScenePointers.Value.Count), staticScenePointers.Value,
new CommonLoadingArguments(realm.Ipfs.EntitiesActiveEndpoint)), PartitionComponent.TOP_PRIORITY);
new CommonLoadingArguments(realm.Ipfs.AssetBundleRegistry)), PartitionComponent.TOP_PRIORITY);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class TestIpfsRealm : IIpfsRealm
public URLDomain LambdasBaseUrl { get; }
public IReadOnlyList<string> SceneUrns { get; }
public URLDomain EntitiesActiveEndpoint { get; }
public URLDomain AssetBundleRegistry { get; }

public URLDomain CatalystBaseUrl { get; }
public URLDomain ContentBaseUrl { get; }
Expand All @@ -24,6 +25,7 @@ public TestIpfsRealm(string[] sceneUrns = null)
CatalystBaseUrl = URLDomain.FromString($"file://{Application.dataPath + "/../TestResources/"}");
ContentBaseUrl = CatalystBaseUrl.Append(URLSubdirectory.FromString("Content/"));
EntitiesActiveEndpoint = URLDomain.FromString($"{ContentBaseUrl.Value}ActiveEntitiesByPointer.json");
AssetBundleRegistry = URLDomain.FromString($"{ContentBaseUrl.Value}ActiveEntitiesByPointer.json");
LambdasBaseUrl = URLDomain.EMPTY;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,8 @@ IMultiPool MultiPoolFactory() =>
debugBuilder,
staticContainer.ComponentsContainer.ComponentPoolsRegistry
.GetReferenceTypePool<PartitionComponent>(),
localSceneDevelopment);
localSceneDevelopment,
bootstrapContainer.DecentralandUrlsSource);

container.reloadSceneController = new ECSReloadScene(staticContainer.ScenesCache, globalWorld, playerEntity, localSceneDevelopment);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using ECS.LifeCycle.Components;
using SceneRunner.Scene;
using System.Linq;
using DCL.Multiplayer.Connections.DecentralandUrls;

namespace PortableExperiences.Controller
{
Expand All @@ -28,6 +29,7 @@ public class ECSPortableExperiencesController : IPortableExperiencesController
private readonly World globalWorld;
private readonly List<IPortableExperiencesController.SpawnResponse> spawnResponsesList = new ();
private readonly FeatureFlagsCache featureFlagsCache;
private readonly IDecentralandUrlsSource urlsSources;
public Dictionary<ENS, Entity> PortableExperienceEntities { get; } = new ();


Expand All @@ -36,13 +38,15 @@ public ECSPortableExperiencesController(
IWeb3IdentityCache web3IdentityCache,
IWebRequestController webRequestController,
IScenesCache scenesCache,
FeatureFlagsCache featureFlagsCache)
FeatureFlagsCache featureFlagsCache,
IDecentralandUrlsSource urlsSources)
{
this.globalWorld = globalWorld;
this.web3IdentityCache = web3IdentityCache;
this.webRequestController = webRequestController;
this.scenesCache = scenesCache;
this.featureFlagsCache = featureFlagsCache;
this.urlsSources = urlsSources;
}

public async UniTask<IPortableExperiencesController.SpawnResponse> CreatePortableExperienceByEnsAsync(ENS ens, CancellationToken ct, bool isGlobalPortableExperience = false, bool force = false)
Expand Down Expand Up @@ -84,7 +88,7 @@ public ECSPortableExperiencesController(

var realmData = new RealmData();
realmData.Reconfigure(
new IpfsRealm(web3IdentityCache, webRequestController, portableExperiencePath, result),
new IpfsRealm(web3IdentityCache, webRequestController, portableExperiencePath, urlsSources, result),
result.configurations.realmName.EnsureNotNull("Realm name not found"),
result.configurations.networkId,
result.comms?.adapter ?? string.Empty,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"GUID:101b8b6ebaf64668909b49c4b7a1420d",
"GUID:1b8e1e1bd01505f478f0369c04a4fb2f",
"GUID:ace653ac543d483ba8abee112a3ba2a6",
"GUID:3640f3c0b42946b0b8794a1ed8e06ca5"
"GUID:3640f3c0b42946b0b8794a1ed8e06ca5",
"GUID:91cf8206af184dac8e30eb46747e9939"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand Down
12 changes: 8 additions & 4 deletions Explorer/Assets/Scripts/Global/Dynamic/RealmController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
using System;
using System.Collections.Generic;
using System.Threading;
using DCL.Browser.DecentralandUrls;
using DCL.DebugUtilities;
using DCL.Multiplayer.Connections.DecentralandUrls;
using ECS.SceneLifeCycle.Realm;
using Unity.Mathematics;

Expand All @@ -49,6 +51,7 @@ public class RealmController : IGlobalRealmController
private readonly SceneAssetLock sceneAssetLock;
private readonly IComponentPool<PartitionComponent> partitionComponentPool;
private readonly bool isLocalSceneDevelopment;
private readonly IDecentralandUrlsSource urlsSource;

private GlobalWorld? globalWorld;
private Entity realmEntity;
Expand Down Expand Up @@ -95,8 +98,8 @@ public RealmController(
SceneAssetLock sceneAssetLock,
IDebugContainerBuilder debugContainerBuilder,
IComponentPool<PartitionComponent> partitionComponentPool,
bool isLocalSceneDevelopment
)
bool isLocalSceneDevelopment,
IDecentralandUrlsSource urlsSource)
{
this.web3IdentityCache = web3IdentityCache;
this.webRequestController = webRequestController;
Expand All @@ -110,6 +113,7 @@ bool isLocalSceneDevelopment
this.sceneAssetLock = sceneAssetLock;
this.partitionComponentPool = partitionComponentPool;
this.isLocalSceneDevelopment = isLocalSceneDevelopment;
this.urlsSource = urlsSource;
realmNavigatorDebugView = new RealmNavigatorDebugView(debugContainerBuilder);
}

Expand All @@ -130,7 +134,7 @@ public async UniTask SetRealmAsync(URLDomain realm, CancellationToken ct)
string hostname = ResolveHostname(realm, result);

realmData.Reconfigure(
new IpfsRealm(web3IdentityCache, webRequestController, realm, result),
new IpfsRealm(web3IdentityCache, webRequestController, realm, urlsSource, result),
result.configurations.realmName.EnsureNotNull("Realm name not found"),
result.configurations.networkId,
result.comms?.adapter ?? result.comms?.fixedAdapter ?? "offline:offline", //"offline property like in previous implementation"
Expand Down Expand Up @@ -185,7 +189,7 @@ await UniTask.WaitUntil(() => GlobalWorld.EcsWorld.TryGet(realmEntity, out fixed

var promise = AssetPromise<SceneDefinitions, GetSceneDefinitionList>.Create(GlobalWorld.EcsWorld,
new GetSceneDefinitionList(new List<SceneEntityDefinition>(staticLoadPositions.Count), staticLoadPositions,
new CommonLoadingArguments(RealmData.Ipfs.EntitiesActiveEndpoint)), PartitionComponent.TOP_PRIORITY);
new CommonLoadingArguments(RealmData.Ipfs.AssetBundleRegistry)), PartitionComponent.TOP_PRIORITY);

promise = await promise.ToUniTaskAsync(GlobalWorld.EcsWorld, cancellationToken: ct);

Expand Down
4 changes: 3 additions & 1 deletion Explorer/Assets/Scripts/Global/StaticContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ await UniTask.WhenAll(

container.PhysicsTickProvider = new PhysicsTickProvider();
container.FeatureFlagsCache = new FeatureFlagsCache();
container.PortableExperiencesController = new ECSPortableExperiencesController(globalWorld, web3IdentityProvider, container.WebRequestsContainer.WebRequestController, container.ScenesCache, container.FeatureFlagsCache);
container.PortableExperiencesController = new ECSPortableExperiencesController(globalWorld,
web3IdentityProvider, container.WebRequestsContainer.WebRequestController, container.ScenesCache,
container.FeatureFlagsCache, decentralandUrlsSource);

container.FeatureFlagsProvider = new HttpFeatureFlagsProvider(container.WebRequestsContainer.WebRequestController,
container.FeatureFlagsCache);
Expand Down

0 comments on commit 7c4359e

Please sign in to comment.