From 3e1905ec6973061eac0bea6bc1b51a0deb310313 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Thu, 2 Oct 2025 17:43:27 +0200 Subject: [PATCH 1/2] Ledger/transaction_logic: add fields doc --- ledger/src/scan_state/transaction_logic.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ledger/src/scan_state/transaction_logic.rs b/ledger/src/scan_state/transaction_logic.rs index d069283da..63731aeae 100644 --- a/ledger/src/scan_state/transaction_logic.rs +++ b/ledger/src/scan_state/transaction_logic.rs @@ -2642,11 +2642,19 @@ pub mod zkapp_command { /// pub type SideLoadedProof = Arc; + /// Authorization methods for zkApp account updates. + /// + /// Defines how an account update is authorized to modify an account's state. + /// /// #[derive(Clone, PartialEq)] pub enum Control { + /// Verified by a zero-knowledge proof against the account's verification + /// key. Proof(SideLoadedProof), + /// Signed by the account's private key. Signature(Signature), + /// No authorization (only valid for certain operations). NoneGiven, } From d43bde4dfee7c2b59e2189561e7a5bcf4fb72b38 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Thu, 2 Oct 2025 18:21:48 +0200 Subject: [PATCH 2/2] CI/verify-coderef: add comment to PR when fails --- .github/scripts/verify-code-references.sh | 72 ++++++++++++++++++++++- .github/workflows/docs.yaml | 24 +++++++- 2 files changed, 94 insertions(+), 2 deletions(-) diff --git a/.github/scripts/verify-code-references.sh b/.github/scripts/verify-code-references.sh index 12fb665f7..223ead52e 100755 --- a/.github/scripts/verify-code-references.sh +++ b/.github/scripts/verify-code-references.sh @@ -17,11 +17,41 @@ EXIT_CODE=0 TOTAL_REFS=0 VALID_REFS=0 INVALID_REFS=0 +COMMENT_FILE="" +ERRORS_COLLECTED="" + +# Parse arguments +while [[ $# -gt 0 ]]; do + case $1 in + --pr-comment) + COMMENT_FILE="$2" + shift 2 + ;; + *) + echo "Unknown option: $1" + exit 1 + ;; + esac +done echo "Verifying code references in documentation..." echo "Repository root: ${REPO_ROOT}" +if [[ -n "${COMMENT_FILE}" ]]; then + echo "PR comment mode: will write to ${COMMENT_FILE}" +fi echo "" +# Function to add error to collection +add_error() { + local error_msg="$1" + if [[ -z "${ERRORS_COLLECTED}" ]]; then + ERRORS_COLLECTED="${error_msg}" + else + ERRORS_COLLECTED="${ERRORS_COLLECTED} +${error_msg}" + fi +} + # Find all markdown files with CODE_REFERENCE comments while IFS= read -r doc_file; do # Extract CODE_REFERENCE comments from this file @@ -41,11 +71,15 @@ while IFS= read -r doc_file; do TOTAL_REFS=$((TOTAL_REFS + 1)) + # Get relative path for documentation file + doc_file_rel="${doc_file#"${REPO_ROOT}"/}" + # Check if the source file exists source_file="${REPO_ROOT}/${file_path}" if [[ ! -f "$source_file" ]]; then echo -e "${RED}✗${NC} Invalid reference in ${doc_file}:${line_num}" echo " File not found: ${file_path}" + add_error "- **${doc_file_rel}:${line_num}** - File not found: \`${file_path}\`" INVALID_REFS=$((INVALID_REFS + 1)) EXIT_CODE=1 continue @@ -57,6 +91,7 @@ while IFS= read -r doc_file; do echo -e "${RED}✗${NC} Invalid reference in ${doc_file}:${line_num}" echo " Line range L${start_line}-L${end_line} exceeds file length (${total_lines} lines)" echo " File: ${file_path}" + add_error "- **${doc_file_rel}:${line_num}** - Line range L${start_line}-L${end_line} exceeds file length (${total_lines} lines) in \`${file_path}\`" INVALID_REFS=$((INVALID_REFS + 1)) EXIT_CODE=1 continue @@ -102,12 +137,14 @@ while IFS= read -r doc_file; do echo " ${file_path}#L${start_line}-L${end_line}" echo " Local code differs from GitHub (${branch})" echo " This may indicate uncommitted changes or branch divergence" + add_error "- **${doc_file_rel}:${line_num}** - Code reference to \`${file_path}#L${start_line}-L${end_line}\` differs from GitHub (\`${branch}\` branch). The referenced code may have been modified locally but not yet merged to \`${branch}\`." INVALID_REFS=$((INVALID_REFS + 1)) EXIT_CODE=1 fi else echo -e "${YELLOW}⚠${NC} Could not parse GitHub URL in ${doc_file}:${line_num}" echo " URL: ${github_url}" + add_error "- **${doc_file_rel}:${line_num}** - Could not parse GitHub URL: \`${github_url}\`" INVALID_REFS=$((INVALID_REFS + 1)) EXIT_CODE=1 fi @@ -115,12 +152,14 @@ while IFS= read -r doc_file; do echo -e "${YELLOW}⚠${NC} Mismatched line range in ${doc_file}:${line_num}" echo " CODE_REFERENCE comment specifies: L${start_line}-L${end_line}" echo " But GitHub URL has different line range" + add_error "- **${doc_file_rel}:${line_num}** - CODE_REFERENCE comment specifies L${start_line}-L${end_line} but GitHub URL has different line range" INVALID_REFS=$((INVALID_REFS + 1)) EXIT_CODE=1 fi else echo -e "${YELLOW}⚠${NC} No GitHub URL found for reference in ${doc_file}:${line_num}" echo " Expected rust reference block with GitHub URL" + add_error "- **${doc_file_rel}:${line_num}** - No GitHub URL found for reference (expected rust reference block with GitHub URL)" INVALID_REFS=$((INVALID_REFS + 1)) EXIT_CODE=1 fi @@ -145,6 +184,37 @@ if [[ $EXIT_CODE -eq 0 ]]; then echo -e "${GREEN}✓ All code references are valid!${NC}" else echo -e "${RED}✗ Some code references are invalid. Please update the documentation.${NC}" + + # If in PR comment mode, write the comment to file + if [[ -n "${COMMENT_FILE}" ]]; then + cat > "${COMMENT_FILE}" <> $GITHUB_OUTPUT + echo "Comment file created, will post to PR" + cat /tmp/pr-comment.md + else + echo "has_errors=false" >> $GITHUB_OUTPUT + echo "No errors found, no comment needed" + fi + + - name: Comment PR on verification failure + if: github.event_name == 'pull_request' && steps.verify-pr.outputs.has_errors == 'true' + uses: thollander/actions-comment-pull-request@v3 + with: + file-path: /tmp/pr-comment.md + comment-tag: code-reference-verification + + - name: Verify code references in documentation (non-PR mode) + if: github.event_name != 'pull_request' run: bash .github/scripts/verify-code-references.sh - name: Build documentation