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

feat: implement Filecoin.ChainGetMessagesInTipset API (server side) #3670

Merged
merged 5 commits into from
Nov 6, 2023

Conversation

hanabi1224
Copy link
Contributor

@hanabi1224 hanabi1224 commented Nov 6, 2023

Summary of changes

As part of #3639

Changes introduced in this pull request:

  • implement Filecoin.ChainGetMessagesInTipset API (server side)

Manually tested on calibnet

request payload:

{
    "jsonrpc": "2.0",
    "id": 2,
    "method": "Filecoin.ChainGetMessagesInTipset",
    "params": [
        [
            {
                "/": "bafy2bzacecctsgyvam3fxhppheh2ubkarpgjvkn7cyvesrmhttuusuwzspk6o"
            },
            {
                "/": "bafy2bzacedt2daxg7mcvbv5sdg47zruj2ogx2wxzrjidoiwpcmyzzyfazjtcu"
            },
            {
                "/": "bafy2bzaceavd2unelg7g2mghiaq2te3qkfyghdjapdyr6ltjti7dlglhuqsni"
            },
            {
                "/": "bafy2bzacebr63zjyie3oqjj7gjxr6mwifazolv44d764hc6g7mhhdehlkgel6"
            }
        ]
    ]
}

Lotus response

{
    "jsonrpc": "2.0",
    "result": [
        {
            "Cid": {
                "/": "bafy2bzaceatwgj5tnix7n2rb3d5vig23wjypzw577rkl4tuq7kxkanbos55yk"
            },
            "Message": {
                "Version": 0,
                "To": "t01022",
                "From": "t3vyfz2c4sc7y3aaujg27cujdirvowx76fzdbowx6tsbrpps54jdgjdz5hnbgghsro7xnodtx3lszg5avmarqq",
                "Nonce": 6813,
                "Value": "147457681006493397129",
                "GasLimit": 34956948,
                "GasFeeCap": "2002463144",
                "GasPremium": "100075",
                "Method": 28,
                "Params": "gYGHCBkIftgqWCkAAYLiA4HoAiComSsWZz1fG4np8VTIbUaUSBVdNw4Li0+ANU5FrokFIRoAEDeUgBoAJ+Ek9g==",
                "CID": {
                    "/": "bafy2bzaceatwgj5tnix7n2rb3d5vig23wjypzw577rkl4tuq7kxkanbos55yk"
                }
            }
        },
        {
            "Cid": {
                "/": "bafy2bzacecvpatko6ylteuqk4prczhpmei3haxrvx6c5lkcsg4zbicqwendci"
            },
            "Message": {
                "Version": 0,
                "To": "t410fgej3qpgoyofbrx4tn4yss7pesbef26zolsew5cq",
                "From": "t410fv6ms7pamek6jigrdfrr5ygymbtkxfukfn2aa4ly",
                "Nonce": 89630,
                "Value": "0",
                "GasLimit": 8247900,
                "GasFeeCap": "1500000200",
                "GasPremium": "1500000000",
                "Method": 3844450837,
                "Params": "WIRVNdv2AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAO2JhZnliZWliem40bzcydXAzdDRuZjdjcmhhY3NnZ3RyY3RzcWJ3emtubDZvYWpnajV5Z25lanBnbWF5AAAAAAA=",
                "CID": {
                    "/": "bafy2bzacebynmaklimwgrrjlwjsvqpg57bjeqfeapvj2ohlm6e446abqrumb4"
                }
            }
        }
    ],
    "id": 2
}

Forest response

