Skip to content

Commit

Permalink
Merge pull request #6366 from planetarium/hotfix/240.1.0
Browse files Browse the repository at this point in the history
Hotfix/240.1.0
  • Loading branch information
jonny-jeahyunchoi authored Nov 15, 2024
2 parents 73d782c + 0f15afa commit 340e36e
Show file tree
Hide file tree
Showing 21 changed files with 38 additions and 31 deletions.
Binary file modified nekoyume/Assets/Packages/Libplanet.Action.dll
Binary file not shown.
Binary file modified nekoyume/Assets/Packages/Libplanet.Common.dll
Binary file not shown.
Binary file modified nekoyume/Assets/Packages/Libplanet.Crypto.dll
Binary file not shown.
Binary file modified nekoyume/Assets/Packages/Libplanet.Mocks.dll
Binary file not shown.
Binary file modified nekoyume/Assets/Packages/Libplanet.RocksDBStore.dll
Binary file not shown.
Binary file modified nekoyume/Assets/Packages/Libplanet.Store.dll
Binary file not shown.
Binary file modified nekoyume/Assets/Packages/Libplanet.Types.dll
Binary file not shown.
Binary file modified nekoyume/Assets/Packages/Libplanet.dll
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace BalanceTool.Util
using Libplanet.Action.State;
using Libplanet.Common;
using Libplanet.Crypto;
using Libplanet.Types.Assets;
using Libplanet.Types.Blocks;
using Libplanet.Types.Tx;

Expand Down Expand Up @@ -55,6 +56,10 @@ public IReadOnlyList<EvidenceBase> Evidence
set => _evs = value;
}

public BlockCommit LastCommit => throw new System.NotImplementedException();

public FungibleAssetValue? MaxGasPrice => throw new System.NotImplementedException();

public void UseGas(long gas)
{
_gasUsed += gas;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ private async UniTaskVoid TrackAsync(StateProxy stateProxy)

var prevBlockHash = BlockHash.FromString(sourceCsvRow.PrevBlockHash);
var signerAddr = new Address(sourceCsvRow.SignerAddr);
var stakeAddr = StakeState.DeriveAddress(signerAddr);
var stakeAddr = LegacyStakeState.DeriveAddress(signerAddr);
try
{
var (_, stakeBalance) = stateProxy is null
Expand Down Expand Up @@ -309,7 +309,7 @@ private static OutputCsvRow ToOutputCsvRow(
};
}

var stakeState = new StakeState(dict);
var stakeState = new LegacyStakeState(dict);
#pragma warning disable CS0618
stakeState.CalculateAccumulatedItemRewardsV2(
sourceCsvRow.BlockIndex,
Expand Down
6 changes: 3 additions & 3 deletions nekoyume/Assets/_Scripts/Blockchain/ActionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,19 @@ protected GoldBalanceState GetGoldBalanceState<T>(ActionEvaluation<T> evaluation

protected async UniTask<(
Address stakeAddr,
StakeStateV2? stakeStateV2,
StakeState? stakeStateV2,
FungibleAssetValue deposit,
int stakingLevel,
StakeRegularFixedRewardSheet stakeRegularFixedRewardSheet,
StakeRegularRewardSheet stakeRegularRewardSheet)>
GetStakeStateAsync<T>(ActionEvaluation<T> evaluation) where T : ActionBase
{
var agentAddr = States.Instance.AgentState.address;
var stakeAddr = StakeStateV2.DeriveAddress(agentAddr);
var stakeAddr = StakeState.DeriveAddress(agentAddr);
var agent = Game.Game.instance.Agent;
Address[] sheetAddrArr;
FungibleAssetValue balance;
StakeStateV2? nullableStakeState;
StakeState? nullableStakeState;
if (!StateGetter.TryGetStakeStateV2(evaluation.OutputState, agentAddr, out var stakeStateV2))
{
nullableStakeState = null;
Expand Down
7 changes: 4 additions & 3 deletions nekoyume/Assets/_Scripts/Blockchain/BlockManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
using System.IO;
using System.Net;
using System.Numerics;
using System.Threading.Tasks;
using Bencodex;
using Bencodex.Types;
using Cysharp.Threading.Tasks;
using JetBrains.Annotations;
using Libplanet.Crypto;
using Libplanet.Types.Blocks;
using Libplanet.Types.Consensus;
using Nekoyume.Action;
using Nekoyume.Model.State;
using UnityEngine;
using UnityEngine.Networking;

namespace Nekoyume.Blockchain
{
using Libplanet.Types.Blocks;
public static class BlockManager
{
// Editor가 아닌 환경에서 사용할 제네시스 블록의 파일명입니다.
Expand Down Expand Up @@ -153,12 +153,13 @@ public static Block ProposeGenesisBlock(
initialValidatorSet[proposer] = BigInteger.One;
}

// todo : 스테이킹 추가 수정 이슈 new ValidatorSet() 값 넣어야함.
return BlockHelper.ProposeGenesisBlock(
new ValidatorSet(),
tableSheets,
goldDistributions,
pendingActivationStates,
new AdminState(new Address("F9A15F870701268Bd7bBeA6502eB15F4997f32f9"), 1500000),
initialValidators: initialValidatorSet,
isActivateAdminAddress: false);
}

Expand Down
2 changes: 1 addition & 1 deletion nekoyume/Assets/_Scripts/Blockchain/StateGetter.TryGet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static bool TryGetAvatarState(
public static bool TryGetStakeStateV2(
HashDigest<SHA256> hash,
Address address,
out StakeStateV2 stakeStateV2)
out StakeState stakeStateV2)
{
try
{
Expand Down
7 changes: 4 additions & 3 deletions nekoyume/Assets/_Scripts/Blockchain/StateGetter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ public static GoldBalanceState GetGoldBalanceState(
Game.Game.instance.Agent.GetBalanceAsync(hash, address, currency).Result);
}

public static StakeStateV2? GetStakeStateV2(HashDigest<SHA256> hash, Address address)
public static StakeState? GetStakeStateV2(HashDigest<SHA256> hash, Address address)
{
var stakeStateAddr = StakeStateV2.DeriveAddress(address);
var stakeStateAddr = StakeState.DeriveAddress(address);
var serialized = Game.Game.instance.Agent.GetState(
hash,
ReservedAddresses.LegacyAccount,
Expand All @@ -106,7 +106,8 @@ public static GoldBalanceState GetGoldBalanceState(

try
{
return StakeStateUtils.Migrate(serialized, GetGameConfigState(hash));
// todo : 스테이킹 추가 수정 이슈 v3 대응해야함.
return StakeStateUtils.MigrateV1ToV2(serialized, GetGameConfigState(hash));
}
catch (InvalidCastException e)
{
Expand Down
12 changes: 6 additions & 6 deletions nekoyume/Assets/_Scripts/Extensions/StakeStateUtilsForClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public static class StakeStateUtilsForClient
public static bool TryMigrate(
IValue serialized,
GameConfigState gameConfigState,
out StakeStateV2 stakeStateV2)
out StakeState stakeStateV2)
{
if (serialized is null or Null)
{
Expand All @@ -21,7 +21,7 @@ public static bool TryMigrate(
// NOTE: StakeStateV2 is serialized as Bencodex List.
if (serialized is List list)
{
stakeStateV2 = new StakeStateV2(list);
stakeStateV2 = new StakeState(list);
return true;
}

Expand Down Expand Up @@ -57,7 +57,7 @@ public static bool TryMigrate(
// - StakeStateV2.Contract.LockupInterval is StakeState.LockupInterval.
// - StakeStateV2.StartedBlockIndex is StakeState.StartedBlockIndex.
// - StakeStateV2.ReceivedBlockIndex is StakeState.ReceivedBlockIndex.
var stakeStateV1 = new StakeState(dict);
var stakeStateV1 = new LegacyStakeState(dict);
var stakeRegularFixedRewardSheetTableName =
stakeStateV1.StartedBlockIndex <
gameConfigState.StakeRegularFixedRewardSheet_V2_StartBlockIndex
Expand Down Expand Up @@ -89,13 +89,13 @@ public static bool TryMigrate(
stakeRegularRewardSheetTableName = "StakeRegularRewardSheet_V5";
}

stakeStateV2 = new StakeStateV2(
stakeStateV2 = new StakeState(
stakeStateV1,
new Contract(
stakeRegularFixedRewardSheetTableName,
stakeRegularRewardSheetTableName,
StakeState.RewardInterval,
StakeState.LockupInterval));
LegacyStakeState.RewardInterval,
LegacyStakeState.LockupInterval));
return true;
}
}
Expand Down
4 changes: 2 additions & 2 deletions nekoyume/Assets/_Scripts/Game/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -793,15 +793,15 @@ private async UniTask SyncTableSheetsAsync()
private async UniTask InitializeStakeStateAsync()
{
// NOTE: Initialize staking states after setting GameConfigState.
var stakeAddr = Model.Stake.StakeStateV2.DeriveAddress(Agent.Address);
var stakeAddr = Model.Stake.StakeState.DeriveAddress(Agent.Address);
var stakeStateIValue = await Agent.GetStateAsync(ReservedAddresses.LegacyAccount, stakeAddr);
var goldCurrency = States.GoldBalanceState.Gold.Currency;
var balance = goldCurrency * 0;
var stakeRegularFixedRewardSheet = new StakeRegularFixedRewardSheet();
var stakeRegularRewardSheet = new StakeRegularRewardSheet();
var policySheet = TableSheets.StakePolicySheet;
Address[] sheetAddr;
Model.Stake.StakeStateV2? stakeState = null;
Model.Stake.StakeState? stakeState = null;
if (!StakeStateUtilsForClient.TryMigrate(
stakeStateIValue,
States.Instance.GameConfigState,
Expand Down
2 changes: 1 addition & 1 deletion nekoyume/Assets/_Scripts/Lib9c/lib9c
Submodule lib9c updated 289 files
4 changes: 2 additions & 2 deletions nekoyume/Assets/_Scripts/State/States.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class States

// NOTE: Staking Properties
public GoldBalanceState StakedBalanceState { get; private set; }
public StakeStateV2? StakeStateV2 { get; private set; }
public StakeState? StakeStateV2 { get; private set; }
public int StakingLevel { get; private set; }
public StakeRegularFixedRewardSheet StakeRegularFixedRewardSheet { get; private set; }
public StakeRegularRewardSheet StakeRegularRewardSheet { get; private set; }
Expand Down Expand Up @@ -426,7 +426,7 @@ public void SetCurrentAvatarBalance<T>(ActionEvaluation<T> eval, Currency curren
}

public void SetStakeState(
StakeStateV2? stakeStateV2,
StakeState? stakeStateV2,
GoldBalanceState stakedBalanceState,
int stakingLevel,
[CanBeNull] StakeRegularFixedRewardSheet stakeRegularFixedRewardSheet,
Expand Down
10 changes: 5 additions & 5 deletions nekoyume/Assets/_Scripts/State/Subjects/StakingSubject.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Libplanet.Types.Assets;
using Nekoyume.Model.Stake;
using Nekoyume.TableData;
Expand All @@ -8,13 +8,13 @@ namespace Nekoyume.State.Subjects
{
public static class StakingSubject
{
private static readonly Subject<StakeStateV2?> StakeStateV2Internal;
private static readonly Subject<StakeState?> StakeStateV2Internal;
private static readonly Subject<FungibleAssetValue> StakedNCGInternal;
private static readonly Subject<int> LevelInternal;
private static readonly Subject<StakeRegularFixedRewardSheet> StakeRegularFixedRewardSheetInternal;
private static readonly Subject<StakeRegularRewardSheet> StakeRegularRewardSheetInternal;

public static readonly IObservable<StakeStateV2?> StakeStateV2;
public static readonly IObservable<StakeState?> StakeStateV2;
public static readonly IObservable<FungibleAssetValue> StakedNCG;
public static readonly IObservable<int> Level;
public static readonly IObservable<StakeRegularFixedRewardSheet>
Expand All @@ -23,7 +23,7 @@ public static readonly IObservable<StakeRegularFixedRewardSheet>

static StakingSubject()
{
StakeStateV2Internal = new Subject<StakeStateV2?>();
StakeStateV2Internal = new Subject<StakeState?>();
StakedNCGInternal = new Subject<FungibleAssetValue>();
LevelInternal = new Subject<int>();
StakeRegularFixedRewardSheetInternal = new Subject<StakeRegularFixedRewardSheet>();
Expand All @@ -36,7 +36,7 @@ static StakingSubject()
StakeRegularRewardSheet = StakeRegularRewardSheetInternal.ObserveOnMainThread();
}

public static void OnNextStakeStateV2(StakeStateV2? stakeStateV2)
public static void OnNextStakeStateV2(StakeState? stakeStateV2)
{
StakeStateV2Internal.OnNext(stakeStateV2);
}
Expand Down
2 changes: 1 addition & 1 deletion nekoyume/Assets/_Scripts/UI/Widget/Popup/StakingPopup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ private void OnBlockUpdated(long blockIndex)
var stakeStateV2 = states.StakeStateV2;
var rewardBlockInterval = stakeStateV2.HasValue
? (int)stakeStateV2.Value.Contract.RewardInterval
: (int)StakeState.RewardInterval;
: (int)LegacyStakeState.RewardInterval;

TryGetWaitedBlockIndex(blockIndex, rewardBlockInterval, out var waitedBlockRange);
var rewardCount = (int)waitedBlockRange / rewardBlockInterval;
Expand Down
4 changes: 2 additions & 2 deletions nekoyume/ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ PlayerSettings:
16:10: 0
16:9: 1
Others: 0
bundleVersion: 240.0.4
bundleVersion: 240.1.0
preloadedAssets: []
metroInputSource: 0
wsaTransparentSwapchain: 0
Expand Down Expand Up @@ -168,7 +168,7 @@ PlayerSettings:
iPhone: 0
tvOS: 0
overrideDefaultApplicationIdentifier: 1
AndroidBundleVersionCode: 260
AndroidBundleVersionCode: 263
AndroidMinSdkVersion: 24
AndroidTargetSdkVersion: 34
AndroidPreferredInstallLocation: 2
Expand Down

0 comments on commit 340e36e

Please sign in to comment.