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

sauron: Add mutinynet support #584

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ca-ruz
Copy link
Contributor

@ca-ruz ca-ruz commented Sep 3, 2024

Adds mutinynet support to sauron. Mutinynet.com uses the mempool.space REST API, which has a slightly different spec from blockstream's Esplora so there is new code to handle that.

We pinned pyln-client to <=24.5 because version 24.8 has some extra requirements that sauron does not meet, we should probably fix this but for now pinning 24.5 should work fine.

sauron/sauron.py Outdated Show resolved Hide resolved
sauron/sauron.py Outdated Show resolved Hide resolved
sauron/sauron.py Outdated Show resolved Hide resolved
@ca-ruz ca-ruz force-pushed the sauron-mutinynet branch 2 times, most recently from f343745 to 7519cc6 Compare September 12, 2024 22:08
sauron/sauron.py Outdated Show resolved Hide resolved
sauron/sauron.py Outdated Show resolved Hide resolved
sauron/sauron.py Outdated Show resolved Hide resolved
sauron/sauron.py Outdated Show resolved Hide resolved
sauron/sauron.py Outdated Show resolved Hide resolved
sauron/sauron.py Outdated Show resolved Hide resolved
sauron/sauron.py Outdated Show resolved Hide resolved
sauron/sauron.py Outdated Show resolved Hide resolved
sauron/sauron.py Outdated Show resolved Hide resolved
sauron/sauron.py Outdated Show resolved Hide resolved
@sip-21
Copy link
Collaborator

sip-21 commented Sep 18, 2024

You need to pin the version of pyln-client in requirements.txt as
pyln-client==24.5 as otherwise a newer version gets installed which causes this error when starting the plugin:
lightningd: --sauron-api-endpoint=https://mutinynet.com/api/: unknown option

@sip-21
Copy link
Collaborator

sip-21 commented Sep 18, 2024

You might want to add some instructions in the README for how to start sauron with Mutinynet. Below command worked for me once I had pyln-client==24.5 installed (see comment above):
lightningd --signet --disable-plugin bcli --plugin $PWD/sauron.py --sauron-api-endpoint https://mutinynet.com/api/

@ca-ruz ca-ruz force-pushed the sauron-mutinynet branch 2 times, most recently from a5483ee to 70dc8ad Compare September 24, 2024 21:01
sauron/sauron.py Outdated Show resolved Hide resolved
sauron/sauron.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@chrisguida chrisguida left a comment

Choose a reason for hiding this comment

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

See comments

sauron/sauron.py Outdated Show resolved Hide resolved
sauron/requirements.txt Outdated Show resolved Hide resolved
@chrisguida
Copy link
Collaborator

Btw @sip-21 noticed that this PR breaks mainnet on blockstream.info. Can you look into this @ca-ruz @iorch ?

@ca-ruz
Copy link
Contributor Author

ca-ruz commented Oct 2, 2024

@sip-21 Can you please give me more details about the tests you wrote and what were you trying to do when Sauron failed? I am trying to replicate it to fix it. Thanks!

@sip-21
Copy link
Collaborator

sip-21 commented Oct 3, 2024

@ca-ruz The failing GitHub actions/tests are here: https://github.com/sip-21/plugins/actions/runs/11116007452/job/30885476517?pr=15

[gw0] [ 20%] PASSED test_sauron.py::test_rpc_getchaininfo 
[gw1] [ 40%] ERROR test_sauron.py::test_rpc_sendrawtransaction_invalid 
[gw2] [ 60%] ERROR test_sauron.py::test_rpc_getrawblockbyheight 
[gw3] [ 80%] ERROR test_sauron.py::test_rpc_getutxout 
[gw1] [ 80%] ERROR test_sauron.py::test_rpc_sendrawtransaction_invalid 
[gw2] [ 80%] ERROR test_sauron.py::test_rpc_getrawblockbyheight 
[gw4] [100%] ERROR test_sauron.py::test_rpc_estimatefees 
[gw3] [100%] ERROR test_sauron.py::test_rpc_getutxout 
[gw4] [100%] ERROR test_sauron.py::test_rpc_estimatefees 

The tests run fine together locally, but in GitHub action lightningd doesn't seem to not shutdown properly after a test. This is why in the logs you then see

  lightningd-0 2024-10-01T00:02:01.508Z **BROKEN** connectd: Failed to listen on socket 127.0.0.1:9735: Address already in use
  Time-out: can't find [re.compile('Server started with public key')] in logs

lightningd seems to randomly be able to shutdown properly, though, and two subsequent tests pass as in this case: https://github.com/sip-21/plugins/actions/runs/11089120680/job/30809842202

@ca-ruz ca-ruz force-pushed the sauron-mutinynet branch 3 times, most recently from 37fe65a to 5091652 Compare October 4, 2024 01:52
@ca-ruz
Copy link
Contributor Author

ca-ruz commented Oct 4, 2024

@sip-21 Thanks!! I recreated the bug and now it's fixed! Can you please run the tests again and let me know?

@ca-ruz ca-ruz force-pushed the sauron-mutinynet branch 2 times, most recently from bef972b to 7402d7d Compare October 4, 2024 22:45
@chrisguida chrisguida changed the title Added mutinynet support sauron: Add mutinynet support Oct 8, 2024
@chrisguida
Copy link
Collaborator

Waiting on @sip-21's PR here ca-ruz#2 (comment)

.ci/test.py Outdated
@@ -241,13 +241,14 @@ def run_one(p: Plugin, workflow: str) -> bool:

logging.info(f"Virtualenv at {vpath}")

num_workers = 1 if p.name == "sauron" else 5
Copy link
Collaborator

Choose a reason for hiding this comment

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

@sip-21 didn't you fix the concurrency? We can get rid of this I think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

If removing this breaks the tests, we should add the changes to this file back, but under the other commit (the one that adds the tests).

Copy link
Contributor Author

@ca-ruz ca-ruz Oct 24, 2024

Choose a reason for hiding this comment

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

Removed these lines from the code. Tests are all failing now.

@@ -1,2 +1,2 @@
pyln-client>=23.2
pyln-client>=23.2,<=24.5
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should create an issue to fix this

Copy link
Contributor Author

@ca-ruz ca-ruz Oct 25, 2024

Choose a reason for hiding this comment

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

Created Issue: #618.

Copy link
Collaborator

@chrisguida chrisguida left a comment

Choose a reason for hiding this comment

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

We're almost there! Just a couple of minor issues.

@chrisguida
Copy link
Collaborator

@sip-21

After adding back concurrency, the tests are failing because they're trying to listen on port 9735... that actually doesn't seem necessary. Can you fix the tests not to require listening on port 9735? (or maybe just listen on a random port)

Screenshot 2024-10-24 at 16 54 40


self.daemon = LightningD(lightning_dir, None) # noqa: F405
options = {
"disable-plugin": "bcli",
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you need to override this class at all. Just set the options appropriately when using the NodeFactory.get_node(). That'll obviate the need for the subclass and the fixtures.

@cdecker
Copy link
Contributor

cdecker commented Oct 25, 2024

Please don't override the fixtures and the node class unless you absolutely need to. options passed to NodeFactory.gey_node() is where you can disable one and enable the other. Furthermore, the tests differ only in the backend used, so you could use pytest's parametrized Tests to reuse the implementation but get the backend as a parameter (they'd run once for each backend then). Finally, you are doing format checking which is great, but we could go one further and actually use the JSON schemas from CLN to ensure all fields are present and types match up.

@chrisguida
Copy link
Collaborator

@cdecker do you have an example of any pytests that use the JSON schema from CLN to check the fields and types? That sounds amazing!

@cdecker
Copy link
Contributor

cdecker commented Oct 31, 2024

It's done automatically by instrumenting the pyln-client library to load and check the schemas. Anything going through pyln-client in a test environment should be checked afaik. I don't think notifications and hooks are checked yet (there are no schemas yet), but that'd be an amazing extension covering the docs vs implementation too

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.

4 participants