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

fix issues in simulate RPC #5265

Merged
merged 9 commits into from
Feb 7, 2025
Merged

fix issues in simulate RPC #5265

merged 9 commits into from
Feb 7, 2025

Conversation

mvadari
Copy link
Collaborator

@mvadari mvadari commented Jan 30, 2025

High Level Overview of Change

This PR prevents the use of seed, secret, seed_hex, and passphrase fields in the simulate RPC, and adds autofilling for NetworkIDs in simulated transactions.

Context of Change

The former is to avoid confusion with RPCs like sign and simulate. Transactions provided in the simulate RPC are supposed to be unsigned, so users should also not submit any secrets alongside those transactions.

The latter is to make it easier to work with networks with a larger network ID.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

API Impact

  • Public API: Fix

Test Plan

Tests added.

@mvadari mvadari requested review from Bronek and oleks-rip January 30, 2025 16:54
Bronek
Bronek previously approved these changes Jan 30, 2025
Copy link
Collaborator

@Bronek Bronek left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

codecov bot commented Jan 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.1%. Comparing base (02387fd) to head (1eb8578).
Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           develop   #5265   +/-   ##
=======================================
  Coverage     78.1%   78.1%           
=======================================
  Files          790     790           
  Lines        67607   67619   +12     
  Branches      8164    8163    -1     
=======================================
+ Hits         52828   52842   +14     
+ Misses       14779   14777    -2     
Files with missing lines Coverage Δ
src/xrpld/rpc/detail/TransactionSign.cpp 90.0% <100.0%> (+0.1%) ⬆️
src/xrpld/rpc/handlers/Simulate.cpp 100.0% <100.0%> (ø)

... and 2 files with indirect coverage changes

Impacted file tree graph

oleks-rip
oleks-rip previously approved these changes Jan 30, 2025
Copy link
Collaborator

@oleks-rip oleks-rip left a comment

Choose a reason for hiding this comment

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

Looks good

@mvadari mvadari added Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required. and removed Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required. labels Jan 30, 2025
@mvadari
Copy link
Collaborator Author

mvadari commented Feb 5, 2025

Adding another fix to this PR

@mvadari mvadari requested review from oleks-rip and Bronek February 5, 2025 15:31
@mvadari mvadari dismissed stale reviews from Bronek and oleks-rip February 5, 2025 15:32

Added a new nontrivial commit

@mvadari mvadari changed the title fix: prevent seed fields in simulate RPC fix issues in simulate RPC Feb 5, 2025
@mvadari
Copy link
Collaborator Author

mvadari commented Feb 5, 2025

Tentative commit message:

make `simulate` RPC easier to use
- prevent the use of `seed`, `secret`, `seed_hex`, and `passphrase` fields (to avoid confusing with the signing methods)\
- add autofilling of the `NetworkID` field

@Bronek Bronek self-requested a review February 5, 2025 20:29
Copy link
Collaborator

@Bronek Bronek left a comment

Choose a reason for hiding this comment

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

Can you pls add an item into API-CHANGELOG.md with the new behaviour of sign-and-submit ?

@mvadari mvadari added this to the 2.4.0 (Feb 2025) milestone Feb 5, 2025
@@ -467,6 +467,13 @@ transactionPreProcessImpl(

if (!tx_json.isMember(jss::Flags))
tx_json[jss::Flags] = tfFullyCanonicalSig;

if (!tx_json.isMember(jss::NetworkID))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please move if (signingArgs.editFields()) block into separate "Autofill" function. transactionPreProcessImpl is already too big and better to split it

Copy link
Collaborator

@oleks-rip oleks-rip Feb 6, 2025

Choose a reason for hiding this comment

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

I have even better idea - the same "Autofill" function must be the used across "submit" and "simulate" (to produce even more consistent results).

Copy link
Collaborator Author

@mvadari mvadari Feb 6, 2025

Choose a reason for hiding this comment

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

I think that's out of scope of this particular PR - but yes, would like to do that as a future refactor.

Copy link
Collaborator

@oleks-rip oleks-rip Feb 6, 2025

Choose a reason for hiding this comment

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

Expanding already big function is a bad change, so I better insist on moving out autofill block. Reusing "autofill" with the "simulate" is up to you, I can't assess the complexity of this change now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Refactoring will expand this PR from just a couple of lines changing here to being much larger, which will also require more testing etc.

Copy link
Collaborator

@oleks-rip oleks-rip left a comment

Choose a reason for hiding this comment

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

ok

@mvadari mvadari added the Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required. label Feb 6, 2025
@kuznetsss
Copy link
Contributor

Ok from Clio team

@bthomee bthomee merged commit d9e4009 into XRPLF:develop Feb 7, 2025
22 checks passed
@mvadari mvadari deleted the simulate-seed branch February 7, 2025 20:27
This was referenced Feb 18, 2025
q73zhao pushed a commit that referenced this pull request Feb 24, 2025
Make `simulate` RPC easier to use:
* Prevent the use of `seed`, `secret`, `seed_hex`, and `passphrase` fields (to avoid confusing with the signing methods).
* Add autofilling of the `NetworkID` field.
This was referenced Feb 26, 2025
This was referenced Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants