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

rpc.discover doesn't work properly #8556

Closed
8 of 18 tasks
ArseniiPetrovich opened this issue Apr 26, 2022 · 0 comments · Fixed by #8738
Closed
8 of 18 tasks

rpc.discover doesn't work properly #8556

ArseniiPetrovich opened this issue Apr 26, 2022 · 0 comments · Fixed by #8738
Labels
area/api kind/bug Kind: Bug P2 P2: Should be resolved

Comments

@ArseniiPetrovich
Copy link
Contributor

ArseniiPetrovich commented Apr 26, 2022

Checklist

  • This is not a security-related bug/issue. If it is, please follow please follow the security policy.
  • This is not a question or a support request. If you have any lotus related questions, please ask in the lotus forum.
  • This is not a new feature request. If it is, please file a feature request instead.
  • This is not an enhancement request. If it is, please file a improvement suggestion instead.
  • I have searched on the issue tracker and the lotus forum, and there is no existing related issue or discussion.
  • I am running the Latest release, or the most recent RC(release canadiate) for the upcoming release or the dev branch(master), or have an issue updating to any of these.
  • I did not make any code changes to lotus.

Lotus component

  • lotus daemon - chain sync
  • lotus miner - mining and block production
  • lotus miner/worker - sealing
  • lotus miner - proving(WindowPoSt)
  • lotus miner/market - storage deal
  • lotus miner/market - retrieval deal
  • lotus miner/market - data transfer
  • lotus client
  • lotus JSON-RPC API
  • lotus message management (mpool)
  • Other

Lotus Version

{"jsonrpc":"2.0","result":{"Version":"1.15.1+mainnet+git.731da45","APIVersion":66816,"BlockDelay":30},"id":999999}

Describe the Bug

@eshon reported a bug to the Glif team. The bug is connected with https://playground.open-rpc.org/, which does not correctly interact with https://api.node.glif.io despite the fact it was when #4711 was merged. Initially we thought that it might be an issue on Glif side, something with the CORS requests. However, when I started an investigation - I figured out the following:

  • Glif endpoints works as expected responding to OPTIONS with CORS details
  • However the rpc.discover request is not passing well, failed with 400 status code.
    Recently we have enforced the requirement for "Content-Type": "application/json" argument to be passed to the endpoints due to security reasons, so my initial thought was that this might be somehow connected. However, I learned that https://playground.open-rpc.org/ is actually sending the "Content-Type": "application/json" header, so this is not connected in any way.

Also I learned that according to #4711 the Filecoin.Discover and rpc.discover should provide similar functionality, however it seems to be that output is different for these two methods. Please, check my test results below:

Tests

Method: any; Content-Type header: no; endpoint: Glif API

