From d5acf34266fd12b0bf1251677b154793bae80197 Mon Sep 17 00:00:00 2001 From: xm0onh Date: Mon, 11 Mar 2024 12:41:05 -0700 Subject: [PATCH 1/8] autofill scripts + updating gitignore --- .gitignore | 4 +++- .pre-commit-config.yaml | 8 ++++++++ scripts/update_last_update.sh | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 .pre-commit-config.yaml create mode 100755 scripts/update_last_update.sh 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/scripts/update_last_update.sh b/scripts/update_last_update.sh new file mode 100755 index 0000000..3492e5b --- /dev/null +++ b/scripts/update_last_update.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Assuming your .env file is at the root of your repository +source "./author.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 "$file" +done From 44f3d9dfc5f7b926d58e5c940f3d42141d5555d0 Mon Sep 17 00:00:00 2001 From: xm0onh Date: Mon, 11 Mar 2024 12:41:28 -0700 Subject: [PATCH 2/8] update proof of archival --- docs/consensus/proof_of_archival_storage.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/consensus/proof_of_archival_storage.md b/docs/consensus/proof_of_archival_storage.md index b8c216f..101250a 100644 --- a/docs/consensus/proof_of_archival_storage.md +++ b/docs/consensus/proof_of_archival_storage.md @@ -8,8 +8,8 @@ keywords: - plotting - auditing last_update: - date: 02/18/2024 - author: Dariia Porechna + date: 03/11/2024 + author: Saeid Yazdinejad --- import Collapsible from '@site/src/components/Collapsible/Collapsible'; @@ -17,6 +17,7 @@ import Collapsible from '@site/src/components/Collapsible/Collapsible'; ### 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 From 7122c3204e015ebeddf9a0f97ff1a36ad0fab06e Mon Sep 17 00:00:00 2001 From: xm0onh Date: Mon, 11 Mar 2024 16:25:12 -0700 Subject: [PATCH 3/8] update readme file and script --- README.md | 35 +++++++++++++++++++++++++++++++++++ scripts/update_last_update.sh | 5 ++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c14690b..1f7d1ba 100644 --- a/README.md +++ b/README.md @@ -15,3 +15,38 @@ 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 +``` + +1. At the root of your repository, create a file named .pre-commit-config.yaml with the following content to set up the pre-commit hook: + +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 pre-commit install to set up the hook. + +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/scripts/update_last_update.sh b/scripts/update_last_update.sh index 3492e5b..8c46d78 100755 --- a/scripts/update_last_update.sh +++ b/scripts/update_last_update.sh @@ -1,7 +1,7 @@ #!/bin/bash # Assuming your .env file is at the root of your repository -source "./author.env" +source "./.env" date=$(date -u +"%m/%d/%Y") author_name=$AUTHOR_NAME @@ -13,6 +13,9 @@ if [[ -z "$author_name" ]]; then fi for file in $(git diff --cached --name-only | grep '\.md$'); do + if [ "$file" == "README.md" ]; then + continue + fi awk -v date="$date" -v author="$author_name" ' BEGIN {printed=0} /^---$/ {count++} # Count the number of occurrences of "---" From 2d4ef2e9103f03f167adda93c1b5c63a27d429ec Mon Sep 17 00:00:00 2001 From: xm0onh Date: Mon, 11 Mar 2024 16:26:26 -0700 Subject: [PATCH 4/8] update README file --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 1f7d1ba..eb91ad8 100644 --- a/README.md +++ b/README.md @@ -42,8 +42,6 @@ The pre-commit package is used to run scripts before each commit automatically, pip install pre-commit ``` -1. At the root of your repository, create a file named .pre-commit-config.yaml with the following content to set up the pre-commit hook: - 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 pre-commit install to set up the hook. From 62a5e20ca94b5dbd98cbad259ac3d003d7c33d28 Mon Sep 17 00:00:00 2001 From: xm0onh Date: Mon, 11 Mar 2024 16:27:19 -0700 Subject: [PATCH 5/8] update README file --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index eb91ad8..4f8da05 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,10 @@ 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 pre-commit install to set up the hook. +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. From f36ec10ac8d6cdedebfd6038233ab14afbfe7346 Mon Sep 17 00:00:00 2001 From: xm0onh Date: Mon, 11 Mar 2024 20:45:31 -0700 Subject: [PATCH 6/8] update latest-update field --- docs/consensus/proof_of_archival_storage.md | 3 +- docs/consensus/proof_of_space.md | 5 ++- docs/consensus/proof_of_time.md | 5 +-- docs/crypto_primitives.md | 7 ++-- docs/decex/bundles_blocks.md | 5 +-- docs/decex/fraud_proofs.md | 5 +-- docs/decex/workflow.md | 5 +-- scripts/update_last_update.sh | 41 +++++++++++++-------- 8 files changed, 41 insertions(+), 35 deletions(-) diff --git a/docs/consensus/proof_of_archival_storage.md b/docs/consensus/proof_of_archival_storage.md index 101250a..5406aa0 100644 --- a/docs/consensus/proof_of_archival_storage.md +++ b/docs/consensus/proof_of_archival_storage.md @@ -8,11 +8,12 @@ keywords: - plotting - auditing last_update: - date: 03/11/2024 + date: 03/12/2024 author: Saeid Yazdinejad --- import Collapsible from '@site/src/components/Collapsible/Collapsible'; + ## Public Parameters and Values ### Protocol Constants 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 index 8c46d78..5b44848 100755 --- a/scripts/update_last_update.sh +++ b/scripts/update_last_update.sh @@ -1,25 +1,27 @@ #!/bin/bash -# Assuming your .env file is at the root of your repository +# Load environment variables source "./.env" -date=$(date -u +"%m/%d/%Y") -author_name=$AUTHOR_NAME - # Check if AUTHOR_NAME is set -if [[ -z "$author_name" ]]; then +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 - if [ "$file" == "README.md" ]; then - continue - fi - awk -v date="$date" -v author="$author_name" ' +# Current date in UTC +current_date=$(date -u +"%m/%d/%Y") + +# Iterate over staged markdown files, excluding README.md +git diff --cached --name-only | grep '\.md$' | grep -v 'README.md' | while read -r file; do + # Create a temporary file + temp_file=$(mktemp) + + # Use awk to update last_update fields + awk -v date="$current_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 "---" + /^---$/ {count++} + count == 1 && !printed { if (/^last_update:/) { print "last_update:" print " date: " date @@ -28,9 +30,16 @@ for file in $(git diff --cached --name-only | grep '\.md$'); do next } } - !/^last_update:/ && !/^ date:/ && !/^ author:/ {print} # Skip old last_update lines - ' "$file" > temp && mv temp "$file" + !/^last_update:/ && !/^ date:/ && !/^ author:/ {print} + ' "$file" > "$temp_file" - # Add the updated file to the staging area - git add "$file" + if [ -s "$temp_file" ]; then + # Only move temp_file to original if temp_file is not empty + mv "$temp_file" "$file" + # Add the updated file to the staging area + git add "$file" + else + echo "Failed to update $file, temp_file was empty." + rm "$temp_file" + fi done From 0cb8dee618bd960faa19fccc6ea173738121e9f1 Mon Sep 17 00:00:00 2001 From: xm0onh Date: Mon, 11 Mar 2024 20:46:13 -0700 Subject: [PATCH 7/8] fix a minor bug within the bash script --- scripts/update_last_update.sh | 40 ++++++++++++----------------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/scripts/update_last_update.sh b/scripts/update_last_update.sh index 5b44848..3492e5b 100755 --- a/scripts/update_last_update.sh +++ b/scripts/update_last_update.sh @@ -1,27 +1,22 @@ #!/bin/bash -# Load environment variables -source "./.env" +# Assuming your .env file is at the root of your repository +source "./author.env" + +date=$(date -u +"%m/%d/%Y") +author_name=$AUTHOR_NAME # Check if AUTHOR_NAME is set -if [[ -z "$AUTHOR_NAME" ]]; then +if [[ -z "$author_name" ]]; then echo "Error: Author name is empty." exit 1 fi -# Current date in UTC -current_date=$(date -u +"%m/%d/%Y") - -# Iterate over staged markdown files, excluding README.md -git diff --cached --name-only | grep '\.md$' | grep -v 'README.md' | while read -r file; do - # Create a temporary file - temp_file=$(mktemp) - - # Use awk to update last_update fields - awk -v date="$current_date" -v author="$AUTHOR_NAME" ' +for file in $(git diff --cached --name-only | grep '\.md$'); do + awk -v date="$date" -v author="$author_name" ' BEGIN {printed=0} - /^---$/ {count++} - count == 1 && !printed { + /^---$/ {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 @@ -30,16 +25,9 @@ git diff --cached --name-only | grep '\.md$' | grep -v 'README.md' | while read next } } - !/^last_update:/ && !/^ date:/ && !/^ author:/ {print} - ' "$file" > "$temp_file" + !/^last_update:/ && !/^ date:/ && !/^ author:/ {print} # Skip old last_update lines + ' "$file" > temp && mv temp "$file" - if [ -s "$temp_file" ]; then - # Only move temp_file to original if temp_file is not empty - mv "$temp_file" "$file" - # Add the updated file to the staging area - git add "$file" - else - echo "Failed to update $file, temp_file was empty." - rm "$temp_file" - fi + # Add the updated file to the staging area + git add "$file" done From 73d2f61159b51964da0b200d9d320a996e2d1733 Mon Sep 17 00:00:00 2001 From: xm0onh Date: Mon, 11 Mar 2024 21:15:24 -0700 Subject: [PATCH 8/8] update the bash script --- scripts/update_last_update.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/update_last_update.sh b/scripts/update_last_update.sh index 3492e5b..acf7fc3 100755 --- a/scripts/update_last_update.sh +++ b/scripts/update_last_update.sh @@ -1,7 +1,11 @@ #!/bin/bash # Assuming your .env file is at the root of your repository -source "./author.env" +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 @@ -29,5 +33,6 @@ for file in $(git diff --cached --name-only | grep '\.md$'); do ' "$file" > temp && mv temp "$file" # Add the updated file to the staging area - git add "$file" + git add "$REPO_ROOT/$file" + done