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(mempool): add pending transaction type #439

Merged

Conversation

MohammadNassar1
Copy link
Contributor

@MohammadNassar1 MohammadNassar1 commented Aug 13, 2024

This change is Reviewable

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/transaction-reference/add-resource-bounds branch from 4cdc00b to fcb733d Compare August 15, 2024 14:54
@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/transaction-queue/add-pending-transaction-type branch from 7bff7dc to 55308a2 Compare August 15, 2024 14:56
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 r1, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @ayeletstarkware, @giladchase, and @MohammadNassar1)


crates/mempool/src/mempool.rs line 238 at r1 (raw file):

        }
    }

Aren't there these getters in SN API?


crates/mempool/src/transaction_queue.rs line 71 at r1 (raw file):

}

/// Encapsulates a transaction reference to assess its order (i.e., priority).

Update comment.

Code quote:

priority

crates/mempool/src/transaction_queue.rs line 72 at r1 (raw file):

/// Encapsulates a transaction reference to assess its order (i.e., priority).
/// A transaction with gas price below the threshold. Sorted according to the gas price.

This belongs next to the data structure that will be holding them; it's our of scope for the transaction struct itself.

Code quote:

/// A transaction with gas price below the threshold. Sorted according to the gas price.

crates/mempool/src/transaction_queue.rs line 77 at r1 (raw file):

/// Compare transactions based only on their gas price, a uint, using the Eq trait. It ensures that
/// two gas price are either exactly equal or not.

But it's the PartialEq trait, I'm confused.
Also, this comment isn't clear to me in general. Did you understand it?

Code quote:

/// Compare transactions based only on their gas price, a uint, using the Eq trait. It ensures that
/// two gas price are either exactly equal or not.

crates/mempool/src/transaction_queue.rs line 101 at r1 (raw file):

        Some(self.cmp(other))
    }
}

I wouldn't repeat all comments for the two structs. Better to refer the reader to PendingTransaction's documentation.

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/transaction-reference/add-resource-bounds branch 3 times, most recently from 362f5e4 to f1559fc Compare August 20, 2024 08:26
@MohammadNassar1 MohammadNassar1 changed the base branch from mohammad/transaction-reference/add-resource-bounds to main August 20, 2024 11:12
@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/transaction-queue/add-pending-transaction-type branch 2 times, most recently from 2da3d4c to c57d7dd Compare August 20, 2024 11:25
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 @ayeletstarkware, @elintul, and @giladchase)


crates/mempool/src/mempool.rs line 238 at r1 (raw file):

Previously, elintul (Elin) wrote…

Aren't there these getters in SN API?

No.


crates/mempool/src/transaction_queue.rs line 101 at r1 (raw file):

Previously, elintul (Elin) wrote…

I wouldn't repeat all comments for the two structs. Better to refer the reader to PendingTransaction's documentation.

Done

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


crates/mempool/src/mempool.rs line 238 at r1 (raw file):

Previously, MohammadNassar1 (mohammad-starkware) wrote…

No.

Don't think they should be public though. Note visibility in general; and specifically when the compiler doesn't complain about unused code - means the code is public, we should be convinced it needs to be.


crates/mempool/src/mempool.rs line 235 at r2 (raw file):

    }

    pub fn get_l2_gas_price(&self) -> Option<u128> {

Do we need this?

Code quote:

get_l2_gas_price

crates/mempool/src/transaction_queue.rs line 102 at r2 (raw file):

}

/// This struct behaves similarly to [`PendingTransaction`], It encapsulates a transaction reference

Suggestion:

, encapsulating

crates/mempool/src/transaction_queue.rs line 106 at r2 (raw file):

/// # See Also
///
/// - [`PendingTransaction`]: for details.

How do I see the resulting doc. file from this?

Code quote:

/// # See Also
///
/// - [`PendingTransaction`]: for details.

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


crates/mempool/src/transaction_queue.rs line 77 at r1 (raw file):

Previously, elintul (Elin) wrote…

But it's the PartialEq trait, I'm confused.
Also, this comment isn't clear to me in general. Did you understand it?