{
    "jsonrpc": "2.0",
    "result": [
        {
            "Cid": {
                "/": "bafy2bzaceatwgj5tnix7n2rb3d5vig23wjypzw577rkl4tuq7kxkanbos55yk"
            },
            "Message": {
                "Version": 0,
                "To": "t01022",
                "From": "t3vyfz2c4sc7y3aaujg27cujdirvowx76fzdbowx6tsbrpps54jdgjdz5hnbgghsro7xnodtx3lszg5avmarqq",
                "Nonce": 6813,
                "Value": "147457681006493397129",
                "GasLimit": 34956948,
                "GasFeeCap": "2002463144",
                "GasPremium": "100075",
                "Method": 28,
                "Params": "gYGHCBkIftgqWCkAAYLiA4HoAiComSsWZz1fG4np8VTIbUaUSBVdNw4Li0+ANU5FrokFIRoAEDeUgBoAJ+Ek9g==",
                "CID": {
                    "/": "bafy2bzaceatwgj5tnix7n2rb3d5vig23wjypzw577rkl4tuq7kxkanbos55yk"
                }
            }
        },
        {
            "Cid": {
                "/": "bafy2bzacecvpatko6ylteuqk4prczhpmei3haxrvx6c5lkcsg4zbicqwendci"
            },
            "Message": {
                "Version": 0,
                "To": "t410fgej3qpgoyofbrx4tn4yss7pesbef26zolsew5cq",
                "From": "t410fv6ms7pamek6jigrdfrr5ygymbtkxfukfn2aa4ly",
                "Nonce": 89630,
                "Value": "0",
                "GasLimit": 8247900,
                "GasFeeCap": "1500000200",
                "GasPremium": "1500000000",
                "Method": 3844450837,
                "Params": "WIRVNdv2AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAO2JhZnliZWliem40bzcydXAzdDRuZjdjcmhhY3NnZ3RyY3RzcWJ3emtubDZvYWpnajV5Z25lanBnbWF5AAAAAAA=",
                "CID": {
                    "/": "bafy2bzacebynmaklimwgrrjlwjsvqpg57bjeqfeapvj2ohlm6e446abqrumb4"
                }
            }
        }
    ],
    "id": 2
}

Reference issue to close (if applicable)

Closes

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

@hanabi1224
Copy link
Contributor Author

@lemmih Do we need to write tests for each single API?

@lemmih
Copy link
Contributor

lemmih commented Nov 6, 2023

@lemmih Do we need to write tests for each single API?

Yes.

@lemmih
Copy link
Contributor

lemmih commented Nov 6, 2023

@lemmih Do we need to write tests for each single API?

Yes.

Testing this method is easy since it has to be identical to Lotus. Add the tests in api_cmd.rs.

@hanabi1224
Copy link
Contributor Author

Testing this method is easy since it has to be identical to Lotus. Add the tests in api_cmd.rs.

@lemmih It seems that this API has been covered in api_cmd.rs, below is what I get.

     Running `target/debug/forest-tool api compare /home/me/fr/snapshots/calibnet/1063920_2023_11_06T04_13_00Z.car.zst`
| RPC Method                            | Forest              | Lotus         |
|---------------------------------------|---------------------|---------------|
| Filecoin.ChainGetBlock                | Valid               | Valid         |
| Filecoin.ChainGetGenesis              | Valid               | Valid         |
| Filecoin.ChainGetMessage (89)         | InternalServerError | Valid         |
| Filecoin.ChainGetMessage (2)          | Valid               | Valid         |
| Filecoin.ChainGetMessagesInTipset     | Valid               | Valid         |
| Filecoin.ChainGetParentMessages       | MissingMethod       | Valid         |
| Filecoin.ChainGetTipSetByHeight       | Valid               | Valid         |
| Filecoin.ChainHead                    | Valid               | Valid         |
| Filecoin.ChainReadObj                 | InvalidResponse     | Valid         |
| Filecoin.Discover                     | MissingMethod       | Valid         |
| Filecoin.MpoolPending                 | Valid               | Valid         |
| Filecoin.NetAddrsListen               | Valid               | Valid         |
| Filecoin.NetInfo                      | Valid               | MissingMethod |
| Filecoin.NetPeers                     | Valid               | Valid         |
| Filecoin.Session                      | MissingMethod       | Valid         |
| Filecoin.StartTime                    | Valid               | Valid         |
| Filecoin.StateGetActor                | Valid               | Valid         |
| Filecoin.StateGetRandomnessFromBeacon | MissingMethod       | Valid         |
| Filecoin.StateMinerActiveSectors      | MissingMethod       | Valid         |
| Filecoin.StateMinerPower (79)         | MissingMethod       | Valid         |
| Filecoin.StateNetworkName             | Valid               | Valid         |
| Filecoin.StateReadState               | MissingMethod       | Valid         |
| Filecoin.Version                      | Valid               | Valid         |

@lemmih
Copy link
Contributor

lemmih commented Nov 6, 2023

Testing this method is easy since it has to be identical to Lotus. Add the tests in api_cmd.rs.

@lemmih It seems that this API has been covered in api_cmd.rs, below is what I get.

     Running `target/debug/forest-tool api compare /home/me/fr/snapshots/calibnet/1063920_2023_11_06T04_13_00Z.car.zst`
| RPC Method                            | Forest              | Lotus         |
|---------------------------------------|---------------------|---------------|
| Filecoin.ChainGetBlock                | Valid               | Valid         |
| Filecoin.ChainGetGenesis              | Valid               | Valid         |
| Filecoin.ChainGetMessage (89)         | InternalServerError | Valid         |
| Filecoin.ChainGetMessage (2)          | Valid               | Valid         |
| Filecoin.ChainGetMessagesInTipset     | Valid               | Valid         |
| Filecoin.ChainGetParentMessages       | MissingMethod       | Valid         |
| Filecoin.ChainGetTipSetByHeight       | Valid               | Valid         |
| Filecoin.ChainHead                    | Valid               | Valid         |
| Filecoin.ChainReadObj                 | InvalidResponse     | Valid         |
| Filecoin.Discover                     | MissingMethod       | Valid         |
| Filecoin.MpoolPending                 | Valid               | Valid         |
| Filecoin.NetAddrsListen               | Valid               | Valid         |
| Filecoin.NetInfo                      | Valid               | MissingMethod |
| Filecoin.NetPeers                     | Valid               | Valid         |
| Filecoin.Session                      | MissingMethod       | Valid         |
| Filecoin.StartTime                    | Valid               | Valid         |
| Filecoin.StateGetActor                | Valid               | Valid         |
| Filecoin.StateGetRandomnessFromBeacon | MissingMethod       | Valid         |
| Filecoin.StateMinerActiveSectors      | MissingMethod       | Valid         |
| Filecoin.StateMinerPower (79)         | MissingMethod       | Valid         |
| Filecoin.StateNetworkName             | Valid               | Valid         |
| Filecoin.StateReadState               | MissingMethod       | Valid         |
| Filecoin.Version                      | Valid               | Valid         |

Good.

@hanabi1224 hanabi1224 marked this pull request as ready for review November 6, 2023 07:14
@hanabi1224 hanabi1224 requested a review from a team as a code owner November 6, 2023 07:14
@hanabi1224 hanabi1224 requested review from LesnyRumcajs and aatifsyed and removed request for a team November 6, 2023 07:14
Copy link
Contributor

@lemmih lemmih left a comment

Choose a reason for hiding this comment

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

Looks good. Replace MessageInTipset with ApiMessage and it's good to go.

src/rpc_api/mod.rs Outdated Show resolved Hide resolved
Copy link
Member

@LesnyRumcajs LesnyRumcajs left a comment

Choose a reason for hiding this comment

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

How is this tested? Say, I change the chain_get_messages_in_tipset to not return any messages, ever, with messages.clear() at the end. Will this be caught?

@lemmih
Copy link
Contributor

lemmih commented Nov 6, 2023

How is this tested? Say, I change the chain_get_messages_in_tipset to not return any messages, ever, with messages.clear() at the end. Will this be caught?

There are tests that will catch that (by comparing our output to that of Lotus), but they're not yet part of the CI. Running the tests in CI is out of scope for this PR.

@hanabi1224 hanabi1224 added this pull request to the merge queue Nov 6, 2023
Merged via the queue into main with commit 7d5ef13 Nov 6, 2023
26 checks passed
@hanabi1224 hanabi1224 deleted the hm/chain_get_messages_in_tipset branch November 6, 2023 12:16
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

3 participants