Skip to content

Commit 7560486

Browse files
committed
Merge remote-tracking branch 'origin/main' into bedrock-library/alloc/src/alloc.rs
2 parents d640ef6 + b0fdecf commit 7560486

File tree

629 files changed

+31615
-14056
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

629 files changed

+31615
-14056
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
name: Tool Application
3+
about: Submit a new tool application
4+
title: "[Tool Application] "
5+
labels: Tool Application
6+
---
7+
8+
<!--
9+
Please see https://model-checking.github.io/verify-rust-std/tool_template.html for the application template.
10+
-->

.github/pull_requests.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,11 @@ members = [
1212
"jaisnan",
1313
"patricklam",
1414
"ranjitjhala",
15-
"carolynzech"
15+
"carolynzech",
16+
"robdockins",
17+
"HuStmpHrrr",
18+
"Eh2406",
19+
"jswrenn",
20+
"havelund",
21+
"jorajeev"
1622
]

.github/workflows/book.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
name: Build Book
44
on:
55
workflow_dispatch:
6+
merge_group:
67
pull_request:
78
branches: [ main ]
89
push:

.github/workflows/kani.yml

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,67 @@
1-
# This workflow is responsible for verifying the standard library with Kani.
2-
31
name: Kani
2+
43
on:
54
workflow_dispatch:
5+
merge_group:
66
pull_request:
77
branches: [ main ]
88
push:
99
paths:
1010
- 'library/**'
1111
- '.github/workflows/kani.yml'
12-
- 'scripts/check_kani.sh'
12+
- 'scripts/run-kani.sh'
1313

1414
defaults:
1515
run:
1616
shell: bash
1717

1818
jobs:
19-
build:
19+
check-kani-on-std:
20+
name: Verify std library
2021
runs-on: ${{ matrix.os }}
2122
strategy:
2223
matrix:
23-
# Kani does not support windows.
2424
os: [ubuntu-latest, macos-latest]
2525
include:
2626
- os: ubuntu-latest
2727
base: ubuntu
2828
- os: macos-latest
2929
base: macos
3030
steps:
31-
- name: Checkout Library
31+
# Step 1: Check out the repository
32+
- name: Checkout Repository
3233
uses: actions/checkout@v4
3334
with:
3435
path: head
3536
submodules: true
3637

37-
- name: Run Kani Script
38-
run: bash ./head/scripts/check_kani.sh ${{github.workspace}}/head
38+
# Step 2: Run Kani on the std library (default configuration)
39+
- name: Run Kani Verification
40+
run: head/scripts/run-kani.sh --path ${{github.workspace}}/head
41+
42+
run-kani-list:
43+
name: Kani List
44+
runs-on: ubuntu-latest
45+
steps:
46+
# Step 1: Check out the repository
47+
- name: Checkout Repository
48+
uses: actions/checkout@v4
49+
with:
50+
path: head
51+
submodules: true
52+
53+
# Step 2: Run list on the std library
54+
- name: Run Kani List
55+
run: head/scripts/run-kani.sh --run list --path ${{github.workspace}}/head
56+
57+
# Step 3: Add output to job summary
58+
- name: Add Kani List output to job summary
59+
uses: actions/github-script@v6
60+
with:
61+
script: |
62+
const fs = require('fs');
63+
const kaniOutput = fs.readFileSync('${{github.workspace}}/head/kani-list.md', 'utf8');
64+
await core.summary
65+
.addHeading('Kani List Output', 2)
66+
.addRaw(kaniOutput, false)
67+
.write();

.github/workflows/pr_approval.yml

Lines changed: 64 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
1+
# This workflow checks that the PR has been approved by 2+ members of the committee listed in `pull_requests.toml`.
2+
#
3+
# Run this action when a pull request review is submitted / dismissed.
4+
# Note that an approval can be dismissed, and this can affect the job status.
5+
# We currently trust that contributors won't make significant changes to their PRs after approval, so we accept
6+
# changes after approval.
7+
#
8+
# We still need to run this in the case of a merge group, since it is a required step. In that case, the workflow
9+
# is a NOP.
110
name: Check PR Approvals
2-
3-
# For now, the workflow gets triggered only when a review is submitted
4-
# This technically means, a PR with zero approvals can be merged by the rules of this workflow alone
5-
# To protect against that scenario, we can turn on number of approvals required to 2 in the github settings
6-
# of the repository
711
on:
12+
merge_group:
813
pull_request_review:
9-
types: [submitted]
14+
types: [submitted, dismissed]
1015

1116
jobs:
1217
check-approvals:
1318
runs-on: ubuntu-latest
1419
steps:
1520
- name: Checkout repository
1621
uses: actions/checkout@v2
22+
if: ${{ github.event_name != 'merge_group' }}
1723

1824
- name: Install TOML parser
1925
run: npm install @iarna/toml
26+
if: ${{ github.event_name != 'merge_group' }}
2027

