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

🔀 merge release/1.5.1 into development #2269

Merged
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
7 changes: 7 additions & 0 deletions .Lib9c.Plugin.Shared/IPluginActionEvaluator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Lib9c.Plugin.Shared
{
public interface IPluginActionEvaluator
{
byte[][] Evaluate(byte[] blockBytes, byte[]? baseStateRootHashBytes);
}
}
23 changes: 23 additions & 0 deletions .Lib9c.Plugin.Shared/IPluginKeyValueStore.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Collections.Immutable;

namespace Lib9c.Plugin.Shared
{
public interface IPluginKeyValueStore
{
public byte[] Get(in ImmutableArray<byte> key);

public void Set(in ImmutableArray<byte> key, byte[] value);

public void Set(IDictionary<ImmutableArray<byte>, byte[]> values);

public void Delete(in ImmutableArray<byte> key);

public void Delete(IEnumerable<ImmutableArray<byte>> keys);

public bool Exists(in ImmutableArray<byte> key);

public IEnumerable<ImmutableArray<byte>> ListKeys();

public void Dispose();
}
}
9 changes: 9 additions & 0 deletions .Lib9c.Plugin.Shared/Lib9c.Plugin.Shared.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
19 changes: 19 additions & 0 deletions .Lib9c.Plugin/Lib9c.Plugin.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EnableDynamicLoading>true</EnableDynamicLoading>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\.Libplanet.Extensions.ActionEvaluatorCommonComponents\Libplanet.Extensions.ActionEvaluatorCommonComponents.csproj" />
<ProjectReference Include="..\Lib9c\Lib9c.csproj" />
<ProjectReference Include="..\.Lib9c.Plugin.Shared\Lib9c.Plugin.Shared.csproj">
<Private>false</Private>
<ExcludeAssets>runtime</ExcludeAssets>
</ProjectReference>
</ItemGroup>

</Project>
34 changes: 34 additions & 0 deletions .Lib9c.Plugin/PluginActionEvaluator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System.Security.Cryptography;
using Lib9c.Plugin.Shared;
using Libplanet.Action;
using Libplanet.Common;
using Libplanet.Extensions.ActionEvaluatorCommonComponents;
using Libplanet.Store;
using Nekoyume.Action;
using Nekoyume.Action.Loader;


namespace Lib9c.Plugin
{
public class PluginActionEvaluator : IPluginActionEvaluator
{
private readonly IActionEvaluator _actionEvaluator;

public PluginActionEvaluator(IPluginKeyValueStore keyValueStore)
{
var stateStore = new TrieStateStore(new WrappedKeyValueStore(keyValueStore));
_actionEvaluator = new ActionEvaluator(
_ => new RewardGold(),
stateStore,
new NCActionLoader());
}

public byte[][] Evaluate(byte[] blockBytes, byte[]? baseStateRootHashBytes)
{
return _actionEvaluator.Evaluate(
PreEvaluationBlockMarshaller.Deserialize(blockBytes),
baseStateRootHashBytes is { } bytes ? new HashDigest<SHA256>(bytes) : null)
.Select(eval => ActionEvaluationMarshaller.Serialize(eval)).ToArray();
}
}
}
44 changes: 44 additions & 0 deletions .Lib9c.Plugin/WrappedKeyValueStore.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Lib9c.Plugin.Shared;
using Libplanet.Store.Trie;

