Skip to content

Commit

Permalink
support Included transaction status
Browse files Browse the repository at this point in the history
  • Loading branch information
telezhnaya committed Mar 14, 2024
1 parent 32c731b commit b4d0547
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
2 changes: 1 addition & 1 deletion chain/chain/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ type BlockApplyChunksResult = (CryptoHash, Vec<(ShardId, Result<ShardUpdateResul
/// Provides current view on the state according to the chain state.
pub struct Chain {
pub(crate) clock: Clock,
chain_store: ChainStore,
pub chain_store: ChainStore,
pub epoch_manager: Arc<dyn EpochManagerAdapter>,
pub shard_tracker: ShardTracker,
pub runtime_adapter: Arc<dyn RuntimeAdapter>,
Expand Down
36 changes: 28 additions & 8 deletions chain/client/src/view_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,18 @@ use near_primitives::sharding::ShardChunk;
use near_primitives::state_sync::{
ShardStateSyncResponse, ShardStateSyncResponseHeader, ShardStateSyncResponseV3,
};
use near_primitives::transaction::SignedTransaction;
use near_primitives::types::{
AccountId, BlockHeight, BlockId, BlockReference, EpochReference, Finality, MaybeBlockId,
ShardId, SyncCheckpoint, TransactionOrReceiptId, ValidatorInfoIdentifier,
};
use near_primitives::views::validator_stake_view::ValidatorStakeView;
use near_primitives::views::{
BlockView, ChunkView, EpochValidatorInfo, ExecutionOutcomeWithIdView, ExecutionStatusView,
FinalExecutionOutcomeView, FinalExecutionOutcomeViewEnum, GasPriceView, LightClientBlockView,
MaintenanceWindowsView, QueryRequest, QueryResponse, ReceiptView, SplitStorageInfoView,
StateChangesKindsView, StateChangesView, TxExecutionStatus, TxStatusView,
FinalExecutionOutcomeView, FinalExecutionOutcomeViewEnum, FinalExecutionStatus, GasPriceView,
LightClientBlockView, MaintenanceWindowsView, QueryRequest, QueryResponse, ReceiptView,
SignedTransactionView, SplitStorageInfoView, StateChangesKindsView, StateChangesView,
TxExecutionStatus, TxStatusView,
};
use near_store::flat::{FlatStorageReadyStatus, FlatStorageStatus};
use near_store::{DBCol, COLD_HEAD_KEY, FINAL_HEAD_KEY, HEAD_KEY};
Expand Down Expand Up @@ -520,11 +522,29 @@ impl ViewClientActor {
Ok(TxStatusView { execution_outcome: Some(res), status })
}
Err(near_chain::Error::DBNotFoundErr(_)) => {
if self.chain.get_execution_outcome(&tx_hash).is_ok() {
Ok(TxStatusView {
execution_outcome: None,
status: TxExecutionStatus::None,
})
if let Ok(Some(transaction)) = self.chain.chain_store.get_transaction(&tx_hash)
{
let transaction: SignedTransactionView =
SignedTransaction::clone(&transaction).into();
if let Ok(tx_outcome) = self.chain.get_execution_outcome(&tx_hash) {
let outcome = FinalExecutionOutcomeViewEnum::FinalExecutionOutcome(
FinalExecutionOutcomeView {
status: FinalExecutionStatus::Started,
transaction,
transaction_outcome: tx_outcome.into(),
receipts_outcome: vec![],
},
);
Ok(TxStatusView {
execution_outcome: Some(outcome),
status: TxExecutionStatus::Included,
})
} else {
Ok(TxStatusView {
execution_outcome: None,
status: TxExecutionStatus::Included,
})
}
} else {
Err(TxStatusError::MissingTransaction(tx_hash))
}
Expand Down

0 comments on commit b4d0547

Please sign in to comment.