Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions crates/sui-framework/docs/std/internal.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ module example::use_permit;
public struct MyType { /* ... */ }

public fun test_permit() {
let permit = internal::permit<MyType>();
/* external_module::call_with_permit(permit); */
let permit = internal::permit<MyType>();
/* external_module::call_with_permit(permit); */
}
```

Expand All @@ -25,7 +25,7 @@ To write a function that is guarded by a <code><a href="../std/internal.md#std_i
module example::type_registry;

public fun register_type<T>(_: internal::Permit<T> /* ... */) {
/* ... */
/* ... */
}
```

Expand Down
28 changes: 14 additions & 14 deletions crates/sui-framework/docs/sui/bcs.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ Usage example:
/// This function reads u8 and u64 value from the input
/// and returns the rest of the bytes.
fun deserialize(bytes: vector<u8>): (u8, u64, vector<u8>) {
use sui::bcs::{Self, BCS};
use sui::bcs::{Self, BCS};

let prepared: BCS = bcs::new(bytes);
let (u8_value, u64_value) = (
prepared.peel_u8(),
prepared.peel_u64()
);
let prepared: BCS = bcs::new(bytes);
let (u8_value, u64_value) = (
prepared.peel_u8(),
prepared.peel_u64()
);

// unpack bcs struct
let leftovers = prepared.into_remainder_bytes();
// unpack bcs struct
let leftovers = prepared.into_remainder_bytes();

(u8_value, u64_value, leftovers)
(u8_value, u64_value, leftovers)
}
```

Expand Down Expand Up @@ -768,11 +768,11 @@ however the tag can be any <code>u32</code> value.
Example:
```rust
let my_enum = match (bcs.peel_enum_tag()) {
0 => Enum::Empty,
1 => Enum::U8(bcs.peel_u8()),
2 => Enum::U16(bcs.peel_u16()),
3 => Enum::Struct { a: bcs.peel_address(), b: bcs.peel_u8() },
_ => abort,
0 => Enum::Empty,
1 => Enum::U8(bcs.peel_u8()),
2 => Enum::U16(bcs.peel_u16()),
3 => Enum::Struct { a: bcs.peel_address(), b: bcs.peel_u8() },
_ => abort,
};
```

Expand Down
10 changes: 5 additions & 5 deletions crates/sui-framework/docs/sui/display.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ on the property values of an Object.
```
// Example of a display object
Display<0x...::capy::Capy> {
fields:
<name, "Capy { genes }">
<link, "https://capy.art/capy/{ id }">
<image, "https://api.capy.art/capy/{ id }/svg">
<description, "Lovely Capy, one of many">
fields:
<name, "Capy { genes }">
<link, "https://capy.art/capy/{ id }">
<image, "https://api.capy.art/capy/{ id }/svg">
<description, "Lovely Capy, one of many">
}
```

Expand Down
28 changes: 14 additions & 14 deletions crates/sui-framework/docs/sui/event.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@ creates and sends a custom MoveEvent as a part of the effects
certificate of the transaction.

Every MoveEvent has the following properties:
- sender
- type signature (<code>T</code>)
- event data (the value of <code>T</code>)
- timestamp (local to a node)
- transaction digest
- sender
- type signature (<code>T</code>)
- event data (the value of <code>T</code>)
- timestamp (local to a node)
- transaction digest

Example:
```
module my::marketplace {
use sui::event;
/* ... */
struct ItemPurchased has copy, drop {
item_id: ID, buyer: address
}
entry fun buy(/* .... */) {
/* ... */
event::emit(ItemPurchased { item_id: ..., buyer: .... })
}
use sui::event;
/* ... */
struct ItemPurchased has copy, drop {
item_id: ID, buyer: address
}
entry fun buy(/* .... */) {
/* ... */
event::emit(ItemPurchased { item_id: ..., buyer: .... })
}
}
```

Expand Down
8 changes: 4 additions & 4 deletions crates/sui-framework/docs/sui/package.md
Original file line number Diff line number Diff line change
Expand Up @@ -704,13 +704,13 @@ package. This ticket only authorizes an upgrade to a package
that matches this digest. A package's contents are identified
by two things:

- modules: [[u8]] a list of the package's module contents
- deps: [[u8; 32]] a list of 32 byte ObjectIDs of the
package's transitive dependencies
- modules: [[u8]] a list of the package's module contents
- deps: [[u8; 32]] a list of 32 byte ObjectIDs of the
package's transitive dependencies

A package's digest is calculated as:

sha3_256(sort(modules ++ deps))
sha3_256(sort(modules ++ deps))


<pre><code><b>public</b> <b>fun</b> <a href="../sui/package.md#sui_package_ticket_digest">ticket_digest</a>(ticket: &<a href="../sui/package.md#sui_package_UpgradeTicket">sui::package::UpgradeTicket</a>): &vector&lt;u8&gt;
Expand Down
6 changes: 3 additions & 3 deletions crates/sui-framework/docs/sui/protocol_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ We should never need to expose this to user packages.
### Arguments

* <code>feature_flag_name</code> - The name of the feature flag as bytes (e.g., b"enable_vdf")
- It is expected to be a valid UTF-8 string
- The flag should exist in the protocol config
- It is expected to be a valid UTF-8 string
- The flag should exist in the protocol config


<a name="@Returns_1"></a>
Expand All @@ -53,7 +53,7 @@ We should never need to expose this to user packages.
use sui::protocol_config;

if (protocol_config::is_feature_enabled(b"enable_accumulators")) {
// Accumulators are available
// Accumulators are available
};
```

