JSON RPC compatibility workarounds to support lbry-sdk #75

Merged
moodyjon merged 3 commits from jsonrpc_compat1 into master 2022-10-29 17:42:24 +02:00
moodyjon commented 2022-10-27 22:09:20 +02:00 (Migrated from github.com)

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                
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 ```
moodyjon commented 2022-10-27 22:11:53 +02:00 (Migrated from github.com)

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

Note test still fails because the 3rd RPC it tries to do is `server.peers.subscribe`.
jeffreypicard (Migrated from github.com) requested changes 2022-10-29 15:45:41 +02:00
jeffreypicard (Migrated from github.com) left a comment

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

Other than the signal.go comment, this looks good.
@ -53,4 +52,1 @@
case <-shutdownRequestChannel:
log.Info("Shutdown requested. Already " +
"shutting down...")
}
jeffreypicard (Migrated from github.com) commented 2022-10-29 15:45:15 +02:00

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.

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.
jeffreypicard (Migrated from github.com) approved these changes 2022-10-29 17:42:16 +02:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: LBRYCommunity/herald.go#75
No description provided.