-
Notifications
You must be signed in to change notification settings - Fork 902
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
cln-rpc & cln-grpc: Backfill more methods #5104
cln-rpc & cln-grpc: Backfill more methods #5104
Conversation
93c10c2
to
f0a5b05
Compare
Yeah, we really need to add these request schemas to to python framework for testing! OK, this isn't complete, but my proposal can be found (on top of this!) here: https://github.com/rustyrussell/lightning/tree/guilt/pr-5104 |
OK, my tree now has all the schema fixes, and some others. If you don't want to mess up your parsing, you can just cherry pick some of those changes (and not the part which actually validates it against the testsuite). |
876ada5
to
ed6e844
Compare
I incorporated @rustyrussell's changes and fixes and got things working again. Currently backfilling some more types since they can be hard and might be considered braking changes if we do it later. Also added a couple of tests to gain some more certainty that the conversion code is working. Will finish the changes by Monday, hoping to get these in asap |
6cbe4fe
to
9d34284
Compare
d70c2ce
to
c88effb
Compare
c88effb
to
0579969
Compare
Some commands have changed schemas maybe? Needs rebasing I think... |
Didn't get time to fold these, but: diff --git a/doc/schemas/signmessage.request.json b/doc/schemas/signmessage.request.json
index f5fd75727..163239e20 100644
--- a/doc/schemas/signmessage.request.json
+++ b/doc/schemas/signmessage.request.json
@@ -2,7 +2,7 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"required": [
- "id"
+ "message"
],
"additionalProperties": false,
"properties": {
diff --git a/tests/test_pay.py b/tests/test_pay.py
index bf8adf148..f4f5cc33b 100644
--- a/tests/test_pay.py
+++ b/tests/test_pay.py
@@ -2136,12 +2136,12 @@ def test_setchannel_routing(node_factory, bitcoind):
l1.rpc.getroute(l3.info['id'], 4001793, 1, fuzzpercent=0)["route"]
# We should consider this unroutable! (MPP is disabled!)
- inv = l3.rpc.call('invoice', {'msatoshi': 4001793,
- 'label': 'test_setchannel_1',
- 'description': 'desc',
- 'dev-routes': []})
+ inv = l3.dev_invoice(msatoshi=4001793,
+ label='test_setchannel_1',
+ description='desc',
+ dev_routes=[])
with pytest.raises(RpcError) as routefail:
- l1.rpc.dev_pay(inv['bolt11'], use_shadow=False)
+ l1.dev_pay(inv['bolt11'], use_shadow=False)
assert routefail.value.error['attempts'][0]['failreason'] == 'No path found'
# 1337 + 4000000 * 137 / 1000000 = 1885 |
Folded those simple fixes... |
0579969
to
94cf5db
Compare
Hmm, I put some cruft test changes in the rebase somehow. Fixed and once it's tested locally I'll push again... |
b655d28
to
6c29b48
Compare
Otherwise we get less nicely consecutive numbers because request and response share one domain. This separates them again.
This will override the schema later. Signed-off-by: Rusty Russell <[email protected]>
This will override the schema later. Signed-off-by: Rusty Russell <[email protected]>
lightningd is happy, but our schema won't be. Signed-off-by: Rusty Russell <[email protected]>
These are useful for requests: 1. "outpoint": <txid>:<outnum> 2. "feerate": strings or a number 3. "outputdesc": bitcoin-style addresses-as-keys 4. "msat_or_all": amount or "all" 4. "msat_or_any": amount or "any" 5. "short_channel_id_dir": scid with /0 or /1. Signed-off-by: Rusty Russell <[email protected]>
Types are fixed, in particular: * rename "OutputDesc" to more consistent "outputdesc". * rename "utxo" to more consistent "outpoint". * it's "boolean" not "bool". * "number" means int or float, usually it should be u32. Specific commands: * close `id` can be by channel id, scid. * close `feerange` is a feerate type. * datastore/deldatastore/listdatastore `key` can be singleton. * delexpiredinvoice: `maxexpirytime` is not required, is a u64. * invoice/delinvoice/listinvoice `label` can be an integer * fundpsbt: many fields are u32 not number (JSON for int or float). * invoice: `msatoshi` can be "any". * invoice: `expiry` has a type (now must be numeric). * invoice: `exposeprivatechannels` can be bool or array of scids. * invoice: `deschashonly` added * keysend: there's no "float" type, use "number" or "u32" etc. * keysend: `routehints` is a valid arg, as is `extratlvs` (EXPERIMENTAL_FEATURES) * listdatastore: `key` is not required. * newaddr: `addresstype` can be "all" * pay: `exemptfee` is "msat", new fields `locaofferid` and `exclude` * sendonion: was mis-formatted, missed `localofferid` and `groupid` fields. * sendpay: add `localofferid` and `groupid` params. * signpsbt: add `signonly` param. * txprepare "outptus" typo. * waitsendpay: add `groupid` and fix `partid` type. * withdraw: `destination` is a bitcoin address, not a pubkey. Signed-off-by: Rusty Russell <[email protected]>
This means suppressing schemas in some places too. Signed-off-by: Rusty Russell <[email protected]>
Sometimes we just want to paper over the schema directly. Mostly useful to sidestep the `oneof` things that are required for expressiveness.
These json structs are gigantic, so let's externalize them a bit.
Got some issues parsing dates for example.
It's schema definition is weirdly asymmetric, with variants dependent on another fields' value. Need to decide if we want to either hand-code a superset or make a more complex decoding, but definitely not something we'd want the generator to be able to do.
So far we were papering over the actual error with a generic string that isn't very useful. Now we decode the error and forward it through the grpc layer as well (though still as a string).
- disconnect - feerates - getroute - listforwards - listpays - ping - signmessage
e6db99f
to
fc6c054
Compare
Rebased, and addressed flake. |
fc6c054
to
0b0c06c
Compare
Signed-off-by: Rusty Russell <[email protected]>
Didn't want to pollute each commit with the changes in the derived files so here are all the changes in one commit :-)
0b0c06c
to
9a76d84
Compare
Ack 9a76d84 Remaining memleak flake is known, on my workaround list soon. |
I now know how @rustyrussell felt filling in the JSON-Schemas for the JSON-RPC responses. This PR mostly consists of me backfilling the JSON-RPC request schemas, and then autogenerating the derived files, occasionally addressing a conversion issue or a missing type.
The PR is based on topp of #5013 and starts with the
msggen: Add meta file to keep the field numbers stable
commit (daa26ff at the time of writing).The following files where changed manually, all others were generated and are unlikely to hold any surprises:
cln-grpc/proto/primitives.proto
to add theFeerate
,Utxo
andOutputDesc
primitivescln-grpc/src/pb.rs
to add a number of protobuf <-> JSON-RPC conversionscln-rpc/Cargo.toml
to add thehex
dependencycln-rpc/src/primitives.rs
contrib/msggen/msggen/__main__.py
to allowlist more RPC methods and add method renaming forconnect
which is already used by grpc internallycontrib/msggen/msggen/grpc.py
to add the fixed mapping from field path to field number required for grpc to work across versions (renumbering fields is not allowed by protobuf and grpc since that's how fields are identified).contrib/msggen/msggen/model.py
andcontrib/msggen/msggen/rust.py
to add mapped typesdoc/schemas/connect.request.json
doc/schemas/createinvoice.request.json
doc/schemas/createonion.request.json
doc/schemas/datastore.request.json
doc/schemas/deldatastore.request.json
doc/schemas/delexpiredinvoice.request.json
doc/schemas/delinvoice.request.json
doc/schemas/fundpsbt.request.json
doc/schemas/invoice.request.json
doc/schemas/keysend.request.json
doc/schemas/listdatastore.request.json
doc/schemas/listinvoices.request.json
doc/schemas/listnodes.request.json
doc/schemas/listsendpays.request.json
doc/schemas/listtransactions.request.json
doc/schemas/newaddr.request.json
doc/schemas/pay.request.json
doc/schemas/sendonion.request.json
doc/schemas/sendpay.request.json
doc/schemas/sendpsbt.request.json
doc/schemas/signpsbt.request.json
doc/schemas/utxopsbt.request.json
doc/schemas/waitanyinvoice.request.json
doc/schemas/waitinvoice.request.json
doc/schemas/waitsendpay.request.json
doc/schemas/withdraw.request.json
It is likely easiest to review the final diff and not the individual commits, since I jumped around a bit between methods that are more or less related. As for completeness you can look at
contrib/msggen/msggen/__main__.py
as to which methods are mapped and which aren't yet. Please let me know if there are any methods that are needed for your use-cases and that should be mapped.This has to be considered experimental code, since I couldn't test most of these commands, due to the sheer surface size. The code compiles, but we make liberal use of panics, which may lead to unexpected results. You have been warned, but feedback is very much welcome to stabilize this interface.