From fd44289fb93a8d6dad4df30faf39f44225b02459 Mon Sep 17 00:00:00 2001 From: Stan Bondi Date: Mon, 24 Jul 2023 13:19:56 +0200 Subject: [PATCH] fix(mempool): add transaction to state store before execution (#625) Description --- fix(mempool): add transaction to state store before execution feat(sqlite state store): add executed_time_ms to transactions Motivation and Context --- Add the transaction to the state store before execution to allow missing transactions to check if a transaction exists but is still executing. How Has This Been Tested? --- Existing cucumber tests, manually What process can a PR reviewer use to test or verify this change? --- Check that missing transaction does not request transactions that are busy executing Breaking Changes --- - [ ] None - [x] Requires data directory to be deleted - [ ] Other - Please specify --- .../src/transaction_executor.rs | 5 +- .../src/json_rpc/handlers.rs | 6 +- .../src/p2p/services/mempool/executor.rs | 9 +- .../src/p2p/services/mempool/service.rs | 25 ++-- dan_layer/consensus/src/hotstuff/error.rs | 3 + .../src/hotstuff/on_receive_proposal.rs | 3 +- dan_layer/consensus/src/hotstuff/worker.rs | 2 +- .../src/support/transaction.rs | 134 ++++++------------ dan_layer/indexer_lib/src/substate_scanner.rs | 2 +- .../up.sql | 43 ++++-- .../down.sql | 4 - .../2023-07-12-192955_add_missing_txs/up.sql | 16 --- dan_layer/state_store_sqlite/src/reader.rs | 24 +++- dan_layer/state_store_sqlite/src/schema.rs | 41 +++--- .../src/sql_models/transaction.rs | 38 +++-- dan_layer/state_store_sqlite/src/writer.rs | 13 +- .../consensus_models/executed_transaction.rs | 90 ++++++++---- dan_layer/storage/src/consensus_models/mod.rs | 2 + .../src/consensus_models/transaction.rs | 128 +++++++++++++++++ dan_layer/storage/src/state_store/mod.rs | 14 +- .../tests/features/claim_burn.feature | 1 - .../tests/features/transfer.feature | 4 + .../tests/features/wallet_daemon.feature | 8 ++ 23 files changed, 398 insertions(+), 217 deletions(-) delete mode 100644 dan_layer/state_store_sqlite/migrations/2023-07-12-192955_add_missing_txs/down.sql delete mode 100644 dan_layer/state_store_sqlite/migrations/2023-07-12-192955_add_missing_txs/up.sql create mode 100644 dan_layer/storage/src/consensus_models/transaction.rs diff --git a/applications/tari_dan_app_utilities/src/transaction_executor.rs b/applications/tari_dan_app_utilities/src/transaction_executor.rs index c4510dc7e..df5376868 100644 --- a/applications/tari_dan_app_utilities/src/transaction_executor.rs +++ b/applications/tari_dan_app_utilities/src/transaction_executor.rs @@ -1,7 +1,7 @@ // Copyright 2023 The Tari Project // SPDX-License-Identifier: BSD-3-Clause -use std::sync::Arc; +use std::{sync::Arc, time::Instant}; use tari_common_types::types::PublicKey; use tari_crypto::tari_utilities::ByteArray; @@ -55,6 +55,7 @@ where TTemplateProvider: TemplateProvider