Skip to content

Latest commit

 

History

History
440 lines (191 loc) · 11.4 KB

features.md

File metadata and controls

440 lines (191 loc) · 11.4 KB

Module 0x2::features

Defines feature flags for Rooch frameworks. Those are used in implementations of features in the moveos-stdlib, rooch-framework and other frameworks.

============================================================================================ Feature Flag Definitions

Each feature flag should come with documentation which justifies the need of the flag. Introduction of a new feature flag requires approval of framework owners. Be frugal when introducing new feature flags, as too many can make it hard to understand the code.

Note that removing a feature flag still requires the function which tests for the feature to stay around for compatibility reasons, as it is a public function. However, once the feature flag is disabled, those functions can constantly return true.

Resource FeatureStore

The enabled features, represented by a bitset stored on chain.

struct FeatureStore has key

Constants

This feature will only be enabled on devnet.

const DEVNET: u64 = 2;

const EAPI_DISABLED: u64 = 2;

const EINVALID_FEATURE: u64 = 1;

This feature will only be enabled on localnet.

const LOCALNET: u64 = 1;

Whether enable the allowlist feature for publishing modules.

Whether allowing replacing module's address, module identifier, struct identifier and constant address. This feature is used for creating a new module through a module template bytes, thus developers can used to publish new modules in Move.

const MODULE_TEMPLATE: u64 = 4;

This feature will only be enabled on testnet, devnet or localnet.

const TESTNET: u64 = 3;

Whether to enable size-based gas fee for adding field values

const VALUE_SIZE_GAS: u64 = 7;

Whether enable the wasm feature.

const WASM: u64 = 6;

Function init_feature_store

public(friend) fun init_feature_store()

Function change_feature_flags

Enable or disable features. Only the framework signers can call this function.

public fun change_feature_flags(framework: &signer, enable: vector<u64>, disable: vector<u64>)

Function is_enabled

Check whether the feature is enabled. All features are enabled for system reserved accounts.

public fun is_enabled(feature: u64): bool

Function get_localnet_feature

public fun get_localnet_feature(): u64

Function localnet_enabled

public fun localnet_enabled(): bool

Function ensure_localnet_enabled

Function get_devnet_feature

public fun get_devnet_feature(): u64

Function devnet_enabled

public fun devnet_enabled(): bool

Function ensure_devnet_enabled

public fun ensure_devnet_enabled()

Function get_testnet_feature

public fun get_testnet_feature(): u64

Function testnet_enabled

public fun testnet_enabled(): bool

Function ensure_testnet_enabled

Function get_module_template_feature

public fun get_module_template_feature(): u64

Function module_template_enabled

public fun module_template_enabled(): bool

Function ensure_module_template_enabled

Function get_module_publishing_allowlist_feature

Function module_publishing_allowlist_enabled

Function ensure_module_publishing_allowlist_enabled

Function get_wasm_feature

public fun get_wasm_feature(): u64

Function wasm_enabled

public fun wasm_enabled(): bool

Function ensure_wasm_enabled

public fun ensure_wasm_enabled()

Function get_value_size_gas_feature

public fun get_value_size_gas_feature(): u64

Function value_size_gas_enabled

public fun value_size_gas_enabled(): bool

Function ensure_value_size_gas_enabled

Function get_all_features

Helper for getting all features. Update this once new feature added.

public fun get_all_features(): vector<u64>