Expand Down
12 changes: 6 additions & 6 deletions crates/sui-framework/docs/sui_system/staking_pool.md
Original file line number Diff line number Diff line change
Expand Up @@ -1099,12 +1099,12 @@ Called at epoch boundaries to process the pending stake.
## Function `withdraw_rewards`

This function does the following:
1. Calculates the total amount of SUI (including principal and rewards) that the provided pool tokens represent
at the current exchange rate.
2. Using the above number and the given <code>principal_withdraw_amount</code>, calculates the rewards portion of the
stake we should withdraw.
3. Withdraws the rewards portion from the rewards pool at the current exchange rate. We only withdraw the rewards
portion because the principal portion was already taken out of the staker's self custodied StakedSui.
1. Calculates the total amount of SUI (including principal and rewards) that the provided pool tokens represent
at the current exchange rate.
2. Using the above number and the given <code>principal_withdraw_amount</code>, calculates the rewards portion of the
stake we should withdraw.
3. Withdraws the rewards portion from the rewards pool at the current exchange rate. We only withdraw the rewards
portion because the principal portion was already taken out of the staker's self custodied StakedSui.


<pre><code><b>fun</b> <a href="../sui_system/staking_pool.md#sui_system_staking_pool_withdraw_rewards">withdraw_rewards</a>(pool: &<b>mut</b> <a href="../sui_system/staking_pool.md#sui_system_staking_pool_StakingPool">sui_system::staking_pool::StakingPool</a>, principal_withdraw_amount: u64, pool_token_withdraw_amount: u64, epoch: u64): <a href="../sui/balance.md#sui_balance_Balance">sui::balance::Balance</a>&lt;<a href="../sui/sui.md#sui_sui_SUI">sui::sui::SUI</a>&gt;
Expand Down
10 changes: 5 additions & 5 deletions crates/sui-framework/docs/sui_system/storage_fund.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ title: Module `sui_system::storage_fund`

Struct representing the storage fund, containing two <code>Balance</code>s:
- <code><a href="../sui_system/storage_fund.md#sui_system_storage_fund_total_object_storage_rebates">total_object_storage_rebates</a></code> has the invariant that it's the sum of <code>storage_rebate</code> of
all objects currently stored on-chain. To maintain this invariant, the only inflow of this
balance is storage charges collected from transactions, and the only outflow is storage rebates
of transactions, including both the portion refunded to the transaction senders as well as
the non-refundable portion taken out and put into <code>non_refundable_balance</code>.
all objects currently stored on-chain. To maintain this invariant, the only inflow of this
balance is storage charges collected from transactions, and the only outflow is storage rebates
of transactions, including both the portion refunded to the transaction senders as well as
the non-refundable portion taken out and put into <code>non_refundable_balance</code>.
- <code>non_refundable_balance</code> contains any remaining inflow of the storage fund that should not
be taken out of the fund.
be taken out of the fund.


