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/proto/decentraland/kernel/comms/rfc4/comms.proto b/proto/decentraland/kernel/comms/rfc4/comms.proto index 83f098d3..87eac24e 100644 --- a/proto/decentraland/kernel/comms/rfc4/comms.proto +++ b/proto/decentraland/kernel/comms/rfc4/comms.proto @@ -59,6 +59,14 @@ 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; + uint64 synced_timestamp = 18; } message MovementCompressed { diff --git a/proto/decentraland/sdk/components/network_entity.proto b/proto/decentraland/sdk/components/network_entity.proto new file mode 100644 index 00000000..b7aae9d1 --- /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) = 1098; + +/** + * 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; +} diff --git a/proto/decentraland/sdk/components/synced_clock.proto b/proto/decentraland/sdk/components/synced_clock.proto new file mode 100644 index 00000000..db4cd003 --- /dev/null +++ b/proto/decentraland/sdk/components/synced_clock.proto @@ -0,0 +1,31 @@ +syntax = "proto3"; + +package decentraland.sdk.components; + +import "decentraland/sdk/components/common/id.proto"; +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 +message PBSyncedClock { + // The current synchronized time (in milliseconds since epoch) + uint64 synced_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..8fe151c0 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_synced_timestamp = 9; // timestamp (in milliseconds) when the tween started, allows synchronization across clients } message Move { 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