Skip to content

Commit 5291707

Browse files
committed
Merge branch 'master' into mraszyk/pic
2 parents 848eec4 + b64644e commit 5291707

File tree

26 files changed

+4515
-284
lines changed

26 files changed

+4515
-284
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,12 @@
6969
/rust/send_http_post/ @dfinity/growth
7070
/rust/simd/ @dfinity/execution
7171
/rust/threshold-ecdsa/ @dfinity/crypto-team
72+
/rust/threshold-mock/ @dfinity/crypto-team
7273
/rust/threshold-schnorr/ @dfinity/crypto-team
7374
/rust/token_transfer/ @dfinity/growth
7475
/rust/token_transfer_from/ @dfinity/growth
7576
/rust/vetkd/ @dfinity/crypto-team
77+
/rust/x509/ @dfinity/crypto-team
7678

7779
/svelte/svelte-motoko-starter/ @dfinity/sdk
7880
/svelte/svelte-starter/ @dfinity/sdk

.github/workflows/close-stale-issues.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ jobs:
1212
steps:
1313
- uses: actions/stale@v5
1414
with:
15-
days-before-issue-stale: 30
16-
days-before-issue-close: 14
15+
days-before-issue-stale: 182
16+
days-before-issue-close: 182
1717
stale-issue-label: "stale"
1818
stale-issue-message: "This issue is stale because it has been open for 30 days with no activity."
1919
close-issue-message: "This issue was closed because it has been inactive for 14 days since being marked as stale."
2020
days-before-pr-stale: -1
2121
days-before-pr-close: -1
22-
repo-token: ${{ secrets.GITHUB_TOKEN }}
22+
repo-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/rust-parallel-calls-example.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
- master
66
pull_request:
77
paths:
8-
- rust/parallel-calls/**
8+
- rust/parallel_calls/**
99
- .github/workflows/provision-darwin.sh
1010
- .github/workflows/provision-linux.sh
1111
- .github/workflows/rust-parallel-calls-example.yml
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: rust-threshold-mock
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
paths:
8+
- rust/threshold-mock/**
9+
- .github/workflows/provision-darwin.sh
10+
- .github/workflows/provision-linux.sh
11+
- .github/workflows/rust-threshold-mock-example.yml
12+
- .ic-commit
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: true
16+
jobs:
17+
rust-threshold-mock-darwin:
18+
runs-on: macos-15
19+
steps:
20+
- uses: actions/checkout@v1
21+
- name: Provision Darwin
22+
run: bash .github/workflows/provision-darwin.sh
23+
- name: Install PocketIC server Darwin
24+
uses: dfinity/pocketic@main
25+
with:
26+
pocket-ic-server-version: "6.0.0"
27+
- name: Build threshold-mock Darwin
28+
run: |
29+
pushd rust/threshold-mock
30+
cargo build --target wasm32-unknown-unknown --release
31+
popd
32+
- name: Lint threshold-mock Darwin
33+
run: |
34+
pushd rust/threshold-mock
35+
cargo fmt --all -- --check && cargo clippy --all-targets --all-features -- -D warnings
36+
popd
37+
- name: Test threshold-mock Darwin
38+
run: |
39+
pushd rust/threshold-mock
40+
cargo test
41+
popd
42+
rust-threshold-mock-linux:
43+
runs-on: ubuntu-20.04
44+
steps:
45+
- uses: actions/checkout@v1
46+
- name: Provision Linux
47+
run: bash .github/workflows/provision-linux.sh
48+
- name: Install PocketIC server Linux
49+
uses: dfinity/pocketic@main
50+
with:
51+
pocket-ic-server-version: "6.0.0"
52+
- name: Build threshold-mock Linux
53+
run: |
54+
pushd rust/threshold-mock
55+
cargo build --target wasm32-unknown-unknown --release
56+
popd
57+
- name: Lint threshold-mock Linux
58+
run: |
59+
pushd rust/threshold-mock
60+
cargo fmt --all -- --check && cargo clippy --all-targets --all-features -- -D warnings
61+
popd
62+
- name: Test threshold-mock Linux
63+
run: |
64+
pushd rust/threshold-mock
65+
cargo test
66+
popd

.github/workflows/rust-x509-example.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ concurrency:
1616
cancel-in-progress: true
1717
jobs:
1818
rust-x509-darwin:
19-
runs-on: macos-12
19+
runs-on: macos-15
2020
steps:
2121
- uses: actions/checkout@v1
2222
- name: Provision Darwin

archive/motoko/defi/src/frontend/package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/basic_bitcoin/src/basic_bitcoin/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ thread_local! {
1414
// The bitcoin network to connect to.
1515
//
1616
// When developing locally this should be `Regtest`.
17-
// When deploying to the IC this should be `Testnet`.
18-
// `Mainnet` is currently unsupported.
17+
// When deploying to the IC this should be `Testnet` or `Mainnet`.
1918
static NETWORK: Cell<BitcoinNetwork> = Cell::new(BitcoinNetwork::Testnet);
2019

2120
// The derivation path to use for the threshold key.

rust/canister-snapshots/src/chat/src/lib.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,20 @@ use std::{cell::RefCell, collections::HashSet};
33

44
thread_local! {
55
static CHAT: RefCell<Vec<String>> = Default::default();
6+
static LENGTH: RefCell<u64> = Default::default();
67
}
78

89
/// Appends a new message to the chat database.
910
#[ic_cdk_macros::update]
1011
fn append(message: String) {
12+
// Ensure that the length of the chat is consistent with the actual chat
13+
// contents.
14+
assert_eq!(
15+
LENGTH.with_borrow(|len| *len),
16+
CHAT.with_borrow(|chat| chat.len() as u64)
17+
);
1118
CHAT.with_borrow_mut(|chat| chat.push(message));
19+
LENGTH.with_borrow_mut(|len| *len += 1);
1220
}
1321

1422
/// Dumps all the chat messages.
@@ -36,6 +44,7 @@ fn remove_spam() -> u64 {
3644
for message in chat {
3745
if message.split(" ").any(|word| spam_keywords.contains(word)) {
3846
spam += 1;
47+
ic_cdk::println!("Found spam message: {message}");
3948
new_chat.push("(removed spam message)".into());
4049
} else {
4150
new_chat.push(message);
@@ -47,5 +56,22 @@ fn remove_spam() -> u64 {
4756
ic_cdk::println!("Removed {spam} messages, updating the chat...");
4857
CHAT.set(new_chat);
4958
}
59+
ic_cdk::println!("Filtered chat: {:?}", CHAT.with_borrow(|chat| chat.clone()));
5060
spam
5161
}
62+
63+
#[ic_cdk_macros::pre_upgrade]
64+
fn pre_upgrade() {
65+
let chat = CHAT.with_borrow(|chat| chat.clone());
66+
let length = LENGTH.with_borrow(|len| *len);
67+
ic_cdk::storage::stable_save((chat, length)).expect("failed to save stable state");
68+
}
69+
70+
#[ic_cdk_macros::post_upgrade]
71+
fn post_upgrade() {
72+
let (chat, length): (Vec<String>, u64) =
73+
ic_cdk::storage::stable_restore().expect("failed to restore stable state");
74+
75+
CHAT.set(chat);
76+
LENGTH.with_borrow_mut(|len| *len = length);
77+
}

0 commit comments

Comments
 (0)