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(JSON-RPC): get_transaction_receipt supports pending #1284

Merged
merged 1 commit into from
Oct 22, 2023

Conversation

ShahakShama
Copy link
Contributor

@ShahakShama ShahakShama commented Oct 17, 2023

This change is Reviewable

Copy link
Contributor Author

@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.

+reviewer:@Yael-Starkware

Reviewable status: 0 of 8 files reviewed, all discussions resolved (waiting on @dan-starkware, @Yael-Starkware, and @yair-starkware)

Copy link
Contributor Author

@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: 0 of 8 files reviewed, all discussions resolved (waiting on @dan-starkware, @Yael-Starkware, and @yair-starkware)

a discussion (no related file):
LMK if this PR is too big and you prefer I split it


@codecov
Copy link

codecov bot commented Oct 17, 2023

Codecov Report

Merging #1284 (6697fbc) into rpc_pending (8c97a85) will decrease coverage by 0.40%.
Report is 24 commits behind head on rpc_pending.
The diff coverage is 58.87%.

❗ Current head 6697fbc differs from pull request most recent head df8169b. Consider uploading reports for the commit df8169b to get more accurate results

@@               Coverage Diff               @@
##           rpc_pending    #1284      +/-   ##
===============================================
- Coverage        72.94%   72.54%   -0.40%     
===============================================
  Files               84       84              
  Lines             8156     8349     +193     
  Branches          8156     8349     +193     
===============================================
+ Hits              5949     6057     +108     
- Misses            1240     1300      +60     
- Partials           967      992      +25     
Files Coverage Δ
crates/papyrus_rpc/src/lib.rs 92.85% <ø> (ø)
crates/papyrus_storage/src/db/mod.rs 83.87% <100.00%> (+0.08%) ⬆️
crates/papyrus_storage/src/lib.rs 58.40% <ø> (ø)
...us_sync/src/sources/central/state_update_stream.rs 91.26% <100.00%> (+0.15%) ⬆️
crates/papyrus_sync/src/sources/pending.rs 19.04% <100.00%> (-1.79%) ⬇️
crates/starknet_client/src/reader/objects/block.rs 88.88% <100.00%> (+1.38%) ⬆️
crates/papyrus_rpc/src/v0_4_0/api/mod.rs 50.80% <71.42%> (ø)
crates/papyrus_rpc/src/v0_4_0/block.rs 70.00% <0.00%> (ø)
crates/papyrus_sync/src/sources/central.rs 75.60% <66.66%> (-0.46%) ⬇️
.../starknet_client/src/reader/objects/transaction.rs 36.68% <50.00%> (+2.24%) ⬆️
... and 7 more

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@ShahakShama ShahakShama force-pushed the shahak/pending/get_transaction_receipt branch from 5f03912 to d547fc3 Compare October 18, 2023 04:31
Copy link
Contributor Author

@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: 0 of 8 files reviewed, all discussions resolved (waiting on @dan-starkware, @Yael-Starkware, and @yair-starkware)


