Skip to content

Commit

Permalink
support Included transaction status (#10796)
Browse files Browse the repository at this point in the history
Ideally, we need to rewrite `chain.get_final_transaction_result` method
completely.
But for now, let's start at least with supporting
`TxExecutionStatus::Included` status.
  • Loading branch information
telezhnaya authored and posvyatokum committed Mar 14, 2024
1 parent 1435100 commit 0f35d0a
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 @@ -216,7 +216,7 @@ type BlockApplyChunksResult = (CryptoHash, Vec<(ShardId, Result<ShardUpdateResul
/// Facade to the blockchain block processing and storage.
/// Provides current view on the state according to the chain state.
pub struct Chain {
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::state_sync::{
ShardStateSyncResponse, ShardStateSyncResponseHeader, ShardStateSyncResponseV3,
};
use near_primitives::static_clock::StaticClock;
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 @@ -513,11 +515,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 0f35d0a

Please sign in to comment.