Skip to content

Commit

Permalink
Accommodate API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
greymistcube committed Sep 25, 2023
1 parent 645b71d commit a09c5a0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
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 @@ -559,7 +560,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

0 comments on commit a09c5a0

Please sign in to comment.