Skip to content

Commit

Permalink
commit on aev
Browse files Browse the repository at this point in the history
  • Loading branch information
riemannulus committed Sep 15, 2023
1 parent 4ad547e commit 114d8ea
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void CheckPairs()
class PostActionEvaluator : IActionEvaluator
{
public IActionLoader ActionLoader => throw new NotSupportedException();
public IReadOnlyList<IActionEvaluation> Evaluate(IPreEvaluationBlock block)
public IReadOnlyList<IActionResult> Evaluate(IPreEvaluationBlock block)
{
return new IActionEvaluation[]
{
Expand All @@ -84,14 +84,14 @@ public IReadOnlyList<IActionEvaluation> Evaluate(IPreEvaluationBlock block)
false),
new AccountStateDelta(),
null)
};
}.Select(x => new ActionResult(x)).ToArray();
}
}

class PreActionEvaluator : IActionEvaluator
{
public IActionLoader ActionLoader => throw new NotSupportedException();
public IReadOnlyList<IActionEvaluation> Evaluate(IPreEvaluationBlock block)
public IReadOnlyList<IActionResult> Evaluate(IPreEvaluationBlock block)
{
return new IActionEvaluation[]
{
Expand All @@ -111,7 +111,7 @@ public IReadOnlyList<IActionEvaluation> Evaluate(IPreEvaluationBlock block)
false),
new AccountStateDelta(),
null)
};
}.Select(x => new ActionResult(x)).ToArray();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public ForkableActionEvaluator(IEnumerable<((long StartIndex, long EndIndex) Ran

public IActionLoader ActionLoader => throw new NotSupportedException();

public IReadOnlyList<IActionEvaluation> Evaluate(IPreEvaluationBlock block)
public IReadOnlyList<IActionResult> Evaluate(IPreEvaluationBlock block)
{
var actionEvaluator = _router.GetEvaluator(block.Index);
return actionEvaluator.Evaluate(block);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ public IAccountState GetAccountState(BlockHash? offset)
{
return new LocalCacheAccountState(_rocksDb, _source.GetAccountState, offset);
}

public IAccountState GetAccountState(HashDigest<SHA256>? stateRootHash) =>
throw new NotImplementedException();

public ITrie Commit(ITrie trie) =>
throw new NotImplementedException();
}

private sealed class LocalCacheAccountState : IAccountState
Expand Down
6 changes: 3 additions & 3 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<IActionResult> actionEvaluations);

if (verbose)
{
Expand Down Expand Up @@ -558,7 +558,7 @@ private void LoggingAboutIncompleteBlockStatesException(
}

private void LoggingActionEvaluations(
IReadOnlyList<IActionEvaluation> actionEvaluations,
IReadOnlyList<IActionResult> actionEvaluations,
TextWriter? textWriter)
{
var count = actionEvaluations.Count;
Expand Down Expand Up @@ -593,7 +593,7 @@ private void LoggingActionEvaluations(

var prefix = $"--- action evaluation {i + 1}/{count}:";
var msg = prefix +
$" tx-id({actionEvaluation.InputContext.TxId})" +
$" tx-id({actionEvaluation.TxId})" +
$", action-type(\"{actionType}\")";
if (actionEvaluation.Exception is null)
{
Expand Down
13 changes: 10 additions & 3 deletions NineChronicles.Headless.Executable/Commands/StateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ IStateStore stateStore
block.Index,
block.Hash
);
IReadOnlyList<IActionEvaluation> delta;
IReadOnlyList<IActionResult> delta;
HashDigest<SHA256> stateRootHash = block.Index < 1
? BlockChain.DetermineGenesisStateRootHash(
actionEvaluator,
Expand All @@ -148,9 +148,16 @@ IStateStore stateStore
block.MarshalBlock(),
$"block_{block.Index}_{block.Hash}"
);
ITrie previous = blockChainStates.GetAccountState(delta.First().PreviousRootHash).Trie;
ITrie output = blockChainStates.GetAccountState(delta.Last().OutputRootHash).Trie;
var diff = output.Diff(previous);
Dictionary diffDict = Dictionary.Empty;
foreach (var item in diff)
{
diffDict = diffDict.Add(item.Path.Hex, item.SourceValue);
}
string deltaDump = DumpBencodexToFile(
new Dictionary(
GetTotalDelta(delta, ToStateKey, ToFungibleAssetKey, ToTotalSupplyKey, ValidatorSetKey)),
diffDict,
$"delta_{block.Index}_{block.Hash}"
);
string message =
Expand Down

0 comments on commit 114d8ea

Please sign in to comment.