From 49474f379f25c4d563547ab9bd9e133382b40d97 Mon Sep 17 00:00:00 2001 From: Nikita Masych <92444221+NikitaMasych@users.noreply.github.com> Date: Thu, 17 Oct 2024 19:56:31 +0300 Subject: [PATCH] ci: added linter of the formatting with prettier (#19) * ci: added linter of the formatting with prettier * chore: added prettier ignore config --- .github/workflows/lint-format.yml | 32 +++++++++++++++++++++++++++++++ .gitignore | 3 ++- .prettierignore | 6 ++++++ README.md | 18 ++++++++--------- package-lock.json | 28 +++++++++++++++++++++++++++ package.json | 25 ++++++++++++++++++++++++ 6 files changed, 102 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/lint-format.yml create mode 100644 .prettierignore create mode 100644 package-lock.json create mode 100644 package.json diff --git a/.github/workflows/lint-format.yml b/.github/workflows/lint-format.yml new file mode 100644 index 0000000..2d64e75 --- /dev/null +++ b/.github/workflows/lint-format.yml @@ -0,0 +1,32 @@ +name: Prettier Check + +on: + push: + branches: + - main + pull_request: + branches: + - main + workflow_dispatch: + +permissions: + contents: read + +jobs: + format: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: "latest" + + - name: Install dependencies + run: npm install + + - name: Run Prettier + run: npm run prettier:check diff --git a/.gitignore b/.gitignore index 3d84f13..d3b2c00 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /target /Cargo.lock -.idea/ \ No newline at end of file +.idea/ +node_modules/ \ No newline at end of file diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..b705382 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,6 @@ +# We use cargo fmt for rust-related files. +src/ +tests/ +Cargo.toml +Cargo.lock +*.rs \ No newline at end of file diff --git a/README.md b/README.md index e643aa8..d64248b 100644 --- a/README.md +++ b/README.md @@ -91,9 +91,9 @@ impl ValueSelector for MyValueSelector { `LeaderElector` trait allows you to define specific conditions, how to select leader for consensus. -__NOTE: it is important to provide deterministic mechanism, +**NOTE: it is important to provide deterministic mechanism, because each participant will compute leader for itself, -and in case it is not deterministic, state divergence occurs.__ +and in case it is not deterministic, state divergence occurs.** We also provide ready-to-use [DefaultLeaderElector](https://distributed-lab.github.io/bpcon/bpcon/leader/struct.DefaultLeaderElector.html) @@ -141,17 +141,17 @@ We welcome you to check our [integration tests](./tests) for examples. In real world applications, we may categorize parties by their behavior to following: 1. Good - party sends messages to other participants based on following events, - and correctly receives and processes messages from other parties. + and correctly receives and processes messages from other parties. 2. Faulty - party has troubles receiving/sending messages. - These are simply mitigated by the weighed threshold and redundancy of consensus participants. + These are simply mitigated by the weighed threshold and redundancy of consensus participants. 3. Malicious - party launches DDoS attack using unbounded sending of messages - - to deal with this, we introduce rate-limiting mechanism in accepting messages inside the `Party`, - however it is also ❗️ required by integrating 'external' system ❗️, which handles `P2P`, to attest to this, because otherwise receiving channel may get flooded by malicious messages and block messages from other parties. - Another way to cause trouble is by sending invalid messages. For this, each party has - a set of checks for certain fields like current ballot number, status, etc. - Additionally, if the state transition caused by incoming message errored, it does not impact the party in either way. + to deal with this, we introduce rate-limiting mechanism in accepting messages inside the `Party`, + however it is also ❗️ required by integrating 'external' system ❗️, which handles `P2P`, to attest to this, because otherwise receiving channel may get flooded by malicious messages and block messages from other parties. + Another way to cause trouble is by sending invalid messages. For this, each party has + a set of checks for certain fields like current ballot number, status, etc. + Additionally, if the state transition caused by incoming message errored, it does not impact the party in either way. ### Note on the leader 👑 diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..4772c6b --- /dev/null +++ b/package-lock.json @@ -0,0 +1,28 @@ +{ + "name": "bpcon", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "bpcon", + "devDependencies": { + "prettier": "^3.3.3" + } + }, + "node_modules/prettier": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz", + "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", + "dev": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..12364eb --- /dev/null +++ b/package.json @@ -0,0 +1,25 @@ +{ + "name": "bpcon", + "description": "Generic Rust library for BPCon (Byzantine Paxos).", + "scripts": { + "prettier:fix": "prettier --cache --write .", + "prettier:check": "prettier --cache --check ." + }, + "repository": { + "type": "git", + "url": "https://github.com/distributed-lab/bpcon" + }, + "keywords": [ + "Rust", + "BPCon", + "DistributedLab" + ], + "author": "DistributedLab", + "bugs": { + "url": "https://github.com/distributed-lab/bpcon/issues" + }, + "homepage": "https://github.com/distributed-lab/bpcon#readme", + "devDependencies": { + "prettier": "^3.3.3" + } +}