Skip to content

Commit

Permalink
Merge pull request #2258 from greymistcube/bump/libplanet-to-3.4.0
Browse files Browse the repository at this point in the history
⬆️ Bump libplanet to 3.4.0
  • Loading branch information
greymistcube authored Oct 4, 2023
2 parents 01dda24 + f1a3919 commit 4ff2d48
Show file tree
Hide file tree
Showing 18 changed files with 113 additions and 336 deletions.
9 changes: 2 additions & 7 deletions Libplanet.Headless/Hosting/LibplanetNodeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ public LibplanetNodeService(
(Store, StateStore) = LoadStore(
Properties.StorePath,
Properties.StoreType,
Properties.StoreStatesCacheSize,
Properties.NoReduceStore);
Properties.StoreStatesCacheSize);

var chainIds = Store.ListChainIds().ToList();
Log.Debug($"Number of chain ids: {chainIds.Count()}");
Expand Down Expand Up @@ -303,7 +302,7 @@ public override async Task StopAsync(CancellationToken cancellationToken)
}
}

protected (IStore, IStateStore) LoadStore(string path, string type, int statesCacheSize, bool noReduceStore = false)
protected (IStore, IStateStore) LoadStore(string path, string type, int statesCacheSize)
{
IStore store = null;
if (type == "rocksdb")
Expand Down Expand Up @@ -344,10 +343,6 @@ public override async Task StopAsync(CancellationToken cancellationToken)
}

store ??= new DefaultStore(path, flush: false);
if (!noReduceStore)
{
store = new ReducedStore(store);
}

IKeyValueStore stateKeyValueStore = new RocksDBKeyValueStore(Path.Combine(path, "states"));
IStateStore stateStore = new TrieStateStore(stateKeyValueStore);
Expand Down
162 changes: 0 additions & 162 deletions Libplanet.Headless/ReducedStore.cs

This file was deleted.

