From 1576ea6237ae2a8f639bd3ddde20d925ae2bf342 Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Tue, 5 Mar 2024 17:56:53 +0900 Subject: [PATCH 01/13] Bump lib9c --- Lib9c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib9c b/Lib9c index 4bca541f4..159c13f32 160000 --- a/Lib9c +++ b/Lib9c @@ -1 +1 @@ -Subproject commit 4bca541f48e17ec5728c0f37071140677ddb385b +Subproject commit 159c13f32bebe7a7b40d3064536a5bd38f831788 From 827705722394760521f60319280bfd341b7c26e5 Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Fri, 8 Mar 2024 13:57:59 +0900 Subject: [PATCH 02/13] Bump lib9c --- Lib9c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib9c b/Lib9c index 159c13f32..c43ba3a6b 160000 --- a/Lib9c +++ b/Lib9c @@ -1 +1 @@ -Subproject commit 159c13f32bebe7a7b40d3064536a5bd38f831788 +Subproject commit c43ba3a6b101eaa20164c21badee6801e01c5155 From db0024fc99d7fc65335646a277e0c675cb734045 Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Wed, 13 Mar 2024 17:01:56 +0900 Subject: [PATCH 03/13] Bump lib9c --- Lib9c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib9c b/Lib9c index 159c13f32..c9a5d81e2 160000 --- a/Lib9c +++ b/Lib9c @@ -1 +1 @@ -Subproject commit 159c13f32bebe7a7b40d3064536a5bd38f831788 +Subproject commit c9a5d81e27974b2af0927a735cb765e150e8804b From 138cbb2ce50aa1a375e6ae94a318d6c9ec33c879 Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Wed, 13 Mar 2024 17:33:40 +0900 Subject: [PATCH 04/13] Bump lib9c --- Lib9c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib9c b/Lib9c index c9a5d81e2..3dcbc480d 160000 --- a/Lib9c +++ b/Lib9c @@ -1 +1 @@ -Subproject commit c9a5d81e27974b2af0927a735cb765e150e8804b +Subproject commit 3dcbc480d640180733ad63cb66478386edbc662f From 3e3e50a0ce16e6cd4eecc6130cf6cfd9b7eac9ea Mon Sep 17 00:00:00 2001 From: hyeon Date: Thu, 14 Mar 2024 15:42:22 +0900 Subject: [PATCH 05/13] Bump lib9c --- Lib9c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib9c b/Lib9c index 3dcbc480d..7642d4a12 160000 --- a/Lib9c +++ b/Lib9c @@ -1 +1 @@ -Subproject commit 3dcbc480d640180733ad63cb66478386edbc662f +Subproject commit 7642d4a1277b5b5a158aafae02ab797d9d0fee52 From 3791233ed3c7c135fe83fc6d6c1d22fbc0bc9818 Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Fri, 15 Mar 2024 10:39:12 +0900 Subject: [PATCH 06/13] Register RetrieveAvatarAssets query --- .../GraphTypes/ActionQueryTest.cs | 21 ++++++++++++ .../GraphTypes/ActionQuery.cs | 1 + .../ActionQueryFields/RetrieveAvatarAssets.cs | 33 +++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 NineChronicles.Headless/GraphTypes/ActionQueryFields/RetrieveAvatarAssets.cs diff --git a/NineChronicles.Headless.Tests/GraphTypes/ActionQueryTest.cs b/NineChronicles.Headless.Tests/GraphTypes/ActionQueryTest.cs index 47ec4c484..45a5ccce9 100644 --- a/NineChronicles.Headless.Tests/GraphTypes/ActionQueryTest.cs +++ b/NineChronicles.Headless.Tests/GraphTypes/ActionQueryTest.cs @@ -1519,5 +1519,26 @@ public async Task RuneSummon() Assert.Equal(groupId, action.GroupId); Assert.Equal(summonCount, action.SummonCount); } + + [Fact] + public async Task RetrieveAvatarAssets() + { + var avatarAddress = new PrivateKey().Address; + + var query = $@"{{ + retrieveAvatarAssets( + avatarAddress: ""{avatarAddress}"" + ) + }}"; + + var queryResult = await ExecuteQueryAsync(query, standaloneContext: _standaloneContext); + var data = (Dictionary)((ExecutionNode)queryResult.Data!).ToValue()!; + var plainValue = _codec.Decode(ByteUtil.ParseHex((string)data["retrieveAvatarAssets"])); + Assert.IsType(plainValue); + var actionBase = DeserializeNCAction(plainValue); + var action = Assert.IsType(actionBase); + + Assert.Equal(avatarAddress, action.AvatarAddress); + } } } diff --git a/NineChronicles.Headless/GraphTypes/ActionQuery.cs b/NineChronicles.Headless/GraphTypes/ActionQuery.cs index 81d34b1db..2afe6d606 100644 --- a/NineChronicles.Headless/GraphTypes/ActionQuery.cs +++ b/NineChronicles.Headless/GraphTypes/ActionQuery.cs @@ -570,6 +570,7 @@ public ActionQuery(StandaloneContext standaloneContext) RegisterGarages(); RegisterSummon(); RegisterClaimItems(); + RegisterRetrieveAvatarAssets(); Field>( name: "craftQuery", diff --git a/NineChronicles.Headless/GraphTypes/ActionQueryFields/RetrieveAvatarAssets.cs b/NineChronicles.Headless/GraphTypes/ActionQueryFields/RetrieveAvatarAssets.cs new file mode 100644 index 000000000..162597f7e --- /dev/null +++ b/NineChronicles.Headless/GraphTypes/ActionQueryFields/RetrieveAvatarAssets.cs @@ -0,0 +1,33 @@ +using GraphQL; +using GraphQL.Types; +using Libplanet.Crypto; +using Libplanet.Explorer.GraphTypes; +using Nekoyume.Action; + +namespace NineChronicles.Headless.GraphTypes; + +public partial class ActionQuery +{ + private void RegisterRetrieveAvatarAssets() + { + Field>( + name: "retrieveAvatarAssets", + arguments: new QueryArguments( + new QueryArgument> + { + Name = "avatarAddress", + Description = "Avatar address to retrieve assets" + } + ), + resolve: context => + { + var avatarAddress = context.GetArgument
("avatarAddress"); + ActionBase action = new RetrieveAvatarAssets() + { + AvatarAddress = avatarAddress + }; + return Encode(context, action); + } + ); + } +} From f5f4c782f36002df68a8cdccc8eec7dc73c5d6f9 Mon Sep 17 00:00:00 2001 From: jonny Date: Fri, 15 Mar 2024 18:33:57 +0900 Subject: [PATCH 07/13] bump Lib9c 1.10.0 --- Lib9c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib9c b/Lib9c index 7642d4a12..2eccd6122 160000 --- a/Lib9c +++ b/Lib9c @@ -1 +1 @@ -Subproject commit 7642d4a1277b5b5a158aafae02ab797d9d0fee52 +Subproject commit 2eccd612294ca839604fddb35b398ad0d217b8be From f23bc218d92d7e3389a9a2b90ba0c338c0a991bf Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Tue, 19 Mar 2024 17:34:03 +0900 Subject: [PATCH 08/13] Bump lib9c --- Lib9c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib9c b/Lib9c index 2eccd6122..ed26c1bfa 160000 --- a/Lib9c +++ b/Lib9c @@ -1 +1 @@ -Subproject commit 2eccd612294ca839604fddb35b398ad0d217b8be +Subproject commit ed26c1bfa8de43b76a3a8de648f234a58f20997b From e03e9cc46192d28dce8a014f3a0fc820c30108eb Mon Sep 17 00:00:00 2001 From: hyeon Date: Tue, 19 Mar 2024 17:46:28 +0900 Subject: [PATCH 09/13] Bump lib9c --- Lib9c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib9c b/Lib9c index ed26c1bfa..5f6ba9c0a 160000 --- a/Lib9c +++ b/Lib9c @@ -1 +1 @@ -Subproject commit ed26c1bfa8de43b76a3a8de648f234a58f20997b +Subproject commit 5f6ba9c0a45d5f2644fd6fe2d1cf6722e7e9df2c From fe24ffb9d78b6fd7ba05630adf1a6c87bb7223ba Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Thu, 21 Mar 2024 14:14:59 +0900 Subject: [PATCH 10/13] Bump lib9c --- Lib9c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib9c b/Lib9c index 5f6ba9c0a..0c8ec469b 160000 --- a/Lib9c +++ b/Lib9c @@ -1 +1 @@ -Subproject commit 5f6ba9c0a45d5f2644fd6fe2d1cf6722e7e9df2c +Subproject commit 0c8ec469b9806f2036d1435f4e67f6e09645bb29 From a6c297df1fdf36b0819a2facd5faccd64a112812 Mon Sep 17 00:00:00 2001 From: area363 Date: Thu, 21 Mar 2024 17:34:11 +0900 Subject: [PATCH 11/13] bump lib9c --- Lib9c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib9c b/Lib9c index 0c8ec469b..0a369cbcc 160000 --- a/Lib9c +++ b/Lib9c @@ -1 +1 @@ -Subproject commit 0c8ec469b9806f2036d1435f4e67f6e09645bb29 +Subproject commit 0a369cbcc5d4d185723b101b336043a4fc2d1ff1 From 4156fd80cafb8be64b69913ef99e3a2e26de9a26 Mon Sep 17 00:00:00 2001 From: area363 Date: Thu, 21 Mar 2024 17:34:41 +0900 Subject: [PATCH 12/13] customize maxtransactionperblock --- .../Configuration.cs | 4 ++++ NineChronicles.Headless.Executable/Program.cs | 14 +++++++++++++- .../GraphTypes/StandaloneQueryTest.cs | 2 +- .../NineChroniclesNodeService.cs | 7 ++++--- .../NineChroniclesNodeServiceProperties.cs | 2 ++ 5 files changed, 24 insertions(+), 5 deletions(-) diff --git a/NineChronicles.Headless.Executable/Configuration.cs b/NineChronicles.Headless.Executable/Configuration.cs index edf895785..29470f69d 100644 --- a/NineChronicles.Headless.Executable/Configuration.cs +++ b/NineChronicles.Headless.Executable/Configuration.cs @@ -85,6 +85,8 @@ public class Configuration public ushort? ConsensusPort { get; set; } public double? ConsensusTargetBlockIntervalMilliseconds { get; set; } + public int? MaxTransactionPerBlock { get; set; } + public string SentryDsn { get; set; } = ""; public double SentryTraceSampleRate { get; set; } = 0.01; @@ -141,6 +143,7 @@ public void Overwrite( string? consensusPrivateKeyString, string[]? consensusSeedStrings, double? consensusTargetBlockIntervalMilliseconds, + int? maxTransactionPerBlock, string? sentryDsn, double? sentryTraceSampleRate, int? arenaParticipantsSyncInterval @@ -192,6 +195,7 @@ public void Overwrite( ConsensusSeedStrings = consensusSeedStrings ?? ConsensusSeedStrings; ConsensusPrivateKeyString = consensusPrivateKeyString ?? ConsensusPrivateKeyString; ConsensusTargetBlockIntervalMilliseconds = consensusTargetBlockIntervalMilliseconds ?? ConsensusTargetBlockIntervalMilliseconds; + MaxTransactionPerBlock = maxTransactionPerBlock ?? MaxTransactionPerBlock; SentryDsn = sentryDsn ?? SentryDsn; SentryTraceSampleRate = sentryTraceSampleRate ?? SentryTraceSampleRate; ArenaParticipantsSyncInterval = arenaParticipantsSyncInterval ?? ArenaParticipantsSyncInterval; diff --git a/NineChronicles.Headless.Executable/Program.cs b/NineChronicles.Headless.Executable/Program.cs index ee45f18fb..43871c2ad 100644 --- a/NineChronicles.Headless.Executable/Program.cs +++ b/NineChronicles.Headless.Executable/Program.cs @@ -205,6 +205,9 @@ public async Task Run( [Option("consensus-target-block-interval", Description = "A target block interval used in consensus context. The unit is millisecond.")] double? consensusTargetBlockIntervalMilliseconds = null, + [Option("maximum-transaction-per-block", + Description = "Maximum transactions allowed in a block. null by default.")] + int? maxTransactionPerBlock = null, [Option("config", new[] { 'C' }, Description = "Absolute path of \"appsettings.json\" file to provide headless configurations.")] string? configPath = "appsettings.json", @@ -302,7 +305,7 @@ public async Task Run( txLifeTime, messageTimeout, tipTimeout, demandBuffer, skipPreload, minimumBroadcastTarget, bucketSize, chainTipStaleBehaviorType, txQuotaPerSigner, maximumPollPeers, consensusPort, consensusPrivateKeyString, consensusSeedStrings, consensusTargetBlockIntervalMilliseconds, - sentryDsn, sentryTraceSampleRate, arenaParticipantsSyncInterval + maxTransactionPerBlock, sentryDsn, sentryTraceSampleRate, arenaParticipantsSyncInterval ); #if SENTRY || ! DEBUG @@ -352,6 +355,14 @@ public async Task Run( ); } + if (headlessConfig.ConsensusPrivateKeyString is null && headlessConfig.MaxTransactionPerBlock is not null) + { + throw new CommandExitedException( + "--maximum-transaction-per-block can only be used when --consensus-private-key is provided.", + -1 + ); + } + if (headlessConfig.StateServiceManagerService is { } stateServiceManagerServiceOptions) { await DownloadStateServices(stateServiceManagerServiceOptions); @@ -459,6 +470,7 @@ IActionLoader MakeSingleActionLoader() MinerCount = headlessConfig.MinerCount, MinerBlockInterval = minerBlockInterval, TxQuotaPerSigner = headlessConfig.TxQuotaPerSigner, + MaxTransactionPerBlock = headlessConfig.MaxTransactionPerBlock }; var arenaMemoryCache = new StateMemoryCache(); hostBuilder.ConfigureServices(services => diff --git a/NineChronicles.Headless.Tests/GraphTypes/StandaloneQueryTest.cs b/NineChronicles.Headless.Tests/GraphTypes/StandaloneQueryTest.cs index 4b36b5309..4de25b8f3 100644 --- a/NineChronicles.Headless.Tests/GraphTypes/StandaloneQueryTest.cs +++ b/NineChronicles.Headless.Tests/GraphTypes/StandaloneQueryTest.cs @@ -897,7 +897,7 @@ public async Task ActivationKeyNonce(bool trim) ConsensusPeers = ImmutableList.Empty }; - var blockPolicy = NineChroniclesNodeService.GetBlockPolicy(Planet.Odin, StaticActionLoaderSingleton.Instance); + var blockPolicy = NineChroniclesNodeService.GetBlockPolicy(Planet.Odin, StaticActionLoaderSingleton.Instance, null); var service = new NineChroniclesNodeService(userPrivateKey, properties, blockPolicy, Planet.Odin, StaticActionLoaderSingleton.Instance); StandaloneContextFx.NineChroniclesNodeService = service; StandaloneContextFx.BlockChain = service.Swarm?.BlockChain; diff --git a/NineChronicles.Headless/NineChroniclesNodeService.cs b/NineChronicles.Headless/NineChroniclesNodeService.cs index 24956e28e..18f784cdf 100644 --- a/NineChronicles.Headless/NineChroniclesNodeService.cs +++ b/NineChronicles.Headless/NineChroniclesNodeService.cs @@ -203,7 +203,8 @@ StandaloneContext context IBlockPolicy blockPolicy = GetBlockPolicy( properties.Planet, - properties.ActionLoader + properties.ActionLoader, + properties.MaxTransactionPerBlock ); var service = new NineChroniclesNodeService( properties.MinerPrivateKey, @@ -256,8 +257,8 @@ StandaloneContext context return service; } - internal static IBlockPolicy GetBlockPolicy(Planet planet, IActionLoader actionLoader) - => new BlockPolicySource(actionLoader).GetPolicy(planet); + internal static IBlockPolicy GetBlockPolicy(Planet planet, IActionLoader actionLoader, int? maxTransactionPerBlock) + => new BlockPolicySource(actionLoader, maxTransactionPerBlock).GetPolicy(planet); public Task CheckPeer(string addr) => NodeService?.CheckPeer(addr) ?? throw new InvalidOperationException(); diff --git a/NineChronicles.Headless/Properties/NineChroniclesNodeServiceProperties.cs b/NineChronicles.Headless/Properties/NineChroniclesNodeServiceProperties.cs index 5121e961b..0480142e5 100644 --- a/NineChronicles.Headless/Properties/NineChroniclesNodeServiceProperties.cs +++ b/NineChronicles.Headless/Properties/NineChroniclesNodeServiceProperties.cs @@ -53,6 +53,8 @@ public NineChroniclesNodeServiceProperties( public int TxQuotaPerSigner { get; set; } + public int? MaxTransactionPerBlock { get; set; } + public IActionLoader ActionLoader { get; init; } public StateServiceManagerServiceOptions? StateServiceManagerService { get; } From c536cfc77a8b3293fbe17d29c4ef4374c2e45c5b Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Tue, 26 Mar 2024 21:23:34 +0900 Subject: [PATCH 13/13] Bump lib9c main v200160 --- Lib9c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib9c b/Lib9c index 0a369cbcc..c6a17ceb8 160000 --- a/Lib9c +++ b/Lib9c @@ -1 +1 @@ -Subproject commit 0a369cbcc5d4d185723b101b336043a4fc2d1ff1 +Subproject commit c6a17ceb8856f4c7c6bdc7a7288be58479d9d006