I think Gilad added this comment.
What's unclear exactly?
PartialEq implements eq method.

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/transaction-queue/add-pending-transaction-type branch from c57d7dd to 158d54c Compare August 20, 2024 11:42
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, 5 unresolved discussions (waiting on @ayeletstarkware, @elintul, and @giladchase)


crates/mempool/src/mempool.rs line 238 at r1 (raw file):

Previously, elintul (Elin) wrote…

Don't think they should be public though. Note visibility in general; and specifically when the compiler doesn't complain about unused code - means the code is public, we should be convinced it needs to be.

It needs to be public so that it can be used in tx queue file.


crates/mempool/src/mempool.rs line 235 at r2 (raw file):

Previously, elintul (Elin) wrote…

Do we need this?

I assume you mean l1.
Removed; it will be added once mempool considers the l1 price.


crates/mempool/src/transaction_queue.rs line 102 at r2 (raw file):

}

/// This struct behaves similarly to [`PendingTransaction`], It encapsulates a transaction reference

Done.


crates/mempool/src/transaction_queue.rs line 106 at r2 (raw file):

Previously, elintul (Elin) wrote…

How do I see the resulting doc. file from this?

Not sure I get it.
What do you mean?

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


crates/mempool/src/mempool.rs line 238 at r1 (raw file):

Previously, MohammadNassar1 (mohammad-starkware) wrote…

It needs to be public so that it can be used in tx queue file.

Okay, cool. I thought it was the other way around.


crates/mempool/src/transaction_queue.rs line 106 at r2 (raw file):

Previously, MohammadNassar1 (mohammad-starkware) wrote…

Not sure I get it.
What do you mean?

The HTML doc. that is created from this doc.; I think you should run cargo build docs or something similar. Was wondering about this syntax, since I don't recognize it.


crates/mempool/src/transaction_queue.rs line 75 at r3 (raw file):

struct PendingTransaction(pub TransactionReference);

/// Compare transactions based only on their gas price, a uint, using the Eq trait. It ensures that

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/transaction-queue/add-pending-transaction-type branch from 158d54c to 582a989 Compare August 20, 2024 13:14
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 r4, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ayeletstarkware, @giladchase, and @MohammadNassar1)

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.

Reviewed 1 of 2 files at r3.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ayeletstarkware, @elintul, and @giladchase)


crates/mempool/src/transaction_queue.rs line 106 at r2 (raw file):

Previously, elintul (Elin) wrote…

The HTML doc. that is created from this doc.; I think you should run cargo build docs or something similar. Was wondering about this syntax, since I don't recognize it.

It seems that it only generates public code, and transactino_queue is a private module.
See output:
file:///home/lt-mohammadn/workspace/sequencer1/target/doc/starknet_mempool/mempool/struct.Mempool.html

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


crates/mempool/src/transaction_queue.rs line 105 at r4 (raw file):

/// to assess its order (i.e., tip).
///
/// # See also `PendingTransaction` docstring for details.

Suggestion:

/// to assess its order (i.e., tip); see its documentation for more details.

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/transaction-queue/add-pending-transaction-type branch 2 times, most recently from f4eb3bd to 591f6f6 Compare August 20, 2024 14:05
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 r5, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ayeletstarkware, @giladchase, and @MohammadNassar1)


crates/mempool/src/mempool.rs line 219 at r5 (raw file):

    pub resource_bounds: ResourceBoundsMapping,
}

Keep error messages (tip and L2 gas) in same format.
Also, is this the earliest point of time this can happen in?

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/transaction-queue/add-pending-transaction-type branch from 591f6f6 to 9e88b7d Compare August 20, 2024 14: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: 1 of 3 files reviewed, 1 unresolved discussion (waiting on @ayeletstarkware, @elintul, and @giladchase)


crates/mempool/src/mempool.rs line 219 at r5 (raw file):

Previously, elintul (Elin) wrote…

Keep error messages (tip and L2 gas) in same format.
Also, is this the earliest point of time this can happen in?

Done.
As the current Transaction type may be a deprecated version, this is the earliest point.

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 r6, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ayeletstarkware, @giladchase, and @MohammadNassar1)


crates/mempool/src/mempool.rs line 219 at r5 (raw file):

Previously, MohammadNassar1 (mohammad-starkware) wrote…

Done.
As the current Transaction type may be a deprecated version, this is the earliest point.

@ArniStarkware, should be changed.


crates/mempool/src/mempool.rs line 239 at r6 (raw file):

            .get(&Resource::L2Gas)
            .map(|bounds| bounds.max_price_per_unit)
            .expect("Expected L2Gas resource found")

Why is it still optional here? This should change in 0.13.3, right?
Please align the error message here too.

Code quote:

            .map(|bounds| bounds.max_price_per_unit)
            .expect("Expected L2Gas resource found")

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


crates/mempool/src/mempool.rs line 239 at r6 (raw file):

Previously, elintul (Elin) wrote…

Why is it still optional here? This should change in 0.13.3, right?
Please align the error message here too.

because resource bounds is a map of resource to resource bound.
So here it is optional since the map keys "may" not include L2Resource.

What do you mean by "align the error message"? Here, I cannot say "expected a valid resource but received none." The resource is not none, the resource is not existed, so I wrote "L2Gas should be found". wdyt?

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/transaction-queue/add-pending-transaction-type branch from 9e88b7d to 322d3fc Compare August 20, 2024 15:13
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, 1 unresolved discussion (waiting on @ayeletstarkware, @giladchase, and @MohammadNassar1)


crates/mempool/src/mempool.rs line 239 at r6 (raw file):

Previously, MohammadNassar1 (mohammad-starkware) wrote…

because resource bounds is a map of resource to resource bound.
So here it is optional since the map keys "may" not include L2Resource.

What do you mean by "align the error message"? Here, I cannot say "expected a valid resource but received none." The resource is not none, the resource is not existed, so I wrote "L2Gas should be found". wdyt?

You can say expected a valid X value, without say what you received.

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/transaction-queue/add-pending-transaction-type branch from 322d3fc to 053ae9a Compare August 20, 2024 18:53
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 3 files reviewed, 1 unresolved discussion (waiting on @ayeletstarkware, @elintul, and @giladchase)


crates/mempool/src/mempool.rs line 239 at r6 (raw file):

Previously, elintul (Elin) wrote…

You can say expected a valid X value, without say what you received.

Done.

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


crates/mempool/src/mempool.rs line 212 at r8 (raw file):

            nonce: tx.nonce(),
            tx_hash: tx.tx_hash(),
            tip: tx.tip().expect("Expected a valid tip value, but received None."),

Suggestion:

"Expected a valid tip value."

crates/mempool/src/mempool.rs line 215 at r8 (raw file):

            resource_bounds: tx
                .resource_bounds()
                .expect("Expected a valid resource bounds value, but received None.")

Suggestion:

"Expected a valid resource bounds value."

crates/mempool/src/mempool.rs line 225 at r8 (raw file):

            .get(&Resource::L2Gas)
            .map(|bounds| bounds.max_price_per_unit)
            .expect("Expected a valid L2Gas resource.")

Suggestion:

"Expected a valid L2 gas resource bounds."

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/transaction-queue/add-pending-transaction-type branch from 053ae9a to 9048645 Compare August 21, 2024 05:10
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:

Reviewed 1 of 1 files at r9, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ayeletstarkware and @giladchase)

@ArniStarkware
Copy link
Contributor

crates/mempool/src/mempool.rs line 219 at r5 (raw file):

Previously, elintul (Elin) wrote…

@ArniStarkware, should be changed.

I don't follow.

@ArniStarkware
Copy link
Contributor

crates/mempool/src/mempool.rs line 219 at r5 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

I don't follow.

I do follow :)

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: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ayeletstarkware and @giladchase)

@MohammadNassar1 MohammadNassar1 merged commit f31354d into main Aug 21, 2024
10 checks passed
@MohammadNassar1 MohammadNassar1 deleted the mohammad/transaction-queue/add-pending-transaction-type branch August 21, 2024 08:07
@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.

3 participants