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

multi: Modify buf.yaml for Buf lint and Format with Buf CLI Comamnd("buf format -w") #354

Merged
merged 4 commits into from
Feb 13, 2025
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
13 changes: 12 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,22 @@ env:
SLOW_MACHINE: 1

jobs:
buf:
runs-on: ubuntu-latest

steps:
# Run `git checkout`
- name: Checkout code
uses: actions/checkout@v4
# Run the `buf` CLI
- name: Buf Action
uses: bufbuild/buf-action@v1

unit-tests:
runs-on: ubuntu-latest

steps:
- name: Checkout code
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Go
Expand Down
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ PeerSwap enables Lightning Network nodes to balance their channels by facilitati
- [Core Lightning](#core-lightning)
- [LND](#lnd)
- [Development](#development)
- [Development: Buf CLI Description](#development-buf-cli-description)
- [Usage](#usage-1)
- [Using Devcontainer](#using-devcontainer)

## Project Status

Expand Down Expand Up @@ -67,8 +70,8 @@ To run Elements for L-BTC swaps, see the [Elements setup guide](./docs/setup_ele

To run LWK for L-BTC swaps, see the [LWK setup guide](./docs/setup_lwk.md).

> **Note**
> Most of the benefits of PeerSwap come from using L-BTC. Swaps using L-BTC are more private, faster, and avoid the mainchain blockchain during high fee environments that can make swaps uneconomical.
> **Note**
> Most of the benefits of PeerSwap come from using L-BTC. Swaps using L-BTC are more private, faster, and avoid the mainchain blockchain during high fee environments that can make swaps uneconomical.

### Usage

Expand All @@ -88,7 +91,7 @@ See the [Upgrade guide](./docs/upgrade.md) for instructions to safely upgrade yo
* Lower Cost - PeerSwap is the lowest cost because there is no 3rd party coordinator or intermediary nodes to collect rent.
* More Private - Swaps are entirely between two consenting nodes. Nobody else is able to record details like who swapped.
* What is the difference between [splicing](https://github.com/lightning/bolts/pull/863) and PeerSwap?
* Both PeerSwap and splicing (through Phoenix Wallet) are now usable on mainnet. Splicing is in general better, though PeerSwap can be attractive more for L-BTC swaps that don't touch the mainnet blockchain at all. Splicing and PeerSwap L-BTC swaps are both good for mainnet efficiency.
* Both PeerSwap and splicing (through Phoenix Wallet) are now usable on mainnet. Splicing is in general better, though PeerSwap can be attractive more for L-BTC swaps that don't touch the mainnet blockchain at all. Splicing and PeerSwap L-BTC swaps are both good for mainnet efficiency.
* What is the difference between [liquidity-ads](https://github.com/lightning/bolts/pull/878) and PeerSwap?
* Liquidity Ads is a great way to lease new channels to be opened toward you for the purpose of gaining incoming capacity. New channels add new capacity in a desired direction but only once.
* PeerSwap lets you repeatedly refill your existing channels at a cost lower than opening, closing, and maintaining additional channels.
Expand All @@ -111,6 +114,14 @@ For a LND Bitcoin signet / Liquid testnet setup guide see this [guide](./docs/si

PeerSwap uses the [nix](https://nixos.org/download.html) package manager for a simple development environment. In order to start hacking, install nix, [golang](https://golang.org/doc/install) and run `nix-shell`. This will fetch all dependencies (except golang).

#### Development: Buf CLI Description

In this project, we utilize Buf CLI to streamline the development environment for Protocol Buffers (protobuf).Buf is a powerful tool for managing the build, linting, formatting, and validation processes for protobuf files in a consistent and efficient manner.

##### Usage

See the [Usage guide](./docs/usage_buf.md) for instructions on how to use Buf.

#### Using Devcontainer

To use devcontainer for development, follow these steps:
Expand Down
55 changes: 48 additions & 7 deletions buf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,51 @@
version: v2
modules:
- path: peerswaprpc

# lint:
# use:
# - STANDARD
# breaking:
# use:
# - FILE
lint:
use:
- STANDARD
except:
# TODO suport excepted standard rules.
# - COMMENT_ENUM
# - COMMENT_ENUM_VALUE
# - COMMENT_FIELD
# - COMMENT_MESSAGE
# - COMMENT_ONEOF
# - COMMENT_RPC
# - COMMENT_SERVICE
# - DIRECTORY_SAME_PACKAGE
# - ENUM_FIRST_VALUE_ZERO
# - ENUM_NO_ALLOW_ALIAS
# - ENUM_PASCAL_CASE
- ENUM_VALUE_PREFIX
# - ENUM_VALUE_UPPER_SNAKE_CASE
- ENUM_ZERO_VALUE_SUFFIX
# - FIELD_LOWER_SNAKE_CASE
# - FIELD_NOT_REQUIRED
# - FILE_LOWER_SNAKE_CASE
# - IMPORT_NO_PUBLIC
# - IMPORT_NO_WEAK
# - IMPORT_USED
# - MESSAGE_PASCAL_CASE
# - ONEOF_LOWER_SNAKE_CASE
# - PACKAGE_DEFINED
- PACKAGE_DIRECTORY_MATCH
# - PACKAGE_LOWER_SNAKE_CASE
# - PACKAGE_NO_IMPORT_CYCLE
# - PACKAGE_SAME_DIRECTORY
- PACKAGE_VERSION_SUFFIX
# - PROTOVALIDATE
# - RPC_NO_CLIENT_STREAMING
# - RPC_NO_SERVER_STREAMING
# - RPC_PASCAL_CASE
- RPC_REQUEST_STANDARD_NAME
- RPC_RESPONSE_STANDARD_NAME
- RPC_REQUEST_RESPONSE_UNIQUE
# - SERVICE_PASCAL_CASE
- SERVICE_SUFFIX
# - STABLE_PACKAGE_NO_IMPORT_UNSTABLE
# - SYNTAX_SPECIFIED
# - PACKAGE_SAME_GO_PACKAGE
breaking:
use:
- FILE
25 changes: 25 additions & 0 deletions docs/usage_buf.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Usage Guide

In this project, we utilize Buf CLI to streamline the development environment for Protocol Buffers (protobuf).Buf is a powerful tool for managing the build, linting, formatting, and validation processes for protobuf files in a consistent and efficient manner.

- [Buf](https://buf.build/)
- [Buf Github URL](https://github.com/bufbuild/buf)

## Why We Use Buf

The adoption of Buf provides several advantages:
- Strict Lint Checks: Ensures a consistent code style across the team and helps prevent potential bugs.
- Simplified Build Process: Reduces the complexity of configuring protoc commands with multiple options.
- CI/CD Integration: Easily integrates automatic linting, formatting, and validation into the CI/CD pipeline.
- Module Management: Simplifies dependency management with Buf modules.

## Installation Instructions

Buf CLI setup guide see this [Install the Buf CLI](https://buf.build/docs/cli/installation/):

## Notes on commands

```bash
make buf-lint ## lint
make buf-format ## format -w
```
3 changes: 2 additions & 1 deletion peerswaprpc/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ ARG GRPC_GATEWAY_VERSION
ENV PROTOC_GEN_GO_GRPC_VERSION="v1.1.0"
ENV GOCACHE=/tmp/build/.cache
ENV GOMODCACHE=/tmp/build/.modcache
ENV GOBIN=/usr/local/bin

RUN echo ${PROTOC_GEN_VERSION}

Expand All @@ -21,7 +22,7 @@ RUN cd /tmp \
&& go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@${PROTOC_GEN_GO_GRPC_VERSION} \
&& go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@${GRPC_GATEWAY_VERSION} \
&& go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@${GRPC_GATEWAY_VERSION} \
&& GOBIN=/usr/local/bin go install github.com/bufbuild/buf/cmd/[email protected] \
&& go install github.com/bufbuild/buf/cmd/[email protected] \
&& chmod -R 777 /tmp/build/

WORKDIR /build
Expand Down
12 changes: 10 additions & 2 deletions peerswaprpc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,19 @@ STUBS= \

all-rpc:
buf generate
.PHONY: all-rpc

buf-lint:
buf lint
.PHONY: all-rpc

buf-format:
buf format -w
.PHONY: all-rpc

clean-rpc:
rm -f ${STUBS}

.PHONY: all-rpc-docker
all-rpc-docker:
./gen_protos_docker.sh

.PHONY: all-rpc-docker
Loading