Skip to content
Merged
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
205 changes: 109 additions & 96 deletions Cargo.lock

Large diffs are not rendered by default.

55 changes: 33 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -71,26 +71,28 @@ RUN apt-get update -qq && \
wget

RUN wget -q https://zlib.net/zlib-1.2.13.tar.gz \
&& tar xvf zlib-1.2.13.tar.gz \
&& cd zlib-1.2.13 \
&& ./configure \
&& make \
&& make install && cd .. && rm zlib-1.2.13.tar.gz && rm -rf zlib-1.2.13
&& tar xvf zlib-1.2.13.tar.gz \
&& cd zlib-1.2.13 \
&& ./configure \
&& make \
&& make install && cd .. && \
rm zlib-1.2.13.tar.gz && \
rm -rf zlib-1.2.13

RUN apt-get install -y --no-install-recommends unzip tclsh \
&& wget -q https://www.sqlite.org/2019/sqlite-src-3290000.zip \
&& unzip sqlite-src-3290000.zip \
&& cd sqlite-src-3290000 \
&& ./configure --enable-static --disable-readline --disable-threadsafe --disable-load-extension \
&& make \
&& make install && cd .. && rm sqlite-src-3290000.zip && rm -rf sqlite-src-3290000
&& wget -q https://www.sqlite.org/2019/sqlite-src-3290000.zip \
&& unzip sqlite-src-3290000.zip \
&& cd sqlite-src-3290000 \
&& ./configure --enable-static --disable-readline --disable-threadsafe --disable-load-extension \
&& make \
&& make install && cd .. && rm sqlite-src-3290000.zip && rm -rf sqlite-src-3290000

RUN wget -q https://gmplib.org/download/gmp/gmp-6.1.2.tar.xz \
&& tar xvf gmp-6.1.2.tar.xz \
&& cd gmp-6.1.2 \
&& ./configure --disable-assembly \
&& make \
&& make install && cd .. && rm gmp-6.1.2.tar.xz && rm -rf gmp-6.1.2
&& tar xvf gmp-6.1.2.tar.xz \
&& cd gmp-6.1.2 \
&& ./configure --disable-assembly \
&& make \
&& make install && cd .. && rm gmp-6.1.2.tar.xz && rm -rf gmp-6.1.2

ENV RUST_PROFILE=release
ENV PATH=$PATH:/root/.cargo/bin/
Expand All @@ -101,21 +103,30 @@ WORKDIR /opt/lightningd
COPY . /tmp/lightning
RUN git clone --recursive /tmp/lightning . && \
git checkout $(git --work-tree=/tmp/lightning --git-dir=/tmp/lightning/.git rev-parse HEAD)
ARG DEVELOPER=0

ARG DEVELOPER=1
ENV PYTHON_VERSION=3
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python3 - \
RUN curl -sSL https://install.python-poetry.org | python3 - \
&& pip3 install -U pip \
&& pip3 install -U wheel \
&& /root/.local/bin/poetry config virtualenvs.create false \
&& /root/.local/bin/poetry install

RUN ./configure --prefix=/tmp/lightning_install --enable-static && make -j3 DEVELOPER=${DEVELOPER} && make install
RUN ./configure --prefix=/tmp/lightning_install --enable-static && \
make DEVELOPER=${DEVELOPER} && \
/root/.local/bin/poetry run make install

FROM debian:bullseye-slim as final

