Skip to content

Commit

Permalink
[config] Rework some APIs (MystenLabs#18463)
Browse files Browse the repository at this point in the history
## Description 

- Reworked some config and denylist APIs to make it more clear what
values are being read
- For deny list, this manifested in having "next_epoch" and
"current_epoch" APIs

## Test plan 

- New tests 

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
  • Loading branch information
tnowacki authored Jul 2, 2024
1 parent ff425e0 commit c1f49f0
Show file tree
Hide file tree
Showing 14 changed files with 513 additions and 259 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ processed 11 tasks
init:
A: object(0,0), B: object(0,1)

task 1 'publish'. lines 13-49:
task 1 'publish'. lines 13-48:
created: object(1,0), object(1,1), object(1,2), object(1,3), object(1,4), object(1,5)
mutated: object(0,0)
gas summary: computation_cost: 1000000, storage_cost: 19539600, storage_rebate: 0, non_refundable_storage_fee: 0
gas summary: computation_cost: 1000000, storage_cost: 19471200, storage_rebate: 0, non_refundable_storage_fee: 0

task 2 'view-object'. lines 50-52:
task 2 'view-object'. lines 49-51:
Owner: Account Address ( A )
Version: 2
Contents: sui::coin::DenyCapV2<test::regulated_coin::REGULATED_COIN> {
Expand All @@ -20,38 +20,38 @@ Contents: sui::coin::DenyCapV2<test::regulated_coin::REGULATED_COIN> {
allow_global_pause: false,
}

task 3 'run'. lines 53-55:
task 3 'run'. lines 52-54:
created: object(3,0)
mutated: object(0,0), object(1,1)
gas summary: computation_cost: 1000000, storage_cost: 3936800, storage_rebate: 2437776, non_refundable_storage_fee: 24624

task 4 'run'. lines 56-58:
events: Event { package_id: sui, transaction_module: Identifier("coin"), sender: A, type_: StructTag { address: sui, module: Identifier("deny_list"), name: Identifier("PerTypeConfigCreated"), type_params: [] }, contents: [0, 0, 0, 0, 0, 0, 0, 0, 96, 51, 98, 101, 102, 55, 99, 55, 54, 53, 56, 50, 52, 55, 51, 100, 97, 54, 49, 49, 50, 102, 50, 48, 55, 51, 56, 52, 54, 55, 52, 102, 50, 98, 101, 49, 51, 55, 100, 49, 54, 48, 48, 100, 57, 48, 101, 53, 53, 55, 102, 54, 49, 49, 48, 99, 100, 102, 53, 101, 54, 56, 52, 101, 57, 58, 58, 114, 101, 103, 117, 108, 97, 116, 101, 100, 95, 99, 111, 105, 110, 58, 58, 82, 69, 71, 85, 76, 65, 84, 69, 68, 95, 67, 79, 73, 78, 109, 24, 236, 99, 254, 182, 140, 13, 147, 176, 159, 191, 147, 65, 224, 205, 34, 117, 213, 245, 234, 161, 224, 174, 12, 246, 80, 29, 144, 63, 192, 74] }
task 4 'run'. lines 55-57:
events: Event { package_id: sui, transaction_module: Identifier("coin"), sender: A, type_: StructTag { address: sui, module: Identifier("deny_list"), name: Identifier("PerTypeConfigCreated"), type_params: [] }, contents: [0, 0, 0, 0, 0, 0, 0, 0, 96, 51, 57, 57, 50, 48, 100, 100, 53, 50, 49, 99, 56, 48, 55, 101, 54, 98, 97, 99, 54, 99, 56, 97, 98, 51, 52, 102, 54, 49, 52, 48, 54, 49, 49, 53, 56, 56, 56, 49, 57, 57, 55, 56, 56, 52, 52, 98, 52, 51, 53, 57, 52, 53, 56, 57, 100, 55, 102, 56, 56, 98, 100, 57, 57, 58, 58, 114, 101, 103, 117, 108, 97, 116, 101, 100, 95, 99, 111, 105, 110, 58, 58, 82, 69, 71, 85, 76, 65, 84, 69, 68, 95, 67, 79, 73, 78, 79, 194, 17, 174, 74, 227, 253, 26, 173, 100, 153, 228, 250, 55, 174, 175, 17, 33, 34, 53, 27, 207, 230, 188, 240, 54, 6, 177, 124, 66, 182, 148] }
created: object(4,0), object(4,1), object(4,2)
mutated: 0x0000000000000000000000000000000000000000000000000000000000000403, object(0,0), object(1,3)
gas summary: computation_cost: 1000000, storage_cost: 12190400, storage_rebate: 2746260, non_refundable_storage_fee: 27740

task 5 'run'. lines 59-61:
task 5 'run'. lines 58-60:
mutated: object(0,0)
unchanged_shared: 0x0000000000000000000000000000000000000000000000000000000000000403
gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880

task 6 'transfer-object'. lines 62-64:
task 6 'transfer-object'. lines 61-63:
Error: Error checking transaction input objects: AddressDeniedForCoin { address: @B, coin_type: "object(1,0)::regulated_coin::REGULATED_COIN" }

task 7 'run'. lines 65-67:
task 7 'run'. lines 64-66:
Error: Error checking transaction input objects: AddressDeniedForCoin { address: @B, coin_type: "object(1,0)::regulated_coin::REGULATED_COIN" }

task 8 'run'. lines 68-70:
task 8 'run'. lines 67-69:
mutated: 0x0000000000000000000000000000000000000000000000000000000000000403, object(0,0), object(1,3)
deleted: object(4,1)
gas summary: computation_cost: 1000000, storage_cost: 4400400, storage_rebate: 6794172, non_refundable_storage_fee: 68628

task 9 'run'. lines 71-73:
task 9 'run'. lines 70-72:
mutated: object(0,0)
unchanged_shared: 0x0000000000000000000000000000000000000000000000000000000000000403
gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880

task 10 'transfer-object'. lines 74-74:
task 10 'transfer-object'. lines 73-73:
mutated: object(0,1), object(3,0)
gas summary: computation_cost: 1000000, storage_cost: 2462400, storage_rebate: 1459656, non_refundable_storage_fee: 14744
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ module test::regulated_coin {
deny_list: &DenyList,
addr: address,
expected: bool,
ctx: &TxContext,
) {
let status = coin::deny_list_v2_most_recent_contains<REGULATED_COIN>(deny_list, addr, ctx);
let status = coin::deny_list_v2_contains_next_epoch<REGULATED_COIN>(deny_list, addr);
assert!(status == expected, 0);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ A: object(0,0), B: object(0,1)
task 1 'publish'. lines 10-72:
created: object(1,0), object(1,1), object(1,2), object(1,3), object(1,4), object(1,5)
mutated: object(0,0)
gas summary: computation_cost: 1000000, storage_cost: 22032400, storage_rebate: 0, non_refundable_storage_fee: 0
gas summary: computation_cost: 1000000, storage_cost: 21964000, storage_rebate: 0, non_refundable_storage_fee: 0

task 2 'run'. lines 73-75:
created: object(2,0)
Expand All @@ -24,7 +24,7 @@ mutated: object(0,0), object(1,1)
gas summary: computation_cost: 1000000, storage_cost: 4119200, storage_rebate: 2437776, non_refundable_storage_fee: 24624

task 5 'run'. lines 82-84:
events: Event { package_id: sui, transaction_module: Identifier("coin"), sender: A, type_: StructTag { address: sui, module: Identifier("deny_list"), name: Identifier("PerTypeConfigCreated"), type_params: [] }, contents: [0, 0, 0, 0, 0, 0, 0, 0, 96, 97, 101, 97, 50, 53, 57, 56, 50, 98, 101, 51, 50, 100, 98, 50, 55, 102, 50, 52, 99, 52, 99, 102, 50, 48, 98, 54, 51, 55, 102, 51, 53, 101, 55, 48, 57, 54, 50, 52, 50, 51, 55, 52, 54, 54, 50, 102, 54, 56, 57, 50, 98, 48, 102, 98, 57, 57, 97, 52, 53, 49, 98, 57, 48, 58, 58, 114, 101, 103, 117, 108, 97, 116, 101, 100, 95, 99, 111, 105, 110, 58, 58, 82, 69, 71, 85, 76, 65, 84, 69, 68, 95, 67, 79, 73, 78, 117, 229, 87, 34, 102, 14, 228, 124, 79, 181, 111, 133, 49, 220, 118, 214, 199, 75, 151, 220, 69, 2, 201, 77, 1, 8, 135, 242, 172, 27, 118, 210] }
events: Event { package_id: sui, transaction_module: Identifier("coin"), sender: A, type_: StructTag { address: sui, module: Identifier("deny_list"), name: Identifier("PerTypeConfigCreated"), type_params: [] }, contents: [0, 0, 0, 0, 0, 0, 0, 0, 96, 54, 101, 99, 53, 53, 52, 55, 102, 50, 98, 99, 101, 48, 55, 97, 49, 48, 97, 102, 50, 57, 49, 57, 101, 97, 48, 101, 97, 57, 54, 97, 97, 102, 97, 56, 57, 54, 57, 56, 55, 56, 55, 50, 49, 50, 56, 55, 101, 98, 102, 54, 54, 102, 52, 48, 51, 100, 50, 100, 54, 99, 53, 57, 50, 58, 58, 114, 101, 103, 117, 108, 97, 116, 101, 100, 95, 99, 111, 105, 110, 58, 58, 82, 69, 71, 85, 76, 65, 84, 69, 68, 95, 67, 79, 73, 78, 254, 127, 25, 0, 75, 139, 142, 51, 141, 181, 23, 12, 237, 165, 178, 199, 150, 191, 43, 48, 121, 145, 70, 28, 15, 98, 69, 101, 83, 67, 172, 114] }
created: object(5,0), object(5,1), object(5,2)
mutated: 0x0000000000000000000000000000000000000000000000000000000000000403, object(0,0), object(1,3)
gas summary: computation_cost: 1000000, storage_cost: 11985200, storage_rebate: 2746260, non_refundable_storage_fee: 27740
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ module test::regulated_coin {
entry fun assert_global_pause_status(
deny_list: &DenyList,
expected: bool,
ctx: &TxContext,
) {
let status = coin::deny_list_v2_most_recent_is_global_pause_enabled<REGULATED_COIN>(deny_list, ctx);
let status =
coin::deny_list_v2_is_global_pause_enabled_next_epoch<REGULATED_COIN>(deny_list);
assert!(status == expected, 0);
}
}
Expand Down
83 changes: 70 additions & 13 deletions crates/sui-framework/docs/sui-framework/coin.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ tokens and coins. <code><a href="../sui-framework/coin.md#0x2_coin_Coin">Coin</a
- [Function `burn`](#0x2_coin_burn)
- [Function `deny_list_v2_add`](#0x2_coin_deny_list_v2_add)
- [Function `deny_list_v2_remove`](#0x2_coin_deny_list_v2_remove)
- [Function `deny_list_v2_most_recent_contains`](#0x2_coin_deny_list_v2_most_recent_contains)
- [Function `deny_list_v2_contains_current_epoch`](#0x2_coin_deny_list_v2_contains_current_epoch)
- [Function `deny_list_v2_contains_next_epoch`](#0x2_coin_deny_list_v2_contains_next_epoch)
- [Function `deny_list_v2_enable_global_pause`](#0x2_coin_deny_list_v2_enable_global_pause)
- [Function `deny_list_v2_disable_global_pause`](#0x2_coin_deny_list_v2_disable_global_pause)
- [Function `deny_list_v2_most_recent_is_global_pause_enabled`](#0x2_coin_deny_list_v2_most_recent_is_global_pause_enabled)
- [Function `deny_list_v2_is_global_pause_enabled_current_epoch`](#0x2_coin_deny_list_v2_is_global_pause_enabled_current_epoch)
- [Function `deny_list_v2_is_global_pause_enabled_next_epoch`](#0x2_coin_deny_list_v2_is_global_pause_enabled_next_epoch)
- [Function `mint_and_transfer`](#0x2_coin_mint_and_transfer)
- [Function `update_name`](#0x2_coin_update_name)
- [Function `update_symbol`](#0x2_coin_update_symbol)
Expand Down Expand Up @@ -898,7 +900,7 @@ type, ensuring that there's only one <code><a href="../sui-framework/coin.md#0x2
description: <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
icon_url: Option&lt;Url&gt;,
allow_global_pause: bool,
ctx: &<b>mut</b> TxContext
ctx: &<b>mut</b> TxContext,
): (<a href="../sui-framework/coin.md#0x2_coin_TreasuryCap">TreasuryCap</a>&lt;T&gt;, <a href="../sui-framework/coin.md#0x2_coin_DenyCapV2">DenyCapV2</a>&lt;T&gt;, <a href="../sui-framework/coin.md#0x2_coin_CoinMetadata">CoinMetadata</a>&lt;T&gt;) {
<b>let</b> (treasury_cap, metadata) = <a href="../sui-framework/coin.md#0x2_coin_create_currency">create_currency</a>(
witness,
Expand Down Expand Up @@ -1074,13 +1076,13 @@ accordingly.

</details>

<a name="0x2_coin_deny_list_v2_most_recent_contains"></a>
<a name="0x2_coin_deny_list_v2_contains_current_epoch"></a>

## Function `deny_list_v2_most_recent_contains`
## Function `deny_list_v2_contains_current_epoch`



<pre><code><b>public</b> <b>fun</b> <a href="../sui-framework/coin.md#0x2_coin_deny_list_v2_most_recent_contains">deny_list_v2_most_recent_contains</a>&lt;T&gt;(<a href="../sui-framework/deny_list.md#0x2_deny_list">deny_list</a>: &<a href="../sui-framework/deny_list.md#0x2_deny_list_DenyList">deny_list::DenyList</a>, addr: <b>address</b>, ctx: &<a href="../sui-framework/tx_context.md#0x2_tx_context_TxContext">tx_context::TxContext</a>): bool
<pre><code><b>public</b> <b>fun</b> <a href="../sui-framework/coin.md#0x2_coin_deny_list_v2_contains_current_epoch">deny_list_v2_contains_current_epoch</a>&lt;T&gt;(<a href="../sui-framework/deny_list.md#0x2_deny_list">deny_list</a>: &<a href="../sui-framework/deny_list.md#0x2_deny_list_DenyList">deny_list::DenyList</a>, addr: <b>address</b>, ctx: &<a href="../sui-framework/tx_context.md#0x2_tx_context_TxContext">tx_context::TxContext</a>): bool
</code></pre>


Expand All @@ -1089,13 +1091,41 @@ accordingly.
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="../sui-framework/coin.md#0x2_coin_deny_list_v2_most_recent_contains">deny_list_v2_most_recent_contains</a>&lt;T&gt;(
<pre><code><b>public</b> <b>fun</b> <a href="../sui-framework/coin.md#0x2_coin_deny_list_v2_contains_current_epoch">deny_list_v2_contains_current_epoch</a>&lt;T&gt;(
<a href="../sui-framework/deny_list.md#0x2_deny_list">deny_list</a>: &DenyList,
addr: <b>address</b>,
ctx: &TxContext,
): bool {
<b>let</b> ty = <a href="../move-stdlib/type_name.md#0x1_type_name_get_with_original_ids">type_name::get_with_original_ids</a>&lt;T&gt;().into_string().into_bytes();
<a href="../sui-framework/deny_list.md#0x2_deny_list">deny_list</a>.v2_most_recent_contains(<a href="../sui-framework/coin.md#0x2_coin_DENY_LIST_COIN_INDEX">DENY_LIST_COIN_INDEX</a>, ty, addr, ctx)
<a href="../sui-framework/deny_list.md#0x2_deny_list">deny_list</a>.v2_contains_current_epoch(<a href="../sui-framework/coin.md#0x2_coin_DENY_LIST_COIN_INDEX">DENY_LIST_COIN_INDEX</a>, ty, addr, ctx)
}
</code></pre>



</details>

<a name="0x2_coin_deny_list_v2_contains_next_epoch"></a>

## Function `deny_list_v2_contains_next_epoch`



<pre><code><b>public</b> <b>fun</b> <a href="../sui-framework/coin.md#0x2_coin_deny_list_v2_contains_next_epoch">deny_list_v2_contains_next_epoch</a>&lt;T&gt;(<a href="../sui-framework/deny_list.md#0x2_deny_list">deny_list</a>: &<a href="../sui-framework/deny_list.md#0x2_deny_list_DenyList">deny_list::DenyList</a>, addr: <b>address</b>): bool
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="../sui-framework/coin.md#0x2_coin_deny_list_v2_contains_next_epoch">deny_list_v2_contains_next_epoch</a>&lt;T&gt;(
<a href="../sui-framework/deny_list.md#0x2_deny_list">deny_list</a>: &DenyList,
addr: <b>address</b>,
): bool {
<b>let</b> ty = <a href="../move-stdlib/type_name.md#0x1_type_name_get_with_original_ids">type_name::get_with_original_ids</a>&lt;T&gt;().into_string().into_bytes();
<a href="../sui-framework/deny_list.md#0x2_deny_list">deny_list</a>.v2_contains_next_epoch(<a href="../sui-framework/coin.md#0x2_coin_DENY_LIST_COIN_INDEX">DENY_LIST_COIN_INDEX</a>, ty, addr)
}
</code></pre>

Expand Down Expand Up @@ -1163,13 +1193,13 @@ accordingly.

</details>

<a name="0x2_coin_deny_list_v2_most_recent_is_global_pause_enabled"></a>
<a name="0x2_coin_deny_list_v2_is_global_pause_enabled_current_epoch"></a>

## Function `deny_list_v2_most_recent_is_global_pause_enabled`
## Function `deny_list_v2_is_global_pause_enabled_current_epoch`



<pre><code><b>public</b> <b>fun</b> <a href="../sui-framework/coin.md#0x2_coin_deny_list_v2_most_recent_is_global_pause_enabled">deny_list_v2_most_recent_is_global_pause_enabled</a>&lt;T&gt;(<a href="../sui-framework/deny_list.md#0x2_deny_list">deny_list</a>: &<a href="../sui-framework/deny_list.md#0x2_deny_list_DenyList">deny_list::DenyList</a>, ctx: &<a href="../sui-framework/tx_context.md#0x2_tx_context_TxContext">tx_context::TxContext</a>): bool
<pre><code><b>public</b> <b>fun</b> <a href="../sui-framework/coin.md#0x2_coin_deny_list_v2_is_global_pause_enabled_current_epoch">deny_list_v2_is_global_pause_enabled_current_epoch</a>&lt;T&gt;(<a href="../sui-framework/deny_list.md#0x2_deny_list">deny_list</a>: &<a href="../sui-framework/deny_list.md#0x2_deny_list_DenyList">deny_list::DenyList</a>, ctx: &<a href="../sui-framework/tx_context.md#0x2_tx_context_TxContext">tx_context::TxContext</a>): bool
</code></pre>


Expand All @@ -1178,12 +1208,39 @@ accordingly.
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="../sui-framework/coin.md#0x2_coin_deny_list_v2_most_recent_is_global_pause_enabled">deny_list_v2_most_recent_is_global_pause_enabled</a>&lt;T&gt;(
<pre><code><b>public</b> <b>fun</b> <a href="../sui-framework/coin.md#0x2_coin_deny_list_v2_is_global_pause_enabled_current_epoch">deny_list_v2_is_global_pause_enabled_current_epoch</a>&lt;T&gt;(
<a href="../sui-framework/deny_list.md#0x2_deny_list">deny_list</a>: &DenyList,
ctx: &TxContext,
): bool {
<b>let</b> ty = <a href="../move-stdlib/type_name.md#0x1_type_name_get_with_original_ids">type_name::get_with_original_ids</a>&lt;T&gt;().into_string().into_bytes();
<a href="../sui-framework/deny_list.md#0x2_deny_list">deny_list</a>.v2_most_recent_is_global_pause_enabled(<a href="../sui-framework/coin.md#0x2_coin_DENY_LIST_COIN_INDEX">DENY_LIST_COIN_INDEX</a>, ty, ctx)
<a href="../sui-framework/deny_list.md#0x2_deny_list">deny_list</a>.v2_is_global_pause_enabled_current_epoch(<a href="../sui-framework/coin.md#0x2_coin_DENY_LIST_COIN_INDEX">DENY_LIST_COIN_INDEX</a>, ty, ctx)
}
</code></pre>



</details>

<a name="0x2_coin_deny_list_v2_is_global_pause_enabled_next_epoch"></a>

## Function `deny_list_v2_is_global_pause_enabled_next_epoch`



<pre><code><b>public</b> <b>fun</b> <a href="../sui-framework/coin.md#0x2_coin_deny_list_v2_is_global_pause_enabled_next_epoch">deny_list_v2_is_global_pause_enabled_next_epoch</a>&lt;T&gt;(<a href="../sui-framework/deny_list.md#0x2_deny_list">deny_list</a>: &<a href="../sui-framework/deny_list.md#0x2_deny_list_DenyList">deny_list::DenyList</a>): bool
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="../sui-framework/coin.md#0x2_coin_deny_list_v2_is_global_pause_enabled_next_epoch">deny_list_v2_is_global_pause_enabled_next_epoch</a>&lt;T&gt;(
<a href="../sui-framework/deny_list.md#0x2_deny_list">deny_list</a>: &DenyList,
): bool {
<b>let</b> ty = <a href="../move-stdlib/type_name.md#0x1_type_name_get_with_original_ids">type_name::get_with_original_ids</a>&lt;T&gt;().into_string().into_bytes();
<a href="../sui-framework/deny_list.md#0x2_deny_list">deny_list</a>.v2_is_global_pause_enabled_next_epoch(<a href="../sui-framework/coin.md#0x2_coin_DENY_LIST_COIN_INDEX">DENY_LIST_COIN_INDEX</a>, ty)
}
</code></pre>

Expand Down
Loading

0 comments on commit c1f49f0

Please sign in to comment.