Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Bencodex to 0.16.0 #3461

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,19 @@ To be released.

### Dependencies

- Upgrade *Bencodex* from [0.14.0][Bencodex 0.14.0] to
[0.16.0][Bencodex 0.16.0]. [[#3461]]
- Upgrade *Bencodex.Json* from [0.11.0][Bencodex.Json 0.11.0] to
[0.16.0][Bencodex.Json 0.16.0]. [[#3461]]
OnedgeLee marked this conversation as resolved.
Show resolved Hide resolved

### CLI tools

[#3454]: https://github.com/planetarium/libplanet/pull/3454
[#3455]: https://github.com/planetarium/libplanet/pull/3455
[#3461]: https://github.com/planetarium/libplanet/pull/3461
[Bencodex 0.16.0]: https://www.nuget.org/packages/Bencodex/0.16.0
[Bencodex.Json 0.11.0]: https://www.nuget.org/packages/Bencodex.json/0.11.0
[Bencodex.Json 0.16.0]: https://www.nuget.org/packages/Bencodex.json/0.16.0


Version 3.6.0
Expand Down
4 changes: 2 additions & 2 deletions Libplanet.Action/Libplanet.Action.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
<ItemGroup>
<PackageReference Include="System.Collections.Immutable" Version="1.*" />
<PackageReference Include="System.Text.Json" Version="6.0.*" />
<PackageReference Include="Bencodex" Version="0.14.0" />
<PackageReference Include="Bencodex.Json" Version="0.11.0" />
<PackageReference Include="Bencodex" Version="0.16.0" />
<PackageReference Include="Bencodex.Json" Version="0.16.0" />
<PackageReference Include="Planetarium.LruCacheNet" Version="1.2.0" />
<PackageReference Include="Serilog" Version="2.8.0" />
<PackageReference Include="Menees.Analyzers.2017" Version="2.0.3">
Expand Down
2 changes: 1 addition & 1 deletion Libplanet.Common/Libplanet.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
runtime; build; native; contentfiles; analyzers; buildtransitive
</IncludeAssets>
</PackageReference>
<PackageReference Include="Bencodex" Version="0.14.0" />
<PackageReference Include="Bencodex" Version="0.16.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.205">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>
Expand Down
2 changes: 1 addition & 1 deletion Libplanet.Crypto/Libplanet.Crypto.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<ItemGroup>
<PackageReference Include="System.Collections.Immutable" Version="1.*" />
<PackageReference Include="System.Text.Json" Version="6.0.*" />
<PackageReference Include="Bencodex" Version="0.14.0" />
<PackageReference Include="Bencodex" Version="0.16.0" />
<PackageReference Include="BouncyCastle.Cryptography" Version="2.0.0" />
<PackageReference Include="Menees.Analyzers.2017" Version="2.0.3">
<PrivateAssets>all</PrivateAssets>
Expand Down
2 changes: 1 addition & 1 deletion Libplanet.Explorer.Tests/GraphTypes/TransactionTypeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ await ExecuteQueryAsync(
var actions = Assert.IsType<Dictionary<string, object>>(
((object[])resultData["actions"])[0]);
Assert.Equal(
transaction.Actions[0].Inspect(true),
transaction.Actions[0].Inspect(),
actions["inspection"]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Libplanet.Explorer/GraphTypes/ActionType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public ActionType()
Field<NonNullGraphType<StringGraphType>>(
name: "Inspection",
description: "A readable representation for debugging.",
resolve: ctx => ctx.Source.Inspect(true)
resolve: ctx => ctx.Source.Inspect()
);

Field<NonNullGraphType<StringGraphType>>(
Expand Down
2 changes: 1 addition & 1 deletion Libplanet.Explorer/Libplanet.Explorer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<ProjectReference Include="..\Libplanet.Net\Libplanet.Net.csproj" />
<ProjectReference Include="..\Libplanet\Libplanet.csproj" />
<ProjectReference Include="..\Libplanet.RocksDBStore\Libplanet.RocksDBStore.csproj" />
<PackageReference Include="Bencodex.Json" Version="0.11.0" />
<PackageReference Include="Bencodex.Json" Version="0.16.0" />
<!-- FIXME: We should specify the version range when the following NuGet
issue is addressed: <https://github.com/NuGet/Home/issues/5556>. -->
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Libplanet.Extensions.Cocona/Commands/ApvCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ void TreeIntoTable(IValue tree, List<(string, string)> table, string key)
{
string k = kv.Key switch
{
Binary bk => ByteUtil.Hex(bk),
Binary bk => ByteUtil.Hex(bk.ToArray()),
Text txt => txt.Value,
_ => kv.Key.ToString() ?? string.Empty,
};
Expand Down
2 changes: 1 addition & 1 deletion Libplanet.Store/BaseStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ ILogger logger
{
const string msg = nameof(TxExecution) +
" must be serialized as a Bencodex dictionary, not {ActualValue}";
logger?.Error(msg, decoded.Inspect(false));
logger?.Error(msg, decoded.Inspect());
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion Libplanet.Store/Libplanet.Store.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<ItemGroup>
<PackageReference Include="System.Collections.Immutable" Version="1.*" />
<PackageReference Include="Bencodex" Version="0.14.0" />
<PackageReference Include="Bencodex" Version="0.16.0" />
<PackageReference Include="Caching.dll" Version="1.4.0.1" />
<PackageReference Include="ImmutableTrie" Version="1.0.0-alpha" />
<PackageReference Include="LiteDB" Version="4.1.4" />
Expand Down
2 changes: 1 addition & 1 deletion Libplanet.Store/Trie/MerkleTrie.Path.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public partial class MerkleTrie
cursor),
HashNode hashNode => ResolveToValue(UnhashNode(hashNode), cursor),
_ => throw new InvalidTrieNodeException(
$"Invalid node value: {node.ToBencodex().Inspect(false)}"),
$"Invalid node value: {node.ToBencodex().Inspect()}"),
};

private INode? ResolveToNode(INode? node, in PathCursor cursor)
Expand Down
2 changes: 1 addition & 1 deletion Libplanet.Store/Trie/MerkleTrie.cs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ private INode Insert(

default:
throw new InvalidTrieNodeException(
$"Unsupported node value: {node.ToBencodex().Inspect(false)}");
$"Unsupported node value: {node.ToBencodex().Inspect()}");
}
}

Expand Down
16 changes: 8 additions & 8 deletions Libplanet.Store/Trie/Nodes/NodeDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public enum NodeType : short
return (allowed & NodeType.Full) == NodeType.Full
? DecodeFull(list)
: throw new InvalidTrieNodeException(
$"Can't decode a node from value {value.Inspect(false)}");
$"Can't decode a node from value {value.Inspect()}");
}
else if (list.Count == 2)
{
Expand All @@ -71,45 +71,45 @@ public enum NodeType : short
return (allowed & NodeType.Short) == NodeType.Short
? DecodeShort(list)
: throw new InvalidTrieNodeException(
$"Can't decode a node from value {value.Inspect(false)}");
$"Can't decode a node from value {value.Inspect()}");
}
else if (list[0] is Null)
{
return (allowed & NodeType.Value) == NodeType.Value
? DecodeValue(list)
: throw new InvalidTrieNodeException(
$"Can't decode a node from value {value.Inspect(false)}");
$"Can't decode a node from value {value.Inspect()}");
}
else
{
throw new InvalidTrieNodeException(
$"Can't decode a node from value {value.Inspect(false)}");
$"Can't decode a node from value {value.Inspect()}");
}
}
else
{
throw new InvalidTrieNodeException(
$"Can't decode a node from the bencodex value: {value.Inspect(false)}");
$"Can't decode a node from the bencodex value: {value.Inspect()}");
}
}
else if (value is Binary binary)
{
return (allowed & NodeType.Hash) == NodeType.Hash
? DecodeHash(binary)
: throw new InvalidTrieNodeException(
$"Can't decode a node from value {value.Inspect(false)}");
$"Can't decode a node from value {value.Inspect()}");
}
else if (value is Null)
{
return (allowed & NodeType.Null) == NodeType.Null
? (INode?)null
: throw new InvalidTrieNodeException(
$"Can't decode a node from value {value.Inspect(false)}");
$"Can't decode a node from value {value.Inspect()}");
}
else
{
throw new InvalidTrieNodeException(
$"Can't decode a node from value {value.Inspect(false)}");
$"Can't decode a node from value {value.Inspect()}");
}
}

