From ce02c0935a3cd553e8cd14a7818297bdb4ceca82 Mon Sep 17 00:00:00 2001 From: Bob Ong <2261238+welbon@users.noreply.github.com> Date: Thu, 12 Dec 2024 16:23:30 +0800 Subject: [PATCH] [compiler-v2 framework] fixed known_attribute warning in move test (#4340) * [compiler-v2 framework] fixed known_attribute warning in move test context * [compiler-v2 framework] removed unused code * [compiler-v2 framework] fixed fmt --- Cargo.lock | 1 + .../sources/validator_consensus_info.move | 42 ------------------- .../validator_consensus_info.spec.move | 5 --- .../src/gas_schedule/starcoin_framework.rs | 6 ++- vm/move-package-manager/src/lib.rs | 2 + .../Cargo.toml | 1 + .../src/lib.rs | 5 ++- 7 files changed, 11 insertions(+), 51 deletions(-) delete mode 100644 vm/framework/starcoin-framework/sources/validator_consensus_info.move delete mode 100644 vm/framework/starcoin-framework/sources/validator_consensus_info.spec.move diff --git a/Cargo.lock b/Cargo.lock index 75d617a633..312c243755 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12067,6 +12067,7 @@ dependencies = [ "starcoin-crypto", "starcoin-dag", "starcoin-dev", + "starcoin-framework 0.1.0", "starcoin-gas-meter", "starcoin-gas-schedule", "starcoin-genesis", diff --git a/vm/framework/starcoin-framework/sources/validator_consensus_info.move b/vm/framework/starcoin-framework/sources/validator_consensus_info.move deleted file mode 100644 index d415b630df..0000000000 --- a/vm/framework/starcoin-framework/sources/validator_consensus_info.move +++ /dev/null @@ -1,42 +0,0 @@ -/// Common type: `ValidatorConsensusInfo`. -module starcoin_framework::validator_consensus_info { - /// Information about a validator that participates consensus. - struct ValidatorConsensusInfo has copy, drop, store { - addr: address, - pk_bytes: vector, - voting_power: u64, - } - - /// Create a default `ValidatorConsensusInfo` object. Value may be invalid. Only for place holding prupose. - public fun default(): ValidatorConsensusInfo { - ValidatorConsensusInfo { - addr: @vm, - pk_bytes: vector[], - voting_power: 0, - } - } - - /// Create a `ValidatorConsensusInfo` object. - public fun new(addr: address, pk_bytes: vector, voting_power: u64): ValidatorConsensusInfo { - ValidatorConsensusInfo { - addr, - pk_bytes, - voting_power, - } - } - - /// Get `ValidatorConsensusInfo.addr`. - public fun get_addr(vci: &ValidatorConsensusInfo): address { - vci.addr - } - - /// Get `ValidatorConsensusInfo.pk_bytes`. - public fun get_pk_bytes(vci: &ValidatorConsensusInfo): vector { - vci.pk_bytes - } - - /// Get `ValidatorConsensusInfo.voting_power`. - public fun get_voting_power(vci: &ValidatorConsensusInfo): u64 { - vci.voting_power - } -} diff --git a/vm/framework/starcoin-framework/sources/validator_consensus_info.spec.move b/vm/framework/starcoin-framework/sources/validator_consensus_info.spec.move deleted file mode 100644 index 82d0fe3b4a..0000000000 --- a/vm/framework/starcoin-framework/sources/validator_consensus_info.spec.move +++ /dev/null @@ -1,5 +0,0 @@ -spec starcoin_framework::validator_consensus_info { - spec module { - pragma verify = true; - } -} diff --git a/vm/gas-schedule/src/gas_schedule/starcoin_framework.rs b/vm/gas-schedule/src/gas_schedule/starcoin_framework.rs index d0e218e310..1b242e555b 100644 --- a/vm/gas-schedule/src/gas_schedule/starcoin_framework.rs +++ b/vm/gas-schedule/src/gas_schedule/starcoin_framework.rs @@ -1,11 +1,13 @@ // Copyright (c) The Starcoin Core Contributors // SPDX-License-Identifier: Apache-2.0 +use move_core_types::gas_algebra::InternalGasPerArg; + +use starcoin_gas_algebra::{InternalGas, InternalGasPerAbstractValueUnit, InternalGasPerByte}; + use crate::gas_schedule::NativeGasParameters; use crate::traits::EXECUTION_GAS_MULTIPLIER as MUL; use crate::ver::gas_feature_versions::*; -use move_core_types::gas_algebra::InternalGasPerArg; -use starcoin_gas_algebra::{InternalGas, InternalGasPerAbstractValueUnit, InternalGasPerByte}; // see starcoin/vm/types/src/on_chain_config/genesis_gas_schedule.rs // same order as from https://github.com/starcoinorg/starcoin-framework/blob/main/sources/VMConfig.move#native_schedule diff --git a/vm/move-package-manager/src/lib.rs b/vm/move-package-manager/src/lib.rs index c0d98dc4f7..a1129717b8 100644 --- a/vm/move-package-manager/src/lib.rs +++ b/vm/move-package-manager/src/lib.rs @@ -136,6 +136,8 @@ pub fn run_integration_test(move_arg: Move, cmd: IntegrationTestCommand) -> Resu // force move to rebuild all packages, so that we can use compile_driver to generate the full compiled program. let mut build_config = move_arg.build_config; build_config.force_recompilation = true; + build_config.compiler_config.known_attributes = + starcoin_framework::extended_checks::get_all_attribute_names().clone(); let resolved_graph = build_config .clone() .resolution_graph_for_package(&rerooted_path, &mut std::io::stdout())?; diff --git a/vm/starcoin-transactional-test-harness/Cargo.toml b/vm/starcoin-transactional-test-harness/Cargo.toml index 1c7f36342e..c6b3a44b0a 100644 --- a/vm/starcoin-transactional-test-harness/Cargo.toml +++ b/vm/starcoin-transactional-test-harness/Cargo.toml @@ -62,6 +62,7 @@ starcoin-vm-runtime = { workspace = true } starcoin-vm-types = { workspace = true } starcoin-gas-meter = { workspace = true } starcoin-gas-schedule = { workspace = true } +starcoin-framework = { workspace = true } stdlib = { workspace = true } starcoin-dag = { workspace = true } bytes = { workspace = true } diff --git a/vm/starcoin-transactional-test-harness/src/lib.rs b/vm/starcoin-transactional-test-harness/src/lib.rs index 33880a17d9..75f21879de 100644 --- a/vm/starcoin-transactional-test-harness/src/lib.rs +++ b/vm/starcoin-transactional-test-harness/src/lib.rs @@ -8,7 +8,6 @@ use move_binary_format::{file_format::CompiledScript, CompiledModule}; use move_command_line_common::address::ParsedAddress; use move_command_line_common::files::verify_and_create_named_address_mapping; use move_compiler::compiled_unit::{AnnotatedCompiledUnit, CompiledUnitEnum}; -use move_compiler::shared::known_attributes::KnownAttribute; use move_compiler::shared::{NumberFormat, NumericalAddress, PackagePaths}; use move_compiler::{construct_pre_compiled_lib, FullyCompiledProgram}; use move_core_types::language_storage::StructTag; @@ -38,6 +37,7 @@ use starcoin_config::{genesis_key_pair, BuiltinNetworkID}; use starcoin_crypto::hash::PlainCryptoHash; use starcoin_crypto::HashValue; use starcoin_dev::playground::call_contract; +use starcoin_framework::extended_checks; use starcoin_gas_meter::StarcoinGasParameters; use starcoin_gas_schedule::FromOnChainGasSchedule; use starcoin_rpc_api::types::{ @@ -1072,7 +1072,8 @@ impl<'a> MoveTestAdapter<'a> for StarcoinTestAdapter<'a> { } fn known_attributes(&self) -> &BTreeSet { - KnownAttribute::get_all_attribute_names() + // KnownAttribute::get_all_attribute_names() + extended_checks::get_all_attribute_names() } fn init(