Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make transaction status stream work #1108

Merged
merged 11 commits into from
May 29, 2023
Merged

Make transaction status stream work #1108

merged 11 commits into from
May 29, 2023

Conversation

freesig
Copy link
Contributor

@freesig freesig commented Apr 6, 2023

This PR refactors the transaction_status_change function to improve its readability and efficiency. The main changes are:

  1. Changed input stream type from BoxStream<'a, Result<TxUpdate, BroadcastStreamRecvError>> to BoxStream<'a, TxStatusMessage>.
  2. Changed return type from impl Stream<Item = anyhow::Result<TransactionStatus>> + 'a to impl Stream<Item = anyhow::Result<ApiTxStatus>> + 'a.
  3. Removed unnecessary async/await and error mapping for the initial database status check.
  4. Replaced the complex unfold logic with a simpler chain of the initial database check and stream, followed by a take_until to handle stream termination.
  5. Replaced the nested match structure with a single match block to improve readability.
  6. Simplified the stream termination logic by closing the stream if s new transaction status is not Submitted.

Additionally, this PR introduces property testing to ensure the refactored transaction_status_change function behaves correctly under various input conditions. This will help identify potential edge cases, increase the test coverage, and provide greater confidence in the robustness of the changes made.

@freesig freesig marked this pull request as ready for review April 6, 2023 03:26
@freesig freesig requested a review from a team April 6, 2023 03:26
@Voxelot
Copy link
Member

Voxelot commented Apr 6, 2023

We'll likely also want to consider this issue as well, because without a terminal message indicating the closing of the stream it makes error handling on the client side more difficult: #823

let (status_sender, _) = broadcast::channel(capacity);
let (update_sender, _) = broadcast::channel(capacity);
let (new_tx_notification_sender, _) = broadcast::channel(capacity);
let update_sender = UpdateSender::new(capacity);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use 100 as capacity right now. It means we can only submit 100 transactions because of the permit. I think we need to increase it or make configurable

Copy link
Collaborator

@xgreenx xgreenx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@freesig I made small changes around the main logic. Could you check it, please? If everything okay, I think we can merge it=)

Copy link
Contributor Author

@freesig freesig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@@ -147,7 +148,10 @@ impl fuel_core_txpool::ports::TxPoolDb for Database {
fn transaction_status(
&self,
tx_id: &fuel_core_types::fuel_types::Bytes32,
) -> StorageResult<Option<fuel_core_types::services::txpool::TransactionStatus>> {
Ok(self.get_tx_status(tx_id)?)
) -> StorageResult<fuel_core_types::services::txpool::TransactionStatus> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kinda weird to return an error for not found

@xgreenx xgreenx merged commit 03f0b4e into master May 29, 2023
@xgreenx xgreenx deleted the freesig/test-submit-await branch May 29, 2023 09:52
@xgreenx xgreenx mentioned this pull request Jun 13, 2023
xgreenx added a commit that referenced this pull request Jun 14, 2023
## What's Changed
* version compatibility cleanup by @Voxelot in
#1171
* Added example with custom query around the `fuel-core-client` by
@xgreenx in #1175
* Update to fuel-vm 0.32 (including wideint gas profiling) by @Dentosal
in #1173
* feat: Client primitives by @bvrooman in
#1144
* Improve executor config by @Voxelot in
#1185
* Added `contract_id` to the `ContractConfig` by @xgreenx in
#1184
* fix windows file name error by @firedpeanut in
#1176
* Make transaction status stream work by @freesig in
#1108
* Added `submit_and_await` endpoint to not miss the notifications by
@xgreenx in #1192
* feat: Use ID types in client api by @bvrooman in
#1191
* Use `fuel-vm 0.33` with predicate estimation by @xgreenx in
#1195
* Add transaction lifecycle diagram to the docs by @digorithm in
#1201
* sync with peers before producing blocks by @leviathanbeak in
#1169
* SMT storage key hashing by @xgreenx in
#1207

## New Contributors
* @firedpeanut made their first contribution in
#1176

**Full Changelog**:
v0.18.1...v0.19.0

---------

Co-authored-by: Brandon Kite <brandonkite92@gmail.com>
crypto523 pushed a commit to crypto523/fuel-core that referenced this pull request Oct 7, 2024
## What's Changed
* version compatibility cleanup by @Voxelot in
FuelLabs/fuel-core#1171
* Added example with custom query around the `fuel-core-client` by
@xgreenx in FuelLabs/fuel-core#1175
* Update to fuel-vm 0.32 (including wideint gas profiling) by @Dentosal
in FuelLabs/fuel-core#1173
* feat: Client primitives by @bvrooman in
FuelLabs/fuel-core#1144
* Improve executor config by @Voxelot in
FuelLabs/fuel-core#1185
* Added `contract_id` to the `ContractConfig` by @xgreenx in
FuelLabs/fuel-core#1184
* fix windows file name error by @firedpeanut in
FuelLabs/fuel-core#1176
* Make transaction status stream work by @freesig in
FuelLabs/fuel-core#1108
* Added `submit_and_await` endpoint to not miss the notifications by
@xgreenx in FuelLabs/fuel-core#1192
* feat: Use ID types in client api by @bvrooman in
FuelLabs/fuel-core#1191
* Use `fuel-vm 0.33` with predicate estimation by @xgreenx in
FuelLabs/fuel-core#1195
* Add transaction lifecycle diagram to the docs by @digorithm in
FuelLabs/fuel-core#1201
* sync with peers before producing blocks by @leviathanbeak in
FuelLabs/fuel-core#1169
* SMT storage key hashing by @xgreenx in
FuelLabs/fuel-core#1207

## New Contributors
* @firedpeanut made their first contribution in
FuelLabs/fuel-core#1176

**Full Changelog**:
FuelLabs/fuel-core@v0.18.1...v0.19.0

---------

Co-authored-by: Brandon Kite <brandonkite92@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants