Skip to content

Commit

Permalink
Merge branch 'master' into jessiemongeon1-patch-4
Browse files Browse the repository at this point in the history
  • Loading branch information
jessiemongeon1 authored Nov 19, 2024
2 parents 7df48c7 + 65dbdf9 commit 1d6af26
Show file tree
Hide file tree
Showing 55 changed files with 805 additions and 628 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,6 @@ The following submoules and their corresponding repos are currently used:
- `/docs/current/references/ii-spec`
- GitHub Repo: https://github.com/dfinity/internet-identity.git

- Interface Spec
- `/docs/current/references/ic-interface-spec `
- GitHub Repo: https://github.com/dfinity/interface-spec.git

- Sample projects
- `/docs/current/references/samples`
- GitHub Repo: https://github.com/dfinity/examples.git
Expand Down
2 changes: 1 addition & 1 deletion blog/features/async-performance-counter.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ image: /img/blog/async-performance-counter.webp

## Background

The Internet Computer can host a full dapp — frontend, backend and data. Users can deploy their dapp as a canister (smart contract) on the Internet Computer. Each canister can store up to 400 GB of data and execute up to 20 Billion WebAssembly instructions per transaction.
The Internet Computer can host a full dapp — frontend, backend and data. Users can deploy their dapp as a canister (smart contract) on the Internet Computer. Each canister can store up to 500GiB of data and execute up to 40 Billion WebAssembly instructions per transaction.

Unlike other blockchains, the Internet Computer offers developers [enormous amounts of resources](/docs/current/developer-docs/smart-contracts/maintain/resource-limits). This poses a real challenge for canister developers: writing efficient canister code. The more efficient a canister is, the less cycles it pays.

Expand Down
2 changes: 1 addition & 1 deletion docs/developer-docs/ai/inference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ An alternative to running the model onchain would be to download the model from

A disadvantage of this workflow is that the model needs to be downloaded to the user's device, resulting in less confidentiality of the model and decreased user experience due to increased latency.

ICP supports this workflow for most existing models because a smart contract on ICP can store models up to 400GiB.
ICP supports this workflow for most existing models because a smart contract on ICP can store models up to 500GiB.

### Examples

