lightning icon indicating copy to clipboard operation
lightning copied to clipboard

Support multiple cln-version in pyln-testing

Open ErikDeSmedt opened this issue 1 year ago • 2 comments

It is sometimes useful to use pyln-testing also on older versions of Core Lightning. In greenlight we use pyln-testing to test our scheduler which has to support multiple versions of Core Lightning at the same time.

A similar issue exists for plug-in developers that want to support a range of cln-versions.

This PR introduces NodeVersion in pyln-client which can be used to compare the versions lightningd and test if the version is greater or not.

It also modifes pyln-testing so it will only use the --developer flag if it is available.

ErikDeSmedt avatar Mar 25 '24 17:03 ErikDeSmedt

See also https://github.com/Blockstream/greenlight/issues/389

ErikDeSmedt avatar Mar 25 '24 17:03 ErikDeSmedt

I got one conceptual question here:

What is the advantage adding the various classes in version.py?

Couldn't we simply parse the version string into an integer value e.g using a function ver_to_int(ver_str) that turns a version string into an int? v23.08 becomes 230800 and v23.08.1 becomes 230801 and v23.08rc3 becomes 230800 as well, according to your ruleset? Versions and their resulting integers are strictly monotone (at least until the end of the century) and we can compare via standard comparsion operators <, >, <=, >= and == instead of parsing an own set of operators for string comparison (from which we only use a check on >=v23.11 for now as far as I can tell).

What do you think about this, do I miss something here? Maybe an advantage of the string based comparison for future extensibility? Otherwise this might safe us approx 290 lines of code to maintain.

nepet avatar May 16 '24 15:05 nepet

I got one conceptual question here:

What is the advantage adding the various classes in version.py?

Couldn't we simply parse the version string into an integer value e.g using a function ver_to_int(ver_str) that turns a version string into an int? v23.08 becomes 230800 and v23.08.1 becomes 230801 and v23.08rc3 becomes 230800 as well, according to your ruleset? Versions and their resulting integers are strictly monotone (at least until the end of the century) and we can compare via standard comparsion operators <, >, <=, >= and == instead of parsing an own set of operators for string comparison (from which we only use a check on >=v23.11 for now as far as I can tell).

What do you think about this, do I miss something here? Maybe an advantage of the string based comparison for future extensibility? Otherwise this might safe us approx 290 lines of code to maintain.

You would normally use a standard version comparitor. But this works...

rustyrussell avatar Jan 22 '25 23:01 rustyrussell

It's a while ago and I don't remember my exact reasoning.

There are a few weird exceptions with versions though. One of them is 1a86e50-modded which I observed in CI.

I might have gone over the top a bit. But I wanted to have one place where we can always hack things in

ErikDeSmedt avatar Jan 29 '25 14:01 ErikDeSmedt

Rebased on master...

rustyrussell avatar Feb 20 '25 04:02 rustyrussell

Pushing a changelog entry to get CI running.

endothermicdev avatar Feb 20 '25 23:02 endothermicdev