Skip to content

Commit

Permalink
Merge pull request #2394 from limebell/chore/remove-legacy-avatar
Browse files Browse the repository at this point in the history
Remove unnecessary legacy keys
  • Loading branch information
limebell authored Feb 15, 2024
2 parents 900fa7e + 028c646 commit d87c61b
Show file tree
Hide file tree
Showing 34 changed files with 21 additions and 135 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using Nekoyume.Model;
using Nekoyume.Module;
using Xunit;
using static Lib9c.SerializeKeys;

namespace Lib9c.DevExtensions.Tests.Action.Craft
{
Expand All @@ -21,13 +20,11 @@ public class UnlockCraftActionTest
private readonly Address _agentAddress;
private readonly Address _avatarAddress;
private readonly IWorld _initialStateV2;
private readonly Address _worldInformationAddress;

public UnlockCraftActionTest()
{
(_tableSheets, _agentAddress, _avatarAddress, _, _initialStateV2) =
InitializeUtil.InitializeStates(isDevEx: true);
_worldInformationAddress = _avatarAddress.Derive(LegacyWorldInformationKey);
}

[Theory]
Expand Down Expand Up @@ -58,8 +55,8 @@ public void StageUnlockTest(string typeIdentifier, int expectedStage)
BlockIndex = 0L
});

