From 9016df2089d2dbda65a9f275add0ae8e32834dcb Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Mon, 29 Apr 2024 14:32:20 +0900 Subject: [PATCH 1/3] Bumped block protocol version to 7 --- Libplanet.Tests/Action/ActionEvaluatorTest.cs | 10 ++++----- Libplanet.Tests/Blocks/BlockMetadataTest.cs | 4 ++-- .../Blocks/PreEvaluationBlockHeaderTest.cs | 21 +++++++++---------- Libplanet.Types/Blocks/BlockMetadata.cs | 2 +- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/Libplanet.Tests/Action/ActionEvaluatorTest.cs b/Libplanet.Tests/Action/ActionEvaluatorTest.cs index 9140c0f2d73..cde2791bcdf 100644 --- a/Libplanet.Tests/Action/ActionEvaluatorTest.cs +++ b/Libplanet.Tests/Action/ActionEvaluatorTest.cs @@ -374,9 +374,9 @@ DumbAction MakeAction(Address address, char identifier, Address? transferTo = nu // have to be updated, since the order may change due to different PreEvaluationHash. (int TxIdx, int ActionIdx, string[] UpdatedStates, Address Signer)[] expectations = { - (1, 0, new[] { null, null, "C", null, null }, _txFx.Address2), // Adds "C" - (0, 0, new[] { "A", null, "C", null, null }, _txFx.Address1), // Adds "A" - (0, 1, new[] { "A", "B", "C", null, null }, _txFx.Address1), // Adds "B" + (0, 0, new[] { "A", null, null, null, null }, _txFx.Address1), // Adds "A" + (0, 1, new[] { "A", "B", null, null, null }, _txFx.Address1), // Adds "B" + (1, 0, new[] { "A", "B", "C", null, null }, _txFx.Address2), // Adds "C" }; Assert.Equal(expectations.Length, evals.Length); foreach (var (expect, eval) in expectations.Zip(evals, (x, y) => (x, y))) @@ -495,8 +495,8 @@ DumbAction MakeAction(Address address, char identifier, Address? transferTo = nu // have to be updated, since the order may change due to different PreEvaluationHash. expectations = new (int TxIdx, int ActionIdx, string[] UpdatedStates, Address Signer)[] { - (0, 0, new[] { "A,D", "B", "C", null, null }, _txFx.Address1), // Adds "D" - (1, 0, new[] { "A,D", "B", "C", "E", null }, _txFx.Address2), // Adds "E" + (1, 0, new[] { "A", "B", "C", "E", null }, _txFx.Address2), // Adds "E" + (0, 0, new[] { "A,D", "B", "C", "E", null }, _txFx.Address1), // Adds "D" (2, 0, new[] { "A,D", "B", "C", "E", "F" }, _txFx.Address3), // Adds "F" }; Assert.Equal(expectations.Length, evals.Length); diff --git a/Libplanet.Tests/Blocks/BlockMetadataTest.cs b/Libplanet.Tests/Blocks/BlockMetadataTest.cs index cf8d01cacb1..7dab2727771 100644 --- a/Libplanet.Tests/Blocks/BlockMetadataTest.cs +++ b/Libplanet.Tests/Blocks/BlockMetadataTest.cs @@ -239,13 +239,13 @@ public void DerivePreEvaluationHash() HashDigest hash = GenesisMetadata.DerivePreEvaluationHash(default); AssertBytesEqual( - FromHex("c1fca9caf552248ba596ff0a8c30e3ead91e0de298c802b98d0cde318931ddd1"), + FromHex("db037e64000f3f672288e62a7f9a646cc9f636256a91d40559ebbffb53340948"), hash.ByteArray); hash = Block1Metadata.DerivePreEvaluationHash( new Nonce(FromHex("e7c1adf92c65d35aaae5"))); AssertBytesEqual( - FromHex("676e767c34b77795c807ef0b90a3e5d15d3412cb921d62e8e705133dc63c1305"), + FromHex("e1fb185006f05b18d8c264622c2e86d231fc7fbb6a777ae86629c41b37dac0d2"), hash.ByteArray); } diff --git a/Libplanet.Tests/Blocks/PreEvaluationBlockHeaderTest.cs b/Libplanet.Tests/Blocks/PreEvaluationBlockHeaderTest.cs index d70af1d80e2..9cd6250690b 100644 --- a/Libplanet.Tests/Blocks/PreEvaluationBlockHeaderTest.cs +++ b/Libplanet.Tests/Blocks/PreEvaluationBlockHeaderTest.cs @@ -169,9 +169,8 @@ public void VerifySignature() // Same as block1.MakeSignature(_contents.Block1Key, arbitraryHash) ImmutableArray validSig = ByteUtil.ParseHexToImmutable( - "304402204ca56d612a01f8215efd4c24519563e3370da2f14d89831aece4e07e8d782a" + - "97022025f38a29b9b97d037b77765647507aad9f703c06d231c4da0e52e1074cfb39c9"); - + "3045022100eefa1d45c56cbc0600f438a8254750fc623c6254fda3dcc31defc0cf6fe6a" + + "4d00220760e4b1d36c96ba7571aaf579f75d7949f8f897fe0d304e223f636d95ab1a7e7"); AssertBytesEqual( validSig, block1.MakeSignature(_contents.Block1Key, arbitraryHash)); @@ -204,22 +203,22 @@ public void DeriveBlockHash() _contents.GenesisMetadata, _contents.GenesisMetadata.DerivePreEvaluationHash(default)); AssertBytesEqual( - fromHex("554216ef9faf1be5c672739a22374027e430f46f13a5a4b9327ec05e1d0bd5e2"), + fromHex("958e5f6f5b52766e19d24f5d9bcdfea7bd00e06c3667b9dd8f9ba05ffd7024c1"), genesis.DeriveBlockHash(default, null) ); AssertBytesEqual( - fromHex("9c203a24a225d4ffa6e96135c0985f19594866357f116c3f8eb1d24cb5628555"), + fromHex("3a18d7549a5a0dfe401dd360d7a73772585f416ed2e0af65414ebe165718b41b"), genesis.DeriveBlockHash( default, genesis.MakeSignature(_contents.GenesisKey, default) ) ); AssertBytesEqual( - fromHex("2463e57b62912b29b355ba2610e1621f71d545e6ad1655177479fe29ac65bd66"), + fromHex("32db0ad1ecc76ff83f411a551a773eed77ad824726e505607e93e414eaf9523e"), genesis.DeriveBlockHash(arbitraryHash, null) ); AssertBytesEqual( - fromHex("97ac26259507f6b3ef48f479a1d295dbc8ace5f16dc904f8a86ceaa782bcdea8"), + fromHex("316c06eadfae65ab5e248f7c559c1d90bcb27e29920de0121e2351f027f86a86"), genesis.DeriveBlockHash( arbitraryHash, genesis.MakeSignature(_contents.GenesisKey, arbitraryHash)) @@ -229,19 +228,19 @@ public void DeriveBlockHash() _contents.Block1Metadata, _contents.Block1Metadata.DerivePreEvaluationHash(default)); AssertBytesEqual( - fromHex("262d6a05b904a6f17e9eed88cace32b89f43e7a8f4bdfc8463bbd5292190ec53"), + fromHex("b74d4ae2fcbf43a78df1b04f8c86ece2ae05c03dd75204d602962ccd1ad537a2"), block1.DeriveBlockHash(default, null) ); AssertBytesEqual( - fromHex("91ef9beb2b4d910639a1298043d8539a5e128cfa56c954d6274bc17a6b6e6852"), + fromHex("baa8f6f1d8f734af4d557eda0fb3b41068814c367c834fa0cb94896399e1b3bf"), block1.DeriveBlockHash(default, block1.MakeSignature(_contents.Block1Key, default)) ); AssertBytesEqual( - fromHex("5e2c9c476b97f67fcfa20b6a460175cba818a9439928d155409b81895019cf73"), + fromHex("0b5a02c2f97c8fe322289e96911478ee014445274cedee30c7841f1a7b2e497e"), block1.DeriveBlockHash(arbitraryHash, null) ); AssertBytesEqual( - fromHex("06f9ecadc8ea6e5cd94db027b1f8068dfc0997010d75c3d5ff7d2d43d1379630"), + fromHex("6af3538b046f310a5e21db173047bcd2a564725071150127cac05e4e9b36b06a"), block1.DeriveBlockHash( arbitraryHash, block1.MakeSignature(_contents.Block1Key, arbitraryHash) ) diff --git a/Libplanet.Types/Blocks/BlockMetadata.cs b/Libplanet.Types/Blocks/BlockMetadata.cs index 02f3bc2540c..d955dec3d05 100644 --- a/Libplanet.Types/Blocks/BlockMetadata.cs +++ b/Libplanet.Types/Blocks/BlockMetadata.cs @@ -21,7 +21,7 @@ public class BlockMetadata : IBlockMetadata /// /// The latest protocol version. /// - public const int CurrentProtocolVersion = 6; + public const int CurrentProtocolVersion = 7; /// /// The starting protocol version where a bug in transferring asset was fixed. From 5bd809c806f3bdf10bbac787983dfff06037d6f5 Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Mon, 29 Apr 2024 15:44:45 +0900 Subject: [PATCH 2/3] Changelog --- CHANGES.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 154d4420b1e..1e503afb02e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,6 +10,9 @@ To be released. ### Backward-incompatible API changes + - (Libplanet.Types) Updated `BlockMetadata.CurrentProtocolVersion` + from 6 to 7. [[#3769]] + ### Backward-incompatible network protocol changes ### Backward-incompatible storage format changes @@ -24,6 +27,8 @@ To be released. ### CLI tools +[#3769]: https://github.com/planetarium/libplanet/pull/3769 + Version 4.4.0 ------------- From a9e7e1d950252c61b1d6a3d8932e40922dc0401b Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Mon, 29 Apr 2024 17:24:51 +0900 Subject: [PATCH 3/3] Fixed missing test --- Libplanet.Net.Tests/Messages/MessageTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libplanet.Net.Tests/Messages/MessageTest.cs b/Libplanet.Net.Tests/Messages/MessageTest.cs index 56625975efa..df7f5e6b153 100644 --- a/Libplanet.Net.Tests/Messages/MessageTest.cs +++ b/Libplanet.Net.Tests/Messages/MessageTest.cs @@ -115,7 +115,7 @@ public void GetId() var message = new BlockHeaderMsg(genesis.Hash, genesis.Header); Assert.Equal( new MessageId(ByteUtil.ParseHex( - "b679318b18ec1efb98ac53beecc811aaef97718ebd30996080bb33305f84dc69")), + "22a7b4b075e5d93677f044796bd9f32b5181de8d7454c374afb9a37ecb7edbc1")), message.Id); }