ubuntu@selfportal:~/DevOps-wiki$ curl -v --request POST 'https://api.node.glif.io' --data-raw '{  "jsonrpc": "2.0",  "params": [],  "id": 999999,  "method": "rpc.discover"}'
Note: Unnecessary use of -X or --request, POST is already inferred.
* Rebuilt URL to: https://api.node.glif.io/
*   Trying 52.84.194.93...
* TCP_NODELAY set
* Connected to api.node.glif.io (52.84.194.93) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
* TLSv1.3 (IN), TLS handshake, Unknown (8):
* TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Client hello (1):
* TLSv1.3 (OUT), TLS Unknown, Certificate Status (22):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_128_GCM_SHA256
* ALPN, server accepted to use h2
* Server certificate:
*  subject: CN=node.glif.io
*  start date: Apr 21 00:00:00 2022 GMT
*  expire date: May 20 23:59:59 2023 GMT
*  subjectAltName: host "api.node.glif.io" matched cert's "*.node.glif.io"
*  issuer: C=US; O=Amazon; OU=Server CA 1B; CN=Amazon
*  SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* TLSv1.3 (OUT), TLS Unknown, Unknown (23):
* TLSv1.3 (OUT), TLS Unknown, Unknown (23):
* TLSv1.3 (OUT), TLS Unknown, Unknown (23):
* Using Stream ID: 1 (easy handle 0x560e9ced8540)
* TLSv1.3 (OUT), TLS Unknown, Unknown (23):
> POST / HTTP/2
> Host: api.node.glif.io
> User-Agent: curl/7.58.0
> Accept: */*
> Content-Length: 77
> Content-Type: application/x-www-form-urlencoded
> 
* TLSv1.3 (OUT), TLS Unknown, Unknown (23):
* We are completely uploaded and fine
* TLSv1.3 (IN), TLS Unknown, Unknown (23):
* Connection state changed (MAX_CONCURRENT_STREAMS updated)!
* TLSv1.3 (OUT), TLS Unknown, Unknown (23):
* TLSv1.3 (IN), TLS Unknown, Unknown (23):
< HTTP/2 415 
< content-type: application/json
< content-length: 37
< date: Tue, 26 Apr 2022 13:39:39 GMT
< x-amzn-requestid: 97ec59b1-1681-43a9-934a-9c5faccc9e1e
< x-amzn-errortype: BadRequestException
< x-amz-apigw-id: RMNkPGngCYcF1ew=
< x-cache: Error from cloudfront
< via: 1.1 58bdfbab355a53b4cbc6b93312bb8748.cloudfront.net (CloudFront)
< x-amz-cf-pop: WAW50-C1
< x-amz-cf-id: JR4UJHs3kzqmAgtvACVqB8Yv2bMQBnJo3fNO7wywjPx0ONujV9JHaQ==
< 
* TLSv1.3 (IN), TLS Unknown, Unknown (23):
* Connection #0 to host api.node.glif.io left intact
{"message": "Unsupported Media Type"}ubuntu@selfportal:~/DevOps-wiki$ 

Method: any; Content-Type header: no; endpoint: Lotus Node

lotus_user@space06-lotus-0:/$ curl -v -X POST 'localhost:1234/rpc/v0' --data-raw '{  "jsonrpc": "2.0",  "params": [],  "id": 999999,  "method": "rpc.discover"}'
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 127.0.0.1:1234...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 1234 (#0)
> POST /rpc/v0 HTTP/1.1
> Host: localhost:1234
> User-Agent: curl/7.68.0
> Accept: */*
> Content-Length: 82
> Content-Type: application/x-www-form-urlencoded
> 
* upload completely sent off: 82 out of 82 bytes
* Mark bundle as not supporting multiuse
< HTTP/1.1 500 Internal Server Error
< Date: Tue, 26 Apr 2022 13:45:19 GMT
< Content-Length: 0
< 
* Connection #0 to host localhost left intact

Method: rpc.discover; Content-Type header: yes; endpoint: Glif API