4 changes: 2 additions & 2 deletions NineChronicles.Headless.Executable/Commands/MarketCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ public void Query(
IEnumerable<(Transaction, ActionBase)> actions = block.Transactions
.Reverse()
.Where(tx => includeFails ||
!(chain.GetTxExecution(block.Hash, tx.Id) is { } e) ||
e is TxSuccess)
!(chain.GetTxExecution(block.Hash, tx.Id) is { } e) ||
!e.Fail)
.SelectMany(tx => tx.Actions is { } ca
? ca.Reverse().Select(a => (tx, ToAction(a)))
: Enumerable.Empty<(Transaction, ActionBase)>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ public ActionContext(

public bool BlockAction => TxId is null;

public void PutLog(string log)
{
// NOTE: Not implemented yet. See also Lib9c.Tests.Action.ActionContext.PutLog().
}

public void UseGas(long gas)
{
}
Expand Down Expand Up @@ -145,8 +140,14 @@ public ValidatorSet GetValidatorSet(BlockHash? offset)

public IAccountState GetAccountState(BlockHash? offset)
{
return new LocalCacheAccountState(_rocksDb, _source.GetAccountState, offset);
return new LocalCacheAccountState(
_rocksDb,
_source.GetAccountState,
offset);
}

public IAccountState GetAccountState(HashDigest<SHA256>? hash)
=> _source.GetAccountState(hash);
}

private sealed class LocalCacheAccountState : IAccountState
Expand All @@ -158,11 +159,11 @@ private sealed class LocalCacheAccountState : IAccountState

public LocalCacheAccountState(
RocksDb rocksDb,
Func<BlockHash?, IAccountState> sourceAccountStateGetter,
Func<BlockHash?, IAccountState> sourceAccountStateGetterWithBlockHash,
BlockHash? offset)
{
_rocksDb = rocksDb;
_sourceAccountStateGetter = sourceAccountStateGetter;
_sourceAccountStateGetter = sourceAccountStateGetterWithBlockHash;
_offset = offset;
}

Expand Down
9 changes: 5 additions & 4 deletions NineChronicles.Headless.Executable/Commands/ReplayCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public int Blocks(
try
{
var rootHash = blockChain.DetermineBlockStateRootHash(block,
out IReadOnlyList<IActionEvaluation> actionEvaluations);
out IReadOnlyList<ICommittedActionEvaluation> actionEvaluations);

if (verbose)
{
Expand Down Expand Up @@ -301,8 +301,9 @@ public int Blocks(
outputSw?.WriteLine(msg);

var actionEvaluator = GetActionEvaluator(blockChain);
var actionEvaluations = actionEvaluator.Evaluate(block);
LoggingActionEvaluations(actionEvaluations, outputSw);
var actionEvaluations = blockChain.DetermineBlockStateRootHash(block,
out IReadOnlyList<ICommittedActionEvaluation> failedActionEvaluations);
LoggingActionEvaluations(failedActionEvaluations, outputSw);

msg = $"- block #{block.Index} evaluating failed with ";
_console.Out.Write(msg);
Expand Down Expand Up @@ -558,7 +559,7 @@ private void LoggingAboutIncompleteBlockStatesException(
}

private void LoggingActionEvaluations(
IReadOnlyList<IActionEvaluation> actionEvaluations,
IReadOnlyList<ICommittedActionEvaluation> actionEvaluations,
TextWriter? textWriter)
{
var count = actionEvaluations.Count;
Expand Down
17 changes: 3 additions & 14 deletions NineChronicles.Headless.Executable/Commands/StateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,31 +132,20 @@ IStateStore stateStore
block.Index,
block.Hash
);
IReadOnlyList<IActionEvaluation> delta;
HashDigest<SHA256> stateRootHash = block.Index < 1
? BlockChain.DetermineGenesisStateRootHash(
actionEvaluator,
preEvalBlock,
out delta)
out _)
: chain.DetermineBlockStateRootHash(
preEvalBlock,
out delta);
out _);
DateTimeOffset now = DateTimeOffset.Now;
if (invalidStateRootHashBlock is null && !stateRootHash.Equals(block.StateRootHash))
{
string blockDump = DumpBencodexToFile(
block.MarshalBlock(),
$"block_{block.Index}_{block.Hash}"
);
string deltaDump = DumpBencodexToFile(
new Dictionary(
GetTotalDelta(delta, ToStateKey, ToFungibleAssetKey, ToTotalSupplyKey, ValidatorSetKey)),
$"delta_{block.Index}_{block.Hash}"
);
string message =
$"Unexpected state root hash for block #{block.Index} {block.Hash}.\n" +
$" Expected: {block.StateRootHash}\n Actual: {stateRootHash}\n" +
$" Block file: {blockDump}\n Evaluated delta file: {deltaDump}\n";
$" Expected: {block.StateRootHash}\n Actual: {stateRootHash}\n";
if (!bypassStateRootHashCheck)
{
throw new CommandExitedException(message, 1);
Expand Down
2 changes: 2 additions & 0 deletions NineChronicles.Headless.Executable/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ IActionLoader MakeSingleActionLoader()
standaloneContext.NineChroniclesNodeService!.ActionRenderer,
standaloneContext.NineChroniclesNodeService!.ExceptionRenderer,
standaloneContext.NineChroniclesNodeService!.NodeStatusRenderer,
standaloneContext.NineChroniclesNodeService!.BlockChain,
IPAddress.Loopback.ToString(),
rpcProperties.RpcListenPort,
context,
Expand Down Expand Up @@ -509,6 +510,7 @@ IActionLoader MakeSingleActionLoader()
standaloneContext.NineChroniclesNodeService!.ActionRenderer,
standaloneContext.NineChroniclesNodeService!.ExceptionRenderer,
standaloneContext.NineChroniclesNodeService!.NodeStatusRenderer,
standaloneContext.NineChroniclesNodeService!.BlockChain,
IPAddress.Loopback.ToString(),
0,
context,
Expand Down
1 change: 1 addition & 0 deletions NineChronicles.Headless.Tests/GraphQLStartupTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public GraphQLStartupTest()
new ActionRenderer(),
new ExceptionRenderer(),
new NodeStatusRenderer(),
standaloneContext!.BlockChain,
"",
0,
new RpcContext(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public GraphQLTestBase(ITestOutputHelper output)
ncService.ActionRenderer,
ncService.ExceptionRenderer,
ncService.NodeStatusRenderer,
ncService.BlockChain,
"",
0,
new RpcContext(),
Expand Down
Loading

0 comments on commit 4ff2d48

Please sign in to comment.