From 328b87fc1815942b435f82541891767106e8a59c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 10 Mar 2023 11:49:34 +0000 Subject: [PATCH 1/5] Bump phpstan/phpstan from 1.10.4 to 1.10.6 (#5617) Bumps [phpstan/phpstan](https://github.com/phpstan/phpstan) from 1.10.4 to 1.10.6. - [Release notes](https://github.com/phpstan/phpstan/releases) - [Changelog](https://github.com/phpstan/phpstan/blob/1.10.x/CHANGELOG.md) - [Commits](https://github.com/phpstan/phpstan/compare/1.10.4...1.10.6) --- updated-dependencies: - dependency-name: phpstan/phpstan dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- composer.json | 2 +- composer.lock | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 64e62ed28..199355ede 100644 --- a/composer.json +++ b/composer.json @@ -56,7 +56,7 @@ "webmozart/path-util": "^2.3" }, "require-dev": { - "phpstan/phpstan": "1.10.4", + "phpstan/phpstan": "1.10.6", "phpstan/phpstan-phpunit": "^1.1.0", "phpstan/phpstan-strict-rules": "^1.2.0", "phpunit/phpunit": "^9.2" diff --git a/composer.lock b/composer.lock index 227bb4025..7a3a2b36c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2230c1697e4d7d490f5957b3a80d80a7", + "content-hash": "825f81aefc92c23eb815207e78fe3fda", "packages": [ { "name": "adhocore/json-comment", @@ -1884,16 +1884,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.10.4", + "version": "1.10.6", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "8d39218664b45a4a42d5be66d2b63dcf8c149982" + "reference": "50d089a3e0904b0fe7e2cf2d4fd37d427d64235a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/8d39218664b45a4a42d5be66d2b63dcf8c149982", - "reference": "8d39218664b45a4a42d5be66d2b63dcf8c149982", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/50d089a3e0904b0fe7e2cf2d4fd37d427d64235a", + "reference": "50d089a3e0904b0fe7e2cf2d4fd37d427d64235a", "shasum": "" }, "require": { @@ -1923,7 +1923,7 @@ ], "support": { "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/1.10.4" + "source": "https://github.com/phpstan/phpstan/tree/1.10.6" }, "funding": [ { @@ -1939,7 +1939,7 @@ "type": "tidelift" } ], - "time": "2023-03-06T13:39:20+00:00" + "time": "2023-03-09T16:55:12+00:00" }, { "name": "phpstan/phpstan-phpunit", From b13e97de3d3fb5ff8dd155cf61f5238426ecb15e Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 11 Mar 2023 19:12:48 +0000 Subject: [PATCH 2/5] Timings: fixed receivePacket timer showing 2x the actual number of received packets --- src/network/mcpe/NetworkSession.php | 53 ++++++++++++++++------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/src/network/mcpe/NetworkSession.php b/src/network/mcpe/NetworkSession.php index 04512e349..2e3b5b8da 100644 --- a/src/network/mcpe/NetworkSession.php +++ b/src/network/mcpe/NetworkSession.php @@ -431,32 +431,39 @@ class NetworkSession{ throw new PacketHandlingException("Unexpected non-serverbound packet"); } - $timings = Timings::getDecodeDataPacketTimings($packet); + $timings = Timings::getReceiveDataPacketTimings($packet); $timings->startTiming(); - try{ - $stream = PacketSerializer::decoder($buffer, 0, $this->packetSerializerContext); - try{ - $packet->decode($stream); - }catch(PacketDecodeException $e){ - throw PacketHandlingException::wrap($e); - } - if(!$stream->feof()){ - $remains = substr($stream->getBuffer(), $stream->getOffset()); - $this->logger->debug("Still " . strlen($remains) . " bytes unread in " . $packet->getName() . ": " . bin2hex($remains)); - } - }finally{ - $timings->stopTiming(); - } - $timings = Timings::getHandleDataPacketTimings($packet); - $timings->startTiming(); try{ - //TODO: I'm not sure DataPacketReceiveEvent should be included in the handler timings, but it needs to be - //included for now to ensure the receivePacket timings are counted the way they were before - $ev = new DataPacketReceiveEvent($this, $packet); - $ev->call(); - if(!$ev->isCancelled() && ($this->handler === null || !$packet->handle($this->handler))){ - $this->logger->debug("Unhandled " . $packet->getName() . ": " . base64_encode($stream->getBuffer())); + $decodeTimings = Timings::getDecodeDataPacketTimings($packet); + $decodeTimings->startTiming(); + try{ + $stream = PacketSerializer::decoder($buffer, 0, $this->packetSerializerContext); + try{ + $packet->decode($stream); + }catch(PacketDecodeException $e){ + throw PacketHandlingException::wrap($e); + } + if(!$stream->feof()){ + $remains = substr($stream->getBuffer(), $stream->getOffset()); + $this->logger->debug("Still " . strlen($remains) . " bytes unread in " . $packet->getName() . ": " . bin2hex($remains)); + } + }finally{ + $decodeTimings->stopTiming(); + } + + $handlerTimings = Timings::getHandleDataPacketTimings($packet); + $handlerTimings->startTiming(); + try{ + //TODO: I'm not sure DataPacketReceiveEvent should be included in the handler timings, but it needs to be + //included for now to ensure the receivePacket timings are counted the way they were before + $ev = new DataPacketReceiveEvent($this, $packet); + $ev->call(); + if(!$ev->isCancelled() && ($this->handler === null || !$packet->handle($this->handler))){ + $this->logger->debug("Unhandled " . $packet->getName() . ": " . base64_encode($stream->getBuffer())); + } + }finally{ + $handlerTimings->stopTiming(); } }finally{ $timings->stopTiming(); From 8e280ebb8bef3aeedda457398ad262fb6c5a118a Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 11 Mar 2023 22:16:24 +0000 Subject: [PATCH 3/5] RuntimeBlockMapping: avoid unnecessary PacketSerializer usage --- .../mcpe/convert/RuntimeBlockMapping.php | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/network/mcpe/convert/RuntimeBlockMapping.php b/src/network/mcpe/convert/RuntimeBlockMapping.php index b7c78a20b..dd396af9b 100644 --- a/src/network/mcpe/convert/RuntimeBlockMapping.php +++ b/src/network/mcpe/convert/RuntimeBlockMapping.php @@ -29,8 +29,7 @@ use pocketmine\data\bedrock\BedrockDataFiles; use pocketmine\data\bedrock\LegacyBlockIdToStringIdMap; use pocketmine\nbt\tag\CompoundTag; use pocketmine\network\mcpe\protocol\serializer\NetworkNbtSerializer; -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\serializer\PacketSerializerContext; +use pocketmine\utils\BinaryStream; use pocketmine\utils\Filesystem; use pocketmine\utils\SingletonTrait; @@ -55,14 +54,14 @@ final class RuntimeBlockMapping{ } public function __construct(string $canonicalBlockStatesFile, string $r12ToCurrentBlockMapFile){ - $stream = PacketSerializer::decoder( - Filesystem::fileGetContents($canonicalBlockStatesFile), - 0, - new PacketSerializerContext(GlobalItemTypeDictionary::getInstance()->getDictionary()) - ); + $stream = new BinaryStream(Filesystem::fileGetContents($canonicalBlockStatesFile)); $list = []; + $nbtReader = new NetworkNbtSerializer(); while(!$stream->feof()){ - $list[] = $stream->getNbtCompoundRoot(); + $offset = $stream->getOffset(); + $blockState = $nbtReader->read($stream->getBuffer(), $offset)->mustGetCompoundTag(); + $stream->setOffset($offset); + $list[] = $blockState; } $this->bedrockKnownStates = $list; @@ -73,14 +72,10 @@ final class RuntimeBlockMapping{ $legacyIdMap = LegacyBlockIdToStringIdMap::getInstance(); /** @var R12ToCurrentBlockMapEntry[] $legacyStateMap */ $legacyStateMap = []; - $legacyStateMapReader = PacketSerializer::decoder( - Filesystem::fileGetContents($r12ToCurrentBlockMapFile), - 0, - new PacketSerializerContext(GlobalItemTypeDictionary::getInstance()->getDictionary()) - ); + $legacyStateMapReader = new BinaryStream(Filesystem::fileGetContents($r12ToCurrentBlockMapFile)); $nbtReader = new NetworkNbtSerializer(); while(!$legacyStateMapReader->feof()){ - $id = $legacyStateMapReader->getString(); + $id = $legacyStateMapReader->get($legacyStateMapReader->getUnsignedVarInt()); $meta = $legacyStateMapReader->getLShort(); $offset = $legacyStateMapReader->getOffset(); From e2071e59c8b48a77094210c08d8101d344f7a58f Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 13 Mar 2023 17:44:10 +0000 Subject: [PATCH 4/5] actions: update PHP versions --- .github/workflows/main.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2a4f17741..c347b8436 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: image: [ubuntu-20.04] - php: [8.0.27, 8.1.14, 8.2.1] + php: [8.0.28, 8.1.16, 8.2.3] steps: - name: Build and prepare PHP cache @@ -32,7 +32,7 @@ jobs: fail-fast: false matrix: image: [ubuntu-20.04] - php: [8.0.27, 8.1.14, 8.2.1] + php: [8.0.28, 8.1.16, 8.2.3] steps: - uses: actions/checkout@v3 @@ -71,7 +71,7 @@ jobs: fail-fast: false matrix: image: [ubuntu-20.04] - php: [8.0.27, 8.1.14, 8.2.1] + php: [8.0.28, 8.1.16, 8.2.3] steps: - uses: actions/checkout@v3 @@ -110,7 +110,7 @@ jobs: fail-fast: false matrix: image: [ubuntu-20.04] - php: [8.0.27, 8.1.14, 8.2.1] + php: [8.0.28, 8.1.16, 8.2.3] steps: - uses: actions/checkout@v3 @@ -151,7 +151,7 @@ jobs: fail-fast: false matrix: image: [ubuntu-20.04] - php: [8.0.27, 8.1.14, 8.2.1] + php: [8.0.28, 8.1.16, 8.2.3] steps: - uses: actions/checkout@v3 From d376399b7f332384532a82eaf69b9b02dad5bd0c Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 14 Mar 2023 17:29:25 +0000 Subject: [PATCH 5/5] Update composer dependencies bedrock-item-upgrade-schema and bedrock-block-upgrade-schema are now minor-version-locked, to prevent introducing new upgrade schemas not intended for the currently in-use version previously I'd intended to do this using max schema IDs, but this has proven to be error-prone, so it makes more sense to lock them in using package version constraints instead. --- composer.json | 4 ++-- composer.lock | 42 +++++++++++++++++++++--------------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/composer.json b/composer.json index 199355ede..47c2e448f 100644 --- a/composer.json +++ b/composer.json @@ -34,9 +34,9 @@ "adhocore/json-comment": "^1.1", "fgrosse/phpasn1": "^2.3", "netresearch/jsonmapper": "^4.0", - "pocketmine/bedrock-block-upgrade-schema": "^1.0.0", + "pocketmine/bedrock-block-upgrade-schema": "~1.0.0", "pocketmine/bedrock-data": "~2.0.0+bedrock-1.19.60", - "pocketmine/bedrock-item-upgrade-schema": "^1.0.0", + "pocketmine/bedrock-item-upgrade-schema": "~1.0.0", "pocketmine/bedrock-protocol": "~19.3.0+bedrock-1.19.62", "pocketmine/binaryutils": "^0.2.1", "pocketmine/callback-validator": "^1.0.2", diff --git a/composer.lock b/composer.lock index 7a3a2b36c..ba9e927a6 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "825f81aefc92c23eb815207e78fe3fda", + "content-hash": "1911f5d75ca37c8390925a70f5e08210", "packages": [ { "name": "adhocore/json-comment", @@ -250,16 +250,16 @@ }, { "name": "pocketmine/bedrock-block-upgrade-schema", - "version": "1.1.0", + "version": "1.0.0", "source": { "type": "git", "url": "https://github.com/pmmp/BedrockBlockUpgradeSchema.git", - "reference": "78c965a2316986ac0eaf3235d75efb187127e7a2" + "reference": "a05ce434eb7f8c11058d26833bc975fe635b23b4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pmmp/BedrockBlockUpgradeSchema/zipball/78c965a2316986ac0eaf3235d75efb187127e7a2", - "reference": "78c965a2316986ac0eaf3235d75efb187127e7a2", + "url": "https://api.github.com/repos/pmmp/BedrockBlockUpgradeSchema/zipball/a05ce434eb7f8c11058d26833bc975fe635b23b4", + "reference": "a05ce434eb7f8c11058d26833bc975fe635b23b4", "shasum": "" }, "type": "library", @@ -270,9 +270,9 @@ "description": "Schemas describing how to upgrade saved block data in older Minecraft: Bedrock Edition world saves", "support": { "issues": "https://github.com/pmmp/BedrockBlockUpgradeSchema/issues", - "source": "https://github.com/pmmp/BedrockBlockUpgradeSchema/tree/1.1.0" + "source": "https://github.com/pmmp/BedrockBlockUpgradeSchema/tree/1.0.0" }, - "time": "2023-03-06T17:53:36+00:00" + "time": "2023-02-01T21:09:54+00:00" }, { "name": "pocketmine/bedrock-data", @@ -1658,16 +1658,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.11.0", + "version": "1.11.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614" + "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/14daed4296fae74d9e3201d2c4925d1acb7aa614", - "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", + "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", "shasum": "" }, "require": { @@ -1705,7 +1705,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.11.0" + "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1" }, "funding": [ { @@ -1713,7 +1713,7 @@ "type": "tidelift" } ], - "time": "2022-03-03T13:19:32+00:00" + "time": "2023-03-08T13:26:56+00:00" }, { "name": "nikic/php-parser", @@ -2362,16 +2362,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.4", + "version": "9.6.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "9125ee085b6d95e78277dc07aa1f46f9e0607b8d" + "reference": "86e761949019ae83f49240b2f2123fb5ab3b2fc5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9125ee085b6d95e78277dc07aa1f46f9e0607b8d", - "reference": "9125ee085b6d95e78277dc07aa1f46f9e0607b8d", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/86e761949019ae83f49240b2f2123fb5ab3b2fc5", + "reference": "86e761949019ae83f49240b2f2123fb5ab3b2fc5", "shasum": "" }, "require": { @@ -2404,8 +2404,8 @@ "sebastian/version": "^3.0.2" }, "suggest": { - "ext-soap": "*", - "ext-xdebug": "*" + "ext-soap": "To be able to generate mocks based on WSDL files", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" }, "bin": [ "phpunit" @@ -2444,7 +2444,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.4" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.5" }, "funding": [ { @@ -2460,7 +2460,7 @@ "type": "tidelift" } ], - "time": "2023-02-27T13:06:37+00:00" + "time": "2023-03-09T06:34:10+00:00" }, { "name": "sebastian/cli-parser",