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

Add minimum tx fee to rosetta construction/metadata #8170

Conversation

jspada
Copy link
Contributor

@jspada jspada commented Mar 9, 2021

This PR adds the minimum tx fee to the rosetta construction/metadata response so that clients can prevent users from creating transactions that would fail to be accepted. The minimum fee is obtained from the compile-time config Mina_compile_config.minimum_user_command_fee

For compatibility with the Rosetta specification we've added the additional "minimum_fee" information to the metadata property like so

{
    "metadata": {
        "sender": "B62qnzbXmRNo9q32n4SNu2mpB8e7FYYLH8NmaX6oFCBYjjQ8SbD7uzV",
        "nonce": "0",
        "token_id": "1",
        "minimum_fee": [
            {
                "value": "1000000",
                "currency": {
                    "symbol": "CODA",
                    "decimals": 9
                }
            }
        ]
    },
    "suggested_fee": [
        {
            "value": "250000000",
            "currency": {
                "symbol": "CODA",
                "decimals": 9
            }
        }
    ]
}

Testing
This can be tested with mina_ledger_wallet send-payment and src/app/rosetta/test-curl/con_metadata.sh. Prior to this change the "minimum_fee" component will not be present in the JSON response. After this change it should be present and contain the value found in src/config/amount_defaults/realistic.mlh.

Checklist:

  • 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:

Closes #8086

@jspada
Copy link
Contributor Author

jspada commented Mar 10, 2021

New format as suggested by Matthew and Brandon is

{
    "metadata": {
        "sender": "B62qnzbXmRNo9q32n4SNu2mpB8e7FYYLH8NmaX6oFCBYjjQ8SbD7uzV",
        "nonce": "0",
        "token_id": "1"
    },
    "suggested_fee": [
        {
            "value": "250000000",
            "currency": {
                "symbol": "CODA",
                "decimals": 9
            },
            "metadata": {
                "minimum_fee": {
                    "value": "1000000",
                    "currency": {
                        "symbol": "CODA",
                        "decimals": 9
                    }
                }
            }
        }
    ]
}

Copy link
Member

@mrmr1993 mrmr1993 left a comment

Choose a reason for hiding this comment

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

Great!

Copy link
Member

@bkase bkase left a comment

Choose a reason for hiding this comment

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

OCaml master

@jspada
Copy link
Contributor Author

jspada commented Mar 11, 2021

Getting there... and thanks to help from Matthew and Omer.

@bkase
Copy link
Member

bkase commented Mar 15, 2021

!approved-for-mainnet

@mrmr1993
Copy link
Member

!ci-build-me

@mrmr1993 mrmr1993 merged commit e003aba into MinaProtocol:compatible Mar 16, 2021
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.

Rosetta construction/metadata interface should return the minimum fee in addition to the default fee
3 participants