Skip to content
This repository has been archived by the owner on Dec 26, 2024. It is now read-only.

feat(network): add conversions from protobuf to transaction outputs #2053

Merged

Conversation

asmaastarkware
Copy link
Contributor

@asmaastarkware asmaastarkware commented May 26, 2024

This change is Reviewable

Copy link

codecov bot commented May 26, 2024

Codecov Report

Attention: Patch coverage is 0% with 79 lines in your changes are missing coverage. Please review.

Project coverage is 70.14%. Comparing base (d780420) to head (5b49e27).

Files Patch % Lines
...work/src/converters/protobuf_conversion/receipt.rs 0.00% 79 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2053      +/-   ##
==========================================
- Coverage   70.29%   70.14%   -0.16%     
==========================================
  Files         130      130              
  Lines       17047    17096      +49     
  Branches    17047    17096      +49     
==========================================
+ Hits        11984    11992       +8     
- Misses       3726     3765      +39     
- Partials     1337     1339       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@ShahakShama ShahakShama left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @asmaastarkware and @dan-starkware)


crates/papyrus_network/src/converters/protobuf_conversion/receipt.rs line 94 at r1 (raw file):

    type Error = ProtobufConversionError;
    fn try_from(value: protobuf::receipt::Deploy) -> Result<Self, Self::Error> {
        let common = value

There's a lot of code duplication here. Could you create a helper function that receives a protobuf::receipt::Common and outputs the following with types as they appear in SN API output: actual_fee, messages_sent, contract_address, execution_status, execution_resources?


crates/papyrus_network/src/converters/protobuf_conversion/receipt.rs line 130 at r1 (raw file):

        })?);

        let execution_status = common.revert_reason.map_or_else(

No need to use map_or_else, you can use map_or since there's no cost here for creating the value and not using it
Same in the other functions

Copy link
Contributor

@ShahakShama ShahakShama left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @asmaastarkware and @dan-starkware)


crates/papyrus_network/src/converters/protobuf_conversion/receipt.rs line 94 at r1 (raw file):

Previously, ShahakShama wrote…

There's a lot of code duplication here. Could you create a helper function that receives a protobuf::receipt::Common and outputs the following with types as they appear in SN API output: actual_fee, messages_sent, contract_address, execution_status, execution_resources?

It will also need to receive a string for ProtobufConversionError

@asmaastarkware asmaastarkware force-pushed the asmaa/add_try_from_conversions_for_transaction_outputs branch from 7a8f5f8 to 94fe5fc Compare May 26, 2024 13:06
Copy link
Contributor Author

@asmaastarkware asmaastarkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @dan-starkware and @ShahakShama)


crates/papyrus_network/src/converters/protobuf_conversion/receipt.rs line 94 at r1 (raw file):

Previously, ShahakShama wrote…

It will also need to receive a string for ProtobufConversionError

Done.


crates/papyrus_network/src/converters/protobuf_conversion/receipt.rs line 130 at r1 (raw file):

Previously, ShahakShama wrote…

No need to use map_or_else, you can use map_or since there's no cost here for creating the value and not using it
Same in the other functions

Done.

@asmaastarkware asmaastarkware force-pushed the asmaa/add_try_from_conversions_for_transaction_outputs branch from 94fe5fc to 8d95021 Compare May 26, 2024 13:06
Copy link
Contributor

@ShahakShama ShahakShama left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @asmaastarkware and @dan-starkware)


crates/papyrus_network/src/converters/protobuf_conversion/receipt.rs line 24 at r2 (raw file):

use crate::protobuf_messages::protobuf::{self};

fn parse_common_receipt_fields(

Put this at the end of the file

@asmaastarkware asmaastarkware force-pushed the asmaa/add_try_from_conversions_for_transaction_outputs branch from 8d95021 to 59c20cc Compare May 26, 2024 13:22
Copy link
Contributor Author

@asmaastarkware asmaastarkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @dan-starkware and @ShahakShama)


crates/papyrus_network/src/converters/protobuf_conversion/receipt.rs line 24 at r2 (raw file):

Previously, ShahakShama wrote…

Put this at the end of the file

Done.

Copy link
Contributor

@ShahakShama ShahakShama left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @dan-starkware)

@asmaastarkware asmaastarkware added this pull request to the merge queue May 26, 2024
Merged via the queue into main with commit dccafdf May 26, 2024
19 checks passed
@asmaastarkware asmaastarkware deleted the asmaa/add_try_from_conversions_for_transaction_outputs branch May 26, 2024 13:34
@github-actions github-actions bot locked and limited conversation to collaborators May 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants