language/diem-framework/releases/artifacts/release-1.4.0-rc0/docs/modules/DiemVMConfig.md
<a name="0x1_DiemVMConfig"></a>
0x1::DiemVMConfigThis module defines structs and methods to initialize VM configurations, including different costs of running the VM.
DiemVMConfigGasScheduleGasConstantsinitializeset_gas_constants<a name="0x1_DiemVMConfig_DiemVMConfig"></a>
DiemVMConfigThe struct to hold config data needed to operate the DiemVM.
<pre><code><b>struct</b> <a href="DiemVMConfig.md#0x1_DiemVMConfig">DiemVMConfig</a> has <b>copy</b>, drop, store </code></pre> <details> <summary>Fields</summary> <dl> <dt> <code>gas_schedule: <a href="DiemVMConfig.md#0x1_DiemVMConfig_GasSchedule">DiemVMConfig::GasSchedule</a></code> </dt> <dd> Cost of running the VM. </dd> </dl> </details><a name="0x1_DiemVMConfig_GasSchedule"></a>
GasScheduleThe gas schedule keeps two separate schedules for the gas:
<a name="0x1_DiemVMConfig_GasConstants"></a>
GasConstants<a name="@Constants_0"></a>
<a name="0x1_DiemVMConfig_EGAS_CONSTANT_INCONSISTENCY"></a>
The provided gas constants were inconsistent.
<pre><code><b>const</b> <a href="DiemVMConfig.md#0x1_DiemVMConfig_EGAS_CONSTANT_INCONSISTENCY">EGAS_CONSTANT_INCONSISTENCY</a>: u64 = 0; </code></pre><a name="0x1_DiemVMConfig_initialize"></a>
initializeInitialize the table under the diem root account
<pre><code><b>public</b> <b>fun</b> <a href="DiemVMConfig.md#0x1_DiemVMConfig_initialize">initialize</a>(dr_account: &signer, instruction_schedule: vector<u8>, native_schedule: vector<u8>) </code></pre> <details> <summary>Implementation</summary> <pre><code><b>public</b> <b>fun</b> <a href="DiemVMConfig.md#0x1_DiemVMConfig_initialize">initialize</a>( dr_account: &signer, instruction_schedule: vector<u8>, native_schedule: vector<u8>, ) { <a href="DiemTimestamp.md#0x1_DiemTimestamp_assert_genesis">DiemTimestamp::assert_genesis</a>(); // The permission "UpdateVMConfig" is granted <b>to</b> DiemRoot [[H11]][PERMISSION]. <a href="Roles.md#0x1_Roles_assert_diem_root">Roles::assert_diem_root</a>(dr_account); <b>let</b> gas_constants = <a href="DiemVMConfig.md#0x1_DiemVMConfig_GasConstants">GasConstants</a> { global_memory_per_byte_cost: 4, global_memory_per_byte_write_cost: 9, min_transaction_gas_units: 600, large_transaction_cutoff: 600, intrinsic_gas_per_byte: 8, maximum_number_of_gas_units: 4000000, min_price_per_gas_unit: 0, max_price_per_gas_unit: 10000, max_transaction_size_in_bytes: 4096, gas_unit_scaling_factor: 1000, default_account_size: 800, }; <a href="DiemConfig.md#0x1_DiemConfig_publish_new_config">DiemConfig::publish_new_config</a>( dr_account, <a href="DiemVMConfig.md#0x1_DiemVMConfig">DiemVMConfig</a> { gas_schedule: <a href="DiemVMConfig.md#0x1_DiemVMConfig_GasSchedule">GasSchedule</a> { instruction_schedule, native_schedule, gas_constants, } }, ); } </code></pre> </details> <details> <summary>Specification</summary> <pre><code><b>let</b> gas_constants = <a href="DiemVMConfig.md#0x1_DiemVMConfig_GasConstants">GasConstants</a> { global_memory_per_byte_cost: 4, global_memory_per_byte_write_cost: 9, min_transaction_gas_units: 600, large_transaction_cutoff: 600, intrinsic_gas_per_byte: 8, maximum_number_of_gas_units: 4000000, min_price_per_gas_unit: 0, max_price_per_gas_unit: 10000, max_transaction_size_in_bytes: 4096, gas_unit_scaling_factor: 1000, default_account_size: 800, }; </code></pre>Must abort if the signer does not have the DiemRoot role [H11].
<pre><code><b>include</b> <a href="Roles.md#0x1_Roles_AbortsIfNotDiemRoot">Roles::AbortsIfNotDiemRoot</a>{account: dr_account}; <b>include</b> <a href="DiemTimestamp.md#0x1_DiemTimestamp_AbortsIfNotGenesis">DiemTimestamp::AbortsIfNotGenesis</a>; <b>include</b> <a href="DiemConfig.md#0x1_DiemConfig_PublishNewConfigAbortsIf">DiemConfig::PublishNewConfigAbortsIf</a><<a href="DiemVMConfig.md#0x1_DiemVMConfig">DiemVMConfig</a>>; <b>include</b> <a href="DiemConfig.md#0x1_DiemConfig_PublishNewConfigEnsures">DiemConfig::PublishNewConfigEnsures</a><<a href="DiemVMConfig.md#0x1_DiemVMConfig">DiemVMConfig</a>> { payload: <a href="DiemVMConfig.md#0x1_DiemVMConfig">DiemVMConfig</a> { gas_schedule: <a href="DiemVMConfig.md#0x1_DiemVMConfig_GasSchedule">GasSchedule</a> { instruction_schedule, native_schedule, gas_constants, } }}; </code></pre> </details><a name="0x1_DiemVMConfig_set_gas_constants"></a>
set_gas_constantsNo one can update DiemVMConfig except for the Diem Root account [H11].
<pre><code><b>include</b> <a href="Roles.md#0x1_Roles_AbortsIfNotDiemRoot">Roles::AbortsIfNotDiemRoot</a>{account: dr_account}; <b>include</b> <a href="DiemConfig.md#0x1_DiemConfig_SetAbortsIf">DiemConfig::SetAbortsIf</a><<a href="DiemVMConfig.md#0x1_DiemVMConfig">DiemVMConfig</a>>{account: dr_account }; <b>aborts_if</b> min_price_per_gas_unit > max_price_per_gas_unit <b>with</b> <a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_ARGUMENT">Errors::INVALID_ARGUMENT</a>; <b>aborts_if</b> min_transaction_gas_units > maximum_number_of_gas_units <b>with</b> <a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_ARGUMENT">Errors::INVALID_ARGUMENT</a>; <b>let</b> config = <a href="DiemConfig.md#0x1_DiemConfig_spec_get_config">DiemConfig::spec_get_config</a><<a href="DiemVMConfig.md#0x1_DiemVMConfig">DiemVMConfig</a>>(); <b>ensures</b> <a href="DiemConfig.md#0x1_DiemConfig_spec_is_published">DiemConfig::spec_is_published</a><<a href="DiemVMConfig.md#0x1_DiemVMConfig">DiemVMConfig</a>>(); <b>ensures</b> <a href="DiemConfig.md#0x1_DiemConfig_get">DiemConfig::get</a><<a href="DiemVMConfig.md#0x1_DiemVMConfig">DiemVMConfig</a>>() == <a href="DiemVMConfig.md#0x1_DiemVMConfig">DiemVMConfig</a> { gas_schedule: <a href="DiemVMConfig.md#0x1_DiemVMConfig_GasSchedule">GasSchedule</a> { instruction_schedule: config.gas_schedule.instruction_schedule, native_schedule: config.gas_schedule.native_schedule, gas_constants: <a href="DiemVMConfig.md#0x1_DiemVMConfig_GasConstants">GasConstants</a> { global_memory_per_byte_cost, global_memory_per_byte_write_cost, min_transaction_gas_units, large_transaction_cutoff, intrinsic_gas_per_byte, maximum_number_of_gas_units, min_price_per_gas_unit, max_price_per_gas_unit, max_transaction_size_in_bytes, gas_unit_scaling_factor, default_account_size, }, } }; <b>ensures</b> <b>old</b>(<a href="DiemConfig.md#0x1_DiemConfig_spec_has_config">DiemConfig::spec_has_config</a>()) == <a href="DiemConfig.md#0x1_DiemConfig_spec_has_config">DiemConfig::spec_has_config</a>(); </code></pre> </details><a name="@Module_Specification_1"></a>
<a name="@Initialization_2"></a>
<a name="@Access_Control_3"></a>
No one can update DiemVMConfig except for the Diem Root account [H11].
<a name="0x1_DiemVMConfig_DiemVMConfigRemainsSame"></a>
<pre><code><b>schema</b> <a href="DiemVMConfig.md#0x1_DiemVMConfig_DiemVMConfigRemainsSame">DiemVMConfigRemainsSame</a> { <b>ensures</b> <b>old</b>(<a href="DiemConfig.md#0x1_DiemConfig_spec_is_published">DiemConfig::spec_is_published</a><<a href="DiemVMConfig.md#0x1_DiemVMConfig">DiemVMConfig</a>>()) ==> <b>global</b><<a href="DiemConfig.md#0x1_DiemConfig">DiemConfig</a><<a href="DiemVMConfig.md#0x1_DiemVMConfig">DiemVMConfig</a>>>(@DiemRoot) == <b>old</b>(<b>global</b><<a href="DiemConfig.md#0x1_DiemConfig">DiemConfig</a><<a href="DiemVMConfig.md#0x1_DiemVMConfig">DiemVMConfig</a>>>(@DiemRoot)); } </code></pre> <pre><code><b>apply</b> <a href="DiemVMConfig.md#0x1_DiemVMConfig_DiemVMConfigRemainsSame">DiemVMConfigRemainsSame</a> <b>to</b> * <b>except</b> set_gas_constants; </code></pre>