Expand Down
6 changes: 3 additions & 3 deletions Libplanet.Tests/Blocks/BlockMarshalerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,23 +179,23 @@ public void UnmarshalBlock()
_output.WriteLine(
"{0} = {1}",
nameof(_marshaledGenesis),
_marshaledGenesis.Inspect(true));
_marshaledGenesis.Inspect());
Assert.Equal(
_fx.Genesis,
BlockMarshaler.UnmarshalBlock(_marshaledGenesis)
);
_output.WriteLine(
"{0} = {1}",
nameof(_marshaledNext),
_marshaledNext.Inspect(true));
_marshaledNext.Inspect());
Assert.Equal(
_fx.Next,
BlockMarshaler.UnmarshalBlock(_marshaledNext)
);
_output.WriteLine(
"{0} = {1}",
nameof(_marshaledHasTx),
_marshaledHasTx.Inspect(true));
_marshaledHasTx.Inspect());
Assert.Equal(
_fx.HasTx,
BlockMarshaler.UnmarshalBlock(_marshaledHasTx)
Expand Down
4 changes: 2 additions & 2 deletions Libplanet.Types/Libplanet.Types.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
<ItemGroup>
<PackageReference Include="System.Collections.Immutable" Version="1.*" />
<PackageReference Include="System.Text.Json" Version="6.0.*" />
<PackageReference Include="Bencodex" Version="0.14.0" />
<PackageReference Include="Bencodex.Json" Version="0.11.0" />
<PackageReference Include="Bencodex" Version="0.16.0" />
<PackageReference Include="Bencodex.Json" Version="0.16.0" />
<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.1" />
<PackageReference Include="Menees.Analyzers.2017" Version="2.0.3">
<PrivateAssets>all</PrivateAssets>
Expand Down
28 changes: 14 additions & 14 deletions Libplanet.Types/Tx/TxMarshaler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ namespace Libplanet.Types.Tx
public static class TxMarshaler
{
private const string TimestampFormat = "yyyy-MM-ddTHH:mm:ss.ffffffZ";
private static readonly Binary UpdatedAddressesKey = new byte[] { 0x75 }; // 'u'
private static readonly Binary TimestampKey = new byte[] { 0x74 }; // 't'
private static readonly Binary GenesisHashKey = new byte[] { 0x67 }; // 'g'
private static readonly Binary MaxGasPriceKey = new byte[] { 0x6d }; // 'm'
private static readonly Binary GasLimitKey = new byte[] { 0x6c }; // 'l'
private static readonly Binary NonceKey = new byte[] { 0x6e }; // 'n'
private static readonly Binary SignerKey = new byte[] { 0x73 }; // 's'
private static readonly Binary PublicKeyKey = new byte[] { 0x70 }; // 'p'
private static readonly Binary SignatureKey = new byte[] { 0x53 }; // 'S'
private static readonly Binary ActionsKey = new byte[] { 0x61 }; // 'a'
private static readonly Binary UpdatedAddressesKey = new Binary(new byte[] { 0x75 }); // 'u'
private static readonly Binary TimestampKey = new Binary(new byte[] { 0x74 }); // 't'
private static readonly Binary GenesisHashKey = new Binary(new byte[] { 0x67 }); // 'g'
private static readonly Binary MaxGasPriceKey = new Binary(new byte[] { 0x6d }); // 'm'
private static readonly Binary GasLimitKey = new Binary(new byte[] { 0x6c }); // 'l'
private static readonly Binary NonceKey = new Binary(new byte[] { 0x6e }); // 'n'
private static readonly Binary SignerKey = new Binary(new byte[] { 0x73 }); // 's'
private static readonly Binary PublicKeyKey = new Binary(new byte[] { 0x70 }); // 'p'
private static readonly Binary SignatureKey = new Binary(new byte[] { 0x53 }); // 'S'
private static readonly Binary ActionsKey = new Binary(new byte[] { 0x61 }); // 'a'
private static readonly Codec Codec = new Codec();

[Pure]
Expand Down Expand Up @@ -139,8 +139,8 @@ public static UnsignedTx UnmarshalUnsignedTx(Bencodex.Types.Dictionary dictionar
public static ImmutableArray<byte>? UnmarshalTransactionSignature(
Bencodex.Types.Dictionary dictionary
) =>
dictionary.TryGetValue(SignatureKey, out IValue v)
? (Binary)v
dictionary.TryGetValue(SignatureKey, out IValue v) && v is Binary bin
? bin.ToImmutableArray()
: (ImmutableArray<byte>?)null;

[Pure]
Expand Down Expand Up @@ -182,8 +182,8 @@ public static Transaction UnmarshalTransactionWithoutVerification(
{
ImmutableArray<byte> sig
= dictionary.TryGetValue(SignatureKey, out IValue s) && s is Binary bin
? bin
: new Binary(Array.Empty<byte>());
? bin.ToImmutableArray()
: ImmutableArray<byte>.Empty;
return UnmarshalUnsignedTx(dictionary).CombineWithoutVerification(sig);
}

Expand Down
2 changes: 1 addition & 1 deletion Libplanet/Libplanet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ https://docs.libplanet.io/</Description>
<ItemGroup>
<PackageReference Include="System.Collections.Immutable" Version="1.*" />
<PackageReference Include="System.Text.Json" Version="6.0.*" />
<PackageReference Include="Bencodex" Version="0.14.0" />
<PackageReference Include="Bencodex" Version="0.16.0" />
<PackageReference Include="BouncyCastle.Cryptography" Version="2.0.0" />
<PackageReference Include="Serilog" Version="2.8.0" />
<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.1" />
Expand Down