From 7ffedbe562d5fcc083f7f2a2e7560632c5425525 Mon Sep 17 00:00:00 2001 From: aldenhu Date: Fri, 29 Apr 2022 00:48:29 -0700 Subject: [PATCH] [executor] log the first different txn_info and version Closes: #719 --- Cargo.lock | 1 + execution/executor-types/Cargo.toml | 3 ++- .../executor-types/src/executed_chunk.rs | 26 ++++++++++++++----- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b88cf326d5654..b8c6f2bb94800 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3035,6 +3035,7 @@ dependencies = [ "aptos-types", "aptos-workspace-hack", "bcs", + "itertools", "scratchpad", "serde 1.0.136", "storage-interface", diff --git a/execution/executor-types/Cargo.toml b/execution/executor-types/Cargo.toml index 2a28d66d230e9..dc82a66100890 100644 --- a/execution/executor-types/Cargo.toml +++ b/execution/executor-types/Cargo.toml @@ -11,10 +11,11 @@ edition = "2018" [dependencies] anyhow = "1.0.52" +bcs = "0.1.2" +itertools = "0.10.0" serde = { version = "1.0.124", default-features = false } thiserror = "1.0.24" -bcs = "0.1.2" aptos-crypto = { path = "../../crates/aptos-crypto" } aptos-secure-net = { path = "../../secure/net" } aptos-state-view = { path = "../../storage/state-view" } diff --git a/execution/executor-types/src/executed_chunk.rs b/execution/executor-types/src/executed_chunk.rs index e7e351f50002e..fc12638a7693c 100644 --- a/execution/executor-types/src/executed_chunk.rs +++ b/execution/executor-types/src/executed_chunk.rs @@ -4,7 +4,7 @@ #![forbid(unsafe_code)] use crate::{ExecutedTrees, StateComputeResult, TransactionData}; -use anyhow::{ensure, Result}; +use anyhow::{bail, ensure, Result}; use aptos_crypto::hash::{CryptoHash, TransactionAccumulatorHasher}; use aptos_types::{ contract_event::ContractEvent, @@ -93,11 +93,25 @@ impl ExecutedChunk { .iter() .map(CryptoHash::hash) .collect::>(); - ensure!( - txn_info_hashes == expected_txn_info_hashes, - "Transaction infos don't match", - ); - Ok(()) + + if txn_info_hashes != expected_txn_info_hashes { + for (idx, ((_, txn_data), expected_txn_info)) in + itertools::zip_eq(self.to_commit.iter(), transaction_infos.iter()).enumerate() + { + if &txn_data.txn_info != expected_txn_info { + bail!( + "Transaction infos don't match. version: {}, txn_info:{}, expected_txn_info:{}", + self.result_view.transaction_accumulator.version() + 1 + idx as u64 + - self.to_commit.len() as u64, + &txn_data.txn_info, + expected_txn_info, + ) + } + } + unreachable!() + } else { + Ok(()) + } } pub fn maybe_select_chunk_ending_ledger_info(