Skip to content

Commit

Permalink
Merge pull request #3769 from greymistcube/bump/block-protocol-versio…
Browse files Browse the repository at this point in the history
…n-to-7

♻️ Bumped block protocol version to 7
  • Loading branch information
greymistcube authored Apr 29, 2024
2 parents 1fa87be + a9e7e1d commit 690a98c
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 20 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -24,6 +27,8 @@ To be released.

### CLI tools

[#3769]: https://github.com/planetarium/libplanet/pull/3769


Version 4.4.0
-------------
Expand Down
2 changes: 1 addition & 1 deletion Libplanet.Net.Tests/Messages/MessageTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
10 changes: 5 additions & 5 deletions Libplanet.Tests/Action/ActionEvaluatorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions Libplanet.Tests/Blocks/BlockMetadataTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,13 @@ public void DerivePreEvaluationHash()

HashDigest<SHA256> 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);
}

Expand Down
21 changes: 10 additions & 11 deletions Libplanet.Tests/Blocks/PreEvaluationBlockHeaderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,8 @@ public void VerifySignature()

// Same as block1.MakeSignature(_contents.Block1Key, arbitraryHash)
ImmutableArray<byte> validSig = ByteUtil.ParseHexToImmutable(
"304402204ca56d612a01f8215efd4c24519563e3370da2f14d89831aece4e07e8d782a" +
"97022025f38a29b9b97d037b77765647507aad9f703c06d231c4da0e52e1074cfb39c9");

"3045022100eefa1d45c56cbc0600f438a8254750fc623c6254fda3dcc31defc0cf6fe6a" +
"4d00220760e4b1d36c96ba7571aaf579f75d7949f8f897fe0d304e223f636d95ab1a7e7");
AssertBytesEqual(
validSig,
block1.MakeSignature(_contents.Block1Key, arbitraryHash));
Expand Down Expand Up @@ -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))
Expand All @@ -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)
)
Expand Down
2 changes: 1 addition & 1 deletion Libplanet.Types/Blocks/BlockMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class BlockMetadata : IBlockMetadata
/// <summary>
/// The latest protocol version.
/// </summary>
public const int CurrentProtocolVersion = 6;
public const int CurrentProtocolVersion = 7;

/// <summary>
/// The starting protocol version where a bug in transferring asset was fixed.
Expand Down

0 comments on commit 690a98c

Please sign in to comment.