<pre><code><b>public</b> <b>struct</b> <a href="../sui_system/storage_fund.md#sui_system_storage_fund_StorageFund">StorageFund</a> <b>has</b> store
Expand Down
8 changes: 4 additions & 4 deletions crates/sui-framework/docs/sui_system/sui_system.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ To properly upgrade the <code>SuiSystemStateInner</code> type, we need to ship a
1. Define a new <code>SuiSystemStateInner</code>type (e.g. <code>SuiSystemStateInnerV2</code>).
2. Define a data migration function that migrates the old <code>SuiSystemStateInner</code> to the new one (i.e. SuiSystemStateInnerV2).
3. Replace all uses of <code>SuiSystemStateInner</code> with <code>SuiSystemStateInnerV2</code> in both sui_system.move and sui_system_state_inner.move,
with the exception of the <code><a href="../sui_system/sui_system_state_inner.md#sui_system_sui_system_state_inner_create">sui_system_state_inner::create</a></code> function, which should always return the genesis type.
with the exception of the <code><a href="../sui_system/sui_system_state_inner.md#sui_system_sui_system_state_inner_create">sui_system_state_inner::create</a></code> function, which should always return the genesis type.
4. Inside <code><a href="../sui_system/sui_system.md#sui_system_sui_system_load_inner_maybe_upgrade">load_inner_maybe_upgrade</a></code> function, check the current version in the wrapper, and if it's not the latest version,
call the data migration function to upgrade the inner object. Make sure to also update the version in the wrapper.
call the data migration function to upgrade the inner object. Make sure to also update the version in the wrapper.
A detailed example can be found in sui/tests/framework_upgrades/mock_sui_systems/shallow_upgrade.
Along with the Move change, we also need to update the Rust code to support the new type. This includes:
1. Define a new <code>SuiSystemStateInner</code> struct type that matches the new Move type, and implement the SuiSystemStateTrait.
Expand All @@ -32,7 +32,7 @@ To upgrade Validator type, besides everything above, we also need to:
2. Define a data migration function that migrates the old Validator to the new one (i.e. ValidatorV2).
3. Replace all uses of Validator with ValidatorV2 except the genesis creation function.
4. In validator_wrapper::upgrade_to_latest, check the current version in the wrapper, and if it's not the latest version,
call the data migration function to upgrade it.
call the data migration function to upgrade it.
In Rust, we also need to add a new case in <code>get_validator_from_table</code>.
Note that it is possible to upgrade SuiSystemStateInner without upgrading Validator, but not the other way around.
And when we only upgrade SuiSystemStateInner, the version of Validator in the wrapper will not be updated, and hence may become
Expand Down Expand Up @@ -1556,7 +1556,7 @@ This function should be called at the end of an epoch, and advances the system t
It does the following things:
1. Add storage charge to the storage fund.
2. Burn the storage rebates from the storage fund. These are already refunded to transaction sender's
gas coins.
gas coins.
3. Distribute computation charge to validator stake.
4. Update all validators.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2202,7 +2202,7 @@ This function should be called at the end of an epoch, and advances the system t
It does the following things:
1. Add storage charge to the storage fund.
2. Burn the storage rebates from the storage fund. These are already refunded to transaction sender's
gas coins.
gas coins.
3. Distribute computation charge to validator stake.
4. Update all validators.

Expand Down
18 changes: 9 additions & 9 deletions crates/sui-framework/docs/sui_system/validator_set.md
Original file line number Diff line number Diff line change
Expand Up @@ -1001,9 +1001,9 @@ Aborts in case the staking amount is smaller than MIN_STAKING_THRESHOLD
Called by <code><a href="../sui_system/sui_system.md#sui_system_sui_system">sui_system</a></code>, to withdraw some share of a stake from the validator. The share to withdraw
is denoted by <code>principal_withdraw_amount</code>. One of two things occurs in this function:
1. If the <code>staked_sui</code> is staked with an active validator, the request is added to the validator's
staking pool's pending stake withdraw entries, processed at the end of the epoch.
staking pool's pending stake withdraw entries, processed at the end of the epoch.
2. If the <code>staked_sui</code> was staked with a validator that is no longer active,
the stake and any rewards corresponding to it will be immediately processed.
the stake and any rewards corresponding to it will be immediately processed.


<pre><code><b>public</b>(package) <b>fun</b> <a href="../sui_system/validator_set.md#sui_system_validator_set_request_withdraw_stake">request_withdraw_stake</a>(self: &<b>mut</b> <a href="../sui_system/validator_set.md#sui_system_validator_set_ValidatorSet">sui_system::validator_set::ValidatorSet</a>, staked_sui: <a href="../sui_system/staking_pool.md#sui_system_staking_pool_StakedSui">sui_system::staking_pool::StakedSui</a>, ctx: &<a href="../sui/tx_context.md#sui_tx_context_TxContext">sui::tx_context::TxContext</a>): <a href="../sui/balance.md#sui_balance_Balance">sui::balance::Balance</a>&lt;<a href="../sui/sui.md#sui_sui_SUI">sui::sui::SUI</a>&gt;
Expand Down Expand Up @@ -1120,11 +1120,11 @@ the stake and any rewards corresponding to it will be immediately processed.

