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

Better tx RPC API #1299

Closed
7 of 8 tasks
frol opened this issue Sep 11, 2019 · 11 comments
Closed
7 of 8 tasks

Better tx RPC API #1299

frol opened this issue Sep 11, 2019 · 11 comments
Assignees
Labels
A-RPC Area: rpc P-high Priority: High
Milestone

Comments

@frol
Copy link
Collaborator

frol commented Sep 11, 2019

near/NEPs#1

RPC API of the transaction (tx) should be restructured according to the conversation near/docs#55 (comment)

NOTE: It is a breaking change. Do we have consumers of this API (except Explorer)? It seems that the only consumer is Explorer and I can fix it.

The issues to address in the RPC API:

  • Expose more information on the tx RPC (there should not be less information than in the block RPC response)
  • Align the structure of the block (the transactions section) and tx responses
  • Transaction should have:
    • block hash
    • shard id (?)
    • fees (Total fees denominated in NEAR, Gas used (units of gas), Gas price (price per unit in NEAR))
  • CreateAccount action should expose the account id
  • Cover the public API with extensive tests, so it gets apparent when something gets changed when it should not. (track separately)
@frol
Copy link
Collaborator Author

frol commented Sep 11, 2019

block RPC currently returns transactions list with a structure that is completely different from the tx RPC:

$ http post http://rpc.nearprotocol.com/ jsonrpc=2.0 id=dontcare method=block 'params:=[173592]'

{
    "id": "dontcare",
    "jsonrpc": "2.0",
    "result": {
        "header": {
            "approval_mask": [
                false,
                true
            ],
            "approval_sigs": [
                "ed25519:5tn8MtX8yQ2qzdRs8W6Homz4KWS2kQcoEnLXBXEa9qRUczAfYqUD3R3QxRAoWA9AwM1niauyt6VaQFn8sijEqkhS"
            ],
            "epoch_hash": "Di12sDSYsUH6ocaMf9NPKcBrUikEiCRPNkydKgZgEi8u",
            "hash": "BZnGxodahyU3Ssuh5dVNbAeBt3wqXTu8f8mLeo5cb4cH",
            "height": 173592,
            "prev_hash": "HhH72gqstfm5KGW6wf8nFa1tVjfeGjhsmv1NSxLutAdQ",
            "prev_state_root": "ABh7ZArZtVvEghH8SNXrDaTAMCFYzEayFFkg61j1qzc9",
            "signature": "ed25519:3CA8HwcmPDSdUuCdjBeFWP8AvK36yQ1PhDRz4PgF8RLT3fgQm4GoH242j5QNJvXrdws8ASygWJtaAqrUkHjug52X",
            "timestamp": 1568047128577482804,
            "total_weight": 208940,
            "tx_root": "11111111111111111111111111111111",
            "validator_proposals": []
        },
        "transactions": [
            {
                "actions": [
                    "CreateAccount",
                    {
                        "Transfer": {
                            "deposit": "10000000000000000000"
                        }
                    },
                    {
                        "AddKey": {
                            "access_key": {
                                "nonce": 0,
                                "permission": "FullAccess"
                            },
                            "public_key": "ed25519:J2Jrr74mgHxL5AmHeRSesWPgCA8jqcGqcEGKC2EEu59t"
                        }
                    }
                ],
                "hash": "2ZBygTrowP7MTeRQ8rXp8v84benMTaYbHhwFw5w85CTS",
                "nonce": 110,
                "public_key": "ed25519:oNCFEmRotRHTySKqmAwifNZ8VRpYS973p8cL61y7eiE",
                "receiver_id": "studio-n5ubb8npy",
                "signature": "ed25519:54uxKxJz5N4nzjYbeAuMKZVqUUwj2i9wXgjEeVNYx79mYXQr9bmfysDE5hGo2Smc1NNsTZ8Q6W62uymxq94TEy8J",
                "signer_id": "test"
            }
        ]
    }
}
$ http post http://rpc.nearprotocol.com/ jsonrpc=2.0 id=dontcare method=tx 'params:=["2ZBygTrowP7MTeRQ8rXp8v84benMTaYbHhwFw5w85CTS"]'

{
    "id": "dontcare",
    "jsonrpc": "2.0",
    "result": {
        "status": "Completed",
        "transactions": [
            {
                "hash": "2ZBygTrowP7MTeRQ8rXp8v84benMTaYbHhwFw5w85CTS",
                "result": {
                    "logs": [],
                    "receipts": [
                        "CdbagwttuZnTcjGT3R8Qs9fsv8GFuFeUtJVnVZeAjoop"
                    ],
                    "result": null,
                    "status": "Completed"
                }
            },
            {
                "hash": "CdbagwttuZnTcjGT3R8Qs9fsv8GFuFeUtJVnVZeAjoop",
                "result": {
                    "logs": [],
                    "receipts": [],
                    "result": "",
                    "status": "Completed"
                }
            }
        ]
    }
}

Notice that there is no information about the actions.

@frol
Copy link
Collaborator Author

frol commented Sep 12, 2019

/cc @vgrichina @evgenykuzyakov

@evgenykuzyakov
Copy link
Collaborator

Suggestion to fix result to be able to get the actual returned values: #1307

@frol
Copy link
Collaborator Author

frol commented Sep 12, 2019

@evgenykuzyakov I must admit that I don't understand #1307 (I lack the knowledge around that area), and how it is related to this issue.

@evgenykuzyakov
Copy link
Collaborator

For CreateAccount action should expose the account id, transaction has the receiver which exposes the newly created account_id

@frol
Copy link
Collaborator Author

frol commented Sep 13, 2019

@evgenykuzyakov Yeap, Illia has already pointed that out to me, so crossing it out from the list.

@evgenykuzyakov
Copy link
Collaborator

Why not just build standard API that is copies the inner structure using View conversion. E.g. expose Receipt with ActionReceipt structure, and also associated TransactionResult.

@evgenykuzyakov
Copy link
Collaborator

So we have a ReceiptView struct that we can serialize towards JSON. It has all the information about what actions are there, who is the predecessor and the signer.
For every executed receipt, we have a TransactionResult, which contain genereated receipt_ids that can be used to retrieve ReceiptViews.

To get the first ReceiptId from the signed transaction we can use TransactionResult of the SignedTransaction hash.

@ilblackdragon
Copy link
Member

@frol do we still need to do something in this issue?

@frol
Copy link
Collaborator Author

frol commented Nov 5, 2019

@ilblackdragon Yes, we still need to provide more information on the transaction, but it is not blocking Explorer, so it is not high priority.

@frol
Copy link
Collaborator Author

frol commented Feb 26, 2020

It seems that most of the items are already addressed.

@frol frol closed this as completed Feb 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-RPC Area: rpc P-high Priority: High
Projects
None yet
Development

No branches or pull requests

3 participants