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

Driveby cleanups #561

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 10 additions & 25 deletions .github/workflows/cln-version-manager-py.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
merge_group:
push:
branches:
- master
- main

jobs:
source:
Expand All @@ -22,30 +22,15 @@ jobs:
with:
sparse-checkout: |
libs/cln-version-manager
- name: Move files to toplevel
run: mv ./libs/cln-version-manager/** .
# Install python-3.8
- name: Install python
uses: actions/setup-python@v4

- name: Install the latest version of uv
uses: astral-sh/setup-uv@v5
with:
python-version: 3.8
# Load the poetry installation if it still cached
- name: Load cached Poetry installation
id: cached-poetry
uses: actions/cache@v3
with:
path: ~/.local # the path depends on the OS
key: poetry-0 # increment to reset cache
# Install poetry. By default the poetry-files venv is created
# in ~/.cache/virtualenvs
- name: Install poetry
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
version: 1.8.2
enable-cache: true
cache-dependency-glob: "**/pyproject.toml"

- name: Install dependencies
run: poetry update && poetry install --no-interaction
- name: Run mypy
run: poetry run mypy
run: uv sync

- name: Run tests
run: poetry run pytest tests
run: uv run pytest tests -vvv libs/cln-version-manager/tests
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ The docs are hosted on https://blockstream.github.io/greenlight/

## Contributing to the documentation

You must have a working installation of `python` and `poetry` to contribute to the docs.
You must have a working installation of `python` and `uv` to contribute to the docs.

To install dependencies make sure you are at the root of the repository

```
poetry install --with-only docs
uv sync --extra docs
```

To build the docs
Expand Down
1,199 changes: 0 additions & 1,199 deletions docs/poetry.lock

This file was deleted.

17 changes: 17 additions & 0 deletions docs/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[project]
name = "gl-docs"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.10"
dependencies = [
"mkdocs>=1.6.1",
"mkdocs-material>=9.5.49",
"mkdocs-redirects>=1.2.2",
"mkdocs-material-extensions>=1.3.1",
"pymdown-extensions>=10.13",
"ghp-import>=2.1.0",
"pdoc>=15.0.1",
"cairosvg>=2.7.1",
"pillow>=11.0.0",
]
365 changes: 0 additions & 365 deletions examples/python/poetry.lock

This file was deleted.

16 changes: 10 additions & 6 deletions examples/python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
[tool.poetry]
[project]
name = "my-gl-example"
version = "0.1.0"
description = "An example application for greenlight that uses the gl-client library"
description = "An example on how to use the gl-client-py library"
readme = "README.md"
requires-python = ">=3.10"
dependencies = [
"gl-client",
"pytest>=8.3.4",
]
authors = []
license = "MIT"

