Skip to content

Commit

Permalink
Merge pull request #3050 from planetarium/release/1.20.0
Browse files Browse the repository at this point in the history
Backmerge 1.20.0
  • Loading branch information
U-lis authored Nov 29, 2024
2 parents 8435d28 + 195cb90 commit 4ac5bc3
Show file tree
Hide file tree
Showing 344 changed files with 15,806 additions and 3,079 deletions.
88 changes: 0 additions & 88 deletions .Lib9c.Benchmarks/Actions/AutoJoinGuild.cs

This file was deleted.

128 changes: 128 additions & 0 deletions .Lib9c.Benchmarks/Actions/MigrateDelegation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
using BenchmarkDotNet.Attributes;
using Bencodex.Types;
using Lib9c.Tests.Action;
using Lib9c.Tests.Util;
using Libplanet.Action.State;
using Libplanet.Crypto;
using Libplanet.Mocks;
using Nekoyume;
using Nekoyume.Action.Guild;
using Nekoyume.Action.Guild.Migration;
using Nekoyume.Action.Guild.Migration.LegacyModels;
using Nekoyume.Extensions;
using Nekoyume.TypedAddress;

namespace Lib9c.Benchmarks.Actions;

public class MigrateDelegation
{
private GuildAddress planetariumGuild = AddressUtil.CreateGuildAddress();
private AgentAddress target = AddressUtil.CreateAgentAddress();
private AgentAddress signer = AddressUtil.CreateAgentAddress();
private IWorld worldEmpty;
private IWorld worldBeforeGuildMigration;
private IWorld worldBeforeParticipantMigration;
private IWorld worldAfterMigration;

[GlobalSetup]
public void Setup()
{
worldEmpty = new World(MockUtil.MockModernWorldState);
var legacyPlanetariumGuild = new LegacyGuild(GuildConfig.PlanetariumGuildOwner);
var legacyPlanetariumGuildParticipant = new LegacyGuildParticipant(planetariumGuild);
worldBeforeGuildMigration = worldEmpty
.MutateAccount(
Addresses.Guild,
account => account.SetState(planetariumGuild, legacyPlanetariumGuild.Bencoded))
.MutateAccount(
Addresses.GuildParticipant,
account => account.SetState(GuildConfig.PlanetariumGuildOwner, legacyPlanetariumGuildParticipant.Bencoded))
.MutateAccount(
Addresses.GuildParticipant,
account => account.SetState(target, legacyPlanetariumGuildParticipant.Bencoded))
.MutateAccount(
Addresses.GuildMemberCounter,
account => account.SetState(planetariumGuild, (Integer)2));
worldBeforeParticipantMigration = new MigratePlanetariumGuild().Execute(new ActionContext
{
PreviousState = worldBeforeGuildMigration,
Signer = new PrivateKey().Address,
});
}

[Benchmark]
public void Execute_Empty()
{
var action = new Nekoyume.Action.Guild.Migration.MigrateDelegation(target);
try
{
action.Execute(new ActionContext
{
IsPolicyAction = false,
PreviousState = worldEmpty,
Signer = signer,
});
}
catch
{
// Do nothing.
}
}

[Benchmark]
public void Execute_Before_Guild_Migration()
{
var action = new Nekoyume.Action.Guild.Migration.MigrateDelegation(target);
try
{
action.Execute(new ActionContext
{
IsPolicyAction = false,
PreviousState = worldBeforeGuildMigration,
Signer = signer,
});
}
catch
{
// Do nothing.
}
}

[Benchmark]
public void Execute_Before_Participant_Migration()
{
var action = new Nekoyume.Action.Guild.Migration.MigrateDelegation(target);
try
{
action.Execute(new ActionContext
{
IsPolicyAction = false,
PreviousState = worldBeforeParticipantMigration,
Signer = signer,
});
}
catch
{
// Do nothing.
}
}

[Benchmark]
public void Execute_After_Migration()
{
var action = new Nekoyume.Action.Guild.Migration.MigrateDelegation(target);
try
{
action.Execute(new ActionContext
{
IsPolicyAction = false,
PreviousState = worldAfterMigration,
Signer = signer,
});
}
catch
{
// Do nothing.
}
}
}
110 changes: 0 additions & 110 deletions .Lib9c.Benchmarks/Actions/MigratePledgeToGuild.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void LoadPlainValue(IValue plainValue)

public IWorld Execute(IActionContext context)
{
context.UseGas(1);
GasTracer.UseGas(1);
return context.PreviousState;
}
}
Expand Down
1 change: 1 addition & 0 deletions .Lib9c.Miner.Tests/Lib9c.Proposer.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Lib9c.Policy\Lib9c.Policy.csproj" />
<ProjectReference Include="..\Lib9c.Proposer\Lib9c.Proposer.csproj" />
</ItemGroup>

Expand Down
Loading

0 comments on commit 4ac5bc3

Please sign in to comment.