diff --git a/.gitignore b/.gitignore index e6e9ac4..4ca509c 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,6 @@ npm-debug.log* yarn-debug.log* -yarn-error.log* \ No newline at end of file +yarn-error.log* + +*.env \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..6012ff2 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,8 @@ +repos: + - repo: local + hooks: + - id: update-last-update + name: Update Last Update Field + entry: scripts/update_last_update.sh + language: script + files: '\.md$' diff --git a/README.md b/README.md index c14690b..4f8da05 100644 --- a/README.md +++ b/README.md @@ -15,3 +15,39 @@ If you would like to contribute check out the following materials, and feel free - [Code of Conduct](CODE_OF_CONDUCT.md) - [Contributing Guide](CONTRIBUTING.md) - [Development Guide](DEVELOPMENT.md) + + +### Setting Up Your Local Environment for Contribution + +To ensure that your contributions include your name in the `last_update` section of documentation files automatically, follow these steps to set up your local environment: + +#### Creating a `.env` File + +1. At the root of your local repository clone, create a file named `.env`. +2. Inside the `.env` file, add the following line, replacing `"Your Name"` with your actual name: + +```sh +AUTHOR_NAME="Your Name" +``` + +3. Save and close the `.env` file. This file will be used by the pre-commit hook to automatically insert your name into the `last_update` section of Markdown files. + +#### Installing the Pre-commit Package + +The pre-commit package is used to run scripts before each commit automatically, allowing us to update the documentation's `last_update` section seamlessly. + +1. Install pre-commit on your system. If you're using pip (Python's package manager), you can install it by running: + +```bash +pip install pre-commit +``` + +2. Make sure the update_last_update.sh script is present in the scripts/ directory at the root of your repository and is executable. You may need to run chmod +x scripts/update_last_update.sh to make it executable. + +3. Run following command to set up the hook. +```bash +pre-commit install +``` + +With these steps completed, your local environment is set up to automatically update the last_update section of Markdown files with your name and the current date whenever you make a commit. This process helps maintain accurate documentation and attribution for contributions. + diff --git a/docs/consensus/proof_of_archival_storage.md b/docs/consensus/proof_of_archival_storage.md index b8c216f..5406aa0 100644 --- a/docs/consensus/proof_of_archival_storage.md +++ b/docs/consensus/proof_of_archival_storage.md @@ -8,15 +8,17 @@ keywords: - plotting - auditing last_update: - date: 02/18/2024 - author: Dariia Porechna + date: 03/12/2024 + author: Saeid Yazdinejad --- import Collapsible from '@site/src/components/Collapsible/Collapsible'; + ## Public Parameters and Values ### Protocol Constants + These parameters are fixed at the beginning of the protocol and used by all clients. - `SLOT_PROBABILITY`: the probability of successful block in a slot (active slots coefficient), currently 1/6. This defines the expected block production rate of 1 block every 6 seconds diff --git a/docs/consensus/proof_of_space.md b/docs/consensus/proof_of_space.md index df3b290..76884ce 100644 --- a/docs/consensus/proof_of_space.md +++ b/docs/consensus/proof_of_space.md @@ -7,11 +7,12 @@ keywords: - tables - plotting last_update: - date: 02/14/2024 - author: Dariia Porechna + date: 03/12/2024 + author: Saeid Yazdinejad --- import Collapsible from '@site/src/components/Collapsible/Collapsible'; + This specification defines a secure proof-of-space construction for [Plotting](proof_of_archival_storage.md#plotting) and [Proving](proof_of_archival_storage.md#proving) sub-protocols of the Dilithium consensus based on Chia PoS. ## Parameters diff --git a/docs/consensus/proof_of_time.md b/docs/consensus/proof_of_time.md index 8011069..1e4c3fe 100644 --- a/docs/consensus/proof_of_time.md +++ b/docs/consensus/proof_of_time.md @@ -7,10 +7,9 @@ keywords: - timekeeper - randomness last_update: - date: 02/14/2024 - author: Dariia Porechna + date: 03/12/2024 + author: Saeid Yazdinejad --- - import Collapsible from '@site/src/components/Collapsible/Collapsible'; diff --git a/docs/crypto_primitives.md b/docs/crypto_primitives.md index 6154598..c738710 100644 --- a/docs/crypto_primitives.md +++ b/docs/crypto_primitives.md @@ -5,10 +5,9 @@ description: Cryptographic Primitives used in the protocol. keywords: - cryptography last_update: - date: 02/14/2024 - author: Dariia Porechna + date: 03/12/2024 + author: Saeid Yazdinejad --- - import Collapsible from '@site/src/components/Collapsible/Collapsible'; The following primitives are used in various parts of the protocol. @@ -226,4 +225,4 @@ Figure 2: Querying the PoS table at a challenge index. On average 37% of indices `is_proof_valid(k, seed, challenge, proof_of_space)` → `bool` -Verifies whether *proof-of-space* `proof_of_space` is valid for `challenge` of a table for `k` and `seed`. \ No newline at end of file +Verifies whether *proof-of-space* `proof_of_space` is valid for `challenge` of a table for `k` and `seed`. diff --git a/docs/decex/bundles_blocks.md b/docs/decex/bundles_blocks.md index 4f5820f..b558c10 100644 --- a/docs/decex/bundles_blocks.md +++ b/docs/decex/bundles_blocks.md @@ -7,10 +7,9 @@ keywords: - decex - bundle last_update: - date: 03/04/2024 - author: Dariia Porechna + date: 03/12/2024 + author: Saeid Yazdinejad --- - import Collapsible from '@site/src/components/Collapsible/Collapsible'; ## Bundles diff --git a/docs/decex/fraud_proofs.md b/docs/decex/fraud_proofs.md index aa44177..3e0de8e 100644 --- a/docs/decex/fraud_proofs.md +++ b/docs/decex/fraud_proofs.md @@ -8,10 +8,9 @@ keywords: - fraud proof - challenge period last_update: - date: 02/22/2024 - author: Dariia Porechna + date: 03/12/2024 + author: Saeid Yazdinejad --- - import Collapsible from '@site/src/components/Collapsible/Collapsible'; diff --git a/docs/decex/workflow.md b/docs/decex/workflow.md index 5942a74..8594ec8 100644 --- a/docs/decex/workflow.md +++ b/docs/decex/workflow.md @@ -7,10 +7,9 @@ keywords: - decex - instantiation last_update: - date: 03/06/2024 - author: Ning Lin + date: 03/12/2024 + author: Saeid Yazdinejad --- - import Collapsible from '@site/src/components/Collapsible/Collapsible'; diff --git a/scripts/update_last_update.sh b/scripts/update_last_update.sh new file mode 100755 index 0000000..acf7fc3 --- /dev/null +++ b/scripts/update_last_update.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# Assuming your .env file is at the root of your repository +SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" +REPO_ROOT=$(dirname "$SCRIPT_DIR") +echo "REPO_ROOT: $REPO_ROOT" + +source "$REPO_ROOT/.env" + +date=$(date -u +"%m/%d/%Y") +author_name=$AUTHOR_NAME + +# Check if AUTHOR_NAME is set +if [[ -z "$author_name" ]]; then + echo "Error: Author name is empty." + exit 1 +fi + +for file in $(git diff --cached --name-only | grep '\.md$'); do + awk -v date="$date" -v author="$author_name" ' + BEGIN {printed=0} + /^---$/ {count++} # Count the number of occurrences of "---" + count == 1 && !printed { # Only print between the first set of "---" + if (/^last_update:/) { + print "last_update:" + print " date: " date + print " author: " author + printed=1 + next + } + } + !/^last_update:/ && !/^ date:/ && !/^ author:/ {print} # Skip old last_update lines + ' "$file" > temp && mv temp "$file" + + # Add the updated file to the staging area + git add "$REPO_ROOT/$file" + +done