var worldInformation =
new WorldInformation((Dictionary)state.GetLegacyState(_worldInformationAddress));
var avatarState = state.GetAvatarState(_avatarAddress);
var worldInformation = avatarState.worldInformation;
Assert.True(worldInformation.IsStageCleared(expectedStage));
}
}
Expand Down
2 changes: 2 additions & 0 deletions .Lib9c.DevExtensions.Tests/Action/ManipulateStateTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,8 @@ public void SetInventoryState(Inventory targetInventory)
[MemberData(nameof(FetchWorldInfo))]
public void SetWorldInformation(int lastClearedStage, WorldInformation targetInfo)
{
// FIXME: The test now writes worldInformation in LegacyAccount,
// which should be moved to Addresses.WorldInformation
var state = Manipulate(
_initialStateV2,
new List<(Address, Address, IValue)>
Expand Down
2 changes: 0 additions & 2 deletions .Lib9c.DevExtensions.Tests/Action/Stage/ClearStageTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ public class ClearStageTest
private readonly Address _agentAddress;
private readonly Address _avatarAddress;
private readonly IWorld _initialStateV2;
private readonly Address _worldInfoAddress;

public ClearStageTest()
{
(_tableSheets, _agentAddress, _avatarAddress, _, _initialStateV2) =
InitializeUtil.InitializeStates(isDevEx: true);
_worldInfoAddress = _avatarAddress.Derive(SerializeKeys.LegacyWorldInformationKey);
}

[Fact]
Expand Down
4 changes: 0 additions & 4 deletions .Lib9c.Tests/Action/EventConsumableItemCrafts0Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ namespace Lib9c.Tests.Action
using Nekoyume.TableData;
using Nekoyume.TableData.Event;
using Xunit;
using static Lib9c.SerializeKeys;

public class EventConsumableItemCrafts0Test
{
Expand All @@ -37,9 +36,6 @@ public EventConsumableItemCrafts0Test()

_agentAddress = new PrivateKey().Address;
_avatarAddress = _agentAddress.Derive("avatar");
var inventoryAddr = _avatarAddress.Derive(LegacyInventoryKey);
var worldInformationAddr = _avatarAddress.Derive(LegacyWorldInformationKey);
var questListAddr = _avatarAddress.Derive(LegacyQuestListKey);

var agentState = new AgentState(_agentAddress);
agentState.avatarAddresses.Add(0, _avatarAddress);
Expand Down
4 changes: 0 additions & 4 deletions .Lib9c.Tests/Action/EventMaterialItemCrafts0Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ public EventMaterialItemCrafts0Test()
_agentAddress = new PrivateKey().Address;
_avatarAddress = _agentAddress.Derive("avatar");

var inventoryAddr = _avatarAddress.Derive(LegacyInventoryKey);
var worldInformationAddr = _avatarAddress.Derive(LegacyWorldInformationKey);
var questListAddr = _avatarAddress.Derive(LegacyQuestListKey);

var agentState = new AgentState(_agentAddress);
agentState.avatarAddresses.Add(0, _avatarAddress);

Expand Down
8 changes: 0 additions & 8 deletions .Lib9c.Tests/Action/HackAndSlashRandomBuffTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ namespace Lib9c.Tests.Action
using Nekoyume.TableData;
using Nekoyume.TableData.Crystal;
using Xunit;
using static Lib9c.SerializeKeys;

public class HackAndSlashRandomBuffTest
{
Expand All @@ -29,10 +28,6 @@ public class HackAndSlashRandomBuffTest
private readonly Address _avatarAddress;
private readonly AvatarState _avatarState;

private readonly Address _inventoryAddress;
private readonly Address _worldInformationAddress;
private readonly Address _questListAddress;

private readonly Address _rankingMapAddress;

private readonly WeeklyArenaState _weeklyArenaState;
Expand Down Expand Up @@ -65,9 +60,6 @@ public HackAndSlashRandomBuffTest()
{
level = 100,
};
_inventoryAddress = _avatarAddress.Derive(LegacyInventoryKey);
_worldInformationAddress = _avatarAddress.Derive(LegacyWorldInformationKey);
_questListAddress = _avatarAddress.Derive(LegacyQuestListKey);
agentState.avatarAddresses.Add(0, _avatarAddress);

_weeklyArenaState = new WeeklyArenaState(0);
Expand Down
16 changes: 0 additions & 16 deletions .Lib9c.Tests/Action/RuneEnhancementTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ namespace Lib9c.Tests.Action
using Nekoyume.Module;
using Nekoyume.TableData;
using Xunit;
using static Lib9c.SerializeKeys;

public class RuneEnhancementTest
{
Expand All @@ -32,9 +31,6 @@ public void Execute(int seed)
{
var agentAddress = new PrivateKey().Address;
var avatarAddress = new PrivateKey().Address;
var inventoryAddress = avatarAddress.Derive(LegacyInventoryKey);
var worldInformationAddress = avatarAddress.Derive(LegacyWorldInformationKey);
var questListAddress = avatarAddress.Derive(LegacyQuestListKey);
var sheets = TableSheetsImporter.ImportSheets();
var tableSheets = new TableSheets(sheets);
var blockIndex = tableSheets.WorldBossListSheet.Values
Expand Down Expand Up @@ -190,9 +186,6 @@ public void Execute_RuneCostNotFoundException()
{
var agentAddress = new PrivateKey().Address;
var avatarAddress = new PrivateKey().Address;
var inventoryAddress = avatarAddress.Derive(LegacyInventoryKey);
var worldInformationAddress = avatarAddress.Derive(LegacyWorldInformationKey);
var questListAddress = avatarAddress.Derive(LegacyQuestListKey);
var sheets = TableSheetsImporter.ImportSheets();
var tableSheets = new TableSheets(sheets);
var blockIndex = tableSheets.WorldBossListSheet.Values
Expand Down Expand Up @@ -249,9 +242,6 @@ public void Execute_RuneCostDataNotFoundException()
{
var agentAddress = new PrivateKey().Address;
var avatarAddress = new PrivateKey().Address;
var inventoryAddress = avatarAddress.Derive(LegacyInventoryKey);
var worldInformationAddress = avatarAddress.Derive(LegacyWorldInformationKey);
var questListAddress = avatarAddress.Derive(LegacyQuestListKey);
var sheets = TableSheetsImporter.ImportSheets();
var tableSheets = new TableSheets(sheets);
var blockIndex = tableSheets.WorldBossListSheet.Values
Expand Down Expand Up @@ -323,9 +313,6 @@ public void Execute_NotEnoughFungibleAssetValueException(bool ncg, bool crystal,
{
var agentAddress = new PrivateKey().Address;
var avatarAddress = new PrivateKey().Address;
var inventoryAddress = avatarAddress.Derive(LegacyInventoryKey);
var worldInformationAddress = avatarAddress.Derive(LegacyWorldInformationKey);
var questListAddress = avatarAddress.Derive(LegacyQuestListKey);
var sheets = TableSheetsImporter.ImportSheets();
var tableSheets = new TableSheets(sheets);
var blockIndex = tableSheets.WorldBossListSheet.Values
Expand Down Expand Up @@ -442,9 +429,6 @@ public void Execute_TryCountIsZeroException()
{
var agentAddress = new PrivateKey().Address;
var avatarAddress = new PrivateKey().Address;
var inventoryAddress = avatarAddress.Derive(LegacyInventoryKey);
var worldInformationAddress = avatarAddress.Derive(LegacyWorldInformationKey);
var questListAddress = avatarAddress.Derive(LegacyQuestListKey);
var sheets = TableSheetsImporter.ImportSheets();
var tableSheets = new TableSheets(sheets);
var blockIndex = tableSheets.WorldBossListSheet.Values
Expand Down
12 changes: 7 additions & 5 deletions .Lib9c.Tests/Action/Scenario/AuraScenarioTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ namespace Lib9c.Tests.Action.Scenario
using Nekoyume.Module;
using Nekoyume.TableData;
using Xunit;
using static SerializeKeys;

public class AuraScenarioTest
{
Expand Down Expand Up @@ -142,10 +141,13 @@ public void Raid()
avatarState.worldInformation.ClearStage(1, i + 1, 0, _tableSheets.WorldSheet, _tableSheets.WorldUnlockSheet);
}

var prevState = _initialState.SetLegacyState(
_avatarAddress.Derive(LegacyWorldInformationKey),
avatarState.worldInformation.Serialize()
);
var prevState = _initialState.SetAvatarState(
_avatarAddress,
avatarState,
false,
false,
true,
false);

var raid = new Raid
{
Expand Down
12 changes: 7 additions & 5 deletions .Lib9c.Tests/Action/SellTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ namespace Lib9c.Tests.Action
using Serilog;
using Xunit;
using Xunit.Abstractions;
using static Lib9c.SerializeKeys;

public class SellTest
{
Expand Down Expand Up @@ -350,10 +349,13 @@ public void Execute_Throw_ItemDoesNotExistException(bool isLock)
var orderLock = new OrderLock(Guid.NewGuid());
_avatarState.inventory.AddItem(tradableItem, 1, orderLock);
Assert.True(_avatarState.inventory.TryGetLockedItem(orderLock, out _));
_initialState = _initialState.SetLegacyState(
_avatarAddress.Derive(LegacyInventoryKey),
_avatarState.inventory.Serialize()
);
_initialState = _initialState.SetAvatarState(
_avatarAddress,
_avatarState,
false,
true,
false,
false);
}

var action = new Sell
Expand Down
9 changes: 3 additions & 6 deletions Lib9c.DevExtensions/Action/Craft/UnlockCraftAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using Nekoyume.Model.State;
using Nekoyume.Module;
using Nekoyume.TableData;
using static Lib9c.SerializeKeys;

namespace Lib9c.DevExtensions.Action.Craft
{
Expand Down Expand Up @@ -55,15 +54,13 @@ public override IWorld Execute(IActionContext context)
$"{ActionType.TypeIdentifier} is not valid action");
}

var worldInformation = new WorldInformation(
var avatarState = states.GetAvatarState(AvatarAddress);
avatarState.worldInformation = new WorldInformation(
context.BlockIndex,
states.GetSheet<WorldSheet>(),
targetStage
);
return states.SetLegacyState(
AvatarAddress.Derive(LegacyWorldInformationKey),
worldInformation.Serialize()
);
return states.SetAvatarState(AvatarAddress, avatarState, false, false, true, false);
}

protected override IImmutableDictionary<string, IValue> PlainValueInternal =>
Expand Down
4 changes: 0 additions & 4 deletions Lib9c.DevExtensions/Action/CreateArenaDummy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using Nekoyume.Model.State;
using Nekoyume.Module;
using Nekoyume.TableData;
using static Lib9c.SerializeKeys;

namespace Lib9c.DevExtensions.Action
{
Expand Down Expand Up @@ -85,9 +84,6 @@ public override IWorld Execute(IActionContext context)
}

agentState.avatarAddresses.Add(0, avatarAddress);
var inventoryAddress = avatarAddress.Derive(LegacyInventoryKey);
var worldInformationAddress = avatarAddress.Derive(LegacyWorldInformationKey);
var questListAddress = avatarAddress.Derive(LegacyQuestListKey);

var rankingState = context.PreviousState.GetRankingState();
var rankingMapAddress = rankingState.UpdateRankingMap(avatarAddress);
Expand Down
4 changes: 0 additions & 4 deletions Lib9c.DevExtensions/Action/CreateTestbed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
using Nekoyume.Model.State;
using Nekoyume.Module;
using Nekoyume.TableData;
using static Lib9c.SerializeKeys;

namespace Lib9c.DevExtensions.Action
{
Expand Down Expand Up @@ -90,9 +89,6 @@ public override IWorld Execute(IActionContext context)
_slotIndex
)
);
var inventoryAddress = avatarAddress.Derive(LegacyInventoryKey);
var worldInformationAddress = avatarAddress.Derive(LegacyWorldInformationKey);
var questListAddress = avatarAddress.Derive(LegacyQuestListKey);
var orderReceiptAddress = OrderDigestListState.DeriveAddress(avatarAddress);

// Create Agent and avatar
Expand Down
3 changes: 0 additions & 3 deletions Lib9c/Action/Buy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ public override IWorld Execute(IActionContext context)
ShardedShopStateV2.DeriveAddress(purchaseInfo.ItemSubType, purchaseInfo.OrderId);
Address sellerAgentAddress = purchaseInfo.SellerAgentAddress;
Address sellerAvatarAddress = purchaseInfo.SellerAvatarAddress;
Address sellerInventoryAddress = sellerAvatarAddress.Derive(LegacyInventoryKey);
var sellerWorldInformationAddress = sellerAvatarAddress.Derive(LegacyWorldInformationKey);
Address sellerQuestListAddress = sellerAvatarAddress.Derive(LegacyQuestListKey);
Guid orderId = purchaseInfo.OrderId;
Address orderAddress = Order.DeriveAddress(orderId);
Address digestListAddress = OrderDigestListState.DeriveAddress(sellerAvatarAddress);
Expand Down
3 changes: 0 additions & 3 deletions Lib9c/Action/ChargeActionPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ public override IWorld Execute(IActionContext context)
{
context.UseGas(1);
var states = context.PreviousState;
var inventoryAddress = avatarAddress.Derive(LegacyInventoryKey);
var worldInformationAddress = avatarAddress.Derive(LegacyWorldInformationKey);
var questListAddress = avatarAddress.Derive(LegacyQuestListKey);
var addressesHex = GetSignerAndOtherAddressesHex(context, avatarAddress);
var started = DateTimeOffset.UtcNow;
Log.Debug("{AddressesHex}ChargeActionPoint exec started", addressesHex);
Expand Down
3 changes: 0 additions & 3 deletions Lib9c/Action/CombinationEquipment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ public override IWorld Execute(IActionContext context)
slotIndex
)
);
var inventoryAddress = avatarAddress.Derive(LegacyInventoryKey);
var worldInformationAddress = avatarAddress.Derive(LegacyWorldInformationKey);
var questListAddress = avatarAddress.Derive(LegacyQuestListKey);

var addressesHex = GetSignerAndOtherAddressesHex(context, avatarAddress);
var started = DateTimeOffset.UtcNow;
Expand Down
3 changes: 0 additions & 3 deletions Lib9c/Action/Coupons/RedeemCoupon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ public override IWorld Execute(IActionContext context)
{
context.UseGas(1);
var states = context.PreviousState;
var inventoryAddress = AvatarAddress.Derive(LegacyInventoryKey);
var worldInformationAddress = AvatarAddress.Derive(LegacyWorldInformationKey);
var questListAddress = AvatarAddress.Derive(LegacyQuestListKey);

if (!states.TryGetAvatarState(
context.Signer,
Expand Down
3 changes: 0 additions & 3 deletions Lib9c/Action/CreateAvatar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ public override IWorld Execute(IActionContext context)
index
)
);
var inventoryAddress = avatarAddress.Derive(LegacyInventoryKey);
var worldInformationAddress = avatarAddress.Derive(LegacyWorldInformationKey);
var questListAddress = avatarAddress.Derive(LegacyQuestListKey);

var addressesHex = GetSignerAndOtherAddressesHex(context, avatarAddress);

Expand Down
3 changes: 0 additions & 3 deletions Lib9c/Action/Grinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ public override IWorld Execute(IActionContext context)
context.UseGas(1);
IActionContext ctx = context;
IWorld states = ctx.PreviousState;
var inventoryAddress = AvatarAddress.Derive(LegacyInventoryKey);
var worldInformationAddress = AvatarAddress.Derive(LegacyWorldInformationKey);
var questListAddress = AvatarAddress.Derive(LegacyQuestListKey);
var addressesHex = GetSignerAndOtherAddressesHex(context, AvatarAddress);
var started = DateTimeOffset.UtcNow;
Log.Debug("{AddressesHex}Grinding exec started", addressesHex);
Expand Down
3 changes: 0 additions & 3 deletions Lib9c/Action/Grinding0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ public override IWorld Execute(IActionContext context)
context.UseGas(1);
IActionContext ctx = context;
IWorld states = ctx.PreviousState;
var inventoryAddress = AvatarAddress.Derive(LegacyInventoryKey);
var worldInformationAddress = AvatarAddress.Derive(LegacyWorldInformationKey);
var questListAddress = AvatarAddress.Derive(LegacyQuestListKey);
var addressesHex = GetSignerAndOtherAddressesHex(context, AvatarAddress);
var started = DateTimeOffset.UtcNow;
Log.Debug("{AddressesHex}Grinding exec started", addressesHex);
Expand Down
4 changes: 0 additions & 4 deletions Lib9c/Action/HackAndSlash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,6 @@ public IWorld Execute(
long blockIndex,
IRandom random)
{
var inventoryAddress = AvatarAddress.Derive(LegacyInventoryKey);
var worldInformationAddress = AvatarAddress.Derive(LegacyWorldInformationKey);
var questListAddress = AvatarAddress.Derive(LegacyQuestListKey);

var addressesHex = $"[{signer.ToHex()}, {AvatarAddress.ToHex()}]";
var started = DateTimeOffset.UtcNow;
const string source = "HackAndSlash";
Expand Down
3 changes: 0 additions & 3 deletions Lib9c/Action/ItemEnhancement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ public override IWorld Execute(IActionContext context)
slotIndex
)
);
var inventoryAddress = avatarAddress.Derive(LegacyInventoryKey);
var worldInformationAddress = avatarAddress.Derive(LegacyWorldInformationKey);
var questListAddress = avatarAddress.Derive(LegacyQuestListKey);
var addressesHex = GetSignerAndOtherAddressesHex(context, avatarAddress);

var sw = new Stopwatch();
Expand Down
3 changes: 0 additions & 3 deletions Lib9c/Action/ItemEnhancement10.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,6 @@ public override IWorld Execute(IActionContext context)
slotIndex
)
);
var inventoryAddress = avatarAddress.Derive(LegacyInventoryKey);
var worldInformationAddress = avatarAddress.Derive(LegacyWorldInformationKey);
var questListAddress = avatarAddress.Derive(LegacyQuestListKey);

CheckObsolete(ActionObsoleteConfig.V200030ObsoleteIndex, context);
var arenaSheetAddress = Addresses.GetSheetAddress<ArenaSheet>();
Expand Down
3 changes: 0 additions & 3 deletions Lib9c/Action/ItemEnhancement11.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,6 @@ public override IWorld Execute(IActionContext context)
slotIndex
)
);
var inventoryAddress = avatarAddress.Derive(LegacyInventoryKey);
var worldInformationAddress = avatarAddress.Derive(LegacyWorldInformationKey);
var questListAddress = avatarAddress.Derive(LegacyQuestListKey);

var costSheetV3Address = Addresses.GetSheetAddress<EnhancementCostSheetV3>();
var sheetState = states.GetLegacyState(costSheetV3Address);
Expand Down
Loading

0 comments on commit d87c61b

Please sign in to comment.