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

refactor(gateway): send internal tx instead of thin tx #360

Merged

Conversation

MohammadNassar1
Copy link
Contributor

@MohammadNassar1 MohammadNassar1 commented Aug 8, 2024

This change is Reviewable

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, 1 unresolved discussion (waiting on @ayeletstarkware, @elintul, and @giladchase)

a discussion (no related file):
Add default external to internal conversion in GW.


Copy link
Contributor

@ayeletstarkware ayeletstarkware left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @elintul, @giladchase, and @MohammadNassar1)


crates/gateway/src/utils.rs line 34 at r1 (raw file):

use crate::errors::StatefulTransactionValidatorResult;

pub fn external_tx_to_internal_tx(

I find the Transaction' / 'internal_tx mismatch very confusing.

Code quote:

external_tx_to_internal_tx

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/mempool/change-thin-tx-to-internal-tx branch 2 times, most recently from ffea932 to 46c4f32 Compare August 13, 2024 11:14
@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/gateway/replace-thin-tx-to-internal-tx branch 2 times, most recently from 857983b to 1008e8e Compare August 13, 2024 11:34
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, @ayeletstarkware, @elintul, and @giladchase)


crates/gateway/src/utils.rs line 34 at r1 (raw file):

Previously, ayeletstarkware (Ayelet Zilber) wrote…

I find the Transaction' / 'internal_tx mismatch very confusing.

Let's discuss it F2F.

@ArniStarkware
Copy link
Contributor

crates/gateway/src/utils.rs line 34 at r1 (raw file):

Previously, MohammadNassar1 (mohammad-starkware) wrote…

Let's discuss it F2F.

Why not external_tx_to_executable_tx?

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/mempool/change-thin-tx-to-internal-tx branch from 46c4f32 to 0e3d0a6 Compare August 15, 2024 08:28
@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/gateway/replace-thin-tx-to-internal-tx branch from 1008e8e to f466382 Compare August 15, 2024 08:31
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, @ayeletstarkware, @elintul, and @giladchase)


crates/gateway/src/utils.rs line 34 at r1 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

Why not external_tx_to_executable_tx?

I Like it. Updated!

Copy link
Contributor

@ayeletstarkware ayeletstarkware left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r3, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @ArniStarkware, @elintul, @giladchase, and @MohammadNassar1)


-- commits line 2 at r3:
fix

Code quote:

internal tx

crates/gateway/src/utils.rs line 34 at r1 (raw file):

Previously, MohammadNassar1 (mohammad-starkware) wrote…

I Like it. Updated!

are you going to change 'TransactiontoExecutabkleTransaction`?

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: all files reviewed, 3 unresolved discussions (waiting on @ArniStarkware, @ayeletstarkware, @elintul, and @giladchase)


crates/gateway/src/utils.rs line 34 at r1 (raw file):

Previously, ayeletstarkware (Ayelet Zilber) wrote…

are you going to change 'TransactiontoExecutabkleTransaction`?

changed already

Copy link
Collaborator

@elintul elintul 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 2 files at r1, all commit messages.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @ArniStarkware, @ayeletstarkware, @giladchase, and @MohammadNassar1)

a discussion (no related file):
Please update commit message.



