Skip to content

Commit

Permalink
Merge pull request #643 from AElfProject/enhancement-code-quality
Browse files Browse the repository at this point in the history
Add log for Incorrect merkle trees
  • Loading branch information
rosona authored Nov 27, 2018
2 parents c323850 + cd6134c commit 65299c2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
19 changes: 12 additions & 7 deletions AElf.Synchronization/BlockExecution/BlockExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,6 @@ public async Task<BlockExecutionResult> ExecuteBlock(IBlock block)
txnRes = await ExecuteTransactions(readyTxs, block.Header.ChainId, block.Header.GetDisambiguationHash());
txnRes = SortToOriginalOrder(txnRes, readyTxs);

_logger?.Trace("Transaction Results:");
foreach (var re in txnRes)
{
_logger?.Trace(re.StateHash.DumpHex);
}

var blockChain = _chainService.GetBlockChain(Hash.LoadHex(ChainConfig.Instance.ChainId));
if (await blockChain.GetBlockByHashAsync(block.GetHash()) != null)
{
Expand Down Expand Up @@ -224,7 +218,7 @@ private async Task<List<TransactionResult>> ExecuteTransactions(List<Transaction
{
var res = new TransactionResult
{
TransactionId = trace.TransactionId,
TransactionId = trace.TransactionId
};
if (string.IsNullOrEmpty(trace.StdErr))
{
Expand All @@ -238,6 +232,9 @@ private async Task<List<TransactionResult>> ExecuteTransactions(List<Transaction
res.Status = Status.Failed;
res.RetVal = ByteString.CopyFromUtf8(trace.StdErr);
res.StateHash = trace.GetSummarizedStateHash();
_logger?.Error($"Transaction execute failed. TransactionId: {res.TransactionId.DumpHex()}, " +
$"StateHash: {res.StateHash} Transaction deatils: {readyTxs.Find(x => x.GetHash() == trace.TransactionId)}" +
$"\n {trace.StdErr}");
}

results.Add(res);
Expand Down Expand Up @@ -389,6 +386,14 @@ private BlockExecutionResult UpdateWorldState(IBlock block, IEnumerable<Transact
{
_logger?.Trace($"{root.DumpHex()} != {block.Header.MerkleTreeRootOfWorldState.DumpHex()}");
_logger?.Warn("ExecuteBlock - Incorrect merkle trees.");
_logger?.Trace("Transaction Results:");
foreach (var r in results)
{
_logger?.Trace($"TransactionId: {r.TransactionId.DumpHex()}, " +
$"StateHash: {r.StateHash.DumpHex()}," +
$"Status: {r.Status}, " +
$"{r.RetVal}");
}
res = BlockExecutionResult.IncorrectStateMerkleTree;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,7 @@ private async Task HandleBlock(IBlock block)

private async Task<BlockExecutionResult> HandleValidBlock(IBlock block)
{
_logger?.Warn(
$"Valid block {block.BlockHashToHex}. Height: *{block.Index}*");
_logger?.Info($"Valid block {block.BlockHashToHex}. Height: *{block.Index}*");

if (_stateFSM.CurrentState != (int) NodeState.BlockExecuting)
{
Expand Down

0 comments on commit 65299c2

Please sign in to comment.