From 864dafc575a61e532bbbd80f44bfabef73aa2521 Mon Sep 17 00:00:00 2001 From: Gonzalo DCL Date: Mon, 12 May 2025 12:01:35 +0200 Subject: [PATCH 1/6] feat: implement timestamp synchronization components --- .../sdk/components/time_component.proto | 31 +++++++++++++++++++ proto/decentraland/sdk/components/tween.proto | 1 + 2 files changed, 32 insertions(+) create mode 100644 proto/decentraland/sdk/components/time_component.proto diff --git a/proto/decentraland/sdk/components/time_component.proto b/proto/decentraland/sdk/components/time_component.proto new file mode 100644 index 00000000..47bd331d --- /dev/null +++ b/proto/decentraland/sdk/components/time_component.proto @@ -0,0 +1,31 @@ +syntax = "proto3"; + +package decentraland.sdk.components; + +import "decentraland/sdk/components/common/id.proto"; +option (common.ecs_component_id) = 1077; + +// PBTimeComponent provides synchronized time information based on NTP server data +// This component can be used to maintain consistent time across all clients +message PBTimeComponent { + // The current synchronized time (in milliseconds since epoch) + uint64 timestamp = 1; + + // The synchronization status + SyncStatus status = 7; +} + +// Status of time synchronization +enum SyncStatus { + // The component is not yet synchronized with the NTP server + SS_UNINITIALIZED = 0; + + // The component is currently attempting to synchronize with the NTP server + SS_SYNCHRONIZING = 1; + + // The component is successfully synchronized with the NTP server + SS_SYNCHRONIZED = 2; + + // The component failed to synchronize with the NTP server + SS_ERROR = 3; +} diff --git a/proto/decentraland/sdk/components/tween.proto b/proto/decentraland/sdk/components/tween.proto index 2ed6d784..e4c0a8be 100644 --- a/proto/decentraland/sdk/components/tween.proto +++ b/proto/decentraland/sdk/components/tween.proto @@ -20,6 +20,7 @@ message PBTween { optional bool playing = 6; // default true (pause or running) optional float current_time = 7; // between 0 and 1 + optional uint64 start_timestamp = 9; // timestamp (in milliseconds) when the tween started, allows synchronization across clients } message Move { From 76f654520c720012f417b20083f028cb616152c6 Mon Sep 17 00:00:00 2001 From: Gonzalo DCL Date: Wed, 14 May 2025 11:16:08 +0200 Subject: [PATCH 2/6] update field names --- proto/decentraland/sdk/components/time_component.proto | 2 +- proto/decentraland/sdk/components/tween.proto | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/proto/decentraland/sdk/components/time_component.proto b/proto/decentraland/sdk/components/time_component.proto index 47bd331d..999b97f1 100644 --- a/proto/decentraland/sdk/components/time_component.proto +++ b/proto/decentraland/sdk/components/time_component.proto @@ -9,7 +9,7 @@ option (common.ecs_component_id) = 1077; // This component can be used to maintain consistent time across all clients message PBTimeComponent { // The current synchronized time (in milliseconds since epoch) - uint64 timestamp = 1; + uint64 synced_timestamp = 1; // The synchronization status SyncStatus status = 7; diff --git a/proto/decentraland/sdk/components/tween.proto b/proto/decentraland/sdk/components/tween.proto index e4c0a8be..8fe151c0 100644 --- a/proto/decentraland/sdk/components/tween.proto +++ b/proto/decentraland/sdk/components/tween.proto @@ -20,7 +20,7 @@ message PBTween { optional bool playing = 6; // default true (pause or running) optional float current_time = 7; // between 0 and 1 - optional uint64 start_timestamp = 9; // timestamp (in milliseconds) when the tween started, allows synchronization across clients + optional uint64 start_synced_timestamp = 9; // timestamp (in milliseconds) when the tween started, allows synchronization across clients } message Move { From d59c668b23c1a232e01a37cf01d3ffa10c242ab8 Mon Sep 17 00:00:00 2001 From: Gonzalo DCL Date: Thu, 15 May 2025 18:30:01 -0300 Subject: [PATCH 3/6] rename TimeComponent to SyncedClock --- proto/decentraland/sdk/components/time_component.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto/decentraland/sdk/components/time_component.proto b/proto/decentraland/sdk/components/time_component.proto index 999b97f1..7dce0fae 100644 --- a/proto/decentraland/sdk/components/time_component.proto +++ b/proto/decentraland/sdk/components/time_component.proto @@ -7,7 +7,7 @@ option (common.ecs_component_id) = 1077; // PBTimeComponent provides synchronized time information based on NTP server data // This component can be used to maintain consistent time across all clients -message PBTimeComponent { +message PBSyncedClock { // The current synchronized time (in milliseconds since epoch) uint64 synced_timestamp = 1; From 451eb6c9aea41e756dca06b460523603efcc7bb5 Mon Sep 17 00:00:00 2001 From: Gonzalo DCL Date: Thu, 15 May 2025 18:36:02 -0300 Subject: [PATCH 4/6] change path file --- .../sdk/components/{time_component.proto => synced_clock.proto} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename proto/decentraland/sdk/components/{time_component.proto => synced_clock.proto} (100%) diff --git a/proto/decentraland/sdk/components/time_component.proto b/proto/decentraland/sdk/components/synced_clock.proto similarity index 100% rename from proto/decentraland/sdk/components/time_component.proto rename to proto/decentraland/sdk/components/synced_clock.proto From fefd7f8f038cac8872482e9e40e5100448264c99 Mon Sep 17 00:00:00 2001 From: gon boedo Date: Tue, 20 May 2025 16:30:58 -0300 Subject: [PATCH 5/6] add network entity --- .../sdk/components/network_entity.proto | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 proto/decentraland/sdk/components/network_entity.proto diff --git a/proto/decentraland/sdk/components/network_entity.proto b/proto/decentraland/sdk/components/network_entity.proto new file mode 100644 index 00000000..da353fe0 --- /dev/null +++ b/proto/decentraland/sdk/components/network_entity.proto @@ -0,0 +1,21 @@ +syntax = "proto3"; + +package decentraland.sdk.components; + +import "decentraland/sdk/components/common/id.proto"; +option (common.ecs_component_id) = 1078; + +/** + * NetworkEntity marks an entity for network synchronization. + + * When receiving network messages, to find which local entity they refer to, + * we look for an entity that has both the same networkId and entityId as the message. + */ +message PBNetworkEntity { + // The enumId or local entity ID + uint32 entity_id = 1; + + // - 0 for fixed entities (created with enumId at initialization) + // - User's address hash for dynamic entities (created at runtime) + uint64 network_id = 2; +} From 4cb4b152882d64e384db05abaa7f0cd7583ffdb1 Mon Sep 17 00:00:00 2001 From: gon boedo Date: Wed, 21 May 2025 11:12:34 -0300 Subject: [PATCH 6/6] fix component id --- proto/decentraland/sdk/components/network_entity.proto | 2 +- proto/decentraland/sdk/components/synced_clock.proto | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/proto/decentraland/sdk/components/network_entity.proto b/proto/decentraland/sdk/components/network_entity.proto index da353fe0..b7aae9d1 100644 --- a/proto/decentraland/sdk/components/network_entity.proto +++ b/proto/decentraland/sdk/components/network_entity.proto @@ -3,7 +3,7 @@ syntax = "proto3"; package decentraland.sdk.components; import "decentraland/sdk/components/common/id.proto"; -option (common.ecs_component_id) = 1078; +option (common.ecs_component_id) = 1098; /** * NetworkEntity marks an entity for network synchronization. diff --git a/proto/decentraland/sdk/components/synced_clock.proto b/proto/decentraland/sdk/components/synced_clock.proto index 7dce0fae..db4cd003 100644 --- a/proto/decentraland/sdk/components/synced_clock.proto +++ b/proto/decentraland/sdk/components/synced_clock.proto @@ -3,7 +3,7 @@ syntax = "proto3"; package decentraland.sdk.components; import "decentraland/sdk/components/common/id.proto"; -option (common.ecs_component_id) = 1077; +option (common.ecs_component_id) = 1099; // PBTimeComponent provides synchronized time information based on NTP server data // This component can be used to maintain consistent time across all clients