crates/gateway/src/gateway.rs line 146 at r3 (raw file):

    // TODO(Arni): Add the Sierra and the Casm to the mempool input.
    Ok(MempoolInput {
        tx: external_tx_to_executable_tx(&tx, validate_info.tx_hash, validate_info.sender_address),

Add new_from_rpc_tx to ExecutableTransaction; better than a floating function.

Code quote:

external_tx_to_executable_tx

crates/gateway/src/utils.rs line 40 at r3 (raw file):

    tx_hash: TransactionHash,
    sender_address: ContractAddress,
) -> Transaction {

Why is this repeating? I saw this in other PRs.

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/mempool/change-thin-tx-to-internal-tx branch 2 times, most recently from 9217193 to 2139259 Compare August 18, 2024 13:49
@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/gateway/replace-thin-tx-to-internal-tx branch from f466382 to 4cda367 Compare August 18, 2024 14:14
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: all files reviewed (commit messages unreviewed), 6 unresolved discussions (waiting on @ArniStarkware, @ayeletstarkware, @elintul, and @giladchase)

a discussion (no related file):

Previously, elintul (Elin) wrote…

Please update commit message.

updated.



-- commits line 2 at r3:

Previously, ayeletstarkware (Ayelet Zilber) wrote…

fix

Done.


crates/gateway/src/gateway.rs line 146 at r3 (raw file):

Previously, elintul (Elin) wrote…

Add new_from_rpc_tx to ExecutableTransaction; better than a floating function.

What do you mean to rename the function?
Or to use a method instead?


crates/gateway/src/utils.rs line 40 at r3 (raw file):

Previously, elintul (Elin) wrote…

Why is this repeating? I saw this in other PRs.

This one converts from external to full transaction.
The other one converts from thin tx to full tx, and it's temporal, removed here.

Copy link
Collaborator

@elintul elintul 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 2 files at r3, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @ArniStarkware, @ayeletstarkware, @giladchase, and @MohammadNassar1)


crates/gateway/src/gateway.rs line 146 at r3 (raw file):

Previously, MohammadNassar1 (mohammad-starkware) wrote…

What do you mean to rename the function?
Or to use a method instead?

Both.


crates/gateway/src/utils.rs line 51 at r4 (raw file):

                calldata: Calldata::default(),
                nonce_data_availability_mode: DataAvailabilityMode::L1,
                fee_data_availability_mode: DataAvailabilityMode::L2,

Please be minded.

Suggestion:

L1

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/mempool/change-thin-tx-to-internal-tx branch from 2139259 to 33b5252 Compare August 19, 2024 06:02
@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/gateway/replace-thin-tx-to-internal-tx branch from 4cda367 to 588350d Compare August 19, 2024 08:48
Copy link
Collaborator

@elintul elintul left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 3 files at r5, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @ArniStarkware, @ayeletstarkware, @giladchase, and @MohammadNassar1)


crates/starknet_api/src/rpc_transaction.rs line 89 at r5 (raw file):

    // TODO(Arni): Update the function to support all transaction types.
    pub fn new_from_rpc_tx(
        &self,

How come &self is passed? This should be a c-tor.

Suggestion:

    }
    
    // TODO(Arni): Update the function to support all transaction types.
    pub fn new_from_rpc_tx(
        &self,

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/gateway/replace-thin-tx-to-internal-tx branch from 588350d to 2b8cc3a Compare August 19, 2024 08:49
Copy link
Collaborator

@elintul elintul left a comment

Choose a reason for hiding this comment

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

Reviewed all commit messages.
Reviewable status: 2 of 3 files reviewed, 5 unresolved discussions (waiting on @ArniStarkware, @ayeletstarkware, @giladchase, and @MohammadNassar1)


crates/starknet_api/src/rpc_transaction.rs line 89 at r5 (raw file):

Previously, elintul (Elin) wrote…

How come &self is passed? This should be a c-tor.

A c-tor of Transaction.

Copy link
Collaborator

@elintul elintul 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 r6.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @ArniStarkware, @ayeletstarkware, @giladchase, and @MohammadNassar1)

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/gateway/replace-thin-tx-to-internal-tx branch from 2b8cc3a to bcdf1d1 Compare August 19, 2024 08:51
Copy link
Collaborator

@elintul elintul 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 r7, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @ArniStarkware, @ayeletstarkware, @giladchase, and @MohammadNassar1)

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/gateway/replace-thin-tx-to-internal-tx branch from bcdf1d1 to 301ba9f Compare August 19, 2024 08:54
Copy link
Collaborator