Expand Down
2 changes: 1 addition & 1 deletion docs/developer-docs/ai/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ This assumes that the model was trained off-chain and then uploaded onchain.
Inference happens on the user's device after downloading the model.
If the user trusts their own device, then they can trust that the inference ran correctly.
A disadvantage here is that the model needs to be downloaded to the user's device with corresponding drawbacks of less confidentiality of the model and decreased user experience due to increased latency.
ICP supports this use case for practically all existing models because a smart contract on ICP can store models up to 400GiB.
ICP supports this use case for practically all existing models because a smart contract on ICP can store models up to 500GiB.
See [an example](https://github.com/patnorris/DecentralizedAIonIC) of an in-browser AI chatbot that uses an open-source LLM model served from ICP.

4. **Tokenization, marketplaces, orchestration**:
Expand Down
2 changes: 1 addition & 1 deletion docs/developer-docs/backend/rust/upgrading.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ When a canister needs to be upgraded, the following workflow is used:

### Versioning stable memory

Stable memory is a data persistence feature on ICP. Stable memory is used to store data that persists across canister upgrades. The maximum data storage size of stable memory is 400 GiB if the subnet can accommodate it.
Stable memory is a data persistence feature on ICP. Stable memory is used to store data that persists across canister upgrades. The maximum data storage size of stable memory is 500GiB if the subnet can accommodate it.

In comparison, heap memory (also referred to as "main memory") refers to the regular Wasm data storage for a canister. Heap memory is not persisted across canister upgrades and is limited to 4GiB.

Expand Down
2 changes: 1 addition & 1 deletion docs/developer-docs/gas-cost.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ These operations reserve some cycles by moving them from the main balance of the
The amount of reserved cycles depends on how many bytes are allocated and on the current subnet usage.

- If subnet usage is below `450GiB`, then the amount of reserved cycles per allocated byte is `0`.
- If subnet usage is above `450GiB`, then the amount of reserved cycles per allocated byte grows linearly depending on the subnet usage, from `0` to `10` years worth of storage payments at the subnet capacity (which is currently `750GiB`).
- If subnet usage is above `450GiB`, then the amount of reserved cycles per allocated byte grows linearly depending on the subnet usage, from `0` to `10` years worth of storage payments at the subnet capacity (which is currently `1TiB`).

A controller of a canister can disable resource reservation by setting the `reserved_cycles_limit=0` in canister settings.
Such opted-out canisters would not be able to allocate if the subnet usage is above `450GiB`.
Expand Down
2 changes: 1 addition & 1 deletion docs/developer-docs/getting-started/network-overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ Currently, subnets contain between 13 and 40 nodes, and most of them are geograp
<tr>
  <td> Memory size </td>
  <td> Few KB </td>
  <td> 404GiB (4GiB Wasm memory + 400GiB of stable memory) </td>
  <td> 504GiB (4GiB Wasm memory + 500GiB of stable memory) </td>
</tr>

<tr>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
hide_table_of_contents: true
---

import { AdornedTabs } from "/src/components/Tabs/AdornedTabs";
import { MarkdownChipRow } from "/src/components/Chip/MarkdownChipRow";
import TabItem from "@theme/TabItem";
Expand Down Expand Up @@ -145,7 +149,7 @@ dfx deploy --playground

#### 4. Interact with your project.

Open the URL in your web browser that `dfx` returned after deploying your
Open the `frontend` URL in your web browser that `dfx` returned after deploying your
project.

</TabItem>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
keywords: [beginner, getting started, quick start, react]
hide_table_of_contents: true
---

import { MarkdownChipRow } from "/src/components/Chip/MarkdownChipRow";
Expand Down
2 changes: 1 addition & 1 deletion docs/developer-docs/multi-chain/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Chain Fusion allows to build more powerful dapps combining non-ICP smart
contracts with the decentralized compute power of ICP.

- **Storage**: Using a competitive pricing model, a single smart contract on ICP
offers up to 400GiB of storage, enabling all application data to be stored
offers up to 500GiB of storage, enabling all application data to be stored
onchain. Through Chain Fusion, these decentralized storage capacities are
made available to non-ICP dapps.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ There are two forms of storage available to ICP canisters: **heap memory** and *

**Heap memory** is a canister's Wasm memory. This memory does not store data long-term. The heap memory is cleared each time a canister is upgraded. Heap memory is limited to 4GiB. It is used by default for data such as variable values, arguments passed to a canister, and the result of a method's execution.

**Stable memory** is a secondary storage type that is used to store data long-term. Stable memory data is persisted throughout the canister's lifetime, including canister upgrades. Stable memory is limited to 400GiB. To use stable memory, you must anticipate which data you want to persist across different canister processes and states.
**Stable memory** is a secondary storage type that is used to store data long-term. Stable memory data is persisted throughout the canister's lifetime, including canister upgrades. Stable memory is limited to 500GiB. To use stable memory, you must anticipate which data you want to persist across different canister processes and states.

| Memory feature | Heap memory | Stable memory |
|----------------|-------------|---------------|
|Storage capacity| 4GiB | 400GiB |
|Storage capacity| 4GiB | 500GiB |
|Intended use | Small datasets, frequently accessed data, temporary data | Large datasets, infrequently accessed data, important data that must persist |
|Persistence | Does not persist across upgrades | Data is preserved and persists across upgrades |
|Performance | Fast read/write operations | Slightly decreased read/write operations |
Expand All @@ -37,7 +37,7 @@ Heap data is better suited to be used for small data sets (under 4GiB) or data t

### Recommendation: Use stable memory for large datasets.

Stable memory should be used for large data sets (More than 4GiB but less than 400GiB) or data that is infrequently accessed.
Stable memory should be used for large data sets (More than 4GiB but less than 500GiB) or data that is infrequently accessed.

Ultimately, the form of memory you choose to utilize for your canister will depend on the most optimal workflow for your project.

Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ The limits depend on the message type as shown in the following table.

| <Tooltip text="A collection of nodes that run their own instance of the ICP consensus algorithm.">Subnet</Tooltip> limits | Constraint |
| ------------------------------------------------------------------------------------ | ----------- |
| Subnet capacity (total memory available per subnet) | 700GiB |
| Subnet capacity (total memory available per subnet) | 1TiB |
| Maximum number of snapshot per canister | 1 |

| Memory resource limits | Constraint |
| ------------------------------------------------------------------------------------ | ----------- |
| Wasm heap memory, per canister | 4GiB |
| Wasm stable memory, per canister | 400GiB |
| Wasm stable memory, per canister | 500GiB |
| Wasm stable memory, data access per replicated message | 2GiB |
| Wasm stable memory, data written per replicated message | 2GiB |
| Wasm stable memory, data access per upgrade message | 8GiB |
Expand Down
10 changes: 5 additions & 5 deletions docs/developer-docs/smart-contracts/maintain/storage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ import { GlossaryTooltip } from "/src/components/Tooltip/GlossaryTooltip";

## Overview

When developing projects on ICP, there are two primary forms of data storage that your <GlossaryTooltip>canisters</GlossaryTooltip> can utilize. The first type of storage is the canister's **heap memory**, sometimes referred to as the canister's *main memory*. Heap memory is **temporary**, and any data stored in a canister's heap memory is cleared whenever the canister is stopped or upgraded.
When developing projects on ICP, there are two primary forms of data storage that your <GlossaryTooltip>canisters</GlossaryTooltip> can utilize. The first type of storage is the canister's **heap memory**, sometimes referred to as the canister's *main memory*. Heap memory is **temporary**, and any data stored in a canister's heap memory is cleared whenever the canister is reinstalled or upgraded.

The second type of storage available to a canister is **stable memory**. Stable memory is a unique feature of ICP that  defines a separate data store aside from a canister's regular Wasm heap memory data storage. It is a secondary storage type that can be used to store data long-term, since all data stored in stable memory will persist across all canister processes.

## Heap memory

Heap memory refers to a canister's regular Wasm memory. It does not persist and does not store data long-term. A canister's heap memory is cleared whenever a canister is stopped or upgraded. Heap memory is used by default for storing things such as variable values, the result of an executed function, or other arguments passed to your canister.
Heap memory refers to a canister's regular Wasm memory. It does not persist and does not store data long-term. A canister's heap memory is cleared whenever a canister is reinstalled or upgraded. Heap memory is used by default for storing things such as variable values, the result of an executed function, or other arguments passed to your canister.

Heap memory is limited to a maximum of 4GiB of data.

## Stable memory

Stable memory is a feature unique to the Internet Computer Protocol that provides a long-term, persistent data storage option separate from a canister's heap memory. When a canister is stopped or upgraded, the data stored in stable memory is not cleared or removed. The stable memory is preserved throughout the process, while any other WebAssembly state is discarded.
Stable memory is a feature unique to the Internet Computer Protocol that provides a long-term, persistent data storage option separate from a canister's heap memory. When a canister is reinstalled or upgraded, the data stored in stable memory is not cleared or removed. The stable memory is preserved throughout the process, while any other WebAssembly state is discarded.

To use stable memory, you must anticipate which portions of the canister's data you want to persist across upgrades by indicating this within the canister code. More information about this can be found in the section below, [Storage handling in different languages](#storage-handling-in-different-languages).

By default, a canister's stable memory is empty. The maximum storage limit for stable memory is 400GiB if the <GlossaryTooltip>subnet</GlossaryTooltip> the canister is deployed on can accommodate it. If a canister uses more than 400GiB of stable memory, the canister will trap and become unrecoverable.
By default, a canister's stable memory is empty. The maximum storage limit for stable memory is 500GiB if the <GlossaryTooltip>subnet</GlossaryTooltip> the canister is deployed on can accommodate it. If a canister uses more than 500GiB of stable memory, the canister will trap and become unrecoverable.

## Storage cost

Expand Down Expand Up @@ -129,4 +129,4 @@ Common errors related to canister memory include:
- [Memory access limit exceeded](/docs/current/references/execution-errors#memory-access-limit-exceeded).
- [Wasm memory limit exceeded](/docs/current/references/execution-errors#wasm-memory-limit-exceeded).
- [Not enough memory allocation given](/docs/current/references/execution-errors#not-enough-memory-allocation-given).
- [Wasm chunk store error](/docs/current/references/execution-errors#wasm-chunk-store-error).
- [Wasm chunk store error](/docs/current/references/execution-errors#wasm-chunk-store-error).
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Balance: 9_811_813_913_485 Cycles
Module hash: 0xe7866e1949e3688a78d8d29bd63e1c13cd6bfb8fbe29444fa606a20e0b1e33f0
```

Canisters can check their own balance programmatically. For example:
Canisters can check their balance programmatically. For example:

<AdornedTabs groupId="language">
<TabItem value="motoko" label="Motoko" default>
Expand Down Expand Up @@ -100,7 +100,7 @@ let current_canister_balance = ic_cdk::api::canister_balance();

### Option 1: If you have ICP on your account

If you have ICP on the account associated with a `dfx` identity, you can tell the ledger canister to take some of that ICP, convert it to cycles, and give it to a canister of your choice using the command `dfx ledger top-up --icp <AMOUNT> <DESTINATION> --network ic`:
If you have ICP on the account associated with a `dfx` identity, you can convert ICP into cycles, then top up a canister with those cycles:

```bash
dfx ledger account-id
Expand All @@ -115,7 +115,7 @@ dfx ledger top-up --icp 1 jqylk-byaaa-aaaal-qbymq-cai --network ic

### Option 2: If you have cycles

If you have a cycles balance associated with your developer identity, you can top up a canister with the command `dfx cycles top-up <DESTINATION> <AMOUNT>`:
If you already have cycles, you can top up a canister with the command `dfx cycles top-up <DESTINATION> <AMOUNT>`:

```bash
dfx cycles balance --network ic
Expand Down Expand Up @@ -150,7 +150,7 @@ dfx wallet balance --network ic
dfx wallet send 1T dfds-sddds-aaaal-qbsms-cai --network ic
```

-   The `wallet balance --network ic ` checks the cycles balance of your cycles wallet on the mainnet.
-   The `wallet balance --network ic` checks the cycles balance of your cycles wallet on the mainnet.
-   The `wallet send 1T dfds-sddds-aaaal-qbsms-cai --network ic` takes one trillion cycles from your cycles wallet and sends them to cycles wallet `dfds-sddds-aaaal-qbsms-cai`.

## Topping up a canister with the NNS frontend dapp
Expand All @@ -159,25 +159,25 @@ You can also top up any canister via the [NNS frontend dapp](https://nns.ic0.app

- #### Step 1: Navigate to the **My Canisters** section of the dapp.
- #### Step 2: Click **Link Canister**.
- #### Step 3: Add a canister principal. It is not necessary for the user to actually control said canister.
- #### Step 3: Add a canister principal. The user doesn't need to control the canister.
- #### Step 4: Once the canister is added, click on that canister.
- #### Step 5: Click `Add cycles` to add cycles using the ICP in your NNS frontend dapp.

## Managing cycle depletion with freezing threshold

ICP features a mechanism to prevent canisters from running out of cycles. Canisters have a configurable `freezing_threshold`, dynamically evaluated in cycles.

In the output of the `dfx canister status` command, you may have noticed the `freezing threshold` value. The freezing threshold is a value defined in seconds, which is used to calculate how many cycles a canister must retain in its cycles balance. This calculation is based off of the canister's memory consumption. The default freezing threshold value is `2_592_000s`, which corresponds to 30 days.
In the output of the `dfx canister status` command, you may have noticed the `freezing threshold` value. The freezing threshold is a value defined in seconds, which is used to calculate how many cycles a canister must retain in its cycles balance. This calculation is based on the canister's memory consumption. The default freezing threshold value is `2_592_000s`, which corresponds to 30 days.

The freezing threshold is important because if a canister runs out of cycles, it will be uninstalled. The freezing threshold protects it from deletion, since if the cycles balance dips below the threshold, the canister will stop processing any new requests; however, it will continue to reply to existing requests.
The freezing threshold is important because if a canister runs out of cycles, it will be uninstalled. The freezing threshold protects it from deletion since if the cycles balance dips below the threshold, the canister will stop processing any new requests; however, it will continue to reply to existing requests.

For example, to set a freezing threshold for your `poll_backend` canister, use the command:

``````bash
```
dfx canister update-settings poll_backend --freezing-threshold 3472000
```

Then, you can confirm that this threshold has been set by running the `dfx canister status poll_backend --network ic ` command again:
Then, confirm that this threshold has been set by running the `dfx canister status poll_backend --network ic ` command again:

```bash
Canister status call result for poll_backend.
Expand Down
11 changes: 11 additions & 0 deletions docs/references/_attachments/ic.did
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,14 @@ type node_metrics_history_result = vec record {
node_metrics : vec node_metrics;
};

type subnet_info_args = record {
subnet_id : principal;
};

type subnet_info_result = record {
replica_version : text;
};

type provisional_create_canister_with_cycles_args = record {
amount : opt nat;
settings : opt canister_settings;
Expand Down Expand Up @@ -445,6 +453,9 @@ service ic : {
// metrics interface
node_metrics_history : (node_metrics_history_args) -> (node_metrics_history_result);

// subnet info
subnet_info : (subnet_info_args) -> (subnet_info_result);

// provisional interfaces for the pre-ledger world
provisional_create_canister_with_cycles : (provisional_create_canister_with_cycles_args) -> (provisional_create_canister_with_cycles_result);
provisional_top_up_canister : (provisional_top_up_canister_args) -> ();
Expand Down
4 changes: 4 additions & 0 deletions docs/references/_attachments/interface-spec-changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Changelog {#changelog}

### 0.30.0 (2024-11-19) {#0_30_0}
* Add management canister endpoint `subnet_info`.
* Support for wasm64: 64-bit system API.

### 0.29.0 (2024-11-14) {#0_29_0}
* Allow anonymous query and read state requests with invalid `ingress_expiry`.
* Add allowed viewers variant to canister log visibility.
Expand Down
Loading

0 comments on commit 1d6af26

Please sign in to comment.