2128
- name: Check PR Relevance and Approvals
2229
uses: actions/github-script@v6
30+
if: ${{ github.event_name != 'merge_group' }}
2331
with:
2432
script: |
2533
const fs = require('fs');
@@ -44,8 +52,11 @@ jobs:
4452
pull_number = context.issue.number;
4553
}
4654
55+
console.log(`owner is ${owner}`);
56+
console.log(`pull_number is ${pull_number}`);
4757
4858
// Get parsed data
59+
let requiredApprovers;
4960
try {
5061
const tomlContent = fs.readFileSync('.github/pull_requests.toml', 'utf8');
5162
console.log('TOML content:', tomlContent);
@@ -62,38 +73,63 @@ jobs:
6273
return;
6374
}
6475
65-
// Get all reviews
66-
const reviews = await github.rest.pulls.listReviews({
67-
owner,
68-
repo,
69-
pull_number
70-
});
76+
// Get all reviews with pagination
77+
async function getAllReviews() {
78+
let allReviews = [];
79+
let page = 1;
80+
let page_limit = 100;
81+
82+
while (page < page_limit) {
83+
const response = await github.rest.pulls.listReviews({
84+
owner,
85+
repo,
86+
pull_number,
87+
per_page: 100,
88+
page
89+
});
90+
91+
allReviews = allReviews.concat(response.data);
92+
93+
if (response.data.length < 100) {
94+
break;
95+
}
96+
97+
page++;
98+
}
99+
100+
if (page == page_limit) {
101+
console.log(`WARNING: Reached page limit of ${page_limit} while fetching reviews data; approvals count may be less than the real total.`)
102+
}
103+
104+
return allReviews;
105+
}
106+
107+
const reviews = await getAllReviews();
71108
72109
// Example: approvers = ["celina", "zyad"]
73110
const approvers = new Set(
74-
reviews.data
111+
reviews
75112
.filter(review => review.state === 'APPROVED')
76113
.map(review => review.user.login)
77114
);
78115
79116
const requiredApprovals = 2;
80-
const currentCountfromCommittee = Array.from(approvers)
81-
.filter(approver => requiredApprovers.includes(approver))
82-
.length;
83-
84-
// TODO: Improve logging and messaging to the user
85-
console.log('PR Approvers:', Array.from(approvers));
86-
console.log('Required Approvers:', requiredApprovals);
117+
const committeeApprovers = Array.from(approvers)
118+
.filter(approver => requiredApprovers.includes(approver));
119+
const currentCountfromCommittee = committeeApprovers.length;
87120
88121
// Core logic that checks if the approvers are in the committee
89-
const checkName = 'PR Approval Status';
90-
const conclusion = (approvers.size >= requiredApprovals && currentCountfromCommittee >= 2) ? 'success' : 'failure';
91-
const output = {
92-
title: checkName,
93-
summary: `PR has ${approvers.size} total approvals and ${requiredApprovals} required approvals.`,
94-
text: `Approvers: ${Array.from(approvers).join(', ')}\nRequired Approvers: ${requiredApprovers.join(', ')}`
95-
};
122+
const conclusion = (currentCountfromCommittee >= 2) ? 'success' : 'failure';
96123
124+
console.log('PR Approval Status');
125+
console.log(`PR has ${approvers.size} total approvals and ${currentCountfromCommittee} required approvals from the committee.`);
126+
127+
console.log(`Committee Members: [${requiredApprovers.join(', ')}]`);
128+
console.log(`Committee Approvers: ${committeeApprovers.length === 0 ? 'NONE' : `[${committeeApprovers.join(', ')}]`}`);
129+
console.log(`All Approvers: ${approvers.size === 0 ? 'NONE' : `[${Array.from(approvers).join(', ')}]`}`);
130+
97131
if (conclusion === 'failure') {
98-
core.setFailed(`PR needs at least ${requiredApprovals} total approvals and 2 required approvals. Current approvals: ${approvers.size}, Required approvals: ${requiredApprovals}`);
132+
core.setFailed(`PR needs 2 approvals from committee members, but it has ${currentCountfromCommittee}`);
133+
} else {
134+
core.info('PR approval check passed successfully.');
99135
}

.github/workflows/rustc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
name: Rust Tests
55
on:
66
workflow_dispatch:
7+
merge_group:
78
pull_request:
89
branches: [ main ]
910
push:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Session.vim
1919
## Build
2020
/book/
2121
/build/
22+
/kani_build/
2223
/target
2324
library/target
2425
*.rlib

README.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,23 @@
77
This repository is a fork of the official Rust programming
88
language repository, created solely to verify the Rust standard
99
library. It should not be used as an alternative to the official
10-
Rust releases. The repository is tool agnostic and welcomes the addition of
10+
Rust releases. The repository is tool agnostic and welcomes the addition of
1111
new tools.
1212

