Skip to content

Commit 6bb22e7

Browse files
committed
fix the code for advice from coderabbitai
1 parent a911641 commit 6bb22e7

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

vm2/executor/src/block_executor.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ pub fn block_execute_with_outputs<S: ChainStateReader + ChainStateWriter + Sync>
109109
.len()
110110
.checked_sub(1)
111111
.ok_or_else(|| BlockExecutorError::BlockTransactionZero)?;
112+
if txns.len() != outputs.len() {
113+
return Err(BlockExecutorError::InvalidOutputCount {
114+
expected: txns.len(),
115+
actual: outputs.len(),
116+
});
117+
}
112118
for (index, (txn, output)) in txns
113119
.iter()
114120
.take(outputs.len())

vm2/types/src/error/block_executor.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,6 @@ pub enum BlockExecutorError {
3333
BlockExecuteRetryErr,
3434
#[error("block transaction is zero")]
3535
BlockTransactionZero,
36+
#[error("the number of transaction outputs is not equal to the number of transactions, expected length: {expected}, actual length: {actual}")]
37+
InvalidOutputCount { expected: usize, actual: usize },
3638
}

0 commit comments

Comments
 (0)