@elintul elintul 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 r8, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @ArniStarkware, @ayeletstarkware, @giladchase, and @MohammadNassar1)

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/gateway/replace-thin-tx-to-internal-tx branch from 301ba9f to 1550b81 Compare August 19, 2024 09:01
Copy link
Collaborator

@elintul elintul left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 3 files at r9, all commit messages.
Reviewable status: all files reviewed, 7 unresolved discussions (waiting on @ArniStarkware, @ayeletstarkware, @giladchase, and @MohammadNassar1)


crates/starknet_api/src/executable_transaction.rs line 67 at r9 (raw file):

    // TODO(Arni): Update the function to support all transaction types.
    pub fn new_from_rpc_tx(
        rpc_tx: crate::rpc_transaction::RpcTransaction,

Why fully-qualified?

Code quote:

crate::rpc_transaction::RpcTransaction

crates/starknet_api/src/executable_transaction.rs line 74 at r9 (raw file):

            tx: crate::transaction::InvokeTransaction::V3(
                crate::transaction::InvokeTransactionV3 {
                    sender_address,

For invoke, take the address from the input transaction.

Code quote:

sender_address,

crates/starknet_api/src/executable_transaction.rs line 76 at r9 (raw file):

                    sender_address,
                    tip: *rpc_tx.tip(),
                    nonce: *rpc_tx.nonce(),

Why cloning?

Code quote:

                    tip: *rpc_tx.tip(),
                    nonce: *rpc_tx.nonce(),

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/gateway/replace-thin-tx-to-internal-tx branch 2 times, most recently from b361bd9 to d81f9e5 Compare August 19, 2024 09:06
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: 2 of 4 files reviewed, 7 unresolved discussions (waiting on @ArniStarkware, @ayeletstarkware, @elintul, and @giladchase)


crates/gateway/src/gateway.rs line 146 at r3 (raw file):

Previously, elintul (Elin) wrote…

Both.

Done.


crates/gateway/src/utils.rs line 51 at r4 (raw file):

Previously, elintul (Elin) wrote…

Please be minded.

Sorry :(.


crates/starknet_api/src/executable_transaction.rs line 67 at r9 (raw file):

Previously, elintul (Elin) wrote…

Why fully-qualified?

removed


crates/starknet_api/src/rpc_transaction.rs line 89 at r5 (raw file):

Previously, elintul (Elin) wrote…

A c-tor of Transaction.

Done.

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: 2 of 4 files reviewed, 7 unresolved discussions (waiting on @Arni, @ArniStarkware, @ayeletstarkware, @elintul, and @giladchase)


crates/starknet_api/src/executable_transaction.rs line 74 at r9 (raw file):

Previously, elintul (Elin) wrote…

For invoke, take the address from the input transaction.

The sender address is calculated during the stateful validation.
and the method should be generic (@Arni will update it).


crates/starknet_api/src/executable_transaction.rs line 76 at r9 (raw file):

Previously, elintul (Elin) wrote…

Why cloning?

It returns &Nonce, and &Tip.

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/mempool/change-thin-tx-to-internal-tx branch from 33b5252 to 4e0601a Compare August 19, 2024 09:17
Copy link
Collaborator

@elintul elintul left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r10, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @Arni, @ArniStarkware, @ayeletstarkware, and @giladchase)


crates/gateway/src/utils.rs line 51 at r4 (raw file):

Previously, MohammadNassar1 (mohammad-starkware) wrote…

Sorry :(.

No worries.


crates/starknet_api/src/executable_transaction.rs line 67 at r9 (raw file):

Previously, MohammadNassar1 (mohammad-starkware) wrote…

removed

Can it receive it by value? The RpcTransaction isn't used after this.


crates/starknet_api/src/executable_transaction.rs line 74 at r9 (raw file):

Previously, MohammadNassar1 (mohammad-starkware) wrote…

The sender address is calculated during the stateful validation.
and the method should be generic (@Arni will update it).

For invoke, it shouldn't be used.

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/mempool/change-thin-tx-to-internal-tx branch from 4e0601a to fdd402c Compare August 19, 2024 12:22
@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/gateway/replace-thin-tx-to-internal-tx branch from d81f9e5 to 3b08d91 Compare August 19, 2024 12:54
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: all files reviewed, 5 unresolved discussions (waiting on @Arni, @ArniStarkware, @ayeletstarkware, @elintul, and @giladchase)


crates/starknet_api/src/executable_transaction.rs line 67 at r9 (raw file):

Previously, elintul (Elin) wrote…

Can it receive it by value? The RpcTransaction isn't used after this.

Can you explain, please, why we need to pass by value and not by ref?
What if we'll use it after this?

Copy link
Collaborator

@elintul elintul 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, 5 unresolved discussions (waiting on @Arni, @ArniStarkware, @ayeletstarkware, and @giladchase)


crates/starknet_api/src/executable_transaction.rs line 67 at r9 (raw file):

Previously, MohammadNassar1 (mohammad-starkware) wrote…

Can you explain, please, why we need to pass by value and not by ref?
What if we'll use it after this?

But we don't, it's the return value of process_tx; i.e., the last line of the function.

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/mempool/change-thin-tx-to-internal-tx branch from fdd402c to 5e66da1 Compare August 19, 2024 13:27
Copy link
Collaborator

@elintul elintul 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, 3 unresolved discussions (waiting on @ArniStarkware, @ayeletstarkware, and @giladchase)


crates/starknet_api/src/executable_transaction.rs line 74 at r9 (raw file):

Previously, elintul (Elin) wrote…

For invoke, it shouldn't be used.

Add a TODO with your suggestion.

Copy link
Collaborator

@elintul elintul left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @ArniStarkware, @ayeletstarkware, and @giladchase)

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/gateway/replace-thin-tx-to-internal-tx branch from 3b08d91 to f9fcf99 Compare August 19, 2024 14:11
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: 2 of 5 files reviewed, 3 unresolved discussions (waiting on @ArniStarkware, @ayeletstarkware, @elintul, and @giladchase)


crates/starknet_api/src/executable_transaction.rs line 67 at r9 (raw file):

Previously, elintul (Elin) wrote…

But we don't, it's the return value of process_tx; i.e., the last line of the function.

Changed to by value.


crates/starknet_api/src/executable_transaction.rs line 74 at r9 (raw file):

Previously, elintul (Elin) wrote…

Add a TODO with your suggestion.

Added.

Copy link
Collaborator

@elintul elintul left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 3 files at r11, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @ArniStarkware, @ayeletstarkware, and @giladchase)


crates/starknet_api/src/executable_transaction.rs line 67 at r9 (raw file):

Previously, MohammadNassar1 (mohammad-starkware) wrote…

Changed to by value.

For the record: this is temporary, until Sierra class is sent to mempool, to be propagated by P2P.

Base automatically changed from mohammad/mempool/change-thin-tx-to-internal-tx to main August 20, 2024 07:18
@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/gateway/replace-thin-tx-to-internal-tx branch from f9fcf99 to 3472d88 Compare August 20, 2024 07:26
Copy link
Contributor

@ayeletstarkware ayeletstarkware 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 r8, 1 of 3 files at r9, 3 of 3 files at r11, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @ArniStarkware and @giladchase)

Copy link
Contributor

@ayeletstarkware ayeletstarkware 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 @ArniStarkware and @giladchase)

@MohammadNassar1 MohammadNassar1 merged commit ec95a9b into main Aug 20, 2024
10 checks passed
@MohammadNassar1 MohammadNassar1 deleted the mohammad/gateway/replace-thin-tx-to-internal-tx branch August 20, 2024 07:54
@github-actions github-actions bot locked and limited conversation to collaborators Aug 22, 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.

4 participants