crates/papyrus_rpc/resources/V0_4_0/starknet_api_openrpc.json line 2202 at r2 (raw file):

                ]
            },
            "PENDING_INVOKE_TXN_RECEIPT": {

This is taken from the latest version of the specs. I talked to @ArielElp and he prefers we deviate from the specs than fixing v0.4.0 on something that's already fixed in a later version

Copy link
Contributor

@yair-starkware yair-starkware left a comment

Choose a reason for hiding this comment

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

Reviewed 4 of 8 files at r1, 3 of 4 files at r2, all commit messages.
Reviewable status: 7 of 8 files reviewed, 3 unresolved discussions (waiting on @dan-starkware, @ShahakShama, and @Yael-Starkware)


crates/papyrus_rpc/src/v0_4_0/transaction.rs line 396 at r2 (raw file):

#[derive(Debug, Clone, Eq, PartialEq, Hash, Deserialize, Serialize, PartialOrd, Ord)]
#[serde(untagged)]
pub enum GeneralTransactionReceipt {

Why do the pending transactions need their own receipt type?


crates/papyrus_rpc/src/v0_4_0/api/api_impl.rs line 407 at r2 (raw file):

        };

        let block_number = transaction_index.0;

IIUC this code is the continuation of the non-pending transaction flow.
Consider changing to if-let and keep the whole code together.


crates/papyrus_rpc/src/v0_4_0/api/test.rs line 745 at r2 (raw file):

    // Ask for a pending transaction.
    let mut rng = get_rng();

Why randomness?
Can you explain what you are doing here?

@ShahakShama ShahakShama force-pushed the shahak/pending/get_transaction_receipt branch from d547fc3 to 327a439 Compare October 18, 2023 08:11
Copy link
Contributor Author

@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: 7 of 8 files reviewed, 3 unresolved discussions (waiting on @dan-starkware, @Yael-Starkware, and @yair-starkware)


crates/papyrus_rpc/src/v0_4_0/transaction.rs line 396 at r2 (raw file):

Previously, yair-starkware (Yair) wrote…

Why do the pending transactions need their own receipt type?

Because they have no block_hash/number, and their output and finality are more prohibiting


crates/papyrus_rpc/src/v0_4_0/api/api_impl.rs line 407 at r2 (raw file):

Previously, yair-starkware (Yair) wrote…

IIUC this code is the continuation of the non-pending transaction flow.
Consider changing to if-let and keep the whole code together.

Where's the common code that I'll be saving? I don't see any intersection


crates/papyrus_rpc/src/v0_4_0/api/test.rs line 745 at r2 (raw file):

Previously, yair-starkware (Yair) wrote…

Why randomness?
Can you explain what you are doing here?

I'll explain, in function :)

@ShahakShama ShahakShama force-pushed the shahak/pending/get_transaction_receipt branch from 327a439 to c3c786d Compare October 22, 2023 08:03
@yair-starkware
Copy link
Contributor

crates/papyrus_rpc/src/v0_4_0/api/test.rs line 745 at r2 (raw file):

Previously, ShahakShama wrote…

I'll explain, in function :)

Make the pending data hard-coded instead of random

Copy link
Contributor

@yair-starkware yair-starkware left a comment

Choose a reason for hiding this comment

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

Reviewed 5 of 8 files at r8, 3 of 5 files at r9, all commit messages.
Reviewable status: 8 of 10 files reviewed, 2 unresolved discussions (waiting on @dan-starkware, @ShahakShama, and @Yael-Starkware)

@ShahakShama ShahakShama force-pushed the shahak/pending/get_transaction_receipt branch from c3c786d to 6697fbc Compare October 22, 2023 11:44
Copy link
Contributor

@yair-starkware yair-starkware 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 r10, all commit messages.
Reviewable status: 9 of 10 files reviewed, 3 unresolved discussions (waiting on @dan-starkware, @ShahakShama, and @Yael-Starkware)


crates/papyrus_rpc/src/v0_4_0/api/api_impl.rs line 407 at r2 (raw file):

Previously, ShahakShama wrote…

Where's the common code that I'll be saving? I don't see any intersection

discussed


crates/papyrus_rpc/src/v0_4_0/api/test.rs line 770 at r10 (raw file):

    assert_eq!(res.output.execution_status(), &TransactionExecutionStatus::Succeeded);

    // Ask for a pending transaction.

// Add a pending transaction and ask for its receipt.

Code quote:

// Ask for a pending transaction.

crates/papyrus_rpc/src/v0_4_0/api/test.rs line 1270 at r10 (raw file):

    let mut client_transaction_receipt = ClientTransactionReceipt::get_test_instance(rng);
    client_transaction_receipt.transaction_hash = pending_transaction_hash;
    let (mut client_transaction, output) = loop {

Add a comment explaining this loop.

Code quote:

let (mut client_transaction, output) = loop {

crates/papyrus_rpc/src/v0_4_0/api/test.rs line 1276 at r10 (raw file):

            .into_starknet_api_transaction_output(&client_transaction);
        let maybe_output =
            PendingTransactionOutput::try_from(TransactionOutput::from(starknet_api_output));

This code is repeated in multiple in api_impl. Consider creating a function.

Code quote:

        let starknet_api_output = client_transaction_receipt
            .clone()
            .into_starknet_api_transaction_output(&client_transaction);
        let maybe_output =
            PendingTransactionOutput::try_from(TransactionOutput::from(starknet_api_output));

Copy link
Contributor Author

@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: 9 of 10 files reviewed, 2 unresolved discussions (waiting on @dan-starkware, @Yael-Starkware, and @yair-starkware)


crates/papyrus_rpc/src/v0_4_0/api/test.rs line 770 at r10 (raw file):

Previously, yair-starkware (Yair) wrote…

// Add a pending transaction and ask for its receipt.

Done.


crates/papyrus_rpc/src/v0_4_0/api/test.rs line 1270 at r10 (raw file):

Previously, yair-starkware (Yair) wrote…

Add a comment explaining this loop.

Done.

@ShahakShama ShahakShama force-pushed the shahak/pending/get_transaction_receipt branch from 6697fbc to df8169b Compare October 22, 2023 12:45
Copy link
Contributor

@yair-starkware yair-starkware 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 r11, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @dan-starkware and @Yael-Starkware)

@ShahakShama ShahakShama merged commit cc4890f into rpc_pending Oct 22, 2023
17 checks passed
@ShahakShama ShahakShama deleted the shahak/pending/get_transaction_receipt branch October 22, 2023 12:55
@github-actions github-actions bot locked and limited conversation to collaborators Oct 24, 2023
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