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

Ignore old, deprecated fields in rosetta transactions #15718

Merged
merged 3 commits into from
Jul 17, 2024

Conversation

mrmr1993
Copy link
Member

@mrmr1993 mrmr1993 commented Jun 5, 2024

This PR allows rosetta parsing to ignore deprecated fields when they are null.

Checklist:

  • Dependency versions are unchanged
    • Notify Velocity team if dependencies must change in CI
  • Modified the current draft of release notes with details on what is completed or incomplete within this project
  • Document code purpose, how to use it
    • Mention expected invariants, implicit constraints
  • Tests were added for the new behavior
    • Document test purpose, significance of failures
    • Test names should reflect their purpose
  • All tests pass (CI will check this if you didn't)
  • Serialized types are in stable-versioned modules
  • Does this close issues? List them

@mrmr1993 mrmr1993 requested a review from a team as a code owner June 5, 2024 13:51
@mrmr1993
Copy link
Member Author

mrmr1993 commented Jun 5, 2024

!ci-build-me

src/lib/rosetta_lib/transaction.ml Outdated Show resolved Hide resolved
src/lib/rosetta_lib/transaction.ml Outdated Show resolved Hide resolved
@mrmr1993
Copy link
Member Author

mrmr1993 commented Jun 5, 2024

!ci-build-me

Copy link
Member

@joaosreis joaosreis left a comment

Choose a reason for hiding this comment

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

Tested it and it works for me. If it fixes the reported issue, all good.

@mrmr1993
Copy link
Member Author

mrmr1993 commented Jun 5, 2024

Confirmed working with transaction

{
  "signature": "a9ad136ccc8dfdfc76937dc884036d625cbdc6baadc968c13f2be090bf53a01f3e0cee3f0959c6a85f6d939ca08d9200ee15a0a64440a0f8e5affe8afde3251f",
  "payment": {
    "to": "B62qkcjubxpCvKyJvtisJqVrnNcXHE7EeZPbQ9FNJbTbFwXPVcYnjgX",
    "from": "B62qoigHEtJCoZ5ekbGHWyr9hYfc6fkZ2A41h9vvVZuvty9amzEz3yB",
    "fee": "10000000000",
    "token": "1",
    "nonce": "68",
    "memo": null,
    "amount": "16571009648348",
    "valid_until": "4294967295"
  },
  "stake_delegation": null,
  "create_token": null,
  "create_token_account": null,
  "mint_tokens": null
}

@joaosreis
Copy link
Member

Tested it by running mina advanced send-rosetta-transaction and sending various payloads, observing the following behaviors:

  • payloads without deprecated fields: accepted
  • payloads with null deprecated fields: accepted
  • payloads with non-null deprecated fields: rejected
  • payloads with unknown fields: rejected

Also, I wrote these cases as unit tests for the JSON deserialization. I can push them to the branch if desired.

@mrmr1993 mrmr1993 requested review from a team, bkase, psteckler and nholland94 as code owners July 17, 2024 12:24
@mrmr1993 mrmr1993 changed the base branch from berkeley to release/3.0.1 July 17, 2024 12:24
@mrmr1993
Copy link
Member Author

!ci-build-me

@mrmr1993
Copy link
Member Author

!approved-for-mainnet

| `Null ->
false
| _ ->
raise (Non_null field)
Copy link
Member

Choose a reason for hiding this comment

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

question

Will this not cause the fold to raise early if there are multiple deprecated fields, but the first is populated.

For example wouldn't it raise here instead of filtering on the second field.

{
  "signature": "a9ad136ccc8dfdfc76937dc884036d625cbdc6baadc968c13f2be090bf53a01f3e0cee3f0959c6a85f6d939ca08d9200ee15a0a64440a0f8e5affe8afde3251f",
  "payment": {
    "to": "B62qkcjubxpCvKyJvtisJqVrnNcXHE7EeZPbQ9FNJbTbFwXPVcYnjgX",
    "from": "B62qoigHEtJCoZ5ekbGHWyr9hYfc6fkZ2A41h9vvVZuvty9amzEz3yB",
    "fee": "10000000000",
    "token": "1",
    "nonce": "68",
    "memo": null,
    "amount": "16571009648348",
    "valid_until": "4294967295"
  },
  "stake_delegation": null,
  "create_token": <non null value>,
  "create_token_account": null,
  "mint_tokens": null

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that's the intention. If there's a non-null value, the transaction is malformed and we want to abort with the error below.

@amc-ie amc-ie merged commit 194aaaf into release/3.0.1 Jul 17, 2024
45 checks passed
@amc-ie amc-ie deleted the feature/accept-old-rosetta-txns branch July 17, 2024 14:34
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

5 participants