From 516aa1ed8bad44c114d6c15947921c88fa5c443c Mon Sep 17 00:00:00 2001 From: Gonzalo DCL Date: Mon, 12 May 2025 12:01:35 +0200 Subject: [PATCH 1/9] 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 f8c89e37e76b5772e23a28ab7644af85dd37cbba Mon Sep 17 00:00:00 2001 From: Gonzalo DCL Date: Wed, 14 May 2025 11:16:08 +0200 Subject: [PATCH 2/9] 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 98846edb04c622effd101d1d96025ff9309ef1e1 Mon Sep 17 00:00:00 2001 From: Gonzalo DCL Date: Thu, 15 May 2025 18:30:01 -0300 Subject: [PATCH 3/9] 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 1f1363245771b3b4ae679a12c0e18b5edb07819d Mon Sep 17 00:00:00 2001 From: Gonzalo DCL Date: Thu, 15 May 2025 18:36:02 -0300 Subject: [PATCH 4/9] 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 42c035fc7dbb7ae2cd1211b798b3f37986a56fb0 Mon Sep 17 00:00:00 2001 From: gon boedo Date: Tue, 20 May 2025 16:30:58 -0300 Subject: [PATCH 5/9] 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 c8a97f30739701e96254cfa5b7207b136ff6de26 Mon Sep 17 00:00:00 2001 From: gon boedo Date: Tue, 20 May 2025 16:40:15 -0300 Subject: [PATCH 6/9] fix experimental validate check --- .github/workflows/validate.yml | 15 ++++++++++++--- Makefile | 2 +- scripts/check-proto-compabitility.sh | 21 ++++++++++++--------- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 264fbd47..bcd73ab0 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -1,7 +1,9 @@ on: - push: - branches-ignore: + pull_request: + types: [opened, synchronize, reopened] + branches: - "main" + - "experimental" name: validate-compatibility jobs: @@ -13,10 +15,17 @@ jobs: - name: install run: make install - name: buf breaking - run: make buf-breaking + env: + BASE_BRANCH: ${{ github.event.pull_request.base.ref }} + run: | + echo "base_ref=${{ github.event.pull_request.base.ref }}" + echo "BASE_BRANCH=$BASE_BRANCH" + make buf-breaking - name: buf lint run: make buf-lint - name: build and compile test run: make test - name: run the check script + env: + BASE_BRANCH: ${{ github.event.pull_request.base.ref }} run: ./scripts/check-proto-compabitility.sh diff --git a/Makefile b/Makefile index cba0f90c..59cd45af 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ buf-build: node_modules/.bin/buf ./node_modules/.bin/buf build proto/ buf-breaking: node_modules/.bin/buf - ./node_modules/.bin/buf breaking proto/ --against 'https://github.com/decentraland/protocol.git#subdir=proto' + ./node_modules/.bin/buf breaking proto/ --against 'https://github.com/decentraland/protocol.git#branch=$(or $(BASE_BRANCH),main),subdir=proto' test: buf-lint bash scripts/test.sh diff --git a/scripts/check-proto-compabitility.sh b/scripts/check-proto-compabitility.sh index c7f7120a..a067f937 100755 --- a/scripts/check-proto-compabitility.sh +++ b/scripts/check-proto-compabitility.sh @@ -1,21 +1,24 @@ #!/bin/bash set -e -x -# Download the main branch ref zip -protocol_main_zip_url="https://github.com/decentraland/protocol/archive/refs/heads/main.zip" -protocol_main_zip_local="./protocol-main.zip" +# Use BASE_BRANCH environment variable or default to main +BRANCH="${BASE_BRANCH:-main}" + +# Download the reference branch zip +protocol_branch_zip_url="https://github.com/decentraland/protocol/archive/refs/heads/${BRANCH}.zip" +protocol_branch_zip_local="./protocol-${BRANCH}.zip" TMP_ZIP_DIR=$(mktemp -d) -curl -L "$protocol_main_zip_url" -o "$protocol_main_zip_local" -unzip "$protocol_main_zip_local" -d "$TMP_ZIP_DIR" -rm "$protocol_main_zip_local" || true +curl -L "$protocol_branch_zip_url" -o "$protocol_branch_zip_local" +unzip "$protocol_branch_zip_local" -d "$TMP_ZIP_DIR" +rm "$protocol_branch_zip_local" || true -ln -s "$(pwd)/node_modules" "$TMP_ZIP_DIR/protocol-main/node_modules" +ln -s "$(pwd)/node_modules" "$TMP_ZIP_DIR/protocol-${BRANCH}/node_modules" # Run the `proto-compatibility-tool` and exclude the downloaded folder. -echo "Checking the compatibility against $base_url" -./node_modules/.bin/proto-compatibility-tool --recursive "$TMP_ZIP_DIR/protocol-main/proto" "proto" +echo "Checking the compatibility against branch: ${BRANCH}" +./node_modules/.bin/proto-compatibility-tool --recursive "$TMP_ZIP_DIR/protocol-${BRANCH}/proto" "proto" # ../proto-compatibility-tool/dist/bin.js --recursive "$TMP_ZIP_DIR/protocol-main" "." # rm -rf "$TMP_ZIP_DIR" || true \ No newline at end of file From b5c0b7c4a28d6575970a3e9c7ac7b0e5da3909f0 Mon Sep 17 00:00:00 2001 From: gon boedo Date: Wed, 21 May 2025 11:12:34 -0300 Subject: [PATCH 7/9] 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 From bb19d9061c6e2303dd3a2fc27209604fb9a8f2f6 Mon Sep 17 00:00:00 2001 From: gon boedo Date: Thu, 22 May 2025 15:12:31 -0300 Subject: [PATCH 8/9] add netowrk entity to movement message --- proto/decentraland/kernel/comms/rfc4/comms.proto | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/proto/decentraland/kernel/comms/rfc4/comms.proto b/proto/decentraland/kernel/comms/rfc4/comms.proto index 83f098d3..06e079d0 100644 --- a/proto/decentraland/kernel/comms/rfc4/comms.proto +++ b/proto/decentraland/kernel/comms/rfc4/comms.proto @@ -59,6 +59,13 @@ message Movement { bool is_stunned = 15; float rotation_y = 16; + + message NetworkEntity { + uint32 entity_id = 1; + uint64 network_id = 2; + } + + optional NetworkEntity network_entity = 17; } message MovementCompressed { From aaf6aaf06a2e9397cebceda14d2697ed47256695 Mon Sep 17 00:00:00 2001 From: gon boedo Date: Fri, 23 May 2025 14:23:46 -0300 Subject: [PATCH 9/9] add synced timestamp --- proto/decentraland/kernel/comms/rfc4/comms.proto | 1 + 1 file changed, 1 insertion(+) diff --git a/proto/decentraland/kernel/comms/rfc4/comms.proto b/proto/decentraland/kernel/comms/rfc4/comms.proto index 06e079d0..87eac24e 100644 --- a/proto/decentraland/kernel/comms/rfc4/comms.proto +++ b/proto/decentraland/kernel/comms/rfc4/comms.proto @@ -66,6 +66,7 @@ message Movement { } optional NetworkEntity network_entity = 17; + uint64 synced_timestamp = 18; } message MovementCompressed {