Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow directly calling the data_struct function with Option type. #1773

Merged
Merged
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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
processed 1 task

task 0 'publish'. lines 1-39:
status EXECUTED
11 changes: 7 additions & 4 deletions moveos/moveos-verifier/src/build.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
// Copyright (c) RoochNetwork
// SPDX-License-Identifier: Apache-2.0

use crate::metadata::{run_extended_checks, RuntimeModuleMetadataV1};
use crate::metadata::{
run_extended_checks, RuntimeModuleMetadataV1, DATA_STRUCT_ATTRIBUTE,
DATA_STRUCT_FUNC_ATTRIBUTE, PRIVATE_GENERICS_ATTRIBUTE,
};
use codespan_reporting::diagnostic::Severity;
use itertools::Itertools;
use move_binary_format::CompiledModule;
Expand Down Expand Up @@ -396,7 +399,7 @@ pub fn compile_and_inject_metadata(

let mut rooch_metadata = RuntimeModuleMetadataV1::default();
for (metadata_type, metadata_item) in ast_metadata.value {
if metadata_type == "private_generics" {
if metadata_type == PRIVATE_GENERICS_ATTRIBUTE {
let mut private_generics_map: BTreeMap<String, Vec<usize>> = BTreeMap::new();
for (metadata_key, metadata_value) in metadata_item.iter() {
let mut generic_type_indices: Vec<usize> = Vec::new();
Expand All @@ -414,7 +417,7 @@ pub fn compile_and_inject_metadata(
rooch_metadata.private_generics_indices = private_generics_map;
}

if metadata_type == "data_struct" {
if metadata_type == DATA_STRUCT_ATTRIBUTE {
let mut data_structs_map: BTreeMap<String, bool> = BTreeMap::new();
for (metadata_key, metadata_value) in metadata_item.iter() {
for idx_expr in metadata_value.iter() {
Expand All @@ -430,7 +433,7 @@ pub fn compile_and_inject_metadata(
rooch_metadata.data_struct_map = data_structs_map;
}

if metadata_type == "data_struct_func" {
if metadata_type == DATA_STRUCT_FUNC_ATTRIBUTE {
let mut data_struct_func_map: BTreeMap<String, Vec<usize>> = BTreeMap::new();
for (metadata_key, metadata_value) in metadata_item.iter() {
let mut generic_type_indices: Vec<usize> = Vec::new();
Expand Down
2 changes: 2 additions & 0 deletions moveos/moveos-verifier/src/error_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ pub enum ErrorCode {
INVALID_DATA_STRUCT_WITHOUT_COPY_ABILITY = 10013,
INVALID_DATA_STRUCT_NOT_ALLOWED_TYPE = 10014,
INVALID_DATA_STRUCT_NOT_IN_MODULE_METADATA = 10015,
INVALID_DATA_STRUCT_WITH_TYPE_PARAMETER = 10016,
INVALID_DATA_STRUCT_OPTION_WITHOUT_TYPE_PARAMETER = 10017,

INVALID_ENTRY_FUNC_SIGNATURE = 11000,
INVALID_PARAM_TYPE_ENTRY_FUNCTION = 11001,
Expand Down
6 changes: 4 additions & 2 deletions moveos/moveos-verifier/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@ pub static mut GLOBAL_DATA_STRUCT_FUNC: GlobalVariableWithRWLocker<BTreeMap<Stri
pub static mut GLOBAL_GAS_FREE_RECORDER: Lazy<BTreeMap<String, Vec<usize>>> =
Lazy::new(|| BTreeMap::new());

const PRIVATE_GENERICS_ATTRIBUTE: &str = "private_generics";
pub const PRIVATE_GENERICS_ATTRIBUTE: &str = "private_generics";

const GAS_FREE_ATTRIBUTE: &str = "gas_free";
const GAS_FREE_VALIDATE: &str = "gas_validate";
const GAS_FREE_CHARGE_POST: &str = "gas_charge_post";

const DATA_STRUCT_ATTRIBUTE: &str = "data_struct";
pub const DATA_STRUCT_ATTRIBUTE: &str = "data_struct";

pub const DATA_STRUCT_FUNC_ATTRIBUTE: &str = "data_struct_func";

/// Enumeration of potentially known attributes
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
Expand Down
Loading
Loading