1313
The goal is to have a verified [Rust standard library](https://doc.rust-lang.org/std/) and prove that it is safe.
1414
1. Contributing to the core mechanism of verifying the rust standard library
1515
2. Creating new techniques to perform scalable verification
1616
3. Apply techniques to verify previously unverified parts of the standard library.
1717

18-
## [Kani](https://github.com/model-checking/kani)
18+
For that we are launching a contest that includes a series of challenges that focus on verifying
19+
memory safety and a subset of undefined behaviors in the Rust standard library.
20+
Each challenge describes the goal, the success criteria, and whether it has a financial award to be awarded upon its
21+
successful completion.
1922

20-
The Kani Rust Verifier is a bit-precise model checker for Rust.
21-
Kani verifies:
22-
* Memory safety (e.g., null pointer dereferences)
23-
* User-specified assertions (i.e `assert!(...)`)
24-
* The absence of panics (eg., `unwrap()` on `None` values)
25-
* The absence of some types of unexpected behavior (e.g., arithmetic overflows).
23+
See [our book](https://model-checking.github.io/verify-rust-std/intro.html) for more details on the challenge rules
24+
and the list of existing challenges.
2625

27-
You can find out more about Kani from the [Kani book](https://model-checking.github.io/kani/) or the [Kani repository on Github](https://github.com/model-checking/kani).
26+
We welcome everyone to participate!
2827

2928
## Contact
3029

@@ -40,11 +39,11 @@ See [SECURITY](https://github.com/model-checking/kani/security/policy) for more
4039
Kani is distributed under the terms of both the MIT license and the Apache License (Version 2.0).
4140
See [LICENSE-APACHE](https://github.com/model-checking/kani/blob/main/LICENSE-APACHE) and [LICENSE-MIT](https://github.com/model-checking/kani/blob/main/LICENSE-MIT) for details.
4241

43-
## Rust
42+
### Rust
4443
Rust is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses.
4544

4645
See [the Rust repository](https://github.com/rust-lang/rust) for details.
4746

4847
## Introducing a New Tool
4948

50-
Please use the [template available in this repository](.github/TOOL_REQUEST_TEMPLATE.md) to introduce a new verification tool.
49+
Please use the [template available in this repository](./doc/src/tool_template.md) to introduce a new verification tool.

doc/src/SUMMARY.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@
1414

1515
- [Challenges](./challenges.md)
1616
- [1: Verify core transmuting methods](./challenges/0001-core-transmutation.md)
17-
- [2: Verify the memory safery of core intrinsics using raw pointers](./challenges/0002-intrinsics-memory.md)
17+
- [2: Verify the memory safety of core intrinsics using raw pointers](./challenges/0002-intrinsics-memory.md)
1818
- [3: Verifying Raw Pointer Arithmetic Operations](./challenges/0003-pointer-arithmentic.md)
1919
- [4: Memory safety of BTreeMap's `btree::node` module](./challenges/0004-btree-node.md)
2020
- [5: Verify functions iterating over inductive data type: `linked_list`](./challenges/0005-linked-list.md)
2121
- [6: Safety of `NonNull`](./challenges/0006-nonnull.md)
22+
- [7: Safety of Methods for Atomic Types & Atomic Intrinsics](./challenges/0007-atomic-types.md)
2223
- [8: Contracts for SmallSort](./challenges/0008-smallsort.md)
2324
- [9: Safe abstractions for `core::time::Duration`](./challenges/0009-duration.md)
2425
- [10: Memory safety of String](./challenges/0010-string.md)
2526
- [11: Safety of Methods for Numeric Primitive Types](./challenges/0011-floats-ints.md)
2627
- [12: Safety of `NonZero`](./challenges/0012-nonzero.md)
27-
28+
- [13: Safety of `CStr`](./challenges/0013-cstr.md)
2829

doc/src/challenge_template.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
- **Status:** *One of the following: \[Open | Resolved | Expired\]*
44
- **Solution:** *Option field to point to the PR that solved this challenge.*
55
- **Tracking Issue:** *Link to issue*
6-
- **Start date:** *YY/MM/DD*
7-
- **End date:** *YY/MM/DD*
6+
- **Start date:** *YYYY/MM/DD*
7+
- **End date:** *YYYY/MM/DD*
8+
- **Reward:** *TBD*[^reward]
89

910
-------------------
1011

@@ -49,3 +50,4 @@ Note: All solutions to verification challenges need to satisfy the criteria esta
4950
in addition to the ones listed above.
5051

5152
[^challenge_id]: The number of the challenge sorted by publication date.
53+
[^reward]: Leave it as TBD when creating a new challenge. This should only be filled by the reward committee.

doc/src/challenges/0001-core-transmutation.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
- **Status:** Open
44
- **Tracking Issue:** [#19](https://github.com/model-checking/verify-rust-std/issues/19)
5-
- **Start date:** 2024-06-12
6-
- **End date:** 2024-12-10
5+
- **Start date:** *2024/06/12*
6+
- **End date:** *2025/04/10*
7+
- **Reward:** *N/A*
78

89
-------------------
910

0 commit comments

Comments
 (0)