Skip to content

refactor: some cleanups in process_tx_internal #13003

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

Merged
merged 5 commits into from
Feb 27, 2025

Conversation

akhi3030
Copy link
Collaborator

  • Remove some more ? by using alternative means to get the data.
  • reduce indentation by inserting explicit returns. This makes it a bit easier to understand what the code is doing. Still I think there is room for improvement but bit by bit.

wip
@akhi3030 akhi3030 requested a review from wacban February 26, 2025 15:29
@akhi3030 akhi3030 requested a review from a team as a code owner February 26, 2025 15:29
Copy link

codecov bot commented Feb 26, 2025

Codecov Report

Attention: Patch coverage is 68.29268% with 13 lines in your changes missing coverage. Please review.

Project coverage is 69.71%. Comparing base (d9b6d9c) to head (2b5efea).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
chain/client/src/client.rs 68.29% 5 Missing and 8 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #13003      +/-   ##
==========================================
+ Coverage   69.69%   69.71%   +0.01%     
==========================================
  Files         859      859              
  Lines      175995   176002       +7     
  Branches   175995   176002       +7     
==========================================
+ Hits       122657   122697      +40     
+ Misses      48176    48150      -26     
+ Partials     5162     5155       -7     
Flag Coverage Δ
backward-compatibility 0.36% <0.00%> (-0.01%) ⬇️
db-migration 0.36% <0.00%> (-0.01%) ⬇️
genesis-check 1.43% <0.00%> (-0.01%) ⬇️
linux 69.11% <68.29%> (+<0.01%) ⬆️
linux-nightly 69.27% <68.29%> (+0.02%) ⬆️
pytests 1.74% <0.00%> (-0.01%) ⬇️
sanity-checks 1.55% <0.00%> (-0.01%) ⬇️
unittests 69.54% <68.29%> (+0.01%) ⬆️
upgradability 0.36% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link
Contributor

@staffik staffik left a comment

Choose a reason for hiding this comment

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

Thanks!

Comment on lines -2330 to +2323
self.forward_tx(&epoch_id, tx, signer)?;
Ok(ProcessTxResponse::RequestRouted)
return Ok(ProcessTxResponse::NoResponse);
}
// We are not tracking this shard, so there is no way to validate this tx. Just rerouting.
self.forward_tx(&epoch_id, tx, signer).map(|()| ProcessTxResponse::RequestRouted)
Copy link
Contributor

Choose a reason for hiding this comment

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

The original version seems more readable to me, but I’m fine with both.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I too think that the original version is easier to read however what I like about this version is that we make it explicit what forward_tx() is returning in the happy path i.e. (). And if we ever make a change there, then the compiler will help us identify all the places where the changes need to be made.

@akhi3030 akhi3030 added this pull request to the merge queue Feb 27, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 27, 2025
@akhi3030 akhi3030 enabled auto-merge February 27, 2025 11:09
@akhi3030 akhi3030 added this pull request to the merge queue Feb 27, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 27, 2025
@akhi3030
Copy link
Collaborator Author

looks like these changes are not correct. Nayduck tests are panicking and I suspect it is probably this line:

.

@akhi3030 akhi3030 enabled auto-merge February 27, 2025 12:24
@akhi3030 akhi3030 added this pull request to the merge queue Feb 27, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 27, 2025
@akhi3030 akhi3030 enabled auto-merge February 27, 2025 13:51

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@akhi3030 akhi3030 added this pull request to the merge queue Feb 27, 2025
Merged via the queue into near:master with commit f7c877d Feb 27, 2025
27 of 29 checks passed
@akhi3030 akhi3030 deleted the refactor-process-tx-internal branch February 27, 2025 14:30
shreyan-gupta pushed a commit to shreyan-gupta/nearcore that referenced this pull request Mar 28, 2025
- Remove some more `?` by using alternative means to get the data.
- reduce indentation by inserting explicit `return`s. This makes it a
bit easier to understand what the code is doing. Still I think there is
room for improvement but bit by bit.
shreyan-gupta pushed a commit to shreyan-gupta/nearcore that referenced this pull request Mar 28, 2025
- Remove some more `?` by using alternative means to get the data.
- reduce indentation by inserting explicit `return`s. This makes it a
bit easier to understand what the code is doing. Still I think there is
room for improvement but bit by bit.
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.

None yet

2 participants