feat(jsonrpc): add "input" as field for transaction input#6467
feat(jsonrpc): add "input" as field for transaction input#6467simbadMarino wants to merge 3 commits intotronprotocol:developfrom
Conversation
Modified unit tests and parameters order
|
Good job! Maybe this pr can be added in the next version, along with some other related interface changes. The features for release 4.8.1 are already close to being ready, and I think it may be too late to include this in this version. |
|
This feature has been included in the discussions for version 4.8.2 |
| @@ -57,8 +60,11 @@ public ContractType getContractType(Wallet wallet) throws JsonRpcInvalidRequestE | |||
| throw new JsonRpcInvalidRequestException("invalid json request"); | |||
| } else if (paramStringIsNull(to)) { | |||
There was a problem hiding this comment.
The new input support is validated with paramStringIsNull(...), but later resolved with StringUtils.isNotEmpty(...) in getTransactionData().
Those are not equivalent in this codebase because paramStringIsNull("0x") == true, while StringUtils.isNotEmpty("0x") == true.
That creates an inconsistent flow where the request can be validated based on data, but then executed using input, silently discarding the actual calldata / bytecode.
Concrete example:
to == nullinput == "0x"data == "0x6080..."
Please use one canonical transaction-data resolver and one emptiness definition everywhere.
| * | ||
| * @return the transaction data/input | ||
| */ | ||
| public String getTransactionData() { |
There was a problem hiding this comment.
The input > data priority is correct, but the conflict case is still undefined.
If both input and data are provided with different values, the current implementation silently prefers input. That makes caller mistakes hard to detect and diverges from geth, which rejects the request explicitly.
Please add a shared conflict check for:
- both fields present
- both non-empty under the project's own null/empty rules
- values not equal
and return a clear params error instead of silently swallowing one side.
| * Check if transaction data parameter is null or empty | ||
| * Supports both 'data' and 'input' parameters | ||
| */ | ||
| public static boolean paramTransactionDataIsNull(String data, String input) { |
There was a problem hiding this comment.
These helpers(paramTransactionDataIsNull and getTransactionData) look like the intended canonical implementation, but they are not actually used by CallArguments / BuildArguments.
Right now the PR adds a shared utility and still keeps separate local implementations, and those implementations already differ on "0x" semantics. Please either:
- make this utility the single source of truth, or
- remove it
but avoid leaving the refactor half-done.
| /** | ||
| * Set transaction data, updating the appropriate field based on which was used | ||
| */ | ||
| public void setTransactionData(String transactionData) { |
There was a problem hiding this comment.
setTransactionData() is currently unused, and its name is broader than its behavior: it only writes data, not input.
That is a maintainability trap for future callers. Please either remove it, or document very explicitly why it only updates data.
| @@ -28,7 +28,7 @@ public class CallArgumentsTest extends BaseTest { | |||
| public void init() { | |||
There was a problem hiding this comment.
It has the same problem as BuildArgumentsTest.java:39
waynercheung
left a comment
There was a problem hiding this comment.
Thanks for the contribution. The direction is valuable and aligning TRON JSON-RPC with the Ethereum input field is the right goal, but I don’t think this is merge-ready yet.
-
The new
input/datahandling is internally inconsistent.
Validation currently usesparamStringIsNull(...), while resolution usesStringUtils.isNotEmpty(...).
In this codebase those are not equivalent, especially for"0x", so the same request can be validated using one field and executed using the other. -
Conflict behavior is still undefined.
When bothinputanddataare provided with different values, the implementation silently prefersinput. Please reject that case explicitly with a clear params error rather than dropping one side. -
Test coverage is insufficient.
The updated tests only adapt constructor signatures and do not assert the new compatibility behavior. Please add explicit coverage for the supported combinations and the"0x"edge cases. -
setTransactionData()is unused and misleading as currently implemented. -
The new helpers in
JsonRpcApiUtilare not wired in, so the refactor is left half-done. -
There are a few minor style issues in
CallArgumentsthat should be cleaned up before merge.
Process note
This PR is opened from the fork’s develop branch and currently includes a merge commit from an internal fork PR. That is not a correctness issue by itself, but it makes review scope more mutable and the history noisier than necessary. For follow-up changes, please prefer a dedicated feature branch rebased onto the latest upstream master or develop, and keep the PR branch frozen during review.
What does this PR do?
Adds "input" field for transaction input while keeping "data" for legacy and compatibility.
Impacted JSON-RPC API methods:
Why are these changes required?
This PR has been tested by:
Follow up
Extra details