COPY --from=downloader /opt/tini /usr/bin/tini
RUN apt-get update && apt-get install -y --no-install-recommends socat inotify-tools python3 python3-pip libpq5\
&& rm -rf /var/lib/apt/lists/*

RUN apt-get update && \
apt-get install -y --no-install-recommends \
socat \
inotify-tools \
python3 \
python3-pip \
libpq5 && \
rm -rf /var/lib/apt/lists/*

ENV LIGHTNINGD_DATA=/root/.lightning
ENV LIGHTNINGD_RPC_PORT=9835
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ default: show-flags all-programs all-test-programs doc-all default-targets

ifneq ($(SUPPRESS_GENERATION),1)
FORCE = FORCE
FORCE::
FORCE:
endif

show-flags: config.vars
Expand Down
7 changes: 5 additions & 2 deletions cln-grpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
[package]
name = "cln-grpc"
version = "0.0.1"
version = "0.1.1"
edition = "2021"
license = "MIT"
repository = "https://github.com/ElementsProject/lightning/tree/master/cln-grpc"
description = "The Core Lightning API as grpc primitives. Provides the bindings used to expose the API over the network."

[dependencies]
anyhow = "1.0"
log = "0.4"
cln-rpc = { path="../cln-rpc/" }
cln-rpc = { path="../cln-rpc/", version = "^0.1" }
tonic = { version = "^0.5", features = ["tls", "transport"] }
prost = "0.8"
hex = "0.4.3"
Expand Down
6 changes: 5 additions & 1 deletion cln-grpc/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
fn main() {
tonic_build::compile_protos("proto/node.proto").unwrap();
let builder = tonic_build::configure();
builder
.protoc_arg("--experimental_allow_proto3_optional")
.compile(&["proto/node.proto"], &["proto"])
.unwrap();
}
22 changes: 12 additions & 10 deletions cln-rpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
[package]
name = "cln-rpc"
version = "0.1.0"
version = "0.1.1"
edition = "2021"
license = "MIT"
description = "An async RPC client for Core Lightning."

[[example]]
name = "cln-rpc-getinfo"
path = "examples/getinfo.rs"

[dependencies]
anyhow = "1.0.51"
bitcoin_hashes = { version = "0.10.0", features = [ "serde" ] }
bytes = "1.1.0"
log = "0.4.14"
secp256k1 = { version = "0.22.1", features = [ "serde" ] }
serde = { version = "1.0.131", features = ["derive"] }
serde_json = "1.0.72"
anyhow = "1.0"
bitcoin_hashes = { version = "0.10", features = [ "serde" ] }
bytes = "1.1"
log = "0.4"
secp256k1 = { version = "0.22", features = [ "serde" ] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tokio-util = { version = "0.6.9", features = ["codec"] }
tokio = { version = "1", features = ["net"]}
futures-util = { version = "*", features = [ "sink" ] }
futures-util = { version = "0.3", features = [ "sink" ] }
hex = "0.4.3"

[dev-dependencies]
tokio = { version = "1", features = ["net", "macros", "rt-multi-thread"]}
env_logger = "*"
env_logger = "0.9"
30 changes: 21 additions & 9 deletions contrib/msggen/msggen/__main__.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
import json
import os
import argparse
from pathlib import Path
from msggen.gen.grpc import GrpcGenerator, GrpcConverterGenerator, GrpcUnconverterGenerator, GrpcServerGenerator
from msggen.gen.grpc2py import Grpc2PyGenerator
from msggen.gen.rust import RustGenerator
from msggen.gen.generator import GeneratorChain
from msggen.utils import repo_root, load_jsonrpc_service
from msggen.utils import load_jsonrpc_service


def add_handler_gen_grpc(generator_chain: GeneratorChain, meta):
"""Load all mapped RPC methods, wrap them in a Service, and split them into messages.
"""
fname = repo_root() / "cln-grpc" / "proto" / "node.proto"
fname = Path("cln-grpc") / "proto" / "node.proto"
dest = open(fname, "w")
generator_chain.add_generator(GrpcGenerator(dest, meta))

fname = repo_root() / "cln-grpc" / "src" / "convert.rs"
fname = Path("cln-grpc") / "src" / "convert.rs"
dest = open(fname, "w")
generator_chain.add_generator(GrpcConverterGenerator(dest))
generator_chain.add_generator(GrpcUnconverterGenerator(dest))

fname = repo_root() / "cln-grpc" / "src" / "server.rs"
fname = Path("cln-grpc") / "src" / "server.rs"
dest = open(fname, "w")
generator_chain.add_generator(GrpcServerGenerator(dest))


def add_handler_get_grpc2py(generator_chain: GeneratorChain):
fname = repo_root() / "contrib" / "pyln-testing" / "pyln" / "testing" / "grpc2py.py"
fname = Path("contrib") / "pyln-testing" / "pyln" / "testing" / "grpc2py.py"
dest = open(fname, "w")
generator_chain.add_generator(Grpc2PyGenerator(dest))


def add_handler_gen_rust_jsonrpc(generator_chain: GeneratorChain):
fname = repo_root() / "cln-rpc" / "src" / "model.rs"
fname = Path("cln-rpc") / "src" / "model.rs"
dest = open(fname, "w")
generator_chain.add_generator(RustGenerator(dest))

Expand All @@ -48,8 +50,9 @@ def write_msggen_meta(meta):
os.rename(f'.msggen.json.tmp.{pid}', '.msggen.json')


def run():
service = load_jsonrpc_service()
def run(rootdir: Path):
schemadir = rootdir / "doc" / "schemas"
service = load_jsonrpc_service(schema_dir=schemadir)
meta = load_msggen_meta()
generator_chain = GeneratorChain()

Expand All @@ -63,4 +66,13 @@ def run():


if __name__ == "__main__":
run()
parser = argparse.ArgumentParser()
parser.add_argument(
'--rootdir',
dest='rootdir',
default='.'
)
args = parser.parse_args()
run(
rootdir=Path(args.rootdir)
)
2 changes: 1 addition & 1 deletion contrib/msggen/msggen/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .utils import load_jsonrpc_method, load_jsonrpc_service, repo_root # noqa
from .utils import load_jsonrpc_method, load_jsonrpc_service # noqa
15 changes: 3 additions & 12 deletions contrib/msggen/msggen/utils/utils.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
import subprocess
import json
from pathlib import Path

from msggen.model import Method, CompositeField, Service


def repo_root():
path = subprocess.check_output(["git", "rev-parse", "--show-toplevel"])
return Path(path.strip().decode('UTF-8'))


def load_jsonrpc_method(name, schema_dir: str = None):
def load_jsonrpc_method(name, schema_dir: Path):
"""Load a method based on the file naming conventions for the JSON-RPC.
"""
if schema_dir is None:
base_path = (repo_root() / "doc" / "schemas").resolve()
else:
base_path = schema_dir
base_path = schema_dir
req_file = base_path / f"{name.lower()}.request.json"
resp_file = base_path / f"{name.lower()}.schema.json"
request = CompositeField.from_js(json.load(open(req_file)), path=name)
Expand All @@ -34,7 +25,7 @@ def load_jsonrpc_method(name, schema_dir: str = None):
)


def load_jsonrpc_service(schema_dir: str = None):
def load_jsonrpc_service(schema_dir: str):
method_names = [
"Getinfo",
"ListPeers",
Expand Down
4 changes: 2 additions & 2 deletions external/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ external-clean:
if [ -f ${TARGET_DIR}/libwally-core-build/Makefile ]; then make -C ${TARGET_DIR}/libwally-core-build clean; fi
if [ -f ${TARGET_DIR}/libwally-core-build/src/Makefile ]; then make -C ${TARGET_DIR}/libwally-core-build/src clean; fi
if [ -f ${TARGET_DIR}/libbacktrace-build/Makefile ]; then make -C ${TARGET_DIR}/libbacktrace-build clean; fi
[ -f external/lowdown/Makefile.configure ] && $(MAKE) -C external/lowdown clean
if [ -f external/lowdown/Makefile.configure ]; then $(MAKE) -C external/lowdown clean; fi

external-distclean:
make -C external/libsodium distclean || true
[ -f external/lowdown/Makefile.configure ] && $(MAKE) -C external/lowdown distclean
if [ -f external/lowdown/Makefile.configure ]; then $(MAKE) -C external/lowdown distclean; fi
$(RM) -rf ${TARGET_DIR}/libbacktrace-build ${TARGET_DIR}/libsodium-build ${TARGET_DIR}/libwally-core-build ${TARGET_DIR}/jsmn-build
$(RM) -r `git status --ignored --porcelain external/libwally-core | grep '^!! ' | cut -c3-`
4 changes: 2 additions & 2 deletions plugins/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cln-plugin"
version = "0.1.0"
version = "0.1.1"
edition = "2021"
license = "MIT"
repository = "https://github.com/ElementsProject/lightning/tree/master/plugins"
Expand All @@ -20,7 +20,7 @@ tokio-util = { version = "0.6.9", features = ["codec"] }
tokio = { version="1", features = ['io-std', 'rt', 'sync', 'macros', 'io-util'] }
tokio-stream = "0.1"
futures = "0.3"
cln-rpc = { path = "../cln-rpc", version = "0.1.0" }
cln-rpc = { path = "../cln-rpc", version = "^0.1" }
env_logger = "0.9"

[dev-dependencies]
Expand Down