From 4df72be922a98e455ac6af9a7c0d61f25114d1f7 Mon Sep 17 00:00:00 2001 From: Dabin <56328777+upa-r-upa@users.noreply.github.com> Date: Fri, 4 Oct 2024 16:45:10 +0900 Subject: [PATCH 01/15] remove unused `ArenaParticipantsWorker` --- .../ArenaParticipantsWorkerTest.cs | 207 ----------- .../ArenaParticipantsWorker.cs | 323 ------------------ 2 files changed, 530 deletions(-) delete mode 100644 NineChronicles.Headless.Tests/ArenaParticipantsWorkerTest.cs delete mode 100644 NineChronicles.Headless/ArenaParticipantsWorker.cs diff --git a/NineChronicles.Headless.Tests/ArenaParticipantsWorkerTest.cs b/NineChronicles.Headless.Tests/ArenaParticipantsWorkerTest.cs deleted file mode 100644 index f0835bbc7..000000000 --- a/NineChronicles.Headless.Tests/ArenaParticipantsWorkerTest.cs +++ /dev/null @@ -1,207 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Lib9c.Tests; -using Libplanet.Action.State; -using Libplanet.Crypto; -using Libplanet.Mocks; -using Nekoyume; -using Nekoyume.Action; -using Nekoyume.Model.Arena; -using Nekoyume.Model.EnumType; -using Nekoyume.Model.Item; -using Nekoyume.Model.State; -using Nekoyume.Module; -using Nekoyume.TableData; -using Xunit; -using Random = Libplanet.Extensions.ActionEvaluatorCommonComponents.Random; - -namespace NineChronicles.Headless.Tests; - -public class ArenaParticipantsWorkerTest -{ - private readonly IWorld _world; - private readonly Dictionary _sheets; - - public ArenaParticipantsWorkerTest() - { - _world = new World(MockWorldState.CreateModern()); - _sheets = TableSheetsImporter.ImportSheets(); - } - - [Fact] - public void GetRoundData() - { - var sheetAddress = Addresses.GetSheetAddress(); - var csv = _sheets[nameof(ArenaSheet)]; - var arenaSheet = new ArenaSheet(); - arenaSheet.Set(csv); - var row = arenaSheet.OrderedList.First(); - var expectedRound = row.Round.First(); - var blockIndex = expectedRound.StartBlockIndex; - var state = _world.SetLegacyState(sheetAddress, csv.Serialize()); - var current = ArenaParticipantsWorker.GetRoundData(state, blockIndex); - Assert.Equal(expectedRound.Round, current.Round); - Assert.Equal(expectedRound.ChampionshipId, current.ChampionshipId); - } - - [Fact] - public void GetArenaParticipantsState() - { - var sheetAddress = Addresses.GetSheetAddress(); - var csv = _sheets[nameof(ArenaSheet)]; - var arenaSheet = new ArenaSheet(); - arenaSheet.Set(csv); - var row = arenaSheet.OrderedList.First(); - var currentRoundData = row.Round.First(); - var state = _world.SetLegacyState(sheetAddress, csv.Serialize()); - Assert.Null(ArenaParticipantsWorker.GetArenaParticipantsState(state, currentRoundData)); - - var participantsAddr = ArenaParticipants.DeriveAddress( - currentRoundData.ChampionshipId, - currentRoundData.Round); - var expected = new ArenaParticipants(currentRoundData.ChampionshipId, currentRoundData.Round); - var avatarAddress = new PrivateKey().Address; - expected.AvatarAddresses.Add(avatarAddress); - state = state.SetLegacyState(participantsAddr, expected.Serialize()); - var actual = ArenaParticipantsWorker.GetArenaParticipantsState(state, currentRoundData); - Assert.NotNull(actual); - Assert.Equal(expected.Serialize(), actual.Serialize()); - } - - [Fact] - public void AvatarAddrAndScoresWithRank() - { - var sheetAddress = Addresses.GetSheetAddress(); - var csv = _sheets[nameof(ArenaSheet)]; - var arenaSheet = new ArenaSheet(); - arenaSheet.Set(csv); - var row = arenaSheet.OrderedList.First(); - var currentRoundData = row.Round.First(); - var championshipId = currentRoundData.ChampionshipId; - var round = currentRoundData.Round; - var participantsAddr = ArenaParticipants.DeriveAddress(championshipId, round); - var participants = new ArenaParticipants(championshipId, round); - var avatarAddress = new PrivateKey().Address; - var avatar2Address = new PrivateKey().Address; - participants.AvatarAddresses.Add(avatarAddress); - participants.AvatarAddresses.Add(avatar2Address); - var arenaScore = new ArenaScore(avatarAddress, championshipId, round); - arenaScore.AddScore(10); - var state = _world - .SetLegacyState(sheetAddress, csv.Serialize()) - .SetLegacyState(participantsAddr, participants.Serialize()) - .SetLegacyState(arenaScore.Address, arenaScore.Serialize()); - var actual = - ArenaParticipantsWorker.AvatarAddrAndScoresWithRank(participants.AvatarAddresses, currentRoundData, state); - Assert.Equal(2, actual.Count); - var first = actual.First(); - Assert.Equal(avatarAddress, first.avatarAddr); - Assert.Equal(1010, first.score); - Assert.Equal(1, first.rank); - var second = actual.Last(); - Assert.Equal(avatar2Address, second.avatarAddr); - Assert.Equal(1000, second.score); - Assert.Equal(2, second.rank); - } - - [Fact] - public void GetArenaParticipants() - { - var tableSheets = new TableSheets(_sheets); - var agentAddress = new PrivateKey().Address; - var avatarAddress = Addresses.GetAvatarAddress(agentAddress, 0); - var avatarState = AvatarState.Create( - avatarAddress, - agentAddress, - 0, - tableSheets.GetAvatarSheets(), - new Address(), - "avatar_state" - ); - var avatar2Address = Addresses.GetAvatarAddress(agentAddress, 1); - var avatarState2 = AvatarState.Create( - avatar2Address, - agentAddress, - 0, - tableSheets.GetAvatarSheets(), - new Address(), - "avatar_state2" - ); - - // equipment - var equipmentSheet = tableSheets.EquipmentItemSheet; - var random = new Random(0); - var equipment = - (Equipment)ItemFactory.CreateItem(equipmentSheet.Values.First(r => r.ItemSubType == ItemSubType.Armor), - random); - equipment.equipped = true; - avatarState.inventory.AddItem(equipment); - avatarState2.inventory.AddItem(equipment); - var itemSlotState = new ItemSlotState(BattleType.Arena); - var itemSlotAddress = ItemSlotState.DeriveAddress(avatarAddress, BattleType.Arena); - itemSlotState.UpdateEquipment(new List - { - equipment.ItemId, - }); - - // rune - var runeListSheet = tableSheets.RuneListSheet; - var runeId = runeListSheet.Values.First().Id; - var runeSlotState = new RuneSlotState(BattleType.Arena); - var runeSlotAddress = RuneSlotState.DeriveAddress(avatarAddress, BattleType.Arena); - var runeSlotInfo = new RuneSlotInfo(0, runeId); - runeSlotState.UpdateSlot(new List - { - runeSlotInfo, - }, runeListSheet); - var runeStates = new AllRuneState(runeId); - - // collection - var collectionSheet = tableSheets.CollectionSheet; - var collectionState = new CollectionState(); - collectionState.Ids.Add(collectionSheet.Values.First().Id); - var arenaSheet = tableSheets.ArenaSheet; - var row = arenaSheet.OrderedList.First(); - var currentRoundData = row.Round.First(); - var championshipId = currentRoundData.ChampionshipId; - var round = currentRoundData.Round; - var participantsAddr = ArenaParticipants.DeriveAddress(championshipId, round); - var participants = new ArenaParticipants(championshipId, round); - participants.AvatarAddresses.Add(avatarAddress); - participants.AvatarAddresses.Add(avatar2Address); - var arenaScore = new ArenaScore(avatarAddress, championshipId, round); - arenaScore.AddScore(10); - var state = _world - .SetAvatarState(avatarAddress, avatarState, true, true, true, true) - .SetAvatarState(avatar2Address, avatarState2, true, true, true, true) - .SetLegacyState(itemSlotAddress, itemSlotState.Serialize()) - .SetRuneState(avatarAddress, runeStates) - .SetLegacyState(runeSlotAddress, runeSlotState.Serialize()) - .SetCollectionState(avatar2Address, collectionState) - .SetLegacyState(participantsAddr, participants.Serialize()) - .SetLegacyState(arenaScore.Address, arenaScore.Serialize()); - foreach (var (key, s) in _sheets) - { - state = state.SetLegacyState(Addresses.GetSheetAddress(key), s.Serialize()); - } - - var avatarAddrAndScoresWithRank = - ArenaParticipantsWorker.AvatarAddrAndScoresWithRank(participants.AvatarAddresses, currentRoundData, state); - var actual = - ArenaParticipantsWorker.GetArenaParticipants(state, participants.AvatarAddresses, - avatarAddrAndScoresWithRank); - Assert.Equal(2, actual.Count); - var first = actual.First(); - Assert.Equal(avatarAddress, first.AvatarAddr); - Assert.Equal(1010, first.Score); - Assert.Equal(1, first.Rank); - Assert.Equal(equipment.Id, first.PortraitId); - var second = actual.Last(); - Assert.Equal(avatar2Address, second.AvatarAddr); - Assert.Equal(1000, second.Score); - Assert.Equal(2, second.Rank); - Assert.Equal(GameConfig.DefaultAvatarArmorId, second.PortraitId); - Assert.True(first.Cp < second.Cp); - } -} diff --git a/NineChronicles.Headless/ArenaParticipantsWorker.cs b/NineChronicles.Headless/ArenaParticipantsWorker.cs deleted file mode 100644 index c31d7f792..000000000 --- a/NineChronicles.Headless/ArenaParticipantsWorker.cs +++ /dev/null @@ -1,323 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Bencodex.Types; -using Libplanet.Action.State; -using Libplanet.Crypto; -using Microsoft.Extensions.Caching.Memory; -using Microsoft.Extensions.Hosting; -using Nekoyume; -using Nekoyume.Battle; -using Nekoyume.Helper; -using Nekoyume.Model.Arena; -using Nekoyume.Model.EnumType; -using Nekoyume.Model.Stat; -using Nekoyume.Model.State; -using Nekoyume.Module; -using Nekoyume.TableData; -using Nekoyume.TableData.Rune; -using NineChronicles.Headless.GraphTypes; -using Serilog; - -namespace NineChronicles.Headless; - -public class ArenaParticipantsWorker : BackgroundService -{ - private ILogger _logger; - - private StateMemoryCache _cache; - - private StandaloneContext _context; - - private int _interval; - - public ArenaParticipantsWorker(StateMemoryCache memoryCache, StandaloneContext context, int interval) - { - _cache = memoryCache; - _context = context; - _logger = Log.Logger.ForContext(); - _interval = interval; - } - - protected override async Task ExecuteAsync(CancellationToken stoppingToken) - { - try - { - while (!stoppingToken.IsCancellationRequested) - { - await Task.Delay(_interval, stoppingToken); - PrepareArenaParticipants(); - } - } - catch (OperationCanceledException) - { - //pass - _logger.Information("[ArenaParticipantsWorker]Cancel ArenaParticipantsWorker"); - } - catch (Exception e) - { - _logger.Error(e, "[ArenaParticipantsWorker]Stopping ArenaParticipantsWorker"); - await StopAsync(stoppingToken); - } - } - - /// - /// Retrieves the state of arena participants from the given world state and current round data. - /// - /// The world state. - /// The current round data. - /// The arena participants state, or null if not found. - public static ArenaParticipants? GetArenaParticipantsState(IWorldState worldState, ArenaSheet.RoundData currentRoundData) - { - var participantsAddr = ArenaParticipants.DeriveAddress( - currentRoundData.ChampionshipId, - currentRoundData.Round); - var participants = worldState.GetLegacyState(participantsAddr) is List participantsList - ? new ArenaParticipants(participantsList) - : null; - return participants; - } - - /// - /// Gets the round data from the specified world state and block index. - /// - /// The world state containing the arena sheet. - /// The block index for which to retrieve the round data. - /// The round data for the specified block index. - public static ArenaSheet.RoundData GetRoundData(IWorldState worldState, long blockIndex) - { - return worldState.GetSheet().GetRoundByBlockIndex(blockIndex); - } - - /// - /// Retrieves the avatar addresses and scores with ranks for a given list of avatar addresses, current round data, and world state. - /// - /// The list of avatar addresses. - /// The current round data. - /// The world state. - /// The list of avatar addresses, scores, and ranks. - public static List<(Address avatarAddr, int score, int rank)> AvatarAddrAndScoresWithRank(List
avatarAddrList, ArenaSheet.RoundData currentRoundData, IWorldState worldState) - { - var avatarAndScoreAddrList = avatarAddrList - .Select(avatarAddr => ( - avatarAddr, - ArenaScore.DeriveAddress( - avatarAddr, - currentRoundData.ChampionshipId, - currentRoundData.Round))) - .ToArray(); - // NOTE: If addresses is too large, and split and get separately. - var scores = worldState.GetLegacyStates( - avatarAndScoreAddrList.Select(tuple => tuple.Item2).ToList()); - var avatarAddrAndScores = new List<(Address avatarAddr, int score)>(); - for (int i = 0; i < avatarAddrList.Count; i++) - { - var tuple = avatarAndScoreAddrList[i]; - var score = scores[i] is List scoreList ? (int)(Integer)scoreList[1] : ArenaScore.ArenaScoreDefault; - avatarAddrAndScores.Add((tuple.avatarAddr, score)); - } - - List<(Address avatarAddr, int score, int rank)> orderedTuples = avatarAddrAndScores - .OrderByDescending(tuple => tuple.score) - .ThenBy(tuple => tuple.avatarAddr) - .Select(tuple => (tuple.avatarAddr, tuple.score, 0)) - .ToList(); - int? currentScore = null; - var currentRank = 1; - var avatarAddrAndScoresWithRank = new List<(Address avatarAddr, int score, int rank)>(); - var trunk = new List<(Address avatarAddr, int score, int rank)>(); - for (var i = 0; i < orderedTuples.Count; i++) - { - var tuple = orderedTuples[i]; - if (!currentScore.HasValue) - { - currentScore = tuple.score; - trunk.Add(tuple); - continue; - } - - if (currentScore.Value == tuple.score) - { - trunk.Add(tuple); - currentRank++; - if (i < orderedTuples.Count - 1) - { - continue; - } - - foreach (var tupleInTrunk in trunk) - { - avatarAddrAndScoresWithRank.Add(( - tupleInTrunk.avatarAddr, - tupleInTrunk.score, - currentRank)); - } - - trunk.Clear(); - - continue; - } - - foreach (var tupleInTrunk in trunk) - { - avatarAddrAndScoresWithRank.Add(( - tupleInTrunk.avatarAddr, - tupleInTrunk.score, - currentRank)); - } - - trunk.Clear(); - if (i < orderedTuples.Count - 1) - { - trunk.Add(tuple); - currentScore = tuple.score; - currentRank++; - continue; - } - - avatarAddrAndScoresWithRank.Add(( - tuple.avatarAddr, - tuple.score, - currentRank + 1)); - } - - return avatarAddrAndScoresWithRank; - } - - /// - /// Retrieve a list of arena participants based on the provided world state, avatar address list, and avatar addresses with scores and ranks. - /// - /// The world state from which to retrieve the arena participants. - /// The list of avatar addresses to filter the matching participants. - /// The list of avatar addresses with their scores and ranks. - /// A list of arena participants. - public static List GetArenaParticipants(IWorldState worldState, List
avatarAddrList, List<(Address avatarAddr, int score, int rank)> avatarAddrAndScoresWithRank) - { - var runeListSheet = worldState.GetSheet(); - var costumeSheet = worldState.GetSheet(); - var characterSheet = worldState.GetSheet(); - var runeOptionSheet = worldState.GetSheet(); - var runeIds = runeListSheet.Values.Select(x => x.Id).ToList(); - var row = characterSheet[GameConfig.DefaultAvatarCharacterId]; - CollectionSheet collectionSheet = new CollectionSheet(); - var collectionStates = worldState.GetCollectionStates(avatarAddrList); - bool collectionSheetExist = true; - try - { - collectionSheet = worldState.GetSheet(); - } - catch (Exception) - { - collectionSheetExist = false; - } - - var result = avatarAddrAndScoresWithRank.Select(tuple => - { - var (avatarAddr, score, rank) = tuple; - var runeStates = worldState.GetRuneState(avatarAddr, out _); - var avatar = worldState.GetAvatarState(avatarAddr, getWorldInformation: false, getQuestList: false); - var itemSlotState = - worldState.GetLegacyState(ItemSlotState.DeriveAddress(avatarAddr, BattleType.Arena)) is - List itemSlotList - ? new ItemSlotState(itemSlotList) - : new ItemSlotState(BattleType.Arena); - - var runeSlotState = - worldState.GetLegacyState(RuneSlotState.DeriveAddress(avatarAddr, BattleType.Arena)) is - List runeSlotList - ? new RuneSlotState(runeSlotList) - : new RuneSlotState(BattleType.Arena); - - var equippedRuneStates = new List(); - foreach (var runeId in runeSlotState.GetRuneSlot().Select(slot => slot.RuneId)) - { - if (!runeId.HasValue) - { - continue; - } - - if (runeStates.TryGetRuneState(runeId.Value, out var runeState)) - { - equippedRuneStates.Add(runeState); - } - } - - var equipments = itemSlotState.Equipments - .Select(guid => - avatar.inventory.Equipments.FirstOrDefault(x => x.ItemId == guid)) - .Where(item => item != null).ToList(); - var costumes = itemSlotState.Costumes - .Select(guid => - avatar.inventory.Costumes.FirstOrDefault(x => x.ItemId == guid)) - .Where(item => item != null).ToList(); - var runeOptions = StateQuery.GetRuneOptions(equippedRuneStates, runeOptionSheet); - var collectionExist = collectionStates.ContainsKey(avatarAddr); - var collectionModifiers = new List(); - if (collectionSheetExist && collectionExist) - { - var collectionState = collectionStates[avatarAddr]; - foreach (var collectionId in collectionState.Ids) - { - collectionModifiers.AddRange(collectionSheet[collectionId].StatModifiers); - } - } - - var cp = CPHelper.TotalCP(equipments, costumes, runeOptions, avatar.level, row, costumeSheet, collectionModifiers, - RuneHelper.CalculateRuneLevelBonus(runeStates, runeListSheet, worldState.GetSheet()) - ); - var portraitId = StateQuery.GetPortraitId(equipments, costumes); - return new ArenaParticipant( - avatarAddr, - score, - rank, - avatar, - portraitId, - 0, - 0, - cp - ); - }).ToList(); - return result; - } - - /// - /// Prepares the arena participants by syncing the arena cache. - /// - public void PrepareArenaParticipants() - { - _logger.Information("[ArenaParticipantsWorker]Start Sync Arena Cache"); - var sw = new Stopwatch(); - sw.Start(); - // Copy from NineChronicles RxProps.Arena - // https://github.com/planetarium/NineChronicles/blob/80.0.1/nekoyume/Assets/_Scripts/State/RxProps.Arena.cs#L279 - var blockChain = _context.BlockChain; - if (blockChain is null) - { - _logger.Warning("[ArenaParticipantsWorker]BlockChain is null"); - throw new Exception(); - } - - var tip = blockChain.Tip; - var blockIndex = blockChain.Tip.Index; - var worldState = blockChain.GetWorldState(tip.Hash); - var currentRoundData = GetRoundData(worldState, blockIndex); - var participants = GetArenaParticipantsState(worldState, currentRoundData); - var cacheKey = $"{currentRoundData.ChampionshipId}_{currentRoundData.Round}"; - if (participants is null) - { - _cache.ArenaParticipantsCache.Set(cacheKey, new List()); - _logger.Information("[ArenaParticipantsWorker] participants({CacheKey}) is null. set empty list", cacheKey); - return; - } - - var avatarAddrList = participants.AvatarAddresses; - var avatarAddrAndScoresWithRank = AvatarAddrAndScoresWithRank(avatarAddrList, currentRoundData, worldState); - var result = GetArenaParticipants(worldState, avatarAddrList, avatarAddrAndScoresWithRank); - _cache.ArenaParticipantsCache.Set(cacheKey, result, TimeSpan.FromHours(1)); - sw.Stop(); - _logger.Information("[ArenaParticipantsWorker]Set Arena Cache[{CacheKey}]: {Elapsed}", cacheKey, sw.Elapsed); - } -} From 9549fa77ffcc872c314095b4e0588bfca1ca5434 Mon Sep 17 00:00:00 2001 From: upa-r-upa Date: Sun, 6 Oct 2024 19:37:57 +0900 Subject: [PATCH 02/15] fix build --- NineChronicles.Headless.Executable/Program.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/NineChronicles.Headless.Executable/Program.cs b/NineChronicles.Headless.Executable/Program.cs index c4a0fc92c..db5821b8f 100644 --- a/NineChronicles.Headless.Executable/Program.cs +++ b/NineChronicles.Headless.Executable/Program.cs @@ -476,11 +476,6 @@ IActionLoader MakeSingleActionLoader() }) ); - // worker - if (arenaParticipantsSync) - { - services.AddHostedService(_ => new ArenaParticipantsWorker(arenaMemoryCache, standaloneContext, headlessConfig.ArenaParticipantsSyncInterval)); - } services.AddSingleton(arenaMemoryCache); }); From d562380d63a87edfff3157121c0aab69d280f354 Mon Sep 17 00:00:00 2001 From: Suho Lee Date: Mon, 7 Oct 2024 16:52:54 +0900 Subject: [PATCH 03/15] fix: use private codec instead of static Codec --- NineChronicles.Headless/BlockChainService.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/NineChronicles.Headless/BlockChainService.cs b/NineChronicles.Headless/BlockChainService.cs index eb4dcbc72..0c2bff96f 100644 --- a/NineChronicles.Headless/BlockChainService.cs +++ b/NineChronicles.Headless/BlockChainService.cs @@ -34,7 +34,6 @@ namespace NineChronicles.Headless { public class BlockChainService : ServiceBase, IBlockChainService { - private static readonly Codec Codec = new Codec(); private BlockChain _blockChain; private Swarm _swarm; private RpcContext _context; @@ -346,7 +345,7 @@ public UnaryResult GetBalanceByStateRootHash( public UnaryResult GetTip() { Bencodex.Types.Dictionary headerDict = _blockChain.Tip.MarshalBlock(); - byte[] headerBytes = Codec.Encode(headerDict); + byte[] headerBytes = _codec.Encode(headerDict); return new UnaryResult(headerBytes); } From 442eeadae33824671c0ceeb1eb2a4ca46a76fcb9 Mon Sep 17 00:00:00 2001 From: hriprsd Date: Wed, 9 Oct 2024 15:43:39 +0530 Subject: [PATCH 04/15] Creating unified Dockerfile for arm/amd arch --- Dockerfile | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6e03a4942..bfa23c20a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,8 @@ -FROM mcr.microsoft.com/dotnet/sdk:8.0-jammy AS build-env +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env WORKDIR /app ARG COMMIT +ARG TARGETPLATFORM +ARG BUILDPLATFORM # Copy csproj and restore as distinct layers COPY ./Lib9c/Lib9c/Lib9c.csproj ./Lib9c/ @@ -16,23 +18,40 @@ RUN dotnet restore NineChronicles.Headless.Executable # Copy everything else and build COPY . ./ -RUN dotnet publish NineChronicles.Headless.Executable/NineChronicles.Headless.Executable.csproj \ +RUN < Date: Wed, 9 Oct 2024 15:47:59 +0530 Subject: [PATCH 05/15] creating unified ACC dockerfile to support multiple arch --- Dockerfile.ACC | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Dockerfile.ACC b/Dockerfile.ACC index 515c74228..cfe01cbf5 100644 --- a/Dockerfile.ACC +++ b/Dockerfile.ACC @@ -2,6 +2,8 @@ FROM mcr.microsoft.com/dotnet/sdk:8.0-jammy AS build-env WORKDIR /app ARG COMMIT +ARG TARGETPLATFORM +ARG BUILDPLATFORM # Copy csproj and restore as distinct layers COPY ./Lib9c/Lib9c/Lib9c.csproj ./Lib9c/ @@ -13,15 +15,33 @@ RUN dotnet restore NineChronicles.Headless.AccessControlCenter # Copy everything else and build COPY . ./ -RUN dotnet publish NineChronicles.Headless.AccessControlCenter/NineChronicles.Headless.AccessControlCenter.csproj \ +RUN < Date: Wed, 9 Oct 2024 15:51:32 +0530 Subject: [PATCH 06/15] updating build ARGS for multi arch support --- .github/workflows/push_docker_image.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/push_docker_image.yml b/.github/workflows/push_docker_image.yml index 90bde4c02..445c39e18 100644 --- a/.github/workflows/push_docker_image.yml +++ b/.github/workflows/push_docker_image.yml @@ -54,6 +54,8 @@ jobs: -f ${{ matrix.docker.dockerfile }}.amd64 \ -t ${{ matrix.docker.repo }}:git-${{ github.sha }}-amd64 \ --build-arg COMMIT=git-${{ github.sha }} + --build-arg TARGETPLATFORM=linux/amd64 + --build-arg BUILDPLATFORM=linux/amd64 docker push ${{ matrix.docker.repo }}:git-${{ github.sha }}-amd64 - name: build-and-push-arm64v8 run: | @@ -61,6 +63,8 @@ jobs: -f ${{ matrix.docker.dockerfile }}.arm64v8 \ -t ${{ matrix.docker.repo }}:git-${{ github.sha }}-arm64v8 \ --build-arg COMMIT=git-${{ github.sha }} + --build-arg TARGETPLATFORM=linux/arm64 + --build-arg BUILDPLATFORM=linux/arm64 docker push ${{ matrix.docker.repo }}:git-${{ github.sha }}-arm64v8 - name: merge-manifest-and-push run: | From d4ed30312a9ac70a928ca20734bd5975b0de177d Mon Sep 17 00:00:00 2001 From: hprasa638 Date: Mon, 14 Oct 2024 12:12:18 +0530 Subject: [PATCH 07/15] fix:build arg, base image --- .github/workflows/push_docker_image.yml | 2 -- Dockerfile | 3 +-- Dockerfile.ACC | 3 +-- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/push_docker_image.yml b/.github/workflows/push_docker_image.yml index 445c39e18..b05186d10 100644 --- a/.github/workflows/push_docker_image.yml +++ b/.github/workflows/push_docker_image.yml @@ -55,7 +55,6 @@ jobs: -t ${{ matrix.docker.repo }}:git-${{ github.sha }}-amd64 \ --build-arg COMMIT=git-${{ github.sha }} --build-arg TARGETPLATFORM=linux/amd64 - --build-arg BUILDPLATFORM=linux/amd64 docker push ${{ matrix.docker.repo }}:git-${{ github.sha }}-amd64 - name: build-and-push-arm64v8 run: | @@ -64,7 +63,6 @@ jobs: -t ${{ matrix.docker.repo }}:git-${{ github.sha }}-arm64v8 \ --build-arg COMMIT=git-${{ github.sha }} --build-arg TARGETPLATFORM=linux/arm64 - --build-arg BUILDPLATFORM=linux/arm64 docker push ${{ matrix.docker.repo }}:git-${{ github.sha }}-arm64v8 - name: merge-manifest-and-push run: | diff --git a/Dockerfile b/Dockerfile index bfa23c20a..cea86d51d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,6 @@ FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env WORKDIR /app ARG COMMIT ARG TARGETPLATFORM -ARG BUILDPLATFORM # Copy csproj and restore as distinct layers COPY ./Lib9c/Lib9c/Lib9c.csproj ./Lib9c/ @@ -44,7 +43,7 @@ fi EOF # Build runtime image -FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0-bookworm-slim +FROM --platform=$TARGETPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0 WORKDIR /app COPY --from=build-env /app/out . diff --git a/Dockerfile.ACC b/Dockerfile.ACC index cfe01cbf5..da97859a6 100644 --- a/Dockerfile.ACC +++ b/Dockerfile.ACC @@ -3,7 +3,6 @@ FROM mcr.microsoft.com/dotnet/sdk:8.0-jammy AS build-env WORKDIR /app ARG COMMIT ARG TARGETPLATFORM -ARG BUILDPLATFORM # Copy csproj and restore as distinct layers COPY ./Lib9c/Lib9c/Lib9c.csproj ./Lib9c/ @@ -41,7 +40,7 @@ fi EOF # Build runtime image -FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0-bookworm-slim +FROM --platform=$TARGETPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0 WORKDIR /app RUN apt-get update && apt-get install -y libc6-dev COPY --from=build-env /app/out . From 2355b36203f5e065786d9f3a2298779c51084e61 Mon Sep 17 00:00:00 2001 From: hriprsd Date: Tue, 15 Oct 2024 12:04:40 +0530 Subject: [PATCH 08/15] adding \ to treat line breaks as single command --- .github/workflows/push_docker_image.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push_docker_image.yml b/.github/workflows/push_docker_image.yml index b05186d10..bd0911e71 100644 --- a/.github/workflows/push_docker_image.yml +++ b/.github/workflows/push_docker_image.yml @@ -53,7 +53,7 @@ jobs: docker build . \ -f ${{ matrix.docker.dockerfile }}.amd64 \ -t ${{ matrix.docker.repo }}:git-${{ github.sha }}-amd64 \ - --build-arg COMMIT=git-${{ github.sha }} + --build-arg COMMIT=git-${{ github.sha }} \ --build-arg TARGETPLATFORM=linux/amd64 docker push ${{ matrix.docker.repo }}:git-${{ github.sha }}-amd64 - name: build-and-push-arm64v8 @@ -61,7 +61,7 @@ jobs: docker build . \ -f ${{ matrix.docker.dockerfile }}.arm64v8 \ -t ${{ matrix.docker.repo }}:git-${{ github.sha }}-arm64v8 \ - --build-arg COMMIT=git-${{ github.sha }} + --build-arg COMMIT=git-${{ github.sha }} \ --build-arg TARGETPLATFORM=linux/arm64 docker push ${{ matrix.docker.repo }}:git-${{ github.sha }}-arm64v8 - name: merge-manifest-and-push From 386bf55a4f4ae569ab0e7f9e2d13523e40201801 Mon Sep 17 00:00:00 2001 From: moreal Date: Tue, 15 Oct 2024 19:45:11 +0900 Subject: [PATCH 09/15] Bump lib9c --- Lib9c | 2 +- .../GraphTypes/States/Models/AvatarStateTypeTest.cs | 4 ++-- .../GraphTypes/States/CombinationSlotStateType.cs | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Lib9c b/Lib9c index 810b1d86a..d72847989 160000 --- a/Lib9c +++ b/Lib9c @@ -1 +1 @@ -Subproject commit 810b1d86a3f11f9780c270671b845bfa7c8bd0a1 +Subproject commit d7284798938ba67750a05fd9e09317a550cff161 diff --git a/NineChronicles.Headless.Tests/GraphTypes/States/Models/AvatarStateTypeTest.cs b/NineChronicles.Headless.Tests/GraphTypes/States/Models/AvatarStateTypeTest.cs index 2bda35e0f..b2e54fc67 100644 --- a/NineChronicles.Headless.Tests/GraphTypes/States/Models/AvatarStateTypeTest.cs +++ b/NineChronicles.Headless.Tests/GraphTypes/States/Models/AvatarStateTypeTest.cs @@ -143,9 +143,9 @@ public async Task QueryActionPoint(bool modern, Dictionary expec ["combinationSlots"] = new World(MockWorldState.CreateModern()).GetAllCombinationSlotState(Fixtures.AvatarAddress).Select(x => new Dictionary { ["address"] = x.address.ToString(), - ["unlockBlockIndex"] = x.UnlockBlockIndex, + ["unlockBlockIndex"] = x.WorkCompleteBlockIndex, ["isUnlocked"] = x.IsUnlocked, - ["startBlockIndex"] = x.StartBlockIndex, + ["startBlockIndex"] = x.WorkStartBlockIndex, ["petId"] = x.PetId }).ToArray(), } diff --git a/NineChronicles.Headless/GraphTypes/States/CombinationSlotStateType.cs b/NineChronicles.Headless/GraphTypes/States/CombinationSlotStateType.cs index c83945f50..f798e4b59 100644 --- a/NineChronicles.Headless/GraphTypes/States/CombinationSlotStateType.cs +++ b/NineChronicles.Headless/GraphTypes/States/CombinationSlotStateType.cs @@ -13,13 +13,13 @@ public CombinationSlotStateType() description: "Address of combination slot.", resolve: context => context.Source.address); Field>( - nameof(CombinationSlotState.UnlockBlockIndex), + "unlockBlockIndex", description: "Block index at the combination slot can be usable.", - resolve: context => context.Source.UnlockBlockIndex); + resolve: context => context.Source.WorkCompleteBlockIndex); Field>( - nameof(CombinationSlotState.StartBlockIndex), + "startBlockIndex", description: "Block index at the combination started.", - resolve: context => context.Source.StartBlockIndex); + resolve: context => context.Source.WorkStartBlockIndex); Field( nameof(CombinationSlotState.PetId), description: "Pet id used in equipment", From 9dfde00969240ca44c64c630b426d530585d6a3d Mon Sep 17 00:00:00 2001 From: eugene-hong <58686228+eugene-doobu@users.noreply.github.com> Date: Mon, 21 Oct 2024 17:42:53 +0900 Subject: [PATCH 10/15] bump lib9c --- Lib9c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib9c b/Lib9c index d72847989..f6382bfea 160000 --- a/Lib9c +++ b/Lib9c @@ -1 +1 @@ -Subproject commit d7284798938ba67750a05fd9e09317a550cff161 +Subproject commit f6382bfea11a68e794ae3ff13426064f121b500d From d967756363e1729295fba73a2f0bc97652be8fc8 Mon Sep 17 00:00:00 2001 From: hyeon Date: Tue, 22 Oct 2024 18:20:04 +0900 Subject: [PATCH 11/15] Bump lib9c --- Lib9c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib9c b/Lib9c index f6382bfea..a8058b946 160000 --- a/Lib9c +++ b/Lib9c @@ -1 +1 @@ -Subproject commit f6382bfea11a68e794ae3ff13426064f121b500d +Subproject commit a8058b946c3d93a61bf4e4d977cb04900562ea13 From f2fe50650e08912b71c4665cb3d7cc292a4bfe18 Mon Sep 17 00:00:00 2001 From: hyeon Date: Tue, 22 Oct 2024 18:28:27 +0900 Subject: [PATCH 12/15] Bump lib9c --- Lib9c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib9c b/Lib9c index a8058b946..55b6e9e8c 160000 --- a/Lib9c +++ b/Lib9c @@ -1 +1 @@ -Subproject commit a8058b946c3d93a61bf4e4d977cb04900562ea13 +Subproject commit 55b6e9e8cf83c8bf32a2d809b204803ca6fdc793 From e4ed419287a86b120e91e934848f9bdbc10377f6 Mon Sep 17 00:00:00 2001 From: hyeon Date: Thu, 24 Oct 2024 10:23:57 +0900 Subject: [PATCH 13/15] Bump lib9c: Bump libplanet to 5.3.2-alpha.1 --- Lib9c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib9c b/Lib9c index 55b6e9e8c..f33874a65 160000 --- a/Lib9c +++ b/Lib9c @@ -1 +1 @@ -Subproject commit 55b6e9e8cf83c8bf32a2d809b204803ca6fdc793 +Subproject commit f33874a6536e6ba05c789a18cda47d5a4b0cafb7 From 87eb1492592ea0b93b3bbf5a89ab27aba5fd5279 Mon Sep 17 00:00:00 2001 From: hyeon Date: Fri, 25 Oct 2024 13:31:56 +0900 Subject: [PATCH 14/15] Bump lib9c: Fix option count --- Lib9c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib9c b/Lib9c index f33874a65..d4cfc48a4 160000 --- a/Lib9c +++ b/Lib9c @@ -1 +1 @@ -Subproject commit f33874a6536e6ba05c789a18cda47d5a4b0cafb7 +Subproject commit d4cfc48a4f737ae8eeffb1a9b4cf89fe6fc6cd19 From 29c4ac506010d433134d2eeda6dc77a0227c7958 Mon Sep 17 00:00:00 2001 From: hyeon Date: Mon, 28 Oct 2024 11:10:24 +0900 Subject: [PATCH 15/15] Bump lib9c to 1.19.0 --- Lib9c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib9c b/Lib9c index d4cfc48a4..9f1661102 160000 --- a/Lib9c +++ b/Lib9c @@ -1 +1 @@ -Subproject commit d4cfc48a4f737ae8eeffb1a9b4cf89fe6fc6cd19 +Subproject commit 9f1661102a74ef38c4715061c7e8a36d8c544366