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

feat: implement thin transaction converter #145

Merged
merged 1 commit into from
May 19, 2024

Conversation

MohammadNassar1
Copy link
Contributor

@MohammadNassar1 MohammadNassar1 commented May 16, 2024

This change is Reviewable

@codecov-commenter
Copy link

codecov-commenter commented May 16, 2024

Codecov Report

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

Project coverage is 45.41%. Comparing base (78975d5) to head (8c0da42).

Files Patch % Lines
crates/gateway/src/utils.rs 0.00% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #145      +/-   ##
==========================================
- Coverage   46.05%   45.41%   -0.65%     
==========================================
  Files          19       19              
  Lines         634      643       +9     
  Branches      634      643       +9     
==========================================
  Hits          292      292              
- Misses        328      337       +9     
  Partials       14       14              

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

Copy link
Contributor

@ArniStarkware ArniStarkware 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: 0 of 2 files reviewed, 2 unresolved discussions (waiting on @elintul, @MohammadNassar1, and @Yael-Starkware)


crates/gateway/src/starknet_api_test_utils.rs line 38 at r1 (raw file):

        ExternalTransaction::Invoke(ExternalInvokeTransaction::V3(tx)) => tx.nonce,
    }
}

Consider defining this in starknet API similar to #234

(Note - I did not include sender_address here as it does not work for deploy account).

Code quote:

pub fn get_tip(tx: &ExternalTransaction) -> Tip {
    match tx {
        ExternalTransaction::Declare(ExternalDeclareTransaction::V3(tx)) => tx.tip,
        ExternalTransaction::DeployAccount(ExternalDeployAccountTransaction::V3(tx)) => tx.tip,
        ExternalTransaction::Invoke(ExternalInvokeTransaction::V3(tx)) => tx.tip,
    }
}

pub fn get_nonce(tx: &ExternalTransaction) -> Nonce {
    match tx {
        ExternalTransaction::Declare(ExternalDeclareTransaction::V3(tx)) => tx.nonce,
        ExternalTransaction::DeployAccount(ExternalDeployAccountTransaction::V3(tx)) => tx.nonce,
        ExternalTransaction::Invoke(ExternalInvokeTransaction::V3(tx)) => tx.nonce,
    }
}

crates/gateway/src/starknet_api_test_utils.rs line 49 at r1 (raw file):

        ExternalTransaction::Invoke(ExternalInvokeTransaction::V3(tx)) => tx.sender_address,
    }
}

Suggestion:

pub fn get_sender_address(tx: &ExternalTransaction) -> ContractAddress {
    match tx {
        ExternalTransaction::Declare(ExternalDeclareTransaction::V3(tx)) => tx.sender_address,
        // TODO(Mohammad): Add support for deploy account.
        ExternalTransaction::DeployAccount(ExternalDeployAccountTransaction::V3(_)) => {
            ContractAddress::default()
        }
        ExternalTransaction::Invoke(ExternalInvokeTransaction::V3(tx)) => tx.sender_address,
    }
}

Copy link
Contributor Author

@MohammadNassar1 MohammadNassar1 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: 0 of 2 files reviewed, 2 unresolved discussions (waiting on @ArniStarkware, @elintul, and @Yael-Starkware)


crates/gateway/src/starknet_api_test_utils.rs line 49 at r1 (raw file):

        ExternalTransaction::Invoke(ExternalInvokeTransaction::V3(tx)) => tx.sender_address,
    }
}

Why sender_address? In Mempool we tend to use contract_address.

@ArniStarkware
Copy link
Contributor

crates/gateway/src/starknet_api_test_utils.rs line 38 at r1 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

Consider defining this in starknet API similar to #234

(Note - I did not include sender_address here as it does not work for deploy account).

As discussed in DMs. This is nonblocking.

I do suggest we conform to the same design.

Copy link
Contributor

@ArniStarkware ArniStarkware 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: 0 of 2 files reviewed, 2 unresolved discussions (waiting on @elintul, @MohammadNassar1, and @Yael-Starkware)


crates/gateway/src/starknet_api_test_utils.rs line 49 at r1 (raw file):

Previously, MohammadNassar1 (mohammad-starkware) wrote…

Why sender_address? In Mempool we tend to use contract_address.

  1. I did not know that about Mempool, so I am willing to concede it.
  2. This field is called sender_address in external transactions. This is a property of external transactions.

Copy link
Contributor Author

@MohammadNassar1 MohammadNassar1 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: 0 of 2 files reviewed, 2 unresolved discussions (waiting on @ArniStarkware, @elintul, and @Yael-Starkware)


crates/gateway/src/starknet_api_test_utils.rs line 38 at r1 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

As discussed in DMs. This is nonblocking.

I do suggest we conform to the same design.

Opened a PR, please take a look:
starkware-libs/starknet-api#255

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/utils/implement-thin-tx-converter branch from f48aaa5 to 8c0da42 Compare May 19, 2024 09:28
Copy link
Contributor Author

@MohammadNassar1 MohammadNassar1 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: 0 of 2 files reviewed, 2 unresolved discussions (waiting on @ArniStarkware, @elintul, and @Yael-Starkware)


crates/gateway/src/starknet_api_test_utils.rs line 38 at r1 (raw file):

Previously, MohammadNassar1 (mohammad-starkware) wrote…

Opened a PR, please take a look:
starkware-libs/starknet-api#255

Integrating the new SN_API commit is a bit more complicated as it includes some breaking changes made by other teams.
Currently, I added a TODO to use it from the SN_API once the blockier supports the new SN_API version.


crates/gateway/src/starknet_api_test_utils.rs line 49 at r1 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…
  1. I did not know that about Mempool, so I am willing to concede it.
  2. This field is called sender_address in external transactions. This is a property of external transactions.

Changed to sender_address.

Copy link
Contributor

@ArniStarkware ArniStarkware 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 2 of 2 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @elintul and @Yael-Starkware)

@MohammadNassar1 MohammadNassar1 merged commit e67e201 into main May 19, 2024
8 checks passed
@MohammadNassar1 MohammadNassar1 deleted the mohammad/utils/implement-thin-tx-converter branch May 19, 2024 10:50
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.

3 participants