[tool.poetry.dependencies]
gl-client = {path = "../../libs/gl-client-py"}
pytest = "^7.1.2"
python = ">=3.7,<4"
[tool.uv.sources]
gl-client = { workspace = true }
1 change: 1 addition & 0 deletions libs/cln-version-manager/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cln_version_manager.egg-info/
20 changes: 20 additions & 0 deletions libs/cln-version-manager/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright 2024 Blockstream

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11 changes: 7 additions & 4 deletions libs/cln-version-manager/clnvm/cln_version_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
class VersionDescriptor:
tag: str
url: str
checksum: str
checksum: str | None


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -72,7 +72,7 @@ class VersionDescriptor:
VersionDescriptor(
tag="v24.02gl1",
url="https://storage.googleapis.com/greenlight-artifacts/cln/lightningd-v24.02gl1.tar.bz2",
checksum="d43e86c40d30b270b6566aa46532c48cc14c3158f61d7ad7565eca17606fb461",
checksum=None,
),
VersionDescriptor(
tag="v24.02",
Expand Down Expand Up @@ -157,7 +157,10 @@ def do() -> List[Tuple[str, NodeVersion]]:

def get_target_path(self, cln_version: VersionDescriptor) -> Path:
"""Computes the path corresponding to which a cln version should be downloaded"""
return Path(self._cln_path) / cln_version.checksum / cln_version.tag
if cln_version.checksum is None:
return Path(self._cln_path) / cln_version.tag
else:
return Path(self._cln_path) / cln_version.checksum / cln_version.tag

def get_descriptor_from_tag(self, tag: str) -> VersionDescriptor:
cln_dict = {d.tag: d for d in CLN_VERSIONS}
Expand Down Expand Up @@ -230,7 +233,7 @@ def _download(self, cln_version: VersionDescriptor, target_path: Path, verify_ta
"Try to unset GL_TESTING_IGNORE_HASH"
)

if (not ignore_hash) and content_sha != cln_version.checksum:
if cln_version.checksum and (not ignore_hash) and content_sha != cln_version.checksum:
raise HashMismatch(
tag=cln_version.tag, expected=cln_version.checksum, actual=content_sha
)
Expand Down
49 changes: 27 additions & 22 deletions libs/cln-version-manager/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
[tool.poetry]
[project]
name = "cln-version-manager"
version = "0.1.1"
description = "A version manager for Core Lightning Binaries"
authors = ["Erik De Smedt <[email protected]>"]
license = "MIT"
license = {file = "LICENSE"}
readme = "README.md"
requires-python = ">=3.8"

packages = [
{ include = "clnvm" },
authors = [
{ name = "Erik De Smedt", email = "[email protected]" },
]
dependencies = [
"click>=8.1.8",
"requests>=2.32.3",
]

[tool.poetry.dependencies]
python = "^3.8"
requests = "^2"
click = "^8"

[tool.poetry.group.dev.dependencies]
types-requests = "^2.31"
pytest = "^8"
mypy = "^1.8.0"
types-click = "^7"
black = "^24.2.0"
[project.scripts]
clnvm = 'clnvm.cli:run'

[tool.poetry.group.lsp_ide.dependencies]
python-lsp-server = "^1.10.0"
[tool.uv]
dev-dependencies = [
"mypy>=1.14.1",
"pytest>=8.3.4",
"types-click>=7.1.8",
"types-requests>=2.32.0.20241016",
]

[tool.poetry.scripts]
clnvm = "clnvm.cli:run"
source = ['.']

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.build.targets.sdist]
ignore-vcs = true

[tool.hatch.build.targets.wheel]
packages = ["clnvm"]
1 change: 1 addition & 0 deletions libs/gl-client-py/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
gl_client.egg-info
index.node
poetry.lock
20 changes: 20 additions & 0 deletions libs/gl-client-py/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright 2024 Blockstream

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
File renamed without changes.
56 changes: 14 additions & 42 deletions libs/gl-client-py/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,53 +1,25 @@
[project]
name = "gl-client"

dependencies = [
"protobuf>=3",
"grpcio>=1.56",
"pyln-grpc-proto>=0.1",
]

[tool.poetry]
name = "gl-client"
version = "0.3.0"
description = ""
authors = ["Christian Decker <[email protected]>"]
license = "MIT"

packages = [
{ include = "glclient" },
description = "Greenlight Client Bindings for Python"
readme = "README.md"
license = {file = "LICENSE"}
requires-python = ">=3.7"
authors = [
{ name = "Christian Decker", email = "[email protected]" },
]

include = [
{ path = "glclient/*.pyi", format = ["wheel", "sdist"] },
{ path = "glclient/py.typed", format = ["wheel", "sdist"] },
dependencies = [
"protobuf>=5.29.2",
"pyln-grpc-proto>=24.2.1",
]

[tool.poetry.group.dev.dependencies]
black = "^23.1.0"
mypy-protobuf = "^3.5"
maturin = {version = ">=1.0,<1.3.2", extras = ["patchelf"]}
mypy = "^1.7.0"
grpcio-tools = "^1.67"

[tool.poetry.dependencies]
python = ">=3.8,<4"
grpcio = ">=1.67"
pyln-grpc-proto = ">=0.1.2,<1.2"
protobuf = ">=4"
maturin = ">=1.0"

[build-system]
requires = ["maturin>=1.0"]
build-backend = "maturin"

[tool.mypy]
exclude = [
'glclient/greenlight_pb2.py',
'glclient/scheduler_pb2.py',
'glclient/greenlight_pb2_grpc.py',
'glclient/scheduler_pb2_grpc.py',
[tool.uv]
dev-dependencies = [
"grpcio-tools>=1.68.1",
"maturin>=1.8.0",
"mypy-protobuf>=3.6.0",
]

[[tool.mypy.overrides]]
module = 'glclient'
4 changes: 1 addition & 3 deletions libs/gl-client/src/lsps/lsps2/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ impl<'de> Deserialize<'de> for Promise {
D: serde::Deserializer<'de>,
{
let str_repr = String::deserialize(deserializer)?;
let promise = Promise::new(str_repr.clone());
Promise::new(str_repr.clone())
.map_err(|_| D::Error::custom("promise exceeds max length"))
Promise::new(str_repr.clone()).map_err(|_| D::Error::custom("promise exceeds max length"))
}
}

Expand Down
5 changes: 3 additions & 2 deletions libs/gl-plugin/src/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use crate::{stager, tramp};
use anyhow::{Context, Error, Result};
use base64::{engine::general_purpose, Engine as _};
use bytes::BufMut;
use gl_client::bitcoin::hashes::hex::ToHex;
use gl_client::persist::State;
use governor::{
clock::MonotonicClock, state::direct::NotKeyed, state::InMemoryState, Quota, RateLimiter,
Expand Down Expand Up @@ -230,7 +229,9 @@ impl Node for PluginNodeServer {
// log entries are produced while we're streaming the
// backlog out, but do we care?
use tokio::io::{AsyncBufReadExt, BufReader};
let file = tokio::fs::File::open("/tmp/log").await?;
// The nodelet uses its CWD, but CLN creates a network
// subdirectory
let file = tokio::fs::File::open("../log").await?;
let mut file = BufReader::new(file).lines();

tokio::spawn(async move {
Expand Down
1 change: 1 addition & 0 deletions libs/gl-plugin/src/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ impl Connected for UnixStream {
}

#[derive(Clone, Debug)]
#[allow(dead_code)] // TODO: Check if this is really needed.
pub struct UdsConnectInfo {
pub peer_addr: Option<Arc<tokio::net::unix::SocketAddr>>,
pub peer_cred: Option<tokio::net::unix::UCred>,
Expand Down
6 changes: 6 additions & 0 deletions libs/gl-testing/tests/test_grpc_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def test_node_grpc_web(scheduler, node_grpc_web_proxy, clients):
c = clients.new()
c.register(configure=True)
n = c.node()
_s = c.signer().run_in_thread()
info = n.get_info()

# Now extract the TLS certificates, so we can sign the payload.
Expand All @@ -62,3 +63,8 @@ def test_node_grpc_web(scheduler, node_grpc_web_proxy, clients):
req = clnpb.GetinfoRequest()
info = web_client.call("Getinfo", req)
print(info)

# Ask for a new address
req = clnpb.NewaddrRequest()
addr = web_client.call("NewAddr", req)
print(addr)
Loading
Loading