Skip to content

Add augmented submit fields to sign-and-submit mode#6304

Open
Copilot wants to merge 10 commits intodevelopfrom
copilot/add-augmented-submit-fields
Open

Add augmented submit fields to sign-and-submit mode#6304
Copilot wants to merge 10 commits intodevelopfrom
copilot/add-augmented-submit-fields

Conversation

Copy link
Contributor

Copilot AI commented Jan 30, 2026

High Level Overview of Change

The submit RPC returns augmented fields (added in #3125) only for binary blob submissions, not for sign-and-submit mode. This PR adds the missing fields to sign-and-submit responses and refactors the code to eliminate duplication.

Context of Change

PR #3125 added augmented response fields to submit: accepted, applied, broadcast, queued, kept, account_sequence_next, account_sequence_available, open_ledger_cost, and validated_ledger_index. These fields were only implemented in the binary blob code path (Submit.cpp), not in the sign-and-submit path (TransactionSign.cpp).

To address code review feedback, the implementation has been refactored to extract a shared helper function (populateAugmentedSubmitFields) that both code paths now use. This eliminates code duplication and ensures both submission modes remain consistent in the future.

Bug introduced: v1.5.0-b6 (PR #3125)

Previous behavior: Sign-and-submit returned only legacy fields (tx_json, tx_blob, engine_result*)

Fixed behavior: Both submission modes now return identical augmented fields using a shared implementation

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Refactor (non-breaking change that only restructures code)
  • Tests (you added tests for code that already exists, or your new feature included in this PR)

API Impact

  • Public API: New feature (new methods and/or new fields)

Before / After

Before:

// Sign-and-submit response (missing fields)
{
  "result": {
    "deprecated": "...",
    "status": "success",
    "tx_blob": "...",
    "tx_json": { ... }
  }
}

After:

// Sign-and-submit response (complete)
{
  "result": {
    "deprecated": "...",
    "status": "success",
    "tx_blob": "...",
    "tx_json": { ... },
    "accepted": true,
    "applied": false,
    "broadcast": true,
    "queued": false,
    "kept": true,
    "account_sequence_next": 3,
    "account_sequence_available": 3,
    "open_ledger_cost": "10",
    "validated_ledger_index": 2
  }
}

Changes

  • src/xrpld/rpc/detail/TransactionSign.h: Added declaration for populateAugmentedSubmitFields helper function
  • src/xrpld/rpc/detail/TransactionSign.cpp: Added populateAugmentedSubmitFields helper function and updated transactionFormatResultImpl to use it
  • src/xrpld/rpc/handlers/Submit.cpp: Refactored to use the shared populateAugmentedSubmitFields helper function, eliminating code duplication
  • src/test/rpc/Submit_test.cpp: Added test coverage verifying augmented fields presence in both sign-and-submit and binary blob modes
  • API-CHANGELOG.md: Added changelog entry documenting the bugfix for version 2.5.0
Original prompt

This section details on the original issue you should resolve

<issue_title>Augmented submit fields should be included in sign-and-submit mode (Version: 1.5.0-b6)</issue_title>
<issue_description>## Issue Description
The new fields added to the submit method response by #3125 are only provided when you submit a binary blob, not when you provide a JSON and secret.

The fields should be provided in all responses to the submit command.

Steps to Reproduce

For a quick offline test:

  1. Start rippled in standalone mode with a fresh ledger.

     rippled -a --start
    
  2. Sign-and-submit a payment from the genesis account to another address of your choice.

     rippled submit masterpassphrase '{"TransactionType":"Payment", "Account":"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh","Destination":"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", "Amount":"50000000000000000"}'
    

Expected Result

The new fields, such as applied, broadcast, account_sequence_available, etc. should be included in the response. Here's an example of a similar transaction submitted as binary, with the new fields provided:

Loading: "/home/mduo13/.config/ripple/rippled.cfg"
2020-Mar-05 00:28:16.291423410 UTC HTTPClient:NFO Connecting to 127.0.0.1:5005

{
   "result" : {
      "accepted" : true,
      "account_sequence_available" : 3,
      "account_sequence_next" : 3,
      "applied" : false,
      "broadcast" : true,
      "engine_result" : "tecUNFUNDED_PAYMENT",
      "engine_result_code" : 104,
      "engine_result_message" : "Insufficient XRP balance to send.",
      "kept" : true,
      "open_ledger_cost" : "10",
      "queued" : false,
      "status" : "success",
      "tx_blob" : "120000228000000024000000026140B1A2BC2EC5000068400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074473045022100856282EB45272689B3E51E9888089497DBCE3C01F28E11BD8403D5195878656502202A32A11DA97AAA2D27F1BEE36FD03017CD7F1645A6E4D863E83B8A570077F67C8114B5F762798A53D543A014CAF8B297CFF8F2F937E883144B4E9C06F24296074F7BC48F92A97916C6DC5EA9",
      "tx_json" : {
         "Account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
         "Amount" : "50000000000000000",
         "Destination" : "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
         "Fee" : "10",
         "Flags" : 2147483648,
         "Sequence" : 2,
         "SigningPubKey" : "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020",
         "TransactionType" : "Payment",
         "TxnSignature" : "3045022100856282EB45272689B3E51E9888089497DBCE3C01F28E11BD8403D5195878656502202A32A11DA97AAA2D27F1BEE36FD03017CD7F1645A6E4D863E83B8A570077F67C",
         "hash" : "9712FE0C29D1FF0351BFC1E7874CB077F95C032B07C7DEE8D84B13211008C6CF"
      },
      "validated_ledger_index" : 2
   }
}

Actual Result

Actual result matches the old (v1.4.0 and lower) result fields for the submit method:

Loading: "/home/mduo13/.config/ripple/rippled.cfg"
2020-Mar-05 00:28:07.292019643 UTC HTTPClient:NFO Connecting to 127.0.0.1:5005

{
   "result" : {
      "deprecated" : "This command has been deprecated and will be removed in a future version of the server. Please migrate to a standalone signing tool.",
      "status" : "success",
      "tx_blob" : "120000228000000024000000026140B1A2BC2EC5000068400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074473045022100856282EB45272689B3E51E9888089497DBCE3C01F28E11BD8403D5195878656502202A32A11DA97AAA2D27F1BEE36FD03017CD7F1645A6E4D863E83B8A570077F67C8114B5F762798A53D543A014CAF8B297CFF8F2F937E883144B4E9C06F24296074F7BC48F92A97916C6DC5EA9",
      "tx_json" : {
         "Account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
         "Amount" : "50000000000000000",
         "Destination" : "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
         "Fee" : "10",
         "Flags" : 2147483648,
         "Sequence" : 2,
         "SigningPubKey" : "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020",
         "TransactionType" : "Payment",
         "TxnSignature" : "3045022100856282EB45272689B3E51E9888089497DBCE3C01F28E11BD8403D5195878656502202A32A11DA97AAA2D27F1BEE36FD03017CD7F1645A6E4D863E83B8A570077F67C",
         "hash" : "9712FE0C29D1FF0351BFC1E7874CB077F95C032B07C7DEE8D84B13211008C6CF"
      }
   }
}

Environment

Version: rippled version 1.5.0-b6
OS: Arch Linux (latest) x86_64
Self-compiled, Boost 1.72.0. All unit tests pass.

</issue_description>

<agent_instructions>Update the submit RPC in sign-and-submit mode to add the missing fields. You can use the regular submit mode to understand how to fetch and add the fields. Note the issue description and the linked PR for a list of all the missing fields. There should also be tests added for this.
One relevant file is probably src/xrpld/rpc/handlers/Submit.cpp.</agent_instructions>

Comments on the Issue (you are...


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits January 30, 2026 15:24
Co-authored-by: mvadari <8029314+mvadari@users.noreply.github.com>
Co-authored-by: mvadari <8029314+mvadari@users.noreply.github.com>
Co-authored-by: mvadari <8029314+mvadari@users.noreply.github.com>
Copilot AI changed the title [WIP] Add augmented submit fields to sign-and-submit mode Add augmented submit fields to sign-and-submit mode Jan 30, 2026
Copilot AI requested a review from mvadari January 30, 2026 15:31
@mvadari mvadari marked this pull request as ready for review January 30, 2026 15:38
@mvadari mvadari requested review from a team and Copilot January 30, 2026 15:38
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR ensures that the submit RPC returns the same augmented result fields in sign-and-submit mode as it already does in binary blob mode, fixing an inconsistency introduced in v1.5.0-b6.

Changes:

  • Extended transactionFormatResultImpl in TransactionSign.cpp to attach the augmented submit fields (accepted, applied, broadcast, queued, kept, plus ledger state fields) based on Transaction::getSubmitResult() and getCurrentLedgerState(), mirroring the existing blob submit handler.
  • Added Submit_test RPC tests to verify that both sign-and-submit and binary blob submission paths return the augmented fields.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/xrpld/rpc/detail/TransactionSign.cpp Adds population of the augmented submit and current-ledger-state fields to sign-and-submit responses, aligning them with the binary blob submit behavior.
src/test/rpc/Submit_test.cpp Introduces RPC tests that assert presence of the augmented fields in both sign-and-submit and binary submit flows, guarding against regressions of this bug.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 703 to 719
auto const submitResult = tpTrans->getSubmitResult();

jvResult[jss::accepted] = submitResult.any();
jvResult[jss::applied] = submitResult.applied;
jvResult[jss::broadcast] = submitResult.broadcast;
jvResult[jss::queued] = submitResult.queued;
jvResult[jss::kept] = submitResult.kept;

if (auto currentLedgerState = tpTrans->getCurrentLedgerState())
{
jvResult[jss::account_sequence_next] = safe_cast<Json::Value::UInt>(currentLedgerState->accountSeqNext);
jvResult[jss::account_sequence_available] =
safe_cast<Json::Value::UInt>(currentLedgerState->accountSeqAvail);
jvResult[jss::open_ledger_cost] = to_string(currentLedgerState->minFeeRequired);
jvResult[jss::validated_ledger_index] =
safe_cast<Json::Value::UInt>(currentLedgerState->validatedLedger);
}
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

The logic that populates the augmented submit fields (accepted/applied/broadcast/queued/kept and the current ledger state fields) is now duplicated here and in rpc/handlers/Submit.cpp (lines 130–145). Duplicating this block in two places increases the risk that the fields diverge in the future if one call site is updated but the other is not. Consider extracting a small helper that takes a Transaction::pointer (and maybe apiVersion, if needed) and mutates a Json::Value with these fields, so both the binary-blob submit path and the sign-and-submit path share the exact same implementation.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Extracted populateAugmentedSubmitFields helper function to eliminate code duplication. Both Submit.cpp and TransactionSign.cpp now use the same implementation. See commit d18a9e2.

@mvadari
Copy link
Collaborator

mvadari commented Jan 30, 2026

@copilot

  • Please run pre-commit and fix the issues
  • Please update the API-CHANGELOG.md with these changes

…GELOG

Co-authored-by: mvadari <8029314+mvadari@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 30, 2026

@copilot

  • Please run pre-commit and fix the issues
  • Please update the API-CHANGELOG.md with these changes

Pre-commit has been run and all issues fixed. API-CHANGELOG.md has been updated with the changes under version 2.5.0. See commit d18a9e2.

@codecov
Copy link

codecov bot commented Jan 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.9%. Comparing base (677758b) to head (980b152).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           develop   #6304   +/-   ##
=======================================
  Coverage     79.9%   79.9%           
=======================================
  Files          840     840           
  Lines        65483   65484    +1     
  Branches      7255    7247    -8     
=======================================
+ Hits         52311   52327   +16     
+ Misses       13172   13157   -15     
Files with missing lines Coverage Δ
src/xrpld/rpc/detail/TransactionSign.cpp 90.0% <100.0%> (+0.2%) ⬆️
src/xrpld/rpc/detail/TransactionSign.h 100.0% <ø> (ø)
src/xrpld/rpc/handlers/Submit.cpp 79.0% <100.0%> (-3.4%) ⬇️

... and 6 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mvadari mvadari added API Change Added to API Changelog API changes have been documented in API-CHANGELOG.md labels Jan 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Added to API Changelog API changes have been documented in API-CHANGELOG.md API Change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Augmented submit fields should be included in sign-and-submit mode (Version: 1.5.0-b6)

2 participants