Update the validator set at the end of epoch.
It does the following things:
1. Distribute stake award.
2. Process pending stake deposits and withdraws for each validator (<code>adjust_stake</code>).
3. Process pending stake deposits, and withdraws.
4. Process pending validator application and withdraws.
5. At the end, we calculate the total stake for the new epoch.
1. Distribute stake award.
2. Process pending stake deposits and withdraws for each validator (<code>adjust_stake</code>).
3. Process pending stake deposits, and withdraws.
4. Process pending validator application and withdraws.
5. At the end, we calculate the total stake for the new epoch.


<pre><code><b>public</b>(package) <b>fun</b> <a href="../sui_system/validator_set.md#sui_system_validator_set_advance_epoch">advance_epoch</a>(self: &<b>mut</b> <a href="../sui_system/validator_set.md#sui_system_validator_set_ValidatorSet">sui_system::validator_set::ValidatorSet</a>, computation_reward: &<b>mut</b> <a href="../sui/balance.md#sui_balance_Balance">sui::balance::Balance</a>&lt;<a href="../sui/sui.md#sui_sui_SUI">sui::sui::SUI</a>&gt;, storage_fund_reward: &<b>mut</b> <a href="../sui/balance.md#sui_balance_Balance">sui::balance::Balance</a>&lt;<a href="../sui/sui.md#sui_sui_SUI">sui::sui::SUI</a>&gt;, validator_report_records: &<b>mut</b> <a href="../sui/vec_map.md#sui_vec_map_VecMap">sui::vec_map::VecMap</a>&lt;<b>address</b>, <a href="../sui/vec_set.md#sui_vec_set_VecSet">sui::vec_set::VecSet</a>&lt;<b>address</b>&gt;&gt;, reward_slashing_rate: u64, low_stake_grace_period: u64, ctx: &<b>mut</b> <a href="../sui/tx_context.md#sui_tx_context_TxContext">sui::tx_context::TxContext</a>)
Expand Down Expand Up @@ -1245,9 +1245,9 @@ It does the following things:
This function does the following:
- removes validators from <code>at_risk</code> group if their voting power is above the LOW threshold
- increments the number of epochs a validator has been below the LOW threshold but above the
VERY LOW threshold
VERY LOW threshold
- removes validators from the active set if they have been below the LOW threshold for more than
<code>low_stake_grace_period</code> epochs
<code>low_stake_grace_period</code> epochs
- removes validators from the active set immediately if they are below the VERY LOW threshold
- activates pending validators if they have sufficient voting power

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "Test"
edition = "2024"

[dependencies]
MoveStdlib = { local = "../../../../move-stdlib/", addr_subst = { "std" = "0x1" } }

[addresses]
a = "0x42"
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
source: crates/move-docgen-tests/tests/testsuite.rs
assertion_line: 74
info:
section_level_start: 1
exclude_private_fun: false
exclude_impl: false
toc_depth: 3
no_collapsed_sections: true
include_dep_diagrams: false
include_call_diagrams: false
---
<a name="a_m"></a>

# Module `a::m`


<a name="@Code_Block_Formatting_0"></a>

## Code Block Formatting


Indented code inside a fenced block should be preserved:

```
fun example() {
let x = 1;
if (x > 0) {
let y = x + 1;
};
}
```

Text after code block with a nested list:

- Item one
- Nested item


- [Code Block Formatting](#@Code_Block_Formatting_0)
- [Function `with_code_blocks`](#a_m_with_code_blocks)


<pre><code></code></pre>



<a name="a_m_with_code_blocks"></a>

## Function `with_code_blocks`

Function with code block in doc:

```
let v = vector[1, 2, 3];
let sum = 0;
while (!vector::is_empty(&v)) {
sum = sum + vector::pop_back(&mut v);
};
```

And indented code block:

```
indented_block();
```


<pre><code><b>entry</b> <b>fun</b> <a href="../a/m.md#a_m_with_code_blocks">with_code_blocks</a>()
</code></pre>



##### Implementation


<pre><code><b>entry</b> <b>fun</b> <a href="../a/m.md#a_m_with_code_blocks">with_code_blocks</a>() { }
</code></pre>
Loading
Loading