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

JSON RPC compatibility workarounds to support lbry-sdk #75

Merged
merged 3 commits into from
Oct 29, 2022

Conversation

moodyjon
Copy link
Contributor

Note --json-rpc-port=50002. Lots of tests use that port number when launching herald apparently:
go build -o herald . && ./herald serve --disable-es --json-rpc-port=50002 --json-rpc-http-port=0 --db-path /Users/swdev1/hub/scribe_db.1030239/lbry-rocksdb --session-timeout=15 --max-sessions=5

With herald running, launch a test. The python herald will be blocked from reusing 50002 because go herald is already running:
python -m unittest -vv -k test_repost tests/integration/claims/test_claim_commands.py

INFO[2022-10-27T16:03:05-04:00] Accepted: [::1]:53046                        
INFO[2022-10-27T16:03:05-04:00] from [::1]:53046 receive header              
INFO[2022-10-27T16:03:05-04:00] raw request: {"jsonrpc": "2.0", "method": "server.version", "id": 0, "params": ["0.110.0", "0.110.0"]} 
INFO[2022-10-27T16:03:05-04:00] patched request: {"jsonrpc":"2.0","method":"server.version","params":[["0.110.0","0.110.0"]],"id":0} 
INFO[2022-10-27T16:03:05-04:00] from [::1]:53046 receive header: rpc.Request{ServiceMethod:"server.version", Seq:0x1, next:(*rpc.Request)(nil)} 
INFO[2022-10-27T16:03:05-04:00] from [::1]:53046 receive body                
INFO[2022-10-27T16:03:05-04:00] from [::1]:53046 receive body: &server.ServerVersionReq{"0.110.0", "0.110.0"} 
INFO[2022-10-27T16:03:05-04:00] from [::1]:53046 receive header              
INFO[2022-10-27T16:03:05-04:00] Version([0.110.0 0.110.0]) -> [0.107.0 0.107.0] 
INFO[2022-10-27T16:03:05-04:00] respond to [::1]:53046                       
INFO[2022-10-27T16:03:05-04:00] raw response: {"id":0,"result":["0.107.0","0.107.0"],"error":null} 
INFO[2022-10-27T16:03:05-04:00] patched response: {"jsonrpc":"2.0","id":0,"result":["0.107.0","0.107.0"]} 
INFO[2022-10-27T16:03:05-04:00] raw request: {"jsonrpc": "2.0", "method": "server.features", "id": 1} 
INFO[2022-10-27T16:03:05-04:00] patched request: {"jsonrpc":"2.0","method":"server.features","params":[],"id":1} 
INFO[2022-10-27T16:03:05-04:00] from [::1]:53046 receive header: rpc.Request{ServiceMethod:"server.features", Seq:0x2, next:(*rpc.Request)(nil)} 
INFO[2022-10-27T16:03:05-04:00] from [::1]:53046 receive body                
INFO[2022-10-27T16:03:05-04:00] from [::1]:53046 receive body: &server.ServerFeaturesReq{} 
INFO[2022-10-27T16:03:05-04:00] from [::1]:53046 receive header              
INFO[2022-10-27T16:03:05-04:00] Features                                     
INFO[2022-10-27T16:03:05-04:00] respond to [::1]:53046                       
INFO[2022-10-27T16:03:05-04:00] raw response: {"id":1,"result":{"hosts":{},"pruning":"","server_version":"0.107.0","protocol_min":"0.54.0","protocol_max":"0.199.0","genesis_hash":"9c89283ba0f3227f6c03b70216b9f665f0118d5e0fa729cedf4fb34d6a34f463","description":"Herald","payment_address":"","donation_address":"","daily_fee":"1.0","hash_function":"sha256","trending_algorithm":"fast_ar"},"error":null} 
INFO[2022-10-27T16:03:05-04:00] patched response: {"jsonrpc":"2.0","id":1,"result":{"daily_fee":"1.0","description":"Herald","donation_address":"","genesis_hash":"9c89283ba0f3227f6c03b70216b9f665f0118d5e0fa729cedf4fb34d6a34f463","hash_function":"sha256","hosts":{},"payment_address":"","protocol_max":"0.199.0","protocol_min":"0.54.0","pruning":"","server_version":"0.107.0","trending_algorithm":"fast_ar"}} 
INFO[2022-10-27T16:03:05-04:00] raw request: {"jsonrpc": "2.0", "method": "server.peers.subscribe", "id": 2} 
INFO[2022-10-27T16:03:05-04:00] patched request: {"jsonrpc":"2.0","method":"server.peers.subscribe","params":[],"id":2} 
INFO[2022-10-27T16:03:05-04:00] from [::1]:53046 receive header: rpc.Request{ServiceMethod:"server.peers.subscribe", Seq:0x3, next:(*rpc.Request)(nil)} 
INFO[2022-10-27T16:03:05-04:00] from [::1]:53046 receive body                
INFO[2022-10-27T16:03:05-04:00] from [::1]:53046 receive body: <nil>         
INFO[2022-10-27T16:03:05-04:00] respond to [::1]:53046                       
INFO[2022-10-27T16:03:05-04:00] raw response: {"id":2,"result":null,"error":"rpc: can't find service server.peers.Subscribe"} 
INFO[2022-10-27T16:03:05-04:00] patched response: {"jsonrpc":"2.0","id":2,"error":"rpc: can't find service server.peers.Subscribe"} 
INFO[2022-10-27T16:03:05-04:00] from [::1]:53046 receive header              
WARN[2022-10-27T16:03:25-04:00] error: read tcp [::1]:50002->[::1]:53046: use of closed network connection 
INFO[2022-10-27T16:03:25-04:00] session [::1]:53046 goroutine exit           
INFO[2022-10-27T16:03:25-04:00] session [::1]:53046 timed out                

Incoming/outgoing JSON is patched using yet another codec (jsonPatchingCodec).
Add more logging of raw/patched JSON.
@moodyjon
Copy link
Contributor Author

Note test still fails because the 3rd RPC it tries to do is server.peers.subscribe.

Copy link
Collaborator

@jeffreypicard jeffreypicard left a comment

Choose a reason for hiding this comment

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

Other than the signal.go comment, this looks good.

@@ -49,10 +49,6 @@ func interruptListener() <-chan struct{} {
case sig := <-interruptChannel:
log.Infof("Received signal (%s). Already "+
"shutting down...", sig)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this should actually stay. I identified the issue with the spamming when it's killed, which was using the stop.Ch() as the shutdownRequestChannel, keeping it as a second channel that could be used later on to possibly kill this from the outside still makes sense.

@lbry-bot lbry-bot assigned moodyjon and unassigned jeffreypicard Oct 29, 2022
@jeffreypicard jeffreypicard merged commit e070e8a into lbryio:master Oct 29, 2022
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.

2 participants