-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2268 from planetarium/release/1.5.1
🔀 merge release/1.5.1 into main
- Loading branch information
Showing
8 changed files
with
185 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: lib9c plugin build and push s3 | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
s3-lib9c-plugin: | ||
strategy: | ||
matrix: | ||
runtime: [ "osx-arm64", "linux-arm64", "linux-x64", "win-x64" ] | ||
name: Publish Lib9c.Plugin (${{ matrix.runtime }}) | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
submodules: true | ||
- uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: 6.0.400 | ||
- name: Publish Lib9c.Plugin | ||
run: dotnet publish ./.Lib9c.Plugin/Lib9c.Plugin.csproj -o out -r ${{ matrix.runtime }} | ||
- name: Compress the build result | ||
run: zip -r ../${{ matrix.runtime }}.zip . | ||
working-directory: ./out | ||
- name: Upload S3 | ||
run: aws s3 cp ${{ matrix.runtime }}.zip s3://9c-dx/Lib9c.Plugin/${{ github.sha }}/ | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
AWS_REGION: "us-east-2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters