Skip to content

Commit

Permalink
Merge pull request #2240 from greymistcube/bump/libplanet-to-3.3.1
Browse files Browse the repository at this point in the history
⬆️ Bump libplanet to 3.3.1
  • Loading branch information
greymistcube authored Sep 8, 2023
2 parents 1b19cc8 + 4aa125d commit 83e5f84
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 496 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public void PruneState(StoreType storeType)
_command.PruneStates(storeType, _storePath);
IStore outputStore = storeType.CreateStore(_storePath);
var outputStateKeyValueStore = new RocksDBKeyValueStore(statesPath);
var outputStateStore = new TrieStateStore(outputStateKeyValueStore, true);
var outputStateStore = new TrieStateStore(outputStateKeyValueStore);
int outputStatesCount = outputStateKeyValueStore.ListKeys().Count();
outputStore.Dispose();
outputStateStore.Dispose();
Expand Down
509 changes: 25 additions & 484 deletions NineChronicles.Headless.Executable/Commands/ReplayCommand.Privates.cs

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions NineChronicles.Headless.Executable/Commands/ReplayCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ public int Tx(
}

// Evaluate tx.
IAccountState previousBlockStates = blockChain.GetBlockState(previousBlock.Hash);
IAccount previousStates = AccountStateDelta.Create(previousBlockStates);
IAccountState previousBlockStates = blockChain.GetAccountState(previousBlock.Hash);
IAccount previousStates = new Account(previousBlockStates);
var actions = tx.Actions.Select(a => ToAction(a));
var actionEvaluations = EvaluateActions(
preEvaluationHash: targetBlock.PreEvaluationHash,
Expand Down Expand Up @@ -398,8 +398,7 @@ public int RemoteTx(
cacheDirectory ?? Path.Join(Path.GetTempPath(), "ncd-replay-remote-tx-cache"));

var previousBlockHash = BlockHash.FromString(previousBlockHashValue);
var previousStates =
AccountStateDelta.Create(blockChainStates.GetBlockState(previousBlockHash));
var previousStates = new Account(blockChainStates.GetAccountState(previousBlockHash));

var actions = transaction.Actions
.Select(ToAction)
Expand Down
3 changes: 3 additions & 0 deletions NineChronicles.Headless.Tests/Common/MockState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Bencodex.Types;
using Libplanet.Action.State;
using Libplanet.Crypto;
using Libplanet.Store.Trie;
using Libplanet.Types.Assets;
using Libplanet.Types.Consensus;

Expand Down Expand Up @@ -85,6 +86,8 @@ private MockState(

public ValidatorSet ValidatorSet => _validatorSet;

public ITrie Trie => throw new NotSupportedException();

public IValue? GetState(Address address) => _states.TryGetValue(address, out IValue? value)
? value
: null;
Expand Down
4 changes: 2 additions & 2 deletions NineChronicles.Headless.Tests/GraphQLTestUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public static StandaloneContext CreateStandaloneContext()
stateStore,
genesisBlock,
actionEvaluator);
var currencyFactory = new CurrencyFactory(blockchain.GetBlockState);
var currencyFactory = new CurrencyFactory(() => blockchain.GetAccountState(blockchain.Tip.Hash));
var fungibleAssetValueFactory = new FungibleAssetValueFactory(currencyFactory);
return new StandaloneContext
{
Expand Down Expand Up @@ -133,7 +133,7 @@ PrivateKey minerPrivateKey
actionEvaluator);
var ncg = new GoldCurrencyState((Dictionary)blockchain.GetState(Addresses.GoldCurrency))
.Currency;
var currencyFactory = new CurrencyFactory(blockchain.GetBlockState, ncg);
var currencyFactory = new CurrencyFactory(() => blockchain.GetAccountState(blockchain.Tip.Hash), ncg);
var fungibleAssetValueFactory = new FungibleAssetValueFactory(currencyFactory);
return new StandaloneContext
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ public async Task TransactionResultIsSuccess()

private Task<ExecutionResult> ExecuteAsync(string query)
{
var currencyFactory = new CurrencyFactory(_blockChain.GetBlockState);
var currencyFactory = new CurrencyFactory(() => _blockChain.GetAccountState(_blockChain.Tip.Hash));
var fungibleAssetValueFactory = new FungibleAssetValueFactory(currencyFactory);
return GraphQLTestUtils.ExecuteQueryAsync<TransactionHeadlessQuery>(query, standaloneContext: new StandaloneContext
{
Expand Down
2 changes: 1 addition & 1 deletion NineChronicles.Headless/BlockChainService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public UnaryResult<byte[]> GetState(byte[] addressBytes, byte[] blockHashBytes)
public async UnaryResult<Dictionary<byte[], byte[]>> GetAvatarStates(IEnumerable<byte[]> addressBytesList, byte[] blockHashBytes)
{
var hash = new BlockHash(blockHashBytes);
var accountState = _blockChain.GetBlockState(hash);
var accountState = _blockChain.GetAccountState(hash);
var result = new ConcurrentDictionary<byte[], byte[]>();
var addresses = addressBytesList.Select(a => new Address(a)).ToList();
var rawAvatarStates = accountState.GetRawAvatarStates(addresses);
Expand Down
2 changes: 1 addition & 1 deletion NineChronicles.Headless/GraphTypes/StandaloneQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public StandaloneQuery(StandaloneContext standaloneContext, IConfiguration confi
}

return new StateContext(
chain.GetBlockState(blockHash),
chain.GetAccountState(blockHash),
blockHash switch
{
BlockHash bh => chain[bh].Index,
Expand Down
3 changes: 2 additions & 1 deletion NineChronicles.Headless/NineChroniclesNodeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@ internal void ConfigureContext(StandaloneContext standaloneContext)
standaloneContext.Store = Store;
standaloneContext.Swarm = Swarm;
standaloneContext.CurrencyFactory =
new CurrencyFactory(standaloneContext.BlockChain.GetBlockState);
new CurrencyFactory(
() => standaloneContext.BlockChain.GetAccountState(standaloneContext.BlockChain.Tip.Hash));
standaloneContext.FungibleAssetValueFactory =
new FungibleAssetValueFactory(standaloneContext.CurrencyFactory);
BootstrapEnded.WaitAsync().ContinueWith((task) =>
Expand Down

0 comments on commit 83e5f84

Please sign in to comment.