ubuntu@selfportal:/$ curl -v --header "Content-Type":"application/json" -X POST 'https://api.node.glif.io' --data-raw '{  "jsonrpc": "2.0",  "params": [],  "id": 999999,  "method": "rpc.discover"}'
Note: Unnecessary use of -X or --request, POST is already inferred.
* Rebuilt URL to: https://api.node.glif.io/
*   Trying 52.84.194.66...
* TCP_NODELAY set
* Connected to api.node.glif.io (52.84.194.66) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
* TLSv1.3 (IN), TLS handshake, Unknown (8):
* TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Client hello (1):
* TLSv1.3 (OUT), TLS Unknown, Certificate Status (22):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_128_GCM_SHA256
* ALPN, server accepted to use h2
* Server certificate:
*  subject: CN=node.glif.io
*  start date: Apr 21 00:00:00 2022 GMT
*  expire date: May 20 23:59:59 2023 GMT
*  subjectAltName: host "api.node.glif.io" matched cert's "*.node.glif.io"
*  issuer: C=US; O=Amazon; OU=Server CA 1B; CN=Amazon
*  SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* TLSv1.3 (OUT), TLS Unknown, Unknown (23):
* TLSv1.3 (OUT), TLS Unknown, Unknown (23):
* TLSv1.3 (OUT), TLS Unknown, Unknown (23):
* Using Stream ID: 1 (easy handle 0x55b87dcf6540)
* TLSv1.3 (OUT), TLS Unknown, Unknown (23):
> POST / HTTP/2
> Host: api.node.glif.io
> User-Agent: curl/7.58.0
> Accept: */*
> Content-Type:application/json
> Content-Length: 77
> 
* TLSv1.3 (OUT), TLS Unknown, Unknown (23):
* We are completely uploaded and fine
* TLSv1.3 (IN), TLS Unknown, Unknown (23):
* Connection state changed (MAX_CONCURRENT_STREAMS updated)!
* TLSv1.3 (OUT), TLS Unknown, Unknown (23):
* TLSv1.3 (IN), TLS Unknown, Unknown (23):
< HTTP/2 503 
< content-type: application/json
< content-length: 98
< date: Tue, 26 Apr 2022 13:53:46 GMT
< x-amzn-requestid: 28268aa4-61b7-4882-b502-a82eff5e1351
< x-amz-apigw-id: RMPotH-PCYcF2Bg=
< x-amzn-trace-id: Root=1-6267f96a-522292650353db4404039e9e
< x-cache: Error from cloudfront
< via: 1.1 c60880d44880ad913f911851a63aacde.cloudfront.net (CloudFront)
< x-amz-cf-pop: WAW50-C1
< x-amz-cf-id: E7bdg4TRaHgJxXCLfBQEe38mStCiQH6XWCKqdW0O5qf4gVf6xp5eSw==
< 
{"jsonrpc":"2.0","id":999999,"error":{"code":-32601,"message":"method 'rpc.discover' not found"}}
* TLSv1.3 (IN), TLS Unknown, Unknown (23):
* Connection #0 to host api.node.glif.io left intact

Method: rpc.discover; Content-Type header: yes; endpoint: Lotus Node

lotus_user@space06-lotus-0:/$ curl -v --header "Content-Type":"application/json" -X POST 'localhost:1234/rpc/v0' --data-raw '{  "jsonrpc": "2.0",  "params": [],  "id": 999999,  "method": "rpc.discover"}'
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 127.0.0.1:1234...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 1234 (#0)
> POST /rpc/v0 HTTP/1.1
> Host: localhost:1234
> User-Agent: curl/7.68.0
> Accept: */*
> Content-Type:application/json
> Content-Length: 77
> 
* upload completely sent off: 77 out of 77 bytes
* Mark bundle as not supporting multiuse
< HTTP/1.1 500 Internal Server Error
< Date: Tue, 26 Apr 2022 13:54:47 GMT
< Content-Length: 98
< Content-Type: text/plain; charset=utf-8
< 
{"jsonrpc":"2.0","id":999999,"error":{"code":-32601,"message":"method 'rpc.discover' not found"}}
* Connection #0 to host localhost left intact

Method: Filecoin.Discover; Content-Type header: yes; endpoint: Glif API

