From 207ae673e658b808a0e301900959359b43770a49 Mon Sep 17 00:00:00 2001 From: Vincenzo Palazzo Date: Wed, 29 Jun 2022 13:26:05 +0100 Subject: [PATCH 1/3] ci: introduce the safety check for rust Signed-off-by: Vincenzo Palazzo --- .github/workflows/ci.yaml | 28 ++++++++++++++++++++++++++++ Makefile | 3 +++ 2 files changed, 31 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 60f1dd523a28..674db9f2bf0c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -32,6 +32,7 @@ jobs: - CFG: "make-EXPERIMENTAL-check" TEST_CMD: "make check-source check-units installcheck check-gen-updated" EXPERIMENTAL_FEATURES: 1 + VALGRIND: 1 steps: - name: Checkout uses: actions/checkout@v2.0.0 @@ -97,6 +98,33 @@ jobs: ./configure make check-doc + check-rust: + name: Check Rust file diff + runs-on: ubuntu-20.04 + env: + DEVELOPER: 1 + VALGRIND: 0 + EXPERIMENTAL_FEATURES: 0 + COMPAT: 1 + steps: + - name: Checkout + uses: actions/checkout@v2.0.0 + + - name: Set up Python 3.7 + uses: actions/setup-python@v2 + with: + python-version: 3.7 + + - name: Install dependencies + run: bash -x .github/scripts/setup.sh + + - name: Check Rust diff file + run: | + pip install mako + ./configure + make check-rust + + proto-test: name: Protocol Test Config runs-on: ubuntu-20.04 diff --git a/Makefile b/Makefile index f2d2c1038900..326063284a29 100644 --- a/Makefile +++ b/Makefile @@ -525,6 +525,9 @@ check-python-flake8: check-pytest-pyln-proto: PATH=$(PYLN_PATH) PYTHONPATH=$(MY_CHECK_PYTHONPATH) $(PYTEST) contrib/pyln-proto/tests/ +check-rust: + git diff --exit-code .msggen.json | echo "diff in rust file, need to be updated by enabling rust" && exit 1 + check-includes: check-src-includes check-hdr-includes @tools/check-includes.sh From fa2e59c3dcfe41c229292a6d9041401c0eba3c33 Mon Sep 17 00:00:00 2001 From: Vincenzo Palazzo Date: Wed, 29 Jun 2022 13:31:27 +0100 Subject: [PATCH 2/3] rust: update model generated Signed-off-by: Vincenzo Palazzo --- .msggen.json | 3 ++- Makefile | 2 +- cln-grpc/proto/node.proto | 1 + cln-grpc/src/convert.rs | 1 + cln-rpc/src/model.rs | 2 ++ 5 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.msggen.json b/.msggen.json index 5f0ba8012904..101427244356 100644 --- a/.msggen.json +++ b/.msggen.json @@ -666,7 +666,8 @@ "ListPeers.peers[].features": 6, "ListPeers.peers[].id": 1, "ListPeers.peers[].log[]": 3, - "ListPeers.peers[].netaddr[]": 5 + "ListPeers.peers[].netaddr[]": 5, + "ListPeers.peers[].remote_addr": 7 }, "ListpeersPeersChannels": { "ListPeers.peers[].channels[].alias": 50, diff --git a/Makefile b/Makefile index 326063284a29..56691f420b6d 100644 --- a/Makefile +++ b/Makefile @@ -526,7 +526,7 @@ check-pytest-pyln-proto: PATH=$(PYLN_PATH) PYTHONPATH=$(MY_CHECK_PYTHONPATH) $(PYTEST) contrib/pyln-proto/tests/ check-rust: - git diff --exit-code .msggen.json | echo "diff in rust file, need to be updated by enabling rust" && exit 1 + git diff --exit-code .msggen.json || echo "diff in rust file, need to be updated by enabling rust" && exit 1 check-includes: check-src-includes check-hdr-includes @tools/check-includes.sh diff --git a/cln-grpc/proto/node.proto b/cln-grpc/proto/node.proto index 228648010ad2..cc47a976a04b 100644 --- a/cln-grpc/proto/node.proto +++ b/cln-grpc/proto/node.proto @@ -128,6 +128,7 @@ message ListpeersPeers { repeated ListpeersPeersLog log = 3; repeated ListpeersPeersChannels channels = 4; repeated string netaddr = 5; + optional string remote_addr = 7; optional bytes features = 6; } diff --git a/cln-grpc/src/convert.rs b/cln-grpc/src/convert.rs index 2f837ed747bf..e6d33b9ab545 100644 --- a/cln-grpc/src/convert.rs +++ b/cln-grpc/src/convert.rs @@ -163,6 +163,7 @@ impl From<&responses::ListpeersPeers> for pb::ListpeersPeers { log: c.log.as_ref().map(|arr| arr.iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 channels: c.channels.iter().map(|i| i.into()).collect(), // Rule #3 for type ListpeersPeersChannels netaddr: c.netaddr.as_ref().map(|arr| arr.iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 + remote_addr: c.remote_addr.clone(), // Rule #2 for type string? features: c.features.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? } } diff --git a/cln-rpc/src/model.rs b/cln-rpc/src/model.rs index 7bee25f885a8..3a595deed0c8 100644 --- a/cln-rpc/src/model.rs +++ b/cln-rpc/src/model.rs @@ -1246,6 +1246,8 @@ pub mod responses { pub channels: Vec, #[serde(alias = "netaddr", skip_serializing_if = "Option::is_none")] pub netaddr: Option>, + #[serde(alias = "remote_addr", skip_serializing_if = "Option::is_none")] + pub remote_addr: Option, #[serde(alias = "features", skip_serializing_if = "Option::is_none")] pub features: Option, } From a4a7c2948c9052f1e1ee4a606c2dd2f4f7050295 Mon Sep 17 00:00:00 2001 From: Vincenzo Palazzo Date: Wed, 29 Jun 2022 15:09:50 +0100 Subject: [PATCH 3/3] fixed Makefile Signed-off-by: Vincenzo Palazzo --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 56691f420b6d..76eaee34826b 100644 --- a/Makefile +++ b/Makefile @@ -526,7 +526,7 @@ check-pytest-pyln-proto: PATH=$(PYLN_PATH) PYTHONPATH=$(MY_CHECK_PYTHONPATH) $(PYTEST) contrib/pyln-proto/tests/ check-rust: - git diff --exit-code .msggen.json || echo "diff in rust file, need to be updated by enabling rust" && exit 1 + git diff --exit-code .msggen.json || (echo "diff in rust file, need to be updated by enabling rust"; exit 1) check-includes: check-src-includes check-hdr-includes @tools/check-includes.sh