namespace Lib9c.Plugin
{
public class WrappedKeyValueStore : IKeyValueStore
{
private readonly IPluginKeyValueStore _pluginKeyValueStore;

public WrappedKeyValueStore(IPluginKeyValueStore pluginKeyValueStore)
{
_pluginKeyValueStore = pluginKeyValueStore;
}

public void Dispose()
{
_pluginKeyValueStore.Dispose();
}

public byte[] Get(in KeyBytes key) =>
_pluginKeyValueStore.Get(key.ByteArray);

public void Set(in KeyBytes key, byte[] value) =>
_pluginKeyValueStore.Set(key.ByteArray, value);

public void Set(IDictionary<KeyBytes, byte[]> values) =>
_pluginKeyValueStore.Set(
values.ToDictionary(kv =>
kv.Key.ByteArray, kv => kv.Value));

public void Delete(in KeyBytes key) =>
_pluginKeyValueStore.Delete(key.ByteArray);

public void Delete(IEnumerable<KeyBytes> keys) =>
_pluginKeyValueStore.Delete(
keys.Select(key => key.ByteArray));

public bool Exists(in KeyBytes key) =>
_pluginKeyValueStore.Exists(key.ByteArray);

public IEnumerable<KeyBytes> ListKeys() =>
_pluginKeyValueStore.ListKeys().Select(key => new KeyBytes(key));
}
}
5 changes: 0 additions & 5 deletions Lib9c.Policy/Policy/MaxTransactionsBytesPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ private MaxTransactionsBytesPolicy(
.Add(new SpannedSubPolicy<long>(
startIndex: 0L,
value: 1024L * 1024L * 15L)) // 15 MiB
// Note: Initial analysis of the heaviest block of 9c-main
// (except for the genesis) weighs 58,408 B (58 KiB).
.Add(new SpannedSubPolicy<long>(
startIndex: 1L,
value: 1024L * 100L)) // 100 KiB
// Note: Temporary limit increase for resolving
// https://github.com/planetarium/NineChronicles/issues/777.
// Issued for v100081. Temporary ad hoc increase was introduced
Expand Down
26 changes: 19 additions & 7 deletions Lib9c.sln
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,23 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Libplanet.Types", ".Libplan
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Libplanet.Store", ".Libplanet\Libplanet.Store\Libplanet.Store.csproj", "{82BCD815-0AB6-4EEF-A12B-CDB9CD98EEA1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Libplanet.Extensions.ActionEvaluatorCommonComponents", ".Libplanet.Extensions.ActionEvaluatorCommonComponents\Libplanet.Extensions.ActionEvaluatorCommonComponents.csproj", "{64C44AFB-1E14-44D3-B236-A4A37DF2C27A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Libplanet.Extensions.ActionEvaluatorCommonComponents", ".Libplanet.Extensions.ActionEvaluatorCommonComponents\Libplanet.Extensions.ActionEvaluatorCommonComponents.csproj", "{64C44AFB-1E14-44D3-B236-A4A37DF2C27A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Libplanet.Extensions.ActionEvaluatorCommonComponents.Tests", ".Libplanet.Extensions.ActionEvaluatorCommonComponents.Tests\Libplanet.Extensions.ActionEvaluatorCommonComponents.Tests.csproj", "{EACB2E8D-9A13-491C-BACD-5D79C6C13783}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Libplanet.Extensions.ActionEvaluatorCommonComponents.Tests", ".Libplanet.Extensions.ActionEvaluatorCommonComponents.Tests\Libplanet.Extensions.ActionEvaluatorCommonComponents.Tests.csproj", "{EACB2E8D-9A13-491C-BACD-5D79C6C13783}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Libplanet.Extensions.RemoteActionEvaluator", ".Libplanet.Extensions.RemoteActionEvaluator\Libplanet.Extensions.RemoteActionEvaluator.csproj", "{0ED5DBA2-C334-40F2-8EB6-2B4D15C1AB4B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Libplanet.Extensions.RemoteActionEvaluator", ".Libplanet.Extensions.RemoteActionEvaluator\Libplanet.Extensions.RemoteActionEvaluator.csproj", "{0ED5DBA2-C334-40F2-8EB6-2B4D15C1AB4B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Libplanet.Extensions.RemoteActionEvaluator.Tests", ".Libplanet.Extensions.RemoteActionEvaluator.Tests\Libplanet.Extensions.RemoteActionEvaluator.Tests.csproj", "{3608A63A-A52D-4EB5-A96D-36C8F11CE603}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Libplanet.Extensions.RemoteActionEvaluator.Tests", ".Libplanet.Extensions.RemoteActionEvaluator.Tests\Libplanet.Extensions.RemoteActionEvaluator.Tests.csproj", "{3608A63A-A52D-4EB5-A96D-36C8F11CE603}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Libplanet.Extensions.RemoteBlockChainStates", ".Libplanet.Extensions.RemoteBlockChainStates\Libplanet.Extensions.RemoteBlockChainStates.csproj", "{63544447-4FCD-48D1-898C-974FBA6834AD}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Libplanet.Extensions.RemoteBlockChainStates", ".Libplanet.Extensions.RemoteBlockChainStates\Libplanet.Extensions.RemoteBlockChainStates.csproj", "{63544447-4FCD-48D1-898C-974FBA6834AD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lib9c.StateService", ".Lib9c.StateService\Lib9c.StateService.csproj", "{EB97AB26-1C8F-48F5-97FF-8A6DF8FAB879}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lib9c.StateService", ".Lib9c.StateService\Lib9c.StateService.csproj", "{EB97AB26-1C8F-48F5-97FF-8A6DF8FAB879}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lib9c.StateService.Shared", ".Lib9c.StateService.Shared\Lib9c.StateService.Shared.csproj", "{5D3489AE-A403-4ADD-94E9-48463A42643E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lib9c.StateService.Shared", ".Lib9c.StateService.Shared\Lib9c.StateService.Shared.csproj", "{5D3489AE-A403-4ADD-94E9-48463A42643E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lib9c.Plugin", ".Lib9c.Plugin\Lib9c.Plugin.csproj", "{484A5A5B-D610-42D4-9CAC-B19EA1A71281}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lib9c.Plugin.Shared", ".Lib9c.Plugin.Shared\Lib9c.Plugin.Shared.csproj", "{76F6C25E-94D2-4EA9-B88D-0249F44D1D16}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -208,6 +212,14 @@ Global
{5D3489AE-A403-4ADD-94E9-48463A42643E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5D3489AE-A403-4ADD-94E9-48463A42643E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5D3489AE-A403-4ADD-94E9-48463A42643E}.Release|Any CPU.Build.0 = Release|Any CPU
{484A5A5B-D610-42D4-9CAC-B19EA1A71281}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{484A5A5B-D610-42D4-9CAC-B19EA1A71281}.Debug|Any CPU.Build.0 = Debug|Any CPU
{484A5A5B-D610-42D4-9CAC-B19EA1A71281}.Release|Any CPU.ActiveCfg = Release|Any CPU
{484A5A5B-D610-42D4-9CAC-B19EA1A71281}.Release|Any CPU.Build.0 = Release|Any CPU
{76F6C25E-94D2-4EA9-B88D-0249F44D1D16}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{76F6C25E-94D2-4EA9-B88D-0249F44D1D16}.Debug|Any CPU.Build.0 = Debug|Any CPU
{76F6C25E-94D2-4EA9-B88D-0249F44D1D16}.Release|Any CPU.ActiveCfg = Release|Any CPU
{76F6C25E-94D2-4EA9-B88D-0249F44D1D16}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Loading