ubuntu@selfportal:/$ curl -v --header "Content-Type":"application/json" -X POST 'https://api.node.glif.io' --data-raw '{  "jsonrpc": "2.0",  "params": [],  "id": 999999,  "method": "Filecoin.Discover"}'
Note: Unnecessary use of -X or --request, POST is already inferred.
* Rebuilt URL to: https://api.node.glif.io/
*   Trying 52.84.194.93...
* TCP_NODELAY set
* Connected to api.node.glif.io (52.84.194.93) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
* TLSv1.3 (IN), TLS handshake, Unknown (8):
* TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Client hello (1):
* TLSv1.3 (OUT), TLS Unknown, Certificate Status (22):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_128_GCM_SHA256
* ALPN, server accepted to use h2
* Server certificate:
*  subject: CN=node.glif.io
*  start date: Apr 21 00:00:00 2022 GMT
*  expire date: May 20 23:59:59 2023 GMT
*  subjectAltName: host "api.node.glif.io" matched cert's "*.node.glif.io"
*  issuer: C=US; O=Amazon; OU=Server CA 1B; CN=Amazon
*  SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* TLSv1.3 (OUT), TLS Unknown, Unknown (23):
* TLSv1.3 (OUT), TLS Unknown, Unknown (23):
* TLSv1.3 (OUT), TLS Unknown, Unknown (23):
* Using Stream ID: 1 (easy handle 0x559017838540)
* TLSv1.3 (OUT), TLS Unknown, Unknown (23):
> POST / HTTP/2
> Host: api.node.glif.io
> User-Agent: curl/7.58.0
> Accept: */*
> Content-Type:application/json
> Content-Length: 82
> 
* TLSv1.3 (OUT), TLS Unknown, Unknown (23):
* We are completely uploaded and fine
* TLSv1.3 (IN), TLS Unknown, Unknown (23):
* Connection state changed (MAX_CONCURRENT_STREAMS updated)!
* TLSv1.3 (OUT), TLS Unknown, Unknown (23):
* TLSv1.3 (IN), TLS Unknown, Unknown (23):
* TLSv1.3 (IN), TLS Unknown, Unknown (23):
< HTTP/2 200 
< content-type: application/json
< content-length: 348715
< date: Tue, 26 Apr 2022 13:55:44 GMT
< x-amzn-requestid: 307491eb-9fa4-4c5a-97a6-e9d9672a2bcb
< access-control-allow-origin: *
< access-control-allow-headers: Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token
< x-amz-apigw-id: RMP7IFD1CYcF3-A=
< access-control-allow-methods: POST,OPTIONS
< x-amzn-trace-id: Root=1-6267f9e0-37d4bf4054b221847b150f9c
< x-cache: Miss from cloudfront
< via: 1.1 f9efc23cea6c58604ef3f56c3631925e.cloudfront.net (CloudFront)
< x-amz-cf-pop: WAW50-C1
< x-amz-cf-id: BA2Ww2jJbIJWtvJ_tw9HghW_O8whYWPDnP0MDfDIsqMP4DBX4xuB6w==
< 
{"jsonrpc":"2.0","result":{"info":{"title":"Lotus RPC API","version":"1.15.1"},"methods":[{"deprecated":false,"description":"```go\nfunc (s *FullNodeStruct) Bea
............................................................................................................................................................
............................................................................................................................................................
ss does not have to be in the wallet.\n"}],"openrpc":"1.2.6"},"id":999999}
* TLSv1.3 (IN), TLS Unknown, Unknown (23):
* Connection #0 to host api.node.glif.io left intact

Method: Filecoin.Discover; Content-Type header: yes; endpoint: Lotus Node

lotus_user@space06-lotus-0:/$ curl -v --header "Content-Type":"application/json" -X POST 'localhost:1234/rpc/v0' --data-raw '{  "jsonrpc": "2.0",  "params": [],  "id": 999999,  "method": "Filecoin.Discover"}'
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 127.0.0.1:1234...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 1234 (#0)
> POST /rpc/v0 HTTP/1.1
> Host: localhost:1234
> User-Agent: curl/7.68.0
> Accept: */*
> Content-Type:application/json
> Content-Length: 82
> 
* upload completely sent off: 82 out of 82 bytes
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Date: Tue, 26 Apr 2022 14:01:54 GMT
< Content-Type: text/plain; charset=utf-8
< Transfer-Encoding: chunked
< 
{"jsonrpc":"2.0","result":{"info":{"title":"Lotus RPC API","version":"1.15.1"},"methods":[{"deprecated":false,"description":"```go\nfunc (s *FullNodeStruct) Bea
............................................................................................................................................................
............................................................................................................................................................
ss does not have to be in the wallet.\n"}],"openrpc":"1.2.6"},"id":999999}
* Connection #0 to host localhost left intact

I have shortened the output of Filecoin.Discover method above. To sum things up:

  1. Lotus expects application/json header to be passed just as Glif endpoints
  2. rpc.discover works not as Filecoin.Discover (not sure if this is intended or not)
  3. rpc.discover is a "not found" method right now

Logging Information

I don't think there is a need for the logs. Also, Glif endpoints are public, so there are just tooooooo many flood in the logs.

Repo Steps

  1. Run commands in the testing section to verify that the issue exists
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api kind/bug Kind: Bug P2 P2: Should be resolved
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants