Skip to content

Commit

Permalink
fix: ReplayCommand.RemoteTx to evaluate with BPV
Browse files Browse the repository at this point in the history
  • Loading branch information
OnedgeLee committed Jun 14, 2024
1 parent a4be33a commit 9ae42c0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ query GetBlockData($hash: ID!)
stateRootHash
}
stateRootHash
protocolVersion
}
}}
}
Expand Down Expand Up @@ -90,6 +91,7 @@ private sealed class BlockType
public string? PreEvaluationHash { get; set; }
public BlockType? PreviousBlock { get; set; }
public string? StateRootHash { get; set; }
public int? ProtocolVersion { get; set; }
}

private sealed class TransactionQueryType
Expand Down
9 changes: 7 additions & 2 deletions NineChronicles.Headless.Executable/Commands/ReplayCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,12 @@ public int RemoteTx(
var previousBlockHashStateRootHash = block?.PreviousBlock?.StateRootHash;
var preEvaluationHashValue = block?.PreEvaluationHash;
var minerValue = block?.Miner;
if (previousBlockHashValue is null || preEvaluationHashValue is null || minerValue is null || previousBlockHashStateRootHash is null)
var protocolVersion = block?.ProtocolVersion;
if (previousBlockHashValue is null
|| preEvaluationHashValue is null
|| minerValue is null
|| previousBlockHashStateRootHash is null
|| protocolVersion is null)
{
throw new CommandExitedException("Failed to get block from query", -1);
}
Expand Down Expand Up @@ -428,7 +433,7 @@ public int RemoteTx(
var actionEvaluations = EvaluateActions(
preEvaluationHash: HashDigest<SHA256>.FromString(preEvaluationHashValue),
blockIndex: transactionResult.BlockIndex ?? 0,
blockProtocolVersion: 0,
blockProtocolVersion: (int)protocolVersion,
txid: transaction.Id,
previousStates: previousStates,
miner: miner,
Expand Down

0 comments on commit 9ae42c0

Please sign in to comment.