diff --git a/sway-core/src/ir_generation/function.rs b/sway-core/src/ir_generation/function.rs index f3a7064568e..4171056c2e7 100644 --- a/sway-core/src/ir_generation/function.rs +++ b/sway-core/src/ir_generation/function.rs @@ -4338,6 +4338,14 @@ impl<'eng> FnCompiler<'eng> { base_type: &Type, span_md_idx: Option, ) -> Result { + // Use the `struct_field_names` to get a field id that is unique even for zero-sized values that live in the same slot. + // We calculate the `unique_field_id` early, here, before the `storage_filed_names` get consumed by `get_storage_key` below. + let unique_field_id = get_storage_field_id( + &storage_field_names, + &struct_field_names, + context.experimental, + ); + // Get the actual storage key as a `Bytes32` as well as the offset, in words, // within the slot. The offset depends on what field of the top level storage // variable is being accessed. @@ -4371,7 +4379,7 @@ impl<'eng> FnCompiler<'eng> { // particular slot is the remaining offset, in words. ( add_to_b256( - get_storage_key(storage_field_names.clone(), key.clone()), + get_storage_key(storage_field_names, key, context.experimental), offset_in_slots, ), offset_remaining, @@ -4428,7 +4436,6 @@ impl<'eng> FnCompiler<'eng> { .add_metadatum(context, span_md_idx); // Store the field identifier as the third field in the `StorageKey` struct - let unique_field_id = get_storage_field_id(storage_field_names, struct_field_names); // use the struct_field_names to get a field id that is unique even for zero-sized values that live in the same slot let field_id = convert_literal_to_value(context, &Literal::B256(unique_field_id.into())) .add_metadatum(context, span_md_idx); let gep_2_val = diff --git a/sway-core/src/ir_generation/storage.rs b/sway-core/src/ir_generation/storage.rs index 14fd2b8ef00..4f42a74a2e8 100644 --- a/sway-core/src/ir_generation/storage.rs +++ b/sway-core/src/ir_generation/storage.rs @@ -3,6 +3,7 @@ use crate::fuel_prelude::{ fuel_tx::StorageSlot, fuel_types::{Bytes32, Bytes8}, }; +use sway_features::ExperimentalFeatures; use sway_ir::{ constant::{Constant, ConstantValue}, context::Context, @@ -20,28 +21,31 @@ enum InByte8Padding { } /// Hands out storage keys using storage field names or an existing key. -/// Basically returns sha256("storage::::.") +/// Basically returns sha256((0u8, "storage::::.")) /// or key if defined. -pub(super) fn get_storage_key(storage_field_names: Vec, key: Option) -> Bytes32 { - if let Some(key) = key { - return key.to_be_bytes().into(); +pub(super) fn get_storage_key( + storage_field_names: Vec, + key: Option, + experimental: ExperimentalFeatures, +) -> Bytes32 { + match key { + Some(key) => key.to_be_bytes().into(), + None => hash_storage_key_string(get_storage_key_string(&storage_field_names), experimental), } - - Hasher::hash(get_storage_key_string(storage_field_names)) } -pub fn get_storage_key_string(storage_field_names: Vec) -> String { +pub fn get_storage_key_string(storage_field_names: &[String]) -> String { if storage_field_names.len() == 1 { format!( "{}{}{}", - sway_utils::constants::STORAGE_DOMAIN, + sway_utils::constants::STORAGE_TOP_LEVEL_NAMESPACE, sway_utils::constants::STORAGE_FIELD_SEPARATOR, storage_field_names.last().unwrap(), ) } else { format!( "{}{}{}{}{}", - sway_utils::constants::STORAGE_DOMAIN, + sway_utils::constants::STORAGE_TOP_LEVEL_NAMESPACE, sway_utils::constants::STORAGE_NAMESPACE_SEPARATOR, storage_field_names .iter() @@ -56,10 +60,11 @@ pub fn get_storage_key_string(storage_field_names: Vec) -> String { } /// Hands out unique storage field ids using storage field names and struct field names. -/// Basically returns sha256("storage::::...") +/// Basically returns sha256((0u8, "storage::::...")). pub(super) fn get_storage_field_id( - storage_field_names: Vec, - struct_field_names: Vec, + storage_field_names: &[String], + struct_field_names: &[String], + experimental: ExperimentalFeatures, ) -> Bytes32 { let data = format!( "{}{}", @@ -74,7 +79,32 @@ pub(super) fn get_storage_field_id( ) } ); - Hasher::hash(data) + + hash_storage_key_string(data, experimental) +} + +fn hash_storage_key_string( + storage_key_string: String, + experimental: ExperimentalFeatures, +) -> Bytes32 { + let mut hasher = Hasher::default(); + // Certain storage types, like, e.g., `StorageMap` allow + // storage slots of their contained elements to be defined + // based on developer's input. E.g., the `key` in a `StorageMap` + // used to calculate the storage slot is a developer input. + // + // To ensure that pre-images of such storage slots can never + // be the same as a pre-image of compiler generated key of storage + // field, we prefix the pre-images with a single byte that denotes + // the domain. Storage types like `StorageMap` must have a different + // domain prefix than the `STORAGE_DOMAIN` which is 0u8. + // + // For detailed elaboration see: https://github.com/FuelLabs/sway/issues/6317 + if experimental.storage_domains { + hasher.input(sway_utils::constants::STORAGE_DOMAIN); + } + hasher.input(storage_key_string); + hasher.finalize() } use uint::construct_uint; @@ -109,17 +139,18 @@ pub fn serialize_to_storage_slots( key: Option, ty: &Type, ) -> Vec { + let experimental = context.experimental; match &constant.value { ConstantValue::Undef => vec![], // If not being a part of an aggregate, single byte values like `bool`, `u8`, and unit // are stored as a byte at the beginning of the storage slot. ConstantValue::Unit if ty.is_unit(context) => vec![StorageSlot::new( - get_storage_key(storage_field_names, key), + get_storage_key(storage_field_names, key, experimental), Bytes32::new([0; 32]), )], ConstantValue::Bool(b) if ty.is_bool(context) => { vec![StorageSlot::new( - get_storage_key(storage_field_names, key), + get_storage_key(storage_field_names, key, experimental), Bytes32::new([ if *b { 1 } else { 0 }, 0, @@ -158,7 +189,7 @@ pub fn serialize_to_storage_slots( } ConstantValue::Uint(b) if ty.is_uint8(context) => { vec![StorageSlot::new( - get_storage_key(storage_field_names, key), + get_storage_key(storage_field_names, key, experimental), Bytes32::new([ *b as u8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -168,7 +199,7 @@ pub fn serialize_to_storage_slots( // Similarly, other uint values are stored at the beginning of the storage slot. ConstantValue::Uint(n) if ty.is_uint(context) => { vec![StorageSlot::new( - get_storage_key(storage_field_names, key), + get_storage_key(storage_field_names, key, experimental), Bytes32::new( n.to_be_bytes() .iter() @@ -182,13 +213,13 @@ pub fn serialize_to_storage_slots( } ConstantValue::U256(b) if ty.is_uint_of(context, 256) => { vec![StorageSlot::new( - get_storage_key(storage_field_names, key), + get_storage_key(storage_field_names, key, experimental), Bytes32::new(b.to_be_bytes()), )] } ConstantValue::B256(b) if ty.is_b256(context) => { vec![StorageSlot::new( - get_storage_key(storage_field_names, key), + get_storage_key(storage_field_names, key, experimental), Bytes32::new(b.to_be_bytes()), )] } @@ -224,8 +255,10 @@ pub fn serialize_to_storage_slots( type_size_in_bytes, ty.as_string(context) ); + + let storage_key = get_storage_key(storage_field_names, key, experimental); (0..(type_size_in_bytes + 31) / 32) - .map(|i| add_to_b256(get_storage_key(storage_field_names.clone(), key.clone()), i)) + .map(|i| add_to_b256(storage_key, i)) .zip((0..packed.len() / 4).map(|i| { Bytes32::new( Vec::from_iter((0..4).flat_map(|j| *packed[4 * i + j])) diff --git a/sway-core/src/language/ty/declaration/storage.rs b/sway-core/src/language/ty/declaration/storage.rs index 23e4b7a09ba..abc5a67b20c 100644 --- a/sway-core/src/language/ty/declaration/storage.rs +++ b/sway-core/src/language/ty/declaration/storage.rs @@ -8,8 +8,10 @@ use sway_types::{Ident, Named, Span, Spanned}; use crate::{ engine_threading::*, - language::{parsed::StorageDeclaration, ty::*}, + ir_generation::storage::get_storage_key_string, + language::parsed::StorageDeclaration, transform::{self}, + ty::*, type_system::*, Namespace, }; @@ -252,6 +254,22 @@ pub struct TyStorageField { pub attributes: transform::AttributesMap, } +impl TyStorageField { + /// Returns the full name of the [TyStorageField], consisting + /// of its name preceded by its full namespace path. + /// E.g., "storage::ns1::ns1.name". + pub fn full_name(&self) -> String { + get_storage_key_string( + &self + .namespace_names + .iter() + .map(|i| i.as_str().to_string()) + .chain(vec![self.name.as_str().to_string()]) + .collect::>(), + ) + } +} + impl EqWithEngines for TyStorageField {} impl PartialEqWithEngines for TyStorageField { fn eq(&self, other: &Self, ctx: &PartialEqWithEnginesContext) -> bool { diff --git a/sway-core/src/semantic_analysis/ast_node/declaration/declaration.rs b/sway-core/src/semantic_analysis/ast_node/declaration/declaration.rs index 0f965bd0d4e..b063fd53028 100644 --- a/sway-core/src/semantic_analysis/ast_node/declaration/declaration.rs +++ b/sway-core/src/semantic_analysis/ast_node/declaration/declaration.rs @@ -441,22 +441,32 @@ impl TyDecl { let initializer = ty::TyExpression::type_check(handler, ctx.by_ref(), &initializer)?; - let mut key_ty_expression = None; - if let Some(key_expression) = key_expression { - let mut key_ctx = - ctx.with_type_annotation(engines.te().id_of_b256()); - - key_ty_expression = Some(ty::TyExpression::type_check( - handler, - key_ctx.by_ref(), - &key_expression, - )?); - } + let key_expression = match key_expression { + Some(key_expression) => { + let key_ctx = ctx + .with_type_annotation(engines.te().id_of_b256()) + .with_help_text("Storage keys must have type \"b256\"."); + + // TODO: Remove the `handler.scope` once https://github.com/FuelLabs/sway/issues/5606 gets solved. + // We need it here so that we can short-circuit in case of a `TypeMismatch` error which is + // not treated as an error in the `type_check()`'s result. + let typed_expr = handler.scope(|handler| { + ty::TyExpression::type_check( + handler, + key_ctx, + &key_expression, + ) + })?; + + Some(typed_expr) + } + None => None, + }; fields_buf.push(ty::TyStorageField { name, namespace_names: namespace_names.clone(), - key_expression: key_ty_expression, + key_expression, type_argument, initializer, span: field_span, diff --git a/sway-core/src/semantic_analysis/ast_node/declaration/storage.rs b/sway-core/src/semantic_analysis/ast_node/declaration/storage.rs index 08e0984b7ed..7df2bb722d4 100644 --- a/sway-core/src/semantic_analysis/ast_node/declaration/storage.rs +++ b/sway-core/src/semantic_analysis/ast_node/declaration/storage.rs @@ -4,8 +4,7 @@ use crate::{ decl_engine::parsed_id::ParsedDeclId, fuel_prelude::fuel_tx::StorageSlot, ir_generation::{ - const_eval::compile_constant_expression_to_constant, - storage::{get_storage_key_string, serialize_to_storage_slots}, + const_eval::compile_constant_expression_to_constant, storage::serialize_to_storage_slots, }, language::{ parsed::StorageDeclaration, @@ -54,32 +53,27 @@ impl ty::TyStorageDecl { let slots = f.get_initialized_storage_slots(engines, context, md_mgr, module); // Check if slot with same key was already used and throw warning. - if let Ok(slots) = slots.clone() { - for s in slots.into_iter() { + if let Ok(slots) = &slots { + for s in slots.iter() { if let Some(old_field) = slot_fields.insert(*s.key(), f.clone()) { handler.emit_warn(CompileWarning { span: f.span(), warning_content: sway_error::warning::Warning::DuplicatedStorageKey { - key: format!("{:X} ", s.key()), - field1: get_storage_key_string( - old_field - .namespace_names - .iter() - .map(|i| i.as_str().to_string()) - .chain(vec![old_field - .name - .as_str() - .to_string()]) - .collect::>(), - ), - field2: get_storage_key_string( - f.namespace_names - .iter() - .map(|i| i.as_str().to_string()) - .chain(vec![f.name.as_str().to_string()]) - .collect::>(), - ), + first_field: (&old_field.name).into(), + first_field_full_name: old_field.full_name(), + first_field_key_is_compiler_generated: old_field + .key_expression + .is_none(), + second_field: (&f.name).into(), + second_field_full_name: f.full_name(), + second_field_key_is_compiler_generated: f + .key_expression + .is_none(), + key: format!("0x{:x}", s.key()), + experimental_storage_domains: context + .experimental + .storage_domains, }, }) } @@ -151,7 +145,7 @@ impl ty::TyStorageField { Ok(Some(key)) } else { Err(CompileError::Internal( - "Expected B256 key", + "Storage keys must have type \"b256\".", key_expression.span.clone(), )) } diff --git a/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/enum_instantiation.rs b/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/enum_instantiation.rs index 4da63001bb4..742cadb1691 100644 --- a/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/enum_instantiation.rs +++ b/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/enum_instantiation.rs @@ -136,9 +136,9 @@ pub(crate) fn instantiate_enum( .with_help_text(help_text) .with_type_annotation(enum_variant_type_id); - // TODO-IG: Remove the `handler.scope` once https://github.com/FuelLabs/sway/issues/5606 gets solved. - // We need it here so that we can short-circuit in case of a `TypeMismatch` error which is - // not treated as an error in the `type_check()`'s result. + // TODO: Remove the `handler.scope` once https://github.com/FuelLabs/sway/issues/5606 gets solved. + // We need it here so that we can short-circuit in case of a `TypeMismatch` error which is + // not treated as an error in the `type_check()`'s result. let typed_expr = handler .scope(|handler| ty::TyExpression::type_check(handler, enum_ctx, single_expr))?; diff --git a/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/struct_instantiation.rs b/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/struct_instantiation.rs index 47c190a0c2b..bf52842ea81 100644 --- a/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/struct_instantiation.rs +++ b/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/struct_instantiation.rs @@ -397,9 +397,9 @@ fn type_check_field_arguments( .with_type_annotation(struct_field.type_argument.type_id) .with_unify_generic(true); - // TODO-IG: Remove the `handler.scope` once https://github.com/FuelLabs/sway/issues/5606 gets solved. - // We need it here so that we can short-circuit in case of a `TypeMismatch` error which is - // not treated as an error in the `type_check()`'s result. + // TODO: Remove the `handler.scope` once https://github.com/FuelLabs/sway/issues/5606 gets solved. + // We need it here so that we can short-circuit in case of a `TypeMismatch` error which is + // not treated as an error in the `type_check()`'s result. let typed_expr = handler .scope(|handler| ty::TyExpression::type_check(handler, ctx, &field.value)); diff --git a/sway-error/src/warning.rs b/sway-error/src/warning.rs index 78a4ac8953b..dce69c85805 100644 --- a/sway-error/src/warning.rs +++ b/sway-error/src/warning.rs @@ -1,4 +1,7 @@ -use crate::diagnostic::{Code, Diagnostic, Hint, Issue, Reason, ToDiagnostic}; +use crate::{ + diagnostic::{Code, Diagnostic, Hint, Issue, Reason, ToDiagnostic}, + formatting::Indent, +}; use core::fmt; @@ -128,9 +131,15 @@ pub enum Warning { message: String, }, DuplicatedStorageKey { + first_field: IdentUnique, + first_field_full_name: String, + first_field_key_is_compiler_generated: bool, + second_field: IdentUnique, + second_field_full_name: String, + second_field_key_is_compiler_generated: bool, key: String, - field1: String, - field2: String, + // True if the experimental feature `storage_domains` is used. + experimental_storage_domains: bool, }, } @@ -279,7 +288,8 @@ impl fmt::Display for Warning { You can enable the new behavior with the --experimental-private-modules flag, which will become the default behavior in a later release. More details are available in the related RFC: https://github.com/FuelLabs/sway-rfcs/blob/master/rfcs/0008-private-modules.md"), UsingDeprecated { message } => write!(f, "{}", message), - DuplicatedStorageKey { key, field1, field2 } => write!(f, "Two storage fields are using the same storage key.\nFirst field: {field1}\nSecond field: {field2}\nKey: {key}"), + DuplicatedStorageKey { first_field_full_name, second_field_full_name, key, .. } => + write!(f, "Two storage fields have the same storage key.\nFirst field: {first_field_full_name}\nSecond field: {second_field_full_name}\nKey: {key}"), } } } @@ -412,6 +422,58 @@ impl ToDiagnostic for CompileWarning { "Consider adding assembly instructions or a return register to the ASM block, or removing the block altogether.".to_string(), ], }, + DuplicatedStorageKey { first_field, first_field_full_name, first_field_key_is_compiler_generated, second_field, second_field_full_name, second_field_key_is_compiler_generated, key, experimental_storage_domains } => Diagnostic { + reason: Some(Reason::new(code(1), "Two storage fields have the same storage key".to_string())), + issue: Issue::warning( + source_engine, + first_field.span(), + format!("\"{first_field_full_name}\" has the same storage key as \"{second_field_full_name}\"."), + ), + hints: vec![ + Hint::info( + source_engine, + second_field.span(), + format!("\"{second_field_full_name}\" is declared here."), + ), + ], + help: vec![ + if *first_field_key_is_compiler_generated || *second_field_key_is_compiler_generated { + format!("The key of \"{}\" is generated by the compiler using the following formula:", + if *first_field_key_is_compiler_generated { + first_field_full_name + } else { + second_field_full_name + } + ) + } else { + "Both keys are explicitly defined by using the `in` keyword.".to_string() + }, + if *first_field_key_is_compiler_generated || *second_field_key_is_compiler_generated { + if *experimental_storage_domains { + format!("{}sha256((0u8, \"{}\"))", + Indent::Single, + if *first_field_key_is_compiler_generated { + first_field_full_name + } else { + second_field_full_name + } + ) + } else { + format!("{}sha256(\"{}\")", + Indent::Single, + if *first_field_key_is_compiler_generated { + first_field_full_name + } else { + second_field_full_name + } + ) + } + } else { + Diagnostic::help_none() + }, + format!("The common key is: {key}.") + ], + }, _ => Diagnostic { // TODO: Temporary we use self here to achieve backward compatibility. // In general, self must not be used and will not be used once we diff --git a/sway-features/src/lib.rs b/sway-features/src/lib.rs index 55d50920891..fdff644741a 100644 --- a/sway-features/src/lib.rs +++ b/sway-features/src/lib.rs @@ -131,6 +131,8 @@ impl ExperimentalFeatures { features! { new_encoding = true, "https://github.com/FuelLabs/sway/issues/5727", + storage_domains = false, + "https://github.com/FuelLabs/sway/issues/6701", } #[derive(Clone, Debug, Default, Parser)] @@ -228,6 +230,7 @@ mod tests { let mut features = ExperimentalFeatures { new_encoding: false, + ..Default::default() }; std::env::set_var("FORC_EXPERIMENTAL", "new_encoding"); diff --git a/sway-ir/tests/tests.rs b/sway-ir/tests/tests.rs index 743b3523977..5e6ccaeaa8f 100644 --- a/sway-ir/tests/tests.rs +++ b/sway-ir/tests/tests.rs @@ -29,6 +29,8 @@ fn run_tests bool>(sub_dir: &str, opt_fn: F) { let experimental = ExperimentalFeatures { new_encoding: false, + // TODO: Properly support experimental features in IR tests. + ..Default::default() }; let mut ir = sway_ir::parser::parse(&input, &source_engine, experimental).unwrap_or_else( diff --git a/sway-lib-std/src/storage/storage_map.sw b/sway-lib-std/src/storage/storage_map.sw index 360ed95ade3..4d7aca969ae 100644 --- a/sway-lib-std/src/storage/storage_map.sw +++ b/sway-lib-std/src/storage/storage_map.sw @@ -6,6 +6,22 @@ use ::result::Result; use ::storage::storage_api::*; use ::storage::storage_key::*; +/// The storage domain value of the [StorageMap]. +/// +/// Storage slots of elements contained within a [StorageMap] +/// are calculated based on developers' or users' input (the key). +/// +/// To ensure that pre-images used to calculate storage slots can never +/// be the same as a pre-image of a compiler generated key of a storage +/// field, we prefix the pre-images with a single byte that denotes +/// the storage map domain. +/// +/// The domain prefix for the [StorageMap] is 1u8. +/// +/// For detailed elaboration see: https://github.com/FuelLabs/sway/issues/6317 +#[cfg(experimental_storage_domains = true)] +const STORAGE_MAP_DOMAIN: u8 = 1; + /// Errors pertaining to the `StorageMap` struct. pub enum StorageMapError { /// Indicates that a value already exists for the key. @@ -51,7 +67,7 @@ where where K: Hash, { - let key = sha256((key, self.field_id())); + let key = self.get_slot_key(key); write::(key, 0, value); } @@ -85,7 +101,7 @@ where where K: Hash, { - let key = sha256((key, self.field_id())); + let key = self.get_slot_key(key); StorageKey::::new(key, 0, key) } @@ -124,7 +140,7 @@ where where K: Hash, { - let key = sha256((key, self.field_id())); + let key = self.get_slot_key(key); clear::(key, 0) } @@ -175,7 +191,7 @@ where where K: Hash, { - let key = sha256((key, self.field_id())); + let key = self.get_slot_key(key); let val = read::(key, 0); @@ -189,4 +205,14 @@ where } } } + + #[cfg(experimental_storage_domains = false)] + fn get_slot_key(self, key: K) -> b256 { + sha256((key, self.field_id())) + } + + #[cfg(experimental_storage_domains = true)] + fn get_slot_key(self, key: K) -> b256 { + sha256((STORAGE_MAP_DOMAIN, key, self.field_id())) + } } diff --git a/sway-utils/src/constants.rs b/sway-utils/src/constants.rs index 00214945ed5..c0f8b6938a9 100644 --- a/sway-utils/src/constants.rs +++ b/sway-utils/src/constants.rs @@ -7,7 +7,8 @@ pub const USER_FORC_DIRECTORY: &str = ".forc"; pub const SRC_DIR: &str = "src"; pub const DEFAULT_NODE_URL: &str = "http://127.0.0.1:4000"; pub const LANGUAGE_NAME: &str = "Sway"; -pub const STORAGE_DOMAIN: &str = "storage"; +pub const STORAGE_DOMAIN: [u8; 1] = [0u8]; +pub const STORAGE_TOP_LEVEL_NAMESPACE: &str = "storage"; pub const STORAGE_NAMESPACE_SEPARATOR: &str = "::"; pub const STORAGE_FIELD_SEPARATOR: &str = "."; pub const STRUCT_FIELD_SEPARATOR: &str = "."; diff --git a/test/src/e2e_vm_tests/harness.rs b/test/src/e2e_vm_tests/harness.rs index 164d442e7bf..31dbcda4b48 100644 --- a/test/src/e2e_vm_tests/harness.rs +++ b/test/src/e2e_vm_tests/harness.rs @@ -398,22 +398,28 @@ pub(crate) fn test_json_abi( } if fs::metadata(oracle_path.clone()).is_err() { - bail!("JSON ABI oracle file does not exist for this test."); + bail!( + "JSON ABI oracle file does not exist for this test\nExpected oracle path: {}", + &oracle_path + ); } if fs::metadata(output_path.clone()).is_err() { - bail!("JSON ABI output file does not exist for this test."); + bail!( + "JSON ABI output file does not exist for this test\nExpected output path: {}", + &output_path + ); } - let oracle_contents = - fs::read_to_string(&oracle_path).expect("Something went wrong reading the file."); - let output_contents = - fs::read_to_string(&output_path).expect("Something went wrong reading the file."); + let oracle_contents = fs::read_to_string(&oracle_path) + .expect("Something went wrong reading the JSON ABI oracle file."); + let output_contents = fs::read_to_string(&output_path) + .expect("Something went wrong reading the JSON ABI output file."); if oracle_contents != output_contents { - println!("Mismatched ABI JSON output [{oracle_path}] versus [{output_path}]",); - println!( - "{}", + bail!( + "Mismatched ABI JSON output.\nOracle path: {}\nOutput path: {}\n{}", + oracle_path, + output_path, prettydiff::diff_lines(&oracle_contents, &output_contents) ); - bail!("Mismatched ABI JSON output."); } Ok(()) } @@ -435,29 +441,47 @@ fn emit_json_abi(file_name: &str, built_package: &BuiltPackage) -> Result<()> { Ok(()) } -pub(crate) fn test_json_storage_slots(file_name: &str, built_package: &BuiltPackage) -> Result<()> { +pub(crate) fn test_json_storage_slots( + file_name: &str, + built_package: &BuiltPackage, + suffix: &Option, +) -> Result<()> { emit_json_storage_slots(file_name, built_package)?; let manifest_dir = env!("CARGO_MANIFEST_DIR"); let oracle_path = format!( - "{}/src/e2e_vm_tests/test_programs/{}/{}", - manifest_dir, file_name, "json_storage_slots_oracle.json" + "{}/src/e2e_vm_tests/test_programs/{}/json_storage_slots_oracle.{}json", + manifest_dir, + file_name, + suffix + .as_ref() + .unwrap() + .strip_prefix("test") + .unwrap() + .strip_suffix("toml") + .unwrap() + .trim_start_matches('.') ); let output_path = format!( "{}/src/e2e_vm_tests/test_programs/{}/{}", manifest_dir, file_name, "json_storage_slots_output.json" ); if fs::metadata(oracle_path.clone()).is_err() { - bail!("JSON storage slots oracle file does not exist for this test."); + bail!("JSON storage slots oracle file does not exist for this test.\nExpected oracle path: {}", &oracle_path); } if fs::metadata(output_path.clone()).is_err() { - bail!("JSON storage slots output file does not exist for this test."); + bail!("JSON storage slots output file does not exist for this test.\nExpected output path: {}", &output_path); } - let oracle_contents = - fs::read_to_string(oracle_path).expect("Something went wrong reading the file."); - let output_contents = - fs::read_to_string(output_path).expect("Something went wrong reading the file."); + let oracle_contents = fs::read_to_string(oracle_path.clone()) + .expect("Something went wrong reading the JSON storage slots oracle file."); + let output_contents = fs::read_to_string(output_path.clone()) + .expect("Something went wrong reading the JSON storage slots output file."); if oracle_contents != output_contents { - bail!("Mismatched storage slots JSON output."); + bail!( + "Mismatched storage slots JSON output.\nOracle path: {}\nOutput path: {}\n{}", + oracle_path, + output_path, + prettydiff::diff_lines(&oracle_contents, &output_contents) + ); } Ok(()) } diff --git a/test/src/e2e_vm_tests/mod.rs b/test/src/e2e_vm_tests/mod.rs index 62dc360fea1..725056b9ac7 100644 --- a/test/src/e2e_vm_tests/mod.rs +++ b/test/src/e2e_vm_tests/mod.rs @@ -515,7 +515,7 @@ impl TestContext { if validate_storage_slots { for (name, built_pkg) in &compiled_pkgs { let (result, out) = run_and_capture_output(|| async { - harness::test_json_storage_slots(name, built_pkg) + harness::test_json_storage_slots(name, built_pkg, &suffix) }) .await; result?; @@ -602,7 +602,15 @@ impl TestContext { ))); } } - _ => todo!(), + TestResult::ReturnData(_) => { + todo!("Test result `ReturnData` is currently not implemented.") + } + TestResult::Return(_) => { + todo!("Test result `Return` is currently not implemented.") + } + TestResult::Revert(_) => { + todo!("Test result `Revert` is currently not implemented.") + } }, Receipt::ReturnData { data, .. } => match expected_result.unwrap() { TestResult::ReturnData(v) => { @@ -612,7 +620,15 @@ impl TestContext { ))); } } - _ => todo!(), + TestResult::Result(_) => { + todo!("Test result `Result` is currently not implemented.") + } + TestResult::Return(_) => { + todo!("Test result `Return` is currently not implemented.") + } + TestResult::Revert(_) => { + todo!("Test result `Revert` is currently not implemented.") + } }, _ => {} }; diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/invalid_cfg_arg/stdout.snap b/test/src/e2e_vm_tests/test_programs/should_fail/invalid_cfg_arg/stdout.snap index fee2b903ecd..84c0fa58caf 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/invalid_cfg_arg/stdout.snap +++ b/test/src/e2e_vm_tests/test_programs/should_fail/invalid_cfg_arg/stdout.snap @@ -11,7 +11,7 @@ warning | 1 | predicate; 2 | #[cfg(c)] a - | --- Unexpected attribute value: "c" for attribute: "cfg" expected value "target" or "program_type" or "experimental_new_encoding" + | --- Unexpected attribute value: "c" for attribute: "cfg" expected value "target" or "program_type" or "experimental_new_encoding" or "experimental_storage_domains" | ____ diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/storage_invalid_storage_key_type/Forc.lock b/test/src/e2e_vm_tests/test_programs/should_fail/storage_invalid_storage_key_type/Forc.lock new file mode 100644 index 00000000000..6024e958c64 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_fail/storage_invalid_storage_key_type/Forc.lock @@ -0,0 +1,8 @@ +[[package]] +name = "core" +source = "path+from-root-C0C563B172E50A8D" + +[[package]] +name = "storage_invalid_storage_key_type" +source = "member" +dependencies = ["core"] diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/storage_invalid_storage_key_type/Forc.toml b/test/src/e2e_vm_tests/test_programs/should_fail/storage_invalid_storage_key_type/Forc.toml new file mode 100644 index 00000000000..18a5527966d --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_fail/storage_invalid_storage_key_type/Forc.toml @@ -0,0 +1,9 @@ +[project] +authors = ["Fuel Labs "] +entry = "main.sw" +license = "Apache-2.0" +name = "storage_invalid_storage_key_type" +implicit-std = false + +[dependencies] +core = { path = "../../../../../../sway-lib-core" } diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/storage_invalid_storage_key_type/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_fail/storage_invalid_storage_key_type/src/main.sw new file mode 100644 index 00000000000..18a4f599f52 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_fail/storage_invalid_storage_key_type/src/main.sw @@ -0,0 +1,9 @@ +contract; + +fn get_u256() -> u256 { + 0x0u256 +} + +storage { + field in get_u256(): u64 = 0, +} \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/storage_invalid_storage_key_type/test.toml b/test/src/e2e_vm_tests/test_programs/should_fail/storage_invalid_storage_key_type/test.toml new file mode 100644 index 00000000000..150a184e449 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_fail/storage_invalid_storage_key_type/test.toml @@ -0,0 +1,17 @@ +category = "fail" + +#check: $()error +#check: $()field in get_u256(): u64 = 0, +#nextln: $()Mismatched types. +#nextln: $()expected: b256 +#nextln: $()found: u256. +#nextln: $()Function return type does not match up with local type annotation. + +#check: $()error +#check: $()field in get_u256(): u64 = 0, +#nextln: $()Mismatched types. +#nextln: $()expected: b256 +#nextln: $()found: u256. +#nextln: $()Storage keys must have type "b256". + +#check: $()2 errors. \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/duplicated_storage_keys/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/duplicated_storage_keys/src/main.sw index 54c8ccf3246..2bfa29631e6 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/duplicated_storage_keys/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/duplicated_storage_keys/src/main.sw @@ -2,12 +2,24 @@ contract; storage { f1:u64 = 1, + #[cfg(experimental_storage_domains = true)] + f2 in 0xcecf0a910789de762c699a85a66835df1662df633238cbb25804b7f78640747b: u64 = 2, + #[cfg(experimental_storage_domains = false)] f2 in 0x36389d1013642dcb070193fc48b0316e9dfdfef1860096dc5957e3eb44430b83: u64 = 2, ns1 { f3 in 0x5f4c20ce4bd128e5393a4c2b82007dac795fa0006d01acf8db4c42632bc680ca: u64 = 2, }, ns2 { f4 in 0x5f4c20ce4bd128e5393a4c2b82007dac795fa0006d01acf8db4c42632bc680ca: u64 = 2, - } + }, + ns3 { + #[cfg(experimental_storage_domains = true)] + f5 in 0x41e70e0fdfa49becc40cbfd5c057ab0540e8844f3d737fa3b1ab21a564b48069: u64 = 3, + #[cfg(experimental_storage_domains = false)] + f5 in 0xa49ebab6739a90f7658bbbdc2ed139942bd0b7be2e89aa8d90a953c45bf7a211: u64 = 3, + }, + ns4 { + f6: u64 = 4, + }, } diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/duplicated_storage_keys/test.storage_domains.toml b/test/src/e2e_vm_tests/test_programs/should_pass/language/duplicated_storage_keys/test.storage_domains.toml new file mode 100644 index 00000000000..4e181f7e13d --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/duplicated_storage_keys/test.storage_domains.toml @@ -0,0 +1,30 @@ +category = "compile" +experimental = { storage_domains = true } + +# check: $()Two storage fields have the same storage key +# check: $()f1:u64 = 1, +# nextln: $()"storage.f1" has the same storage key as "storage.f2". +# check: $()f2 in 0xcecf0a910789de762c699a85a66835df1662df633238cbb25804b7f78640747b: u64 = 2, +# nextln: $()"storage.f2" is declared here. +# check: $()The key of "storage.f1" is generated by the compiler using the following formula: +# nextln: $()sha256((0u8, "storage.f1")) +# nextln: $()The common key is: 0xcecf0a910789de762c699a85a66835df1662df633238cbb25804b7f78640747b. + +# check: $()Two storage fields have the same storage key +# check: $()f3 in 0x5f4c20ce4bd128e5393a4c2b82007dac795fa0006d01acf8db4c42632bc680ca: u64 = 2, +# nextln: $()"storage::ns1.f3" has the same storage key as "storage::ns2.f4". +# check: $()f4 in 0x5f4c20ce4bd128e5393a4c2b82007dac795fa0006d01acf8db4c42632bc680ca: u64 = 2, +# nextln: $()"storage::ns2.f4" is declared here. +# check: $()Both keys are explicitly defined by using the `in` keyword. +# nextln: $()The common key is: 0x5f4c20ce4bd128e5393a4c2b82007dac795fa0006d01acf8db4c42632bc680ca. + +# check: $()Two storage fields have the same storage key +# check: $()f5 in 0x41e70e0fdfa49becc40cbfd5c057ab0540e8844f3d737fa3b1ab21a564b48069: u64 = 3, +# nextln: $()"storage::ns3.f5" has the same storage key as "storage::ns4.f6". +# check: $()f6: u64 = 4, +# nextln: $()"storage::ns4.f6" is declared here. +# check: $()The key of "storage::ns4.f6" is generated by the compiler using the following formula: +# nextln: $()sha256((0u8, "storage::ns4.f6")) +# nextln: $()The common key is: 0x41e70e0fdfa49becc40cbfd5c057ab0540e8844f3d737fa3b1ab21a564b48069. + +expected_warnings = 9 diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/duplicated_storage_keys/test.toml b/test/src/e2e_vm_tests/test_programs/should_pass/language/duplicated_storage_keys/test.toml index 8e5e7a86ef3..30c36d8b5f8 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/duplicated_storage_keys/test.toml +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/duplicated_storage_keys/test.toml @@ -1,13 +1,29 @@ category = "compile" -# check: $()Two storage fields are using the same storage key. -# nextln: $()First field: storage.f1 -# nextln: $()Second field: storage.f2 -# nextln: $()Key: 36389D1013642DCB070193FC48B0316E9DFDFEF1860096DC5957E3EB44430B83 +# check: $()Two storage fields have the same storage key +# check: $()f1:u64 = 1, +# nextln: $()"storage.f1" has the same storage key as "storage.f2". +# check: $()f2 in 0x36389d1013642dcb070193fc48b0316e9dfdfef1860096dc5957e3eb44430b83: u64 = 2, +# nextln: $()"storage.f2" is declared here. +# check: $()The key of "storage.f1" is generated by the compiler using the following formula: +# nextln: $()sha256("storage.f1") +# nextln: $()The common key is: 0x36389d1013642dcb070193fc48b0316e9dfdfef1860096dc5957e3eb44430b83. -# check: $()Two storage fields are using the same storage key. -# nextln: $()First field: storage::ns1.f3 -# nextln: $()Second field: storage::ns2.f4 -# nextln: $()Key: 5F4C20CE4BD128E5393A4C2B82007DAC795FA0006D01ACF8DB4C42632BC680CA +# check: $()Two storage fields have the same storage key +# check: $()f3 in 0x5f4c20ce4bd128e5393a4c2b82007dac795fa0006d01acf8db4c42632bc680ca: u64 = 2, +# nextln: $()"storage::ns1.f3" has the same storage key as "storage::ns2.f4". +# check: $()f4 in 0x5f4c20ce4bd128e5393a4c2b82007dac795fa0006d01acf8db4c42632bc680ca: u64 = 2, +# nextln: $()"storage::ns2.f4" is declared here. +# check: $()Both keys are explicitly defined by using the `in` keyword. +# nextln: $()The common key is: 0x5f4c20ce4bd128e5393a4c2b82007dac795fa0006d01acf8db4c42632bc680ca. -expected_warnings = 6 +# check: $()Two storage fields have the same storage key +# check: $()f5 in 0xa49ebab6739a90f7658bbbdc2ed139942bd0b7be2e89aa8d90a953c45bf7a211: u64 = 3, +# nextln: $()"storage::ns3.f5" has the same storage key as "storage::ns4.f6". +# check: $()f6: u64 = 4, +# nextln: $()"storage::ns4.f6" is declared here. +# check: $()The key of "storage::ns4.f6" is generated by the compiler using the following formula: +# nextln: $()sha256("storage::ns4.f6") +# nextln: $()The common key is: 0xa49ebab6739a90f7658bbbdc2ed139942bd0b7be2e89aa8d90a953c45bf7a211. + +expected_warnings = 9 diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_basic_storage/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_basic_storage/src/main.sw index 1ed97f22e9d..d7218234e92 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_basic_storage/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_basic_storage/src/main.sw @@ -4,7 +4,7 @@ use basic_storage_abi::{BasicStorage, Quad}; #[cfg(experimental_new_encoding = false)] const CONTRACT_ID = 0x94db39f409a31b9f2ebcadeea44378e419208c20de90f5d8e1e33dc1523754cb; #[cfg(experimental_new_encoding = true)] -const CONTRACT_ID = 0xb48002b23e2861d62237348199ff111e310f5dd10298a01562e3a4d41cb6aae6; // AUTO-CONTRACT-ID ../../test_contracts/basic_storage --release +const CONTRACT_ID = 0x27857d650234acd05b5fa9a9bc34abf76fa66d2e6ce8c8b24416805b75005bd0; // AUTO-CONTRACT-ID ../../test_contracts/basic_storage --release fn main() -> u64 { let addr = abi(BasicStorage, CONTRACT_ID); diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_storage_enum/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_storage_enum/src/main.sw index af5bdc4cd47..06673118a96 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_storage_enum/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_storage_enum/src/main.sw @@ -5,7 +5,7 @@ use storage_enum_abi::*; #[cfg(experimental_new_encoding = false)] const CONTRACT_ID = 0xc601d11767195485a6654d566c67774134668863d8c797a8c69e8778fb1f89e9; #[cfg(experimental_new_encoding = true)] -const CONTRACT_ID = 0x434f5f10c3270134e51a1963f610286466e448c1c6109e4f20502939c7a3d429; // AUTO-CONTRACT-ID ../../test_contracts/storage_enum_contract --release +const CONTRACT_ID = 0x47084a8c1eb453b655842e1b3067ee1f0d9081052bd74ac606efa6ae9a56d901; // AUTO-CONTRACT-ID ../../test_contracts/storage_enum_contract --release fn main() -> u64 { let caller = abi(StorageEnum, CONTRACT_ID); diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/storage_slot_key_calculation/Forc.lock b/test/src/e2e_vm_tests/test_programs/should_pass/storage_slot_key_calculation/Forc.lock new file mode 100644 index 00000000000..fe96407a20f --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/storage_slot_key_calculation/Forc.lock @@ -0,0 +1,13 @@ +[[package]] +name = "core" +source = "path+from-root-90F1067CD9AC8A94" + +[[package]] +name = "std" +source = "path+from-root-90F1067CD9AC8A94" +dependencies = ["core"] + +[[package]] +name = "storage_slot_key_calculation" +source = "member" +dependencies = ["std"] diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/storage_slot_key_calculation/Forc.toml b/test/src/e2e_vm_tests/test_programs/should_pass/storage_slot_key_calculation/Forc.toml new file mode 100644 index 00000000000..cb479a470ea --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/storage_slot_key_calculation/Forc.toml @@ -0,0 +1,8 @@ +[project] +name = "storage_slot_key_calculation" +authors = ["Fuel Labs "] +entry = "main.sw" +license = "Apache-2.0" + +[dependencies] +std = { path = "../../../../../../sway-lib-std" } diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/storage_slot_key_calculation/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/storage_slot_key_calculation/src/main.sw new file mode 100644 index 00000000000..a4810dff242 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/storage_slot_key_calculation/src/main.sw @@ -0,0 +1,53 @@ +contract; + +use std::hash::*; + +storage { + a: u8 = 0, + b: u8 = 0, + ns1 { + a: u8 = 0, + b: u8 = 0, + }, + ns2 { + ns3 { + a: u8 = 0, + b: u8 = 0, + }, + }, +} + +abi TestStorageKeyCalculation { + #[storage(read)] + fn test_storage_key_calculation(); +} + +impl TestStorageKeyCalculation for Contract { + #[cfg(experimental_storage_domains = false)] + #[storage(read)] + fn test_storage_key_calculation() { + assert_eq(storage.a.slot(), sha256("storage.a")); + assert_eq(storage.b.slot(), sha256("storage.b")); + assert_eq(storage::ns1.a.slot(), sha256("storage::ns1.a")); + assert_eq(storage::ns1.b.slot(), sha256("storage::ns1.b")); + assert_eq(storage::ns2::ns3.a.slot(), sha256("storage::ns2::ns3.a")); + assert_eq(storage::ns2::ns3.b.slot(), sha256("storage::ns2::ns3.b")); + } + + #[cfg(experimental_storage_domains = true)] + #[storage(read)] + fn test_storage_key_calculation() { + assert_eq(storage.a.slot(), sha256((0u8, "storage.a"))); + assert_eq(storage.b.slot(), sha256((0u8, "storage.b"))); + assert_eq(storage::ns1.a.slot(), sha256((0u8, "storage::ns1.a"))); + assert_eq(storage::ns1.b.slot(), sha256((0u8, "storage::ns1.b"))); + assert_eq(storage::ns2::ns3.a.slot(), sha256((0u8, "storage::ns2::ns3.a"))); + assert_eq(storage::ns2::ns3.b.slot(), sha256((0u8, "storage::ns2::ns3.b"))); + } +} + +#[test] +fn test() { + let caller = abi(TestStorageKeyCalculation, CONTRACT_ID); + caller.test_storage_key_calculation(); +} \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/storage_slot_key_calculation/test.storage_domains.toml b/test/src/e2e_vm_tests/test_programs/should_pass/storage_slot_key_calculation/test.storage_domains.toml new file mode 100644 index 00000000000..0890b8a8510 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/storage_slot_key_calculation/test.storage_domains.toml @@ -0,0 +1 @@ +experimental = { storage_domains = true } diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/storage_slot_key_calculation/test.toml b/test/src/e2e_vm_tests/test_programs/should_pass/storage_slot_key_calculation/test.toml new file mode 100644 index 00000000000..c82484373af --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/storage_slot_key_calculation/test.toml @@ -0,0 +1,2 @@ +category = "unit_tests_pass" +expected_warnings = 1 diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/basic_storage/json_abi_oracle.storage_domains.json b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/basic_storage/json_abi_oracle.storage_domains.json new file mode 100644 index 00000000000..2f821ed58f1 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/basic_storage/json_abi_oracle.storage_domains.json @@ -0,0 +1,297 @@ +{ + "concreteTypes": [ + { + "concreteTypeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d", + "type": "()" + }, + { + "concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b", + "type": "b256" + }, + { + "concreteTypeId": "d852149004cc9ec0bbe7dc4e37bffea1d41469b759512b6136f2e865a4c06e7d", + "metadataTypeId": 0, + "type": "enum std::option::Option", + "typeArguments": [ + "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + ] + }, + { + "concreteTypeId": "6906df92e2e485dde893b7d719d621b8910422e7c468f99caa5920e6ac19d9c6", + "metadataTypeId": 3, + "type": "struct basic_storage_abi::Quad" + }, + { + "concreteTypeId": "7880d311d30802b48bd6a100a31adb5af17f94bff12daee556d4f02c1ac5b2ff", + "metadataTypeId": 5, + "type": "struct std::vec::Vec", + "typeArguments": [ + "6906df92e2e485dde893b7d719d621b8910422e7c468f99caa5920e6ac19d9c6" + ] + }, + { + "concreteTypeId": "1b5759d94094368cfd443019e7ca5ec4074300e544e5ea993a979f5da627261e", + "type": "u256" + }, + { + "concreteTypeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0", + "type": "u64" + }, + { + "concreteTypeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b", + "type": "u8" + } + ], + "configurables": [], + "encodingVersion": "1", + "functions": [ + { + "attributes": [ + { + "arguments": [ + "read" + ], + "name": "storage" + } + ], + "inputs": [ + { + "concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b", + "name": "storage_key" + } + ], + "name": "get_u64", + "output": "d852149004cc9ec0bbe7dc4e37bffea1d41469b759512b6136f2e865a4c06e7d" + }, + { + "attributes": [ + { + "arguments": [ + "read" + ], + "name": "storage" + } + ], + "inputs": [ + { + "concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b", + "name": "key" + }, + { + "concreteTypeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0", + "name": "slots" + } + ], + "name": "intrinsic_load_quad", + "output": "7880d311d30802b48bd6a100a31adb5af17f94bff12daee556d4f02c1ac5b2ff" + }, + { + "attributes": [ + { + "arguments": [ + "read" + ], + "name": "storage" + } + ], + "inputs": [ + { + "concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b", + "name": "key" + } + ], + "name": "intrinsic_load_word", + "output": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + }, + { + "attributes": [ + { + "arguments": [ + "write" + ], + "name": "storage" + } + ], + "inputs": [ + { + "concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b", + "name": "key" + }, + { + "concreteTypeId": "7880d311d30802b48bd6a100a31adb5af17f94bff12daee556d4f02c1ac5b2ff", + "name": "values" + } + ], + "name": "intrinsic_store_quad", + "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" + }, + { + "attributes": [ + { + "arguments": [ + "write" + ], + "name": "storage" + } + ], + "inputs": [ + { + "concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b", + "name": "key" + }, + { + "concreteTypeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0", + "name": "value" + } + ], + "name": "intrinsic_store_word", + "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" + }, + { + "attributes": [ + { + "arguments": [ + "write" + ], + "name": "storage" + } + ], + "inputs": [ + { + "concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b", + "name": "key" + }, + { + "concreteTypeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0", + "name": "value" + } + ], + "name": "store_u64", + "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" + }, + { + "attributes": [ + { + "arguments": [ + "read", + "write" + ], + "name": "storage" + } + ], + "inputs": [], + "name": "test_storage_exhaustive", + "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" + } + ], + "loggedTypes": [ + { + "concreteTypeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b", + "logId": "14454674236531057292" + }, + { + "concreteTypeId": "1b5759d94094368cfd443019e7ca5ec4074300e544e5ea993a979f5da627261e", + "logId": "1970142151624111756" + }, + { + "concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b", + "logId": "8961848586872524460" + }, + { + "concreteTypeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0", + "logId": "1515152261580153489" + } + ], + "messagesTypes": [], + "metadataTypes": [ + { + "components": [ + { + "name": "None", + "typeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" + }, + { + "name": "Some", + "typeId": 1 + } + ], + "metadataTypeId": 0, + "type": "enum std::option::Option", + "typeParameters": [ + 1 + ] + }, + { + "metadataTypeId": 1, + "type": "generic T" + }, + { + "metadataTypeId": 2, + "type": "raw untyped ptr" + }, + { + "components": [ + { + "name": "v1", + "typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + }, + { + "name": "v2", + "typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + }, + { + "name": "v3", + "typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + }, + { + "name": "v4", + "typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + } + ], + "metadataTypeId": 3, + "type": "struct basic_storage_abi::Quad" + }, + { + "components": [ + { + "name": "ptr", + "typeId": 2 + }, + { + "name": "cap", + "typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + } + ], + "metadataTypeId": 4, + "type": "struct std::vec::RawVec", + "typeParameters": [ + 1 + ] + }, + { + "components": [ + { + "name": "buf", + "typeArguments": [ + { + "name": "", + "typeId": 1 + } + ], + "typeId": 4 + }, + { + "name": "len", + "typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + } + ], + "metadataTypeId": 5, + "type": "struct std::vec::Vec", + "typeParameters": [ + 1 + ] + } + ], + "programType": "contract", + "specVersion": "1" +} \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/basic_storage/json_storage_slots_oracle.storage_domains.json b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/basic_storage/json_storage_slots_oracle.storage_domains.json new file mode 100644 index 00000000000..8c0169567bb --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/basic_storage/json_storage_slots_oracle.storage_domains.json @@ -0,0 +1,58 @@ +[ + { + "key": "040f131e97eaba9c2d25f5c1d6ea9489ce530940dd87d486f8cd9c7ff5360f6c", + "value": "6161616161000000000000000000000000000000000000000000000000000000" + }, + { + "key": "077f64b0ca598a020551265c0faf95f8e860b45700f27c06af3640a123818b17", + "value": "6161000000000000000000000000000000000000000000000000000000000000" + }, + { + "key": "2b46310c8d886cf7d9e4339837ecc696ecfaf2c431e56e725c552b92b11c3bc8", + "value": "0000000000000000000000000000000000000000000000000000000001234567" + }, + { + "key": "30226b031f925fbb2a1ad161ce31b798a684c6f52ed49cf84e244d324eceaf58", + "value": "6161616100000000000000000000000000000000000000000000000000000000" + }, + { + "key": "42e97a774f87c61347e7283755a043a5a896d37e801045e8f5ce538b6d1ce8c8", + "value": "0000000000000000000000000000000000000000000000000000000001234567" + }, + { + "key": "78dabd24c80fc40f05bae92654874f2f77bd13ef803fd55ccf014ff5849cdfd0", + "value": "6161616161610000000000000000000000000000000000000000000000000000" + }, + { + "key": "848a0a618b9c374a4b1b47c59ef2f0a01f5c42bb5e805ffd669412ce283b992a", + "value": "6161616161616161000000000000000000000000000000000000000000000000" + }, + { + "key": "84e44dc0900861559343f0fc02dc0d92f7e87872a50e730a85740b701b162863", + "value": "6161616161616100000000000000000000000000000000000000000000000000" + }, + { + "key": "933a534d4af4c376b0b569e8d8a2c62e635e26f403e124cb91d9c42e83d54373", + "value": "0100000000000000000000000000000000000000000000000000000000000000" + }, + { + "key": "976540acfef542cb328d6679def3e281cdb1a5bbaca7d9e59a30aa74f3952d90", + "value": "6100000000000000000000000000000000000000000000000000000000000000" + }, + { + "key": "9d3f8eb1f2d99b97a2fd6fa68fe7e5a9c5b6734739f8dd84f2ae3da221206a80", + "value": "0000000000000002000000000000000000000000000000000000000000000000" + }, + { + "key": "a42ed3ecc6aaf8d594f165e6c60cdaf172d59436167556f954e6559036736ceb", + "value": "6161610000000000000000000000000000000000000000000000000000000000" + }, + { + "key": "d33763008c92b260fc4381d53aa5976de2b5f991798799fa5edf300bb4a40e02", + "value": "6161616161616161616100000000000000000000000000000000000000000000" + }, + { + "key": "f8fde9e56bb5ab545fdfe17edabb876e6f4cd1b3296d92b266d4acb9ca0b5f79", + "value": "6161616161616161610000000000000000000000000000000000000000000000" + } +] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/basic_storage/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/basic_storage/src/main.sw index 532709bfed7..251577caf5b 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/basic_storage/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/basic_storage/src/main.sw @@ -296,8 +296,6 @@ fn test_storage() { assert_eq(storage::ns1::ns2.c1.read(), NS1_NS2_C1); assert_eq(storage.c1.slot(), C1KEY); - assert_eq(storage.const_b256.slot(), sha256("storage.const_b256")); - assert_eq(storage::ns1::ns2.c1.slot(), sha256("storage::ns1::ns2.c1")); } // If these comparisons are done inline just above then it blows out the register allocator due to diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/basic_storage/test.storage_domains.toml b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/basic_storage/test.storage_domains.toml new file mode 100644 index 00000000000..0890b8a8510 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/basic_storage/test.storage_domains.toml @@ -0,0 +1 @@ +experimental = { storage_domains = true } diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/basic_storage/test.toml b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/basic_storage/test.toml index 8bce24f6a24..c1349fc15dc 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/basic_storage/test.toml +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/basic_storage/test.toml @@ -1,4 +1,4 @@ category = "compile" validate_abi = true validate_storage_slots = true -expected_warnings = 3 +expected_warnings = 2 # TODO-DCA: Set to zero once https://github.com/FuelLabs/sway/issues/5921 is fixed. diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/increment_contract/json_abi_oracle.storage_domains.json b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/increment_contract/json_abi_oracle.storage_domains.json new file mode 100644 index 00000000000..edd98a1f3d1 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/increment_contract/json_abi_oracle.storage_domains.json @@ -0,0 +1,102 @@ +{ + "concreteTypes": [ + { + "concreteTypeId": "d852149004cc9ec0bbe7dc4e37bffea1d41469b759512b6136f2e865a4c06e7d", + "metadataTypeId": 1, + "type": "enum std::option::Option", + "typeArguments": [ + "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + ] + }, + { + "concreteTypeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0", + "type": "u64" + } + ], + "configurables": [], + "encodingVersion": "1", + "functions": [ + { + "attributes": [ + { + "arguments": [ + "read" + ], + "name": "storage" + } + ], + "inputs": [], + "name": "get", + "output": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + }, + { + "attributes": [ + { + "arguments": [ + "read", + "write" + ], + "name": "storage" + } + ], + "inputs": [ + { + "concreteTypeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0", + "name": "increment_by" + } + ], + "name": "increment", + "output": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + }, + { + "attributes": [ + { + "arguments": [ + "read", + "write" + ], + "name": "storage" + } + ], + "inputs": [ + { + "concreteTypeId": "d852149004cc9ec0bbe7dc4e37bffea1d41469b759512b6136f2e865a4c06e7d", + "name": "initial_value" + } + ], + "name": "increment_or_not", + "output": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + } + ], + "loggedTypes": [], + "messagesTypes": [], + "metadataTypes": [ + { + "metadataTypeId": 0, + "type": "()" + }, + { + "components": [ + { + "name": "None", + "typeId": 0 + }, + { + "name": "Some", + "typeId": 2 + } + ], + "metadataTypeId": 1, + "type": "enum std::option::Option", + "typeParameters": [ + 2 + ] + }, + { + "metadataTypeId": 2, + "type": "generic T" + } + ], + "programType": "contract", + "specVersion": "1" +} \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/increment_contract/json_storage_slots_oracle.storage_domains.json b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/increment_contract/json_storage_slots_oracle.storage_domains.json new file mode 100644 index 00000000000..efa6132760a --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/increment_contract/json_storage_slots_oracle.storage_domains.json @@ -0,0 +1,6 @@ +[ + { + "key": "d810923c0d6cc6ed49622594d7368eb1e124753474e3ebd52a66c6c2ecb42642", + "value": "0000000000000000000000000000000000000000000000000000000000000000" + } +] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/increment_contract/test.storage_domains.toml b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/increment_contract/test.storage_domains.toml new file mode 100644 index 00000000000..24be96bbf31 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/increment_contract/test.storage_domains.toml @@ -0,0 +1 @@ +experimental = { storage_domains = true } \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_access_contract/json_abi_oracle.storage_domains.json b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_access_contract/json_abi_oracle.storage_domains.json new file mode 100644 index 00000000000..9a1f9ebd31e --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_access_contract/json_abi_oracle.storage_domains.json @@ -0,0 +1,769 @@ +{ + "concreteTypes": [ + { + "concreteTypeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d", + "type": "()" + }, + { + "concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b", + "type": "b256" + }, + { + "concreteTypeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903", + "type": "bool" + }, + { + "concreteTypeId": "35b24140807b67d1f1675de36775d5d6c62b04f3721f616a9adee739e24c9c15", + "metadataTypeId": 0, + "type": "enum storage_access_abi::E" + }, + { + "concreteTypeId": "893a66eb2f595d7e0cc15e2253da1b6e53fd634ad542b2f1a198a8ae3d8d92b2", + "type": "str[40]" + }, + { + "concreteTypeId": "427fd62288add8763eb5e0c4facf553d877489a3038b29a8a1045e9a853660f0", + "metadataTypeId": 1, + "type": "struct storage_access_abi::S" + }, + { + "concreteTypeId": "74df8abb4a65a07ec7420c0f167703fc6e26c9e43b8036ffacb89d399f13db73", + "metadataTypeId": 2, + "type": "struct storage_access_abi::T" + }, + { + "concreteTypeId": "29881aad8730c5ab11d275376323d8e4ff4179aae8ccb6c13fe4902137e162ef", + "type": "u16" + }, + { + "concreteTypeId": "d7649d428b9ff33d188ecbf38a7e4d8fd167fa01b2e10fe9a8f9308e52f1d7cc", + "type": "u32" + }, + { + "concreteTypeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0", + "type": "u64" + }, + { + "concreteTypeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b", + "type": "u8" + } + ], + "configurables": [], + "encodingVersion": "1", + "functions": [ + { + "attributes": [ + { + "arguments": [ + "read" + ], + "name": "storage" + } + ], + "inputs": [], + "name": "get_boolean", + "output": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903" + }, + { + "attributes": [ + { + "arguments": [ + "read" + ], + "name": "storage" + } + ], + "inputs": [], + "name": "get_e", + "output": "35b24140807b67d1f1675de36775d5d6c62b04f3721f616a9adee739e24c9c15" + }, + { + "attributes": [ + { + "arguments": [ + "read" + ], + "name": "storage" + } + ], + "inputs": [], + "name": "get_e2", + "output": "35b24140807b67d1f1675de36775d5d6c62b04f3721f616a9adee739e24c9c15" + }, + { + "attributes": [ + { + "arguments": [ + "read" + ], + "name": "storage" + } + ], + "inputs": [], + "name": "get_int16", + "output": "29881aad8730c5ab11d275376323d8e4ff4179aae8ccb6c13fe4902137e162ef" + }, + { + "attributes": [ + { + "arguments": [ + "read" + ], + "name": "storage" + } + ], + "inputs": [], + "name": "get_int32", + "output": "d7649d428b9ff33d188ecbf38a7e4d8fd167fa01b2e10fe9a8f9308e52f1d7cc" + }, + { + "attributes": [ + { + "arguments": [ + "read" + ], + "name": "storage" + } + ], + "inputs": [], + "name": "get_int8", + "output": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + }, + { + "attributes": [ + { + "arguments": [ + "read" + ], + "name": "storage" + } + ], + "inputs": [], + "name": "get_s", + "output": "427fd62288add8763eb5e0c4facf553d877489a3038b29a8a1045e9a853660f0" + }, + { + "attributes": [ + { + "arguments": [ + "read" + ], + "name": "storage" + } + ], + "inputs": [], + "name": "get_s_dot_t", + "output": "74df8abb4a65a07ec7420c0f167703fc6e26c9e43b8036ffacb89d399f13db73" + }, + { + "attributes": [ + { + "arguments": [ + "read" + ], + "name": "storage" + } + ], + "inputs": [], + "name": "get_s_dot_t_dot_boolean", + "output": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903" + }, + { + "attributes": [ + { + "arguments": [ + "read" + ], + "name": "storage" + } + ], + "inputs": [], + "name": "get_s_dot_t_dot_int16", + "output": "29881aad8730c5ab11d275376323d8e4ff4179aae8ccb6c13fe4902137e162ef" + }, + { + "attributes": [ + { + "arguments": [ + "read" + ], + "name": "storage" + } + ], + "inputs": [], + "name": "get_s_dot_t_dot_int32", + "output": "d7649d428b9ff33d188ecbf38a7e4d8fd167fa01b2e10fe9a8f9308e52f1d7cc" + }, + { + "attributes": [ + { + "arguments": [ + "read" + ], + "name": "storage" + } + ], + "inputs": [], + "name": "get_s_dot_t_dot_int8", + "output": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + }, + { + "attributes": [ + { + "arguments": [ + "read" + ], + "name": "storage" + } + ], + "inputs": [], + "name": "get_s_dot_t_dot_x", + "output": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + }, + { + "attributes": [ + { + "arguments": [ + "read" + ], + "name": "storage" + } + ], + "inputs": [], + "name": "get_s_dot_t_dot_y", + "output": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + }, + { + "attributes": [ + { + "arguments": [ + "read" + ], + "name": "storage" + } + ], + "inputs": [], + "name": "get_s_dot_t_dot_z", + "output": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b" + }, + { + "attributes": [ + { + "arguments": [ + "read" + ], + "name": "storage" + } + ], + "inputs": [], + "name": "get_s_dot_x", + "output": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + }, + { + "attributes": [ + { + "arguments": [ + "read" + ], + "name": "storage" + } + ], + "inputs": [], + "name": "get_s_dot_y", + "output": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + }, + { + "attributes": [ + { + "arguments": [ + "read" + ], + "name": "storage" + } + ], + "inputs": [], + "name": "get_s_dot_z", + "output": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b" + }, + { + "attributes": [ + { + "arguments": [ + "read" + ], + "name": "storage" + } + ], + "inputs": [], + "name": "get_string", + "output": "893a66eb2f595d7e0cc15e2253da1b6e53fd634ad542b2f1a198a8ae3d8d92b2" + }, + { + "attributes": [ + { + "arguments": [ + "read" + ], + "name": "storage" + } + ], + "inputs": [], + "name": "get_x", + "output": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + }, + { + "attributes": [ + { + "arguments": [ + "read" + ], + "name": "storage" + } + ], + "inputs": [], + "name": "get_y", + "output": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b" + }, + { + "attributes": [ + { + "arguments": [ + "write" + ], + "name": "storage" + } + ], + "inputs": [ + { + "concreteTypeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903", + "name": "boolean" + } + ], + "name": "set_boolean", + "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" + }, + { + "attributes": [ + { + "arguments": [ + "write" + ], + "name": "storage" + } + ], + "inputs": [ + { + "concreteTypeId": "35b24140807b67d1f1675de36775d5d6c62b04f3721f616a9adee739e24c9c15", + "name": "e" + } + ], + "name": "set_e", + "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" + }, + { + "attributes": [ + { + "arguments": [ + "write" + ], + "name": "storage" + } + ], + "inputs": [ + { + "concreteTypeId": "29881aad8730c5ab11d275376323d8e4ff4179aae8ccb6c13fe4902137e162ef", + "name": "int16" + } + ], + "name": "set_int16", + "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" + }, + { + "attributes": [ + { + "arguments": [ + "write" + ], + "name": "storage" + } + ], + "inputs": [ + { + "concreteTypeId": "d7649d428b9ff33d188ecbf38a7e4d8fd167fa01b2e10fe9a8f9308e52f1d7cc", + "name": "int32" + } + ], + "name": "set_int32", + "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" + }, + { + "attributes": [ + { + "arguments": [ + "write" + ], + "name": "storage" + } + ], + "inputs": [ + { + "concreteTypeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b", + "name": "int8" + } + ], + "name": "set_int8", + "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" + }, + { + "attributes": [ + { + "arguments": [ + "write" + ], + "name": "storage" + } + ], + "inputs": [ + { + "concreteTypeId": "427fd62288add8763eb5e0c4facf553d877489a3038b29a8a1045e9a853660f0", + "name": "s" + } + ], + "name": "set_s", + "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" + }, + { + "attributes": [ + { + "arguments": [ + "write" + ], + "name": "storage" + } + ], + "inputs": [ + { + "concreteTypeId": "74df8abb4a65a07ec7420c0f167703fc6e26c9e43b8036ffacb89d399f13db73", + "name": "t" + } + ], + "name": "set_s_dot_t", + "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" + }, + { + "attributes": [ + { + "arguments": [ + "write" + ], + "name": "storage" + } + ], + "inputs": [ + { + "concreteTypeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903", + "name": "boolean" + } + ], + "name": "set_s_dot_t_dot_boolean", + "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" + }, + { + "attributes": [ + { + "arguments": [ + "write" + ], + "name": "storage" + } + ], + "inputs": [ + { + "concreteTypeId": "29881aad8730c5ab11d275376323d8e4ff4179aae8ccb6c13fe4902137e162ef", + "name": "int16" + } + ], + "name": "set_s_dot_t_dot_int16", + "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" + }, + { + "attributes": [ + { + "arguments": [ + "write" + ], + "name": "storage" + } + ], + "inputs": [ + { + "concreteTypeId": "d7649d428b9ff33d188ecbf38a7e4d8fd167fa01b2e10fe9a8f9308e52f1d7cc", + "name": "int32" + } + ], + "name": "set_s_dot_t_dot_int32", + "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" + }, + { + "attributes": [ + { + "arguments": [ + "write" + ], + "name": "storage" + } + ], + "inputs": [ + { + "concreteTypeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b", + "name": "int8" + } + ], + "name": "set_s_dot_t_dot_int8", + "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" + }, + { + "attributes": [ + { + "arguments": [ + "write" + ], + "name": "storage" + } + ], + "inputs": [ + { + "concreteTypeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0", + "name": "x" + } + ], + "name": "set_s_dot_t_dot_x", + "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" + }, + { + "attributes": [ + { + "arguments": [ + "write" + ], + "name": "storage" + } + ], + "inputs": [ + { + "concreteTypeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0", + "name": "y" + } + ], + "name": "set_s_dot_t_dot_y", + "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" + }, + { + "attributes": [ + { + "arguments": [ + "write" + ], + "name": "storage" + } + ], + "inputs": [ + { + "concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b", + "name": "z" + } + ], + "name": "set_s_dot_t_dot_z", + "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" + }, + { + "attributes": [ + { + "arguments": [ + "write" + ], + "name": "storage" + } + ], + "inputs": [ + { + "concreteTypeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0", + "name": "x" + } + ], + "name": "set_s_dot_x", + "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" + }, + { + "attributes": [ + { + "arguments": [ + "write" + ], + "name": "storage" + } + ], + "inputs": [ + { + "concreteTypeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0", + "name": "y" + } + ], + "name": "set_s_dot_y", + "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" + }, + { + "attributes": [ + { + "arguments": [ + "write" + ], + "name": "storage" + } + ], + "inputs": [ + { + "concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b", + "name": "z" + } + ], + "name": "set_s_dot_z", + "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" + }, + { + "attributes": [ + { + "arguments": [ + "write" + ], + "name": "storage" + } + ], + "inputs": [ + { + "concreteTypeId": "893a66eb2f595d7e0cc15e2253da1b6e53fd634ad542b2f1a198a8ae3d8d92b2", + "name": "string" + } + ], + "name": "set_string", + "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" + }, + { + "attributes": [ + { + "arguments": [ + "write" + ], + "name": "storage" + } + ], + "inputs": [ + { + "concreteTypeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0", + "name": "x" + } + ], + "name": "set_x", + "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" + }, + { + "attributes": [ + { + "arguments": [ + "write" + ], + "name": "storage" + } + ], + "inputs": [ + { + "concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b", + "name": "y" + } + ], + "name": "set_y", + "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" + } + ], + "loggedTypes": [ + { + "concreteTypeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903", + "logId": "13213829929622723620" + } + ], + "messagesTypes": [], + "metadataTypes": [ + { + "components": [ + { + "name": "A", + "typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + }, + { + "name": "B", + "typeId": 2 + } + ], + "metadataTypeId": 0, + "type": "enum storage_access_abi::E" + }, + { + "components": [ + { + "name": "x", + "typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + }, + { + "name": "y", + "typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + }, + { + "name": "z", + "typeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b" + }, + { + "name": "t", + "typeId": 2 + } + ], + "metadataTypeId": 1, + "type": "struct storage_access_abi::S" + }, + { + "components": [ + { + "name": "x", + "typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + }, + { + "name": "y", + "typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + }, + { + "name": "z", + "typeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b" + }, + { + "name": "boolean", + "typeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903" + }, + { + "name": "int8", + "typeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + }, + { + "name": "int16", + "typeId": "29881aad8730c5ab11d275376323d8e4ff4179aae8ccb6c13fe4902137e162ef" + }, + { + "name": "int32", + "typeId": "d7649d428b9ff33d188ecbf38a7e4d8fd167fa01b2e10fe9a8f9308e52f1d7cc" + } + ], + "metadataTypeId": 2, + "type": "struct storage_access_abi::T" + } + ], + "programType": "contract", + "specVersion": "1" +} \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_access_contract/json_storage_slots_oracle.storage_domains.json b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_access_contract/json_storage_slots_oracle.storage_domains.json new file mode 100644 index 00000000000..ff1eae7956b --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_access_contract/json_storage_slots_oracle.storage_domains.json @@ -0,0 +1,74 @@ +[ + { + "key": "419b1120ea993203d7e223dfbe76184322453d6f8de946e827a8669102ab395b", + "value": "0000000000000040000000000000000000000000000000000000000000000000" + }, + { + "key": "4b06f7ce27bc88217a7c9d4300619d2900cef25ecb29a790ec869b02e4191275", + "value": "4141414141414141414141414141414141414141414141414141414141414141" + }, + { + "key": "4b06f7ce27bc88217a7c9d4300619d2900cef25ecb29a790ec869b02e4191276", + "value": "4141414141414141000000000000000000000000000000000000000000000000" + }, + { + "key": "7299da45c4430837636de04fb23f3343a80d88c1dc0455562b3066913f0d7745", + "value": "0000000000000020000000000000000000000000000000000000000000000000" + }, + { + "key": "865b6b6b53f4babe503029163d7076d649da88a10c4ed333d19c645d271f495c", + "value": "0000000000000010000000000000000000000000000000000000000000000000" + }, + { + "key": "8e06966f123f8d6e298f853c70d34036061474c4674b7960119ac4a08a557f0c", + "value": "0000000000000001000000000000000100000000000000020000000000000000" + }, + { + "key": "8e06966f123f8d6e298f853c70d34036061474c4674b7960119ac4a08a557f0d", + "value": "0000000000000000000000000000000000000000000000030100000000000000" + }, + { + "key": "8e06966f123f8d6e298f853c70d34036061474c4674b7960119ac4a08a557f0e", + "value": "0400000000000000000000000000000500000000000000060000000000000000" + }, + { + "key": "9538bea0a4c2601b6bd45782e4c10df5728427e310421d9a5d93f85a1f3704f2", + "value": "0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "key": "9538bea0a4c2601b6bd45782e4c10df5728427e310421d9a5d93f85a1f3704f3", + "value": "0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "key": "9538bea0a4c2601b6bd45782e4c10df5728427e310421d9a5d93f85a1f3704f4", + "value": "0000000000000000000000000000000000000000000003090000000000000000" + }, + { + "key": "ae10a55cca3f364be094340b109ccf393d12c2c07417ff2e719b1816ac793c86", + "value": "0000000000000001000000000000000200000000000000000000000000000000" + }, + { + "key": "ae10a55cca3f364be094340b109ccf393d12c2c07417ff2e719b1816ac793c87", + "value": "0000000000000000000000000000000300000000000000040000000000000005" + }, + { + "key": "ae10a55cca3f364be094340b109ccf393d12c2c07417ff2e719b1816ac793c88", + "value": "0000000000000000000000000000000000000000000000000000000000000006" + }, + { + "key": "ae10a55cca3f364be094340b109ccf393d12c2c07417ff2e719b1816ac793c89", + "value": "0100000000000000070000000000000000000000000000080000000000000009" + }, + { + "key": "d871d81721e9905a5cafe5b82dfde0ddb930f96a8e6deb44f92a8c9ce4d24ac1", + "value": "0800000000000000000000000000000000000000000000000000000000000000" + }, + { + "key": "e8aaf9a6b72b4eee2bcb2315773bc50e9166ff05c4221843637e25f0424a5dd5", + "value": "0100000000000000000000000000000000000000000000000000000000000000" + }, + { + "key": "eb390d9f85c8c849ff8aeb05c865ca66b37ba69a7bec8489b1c467f029b650af", + "value": "0101010101010101010101010101010101010101010101010101010101010101" + } +] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_access_contract/test.storage_domains.toml b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_access_contract/test.storage_domains.toml new file mode 100644 index 00000000000..24be96bbf31 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_access_contract/test.storage_domains.toml @@ -0,0 +1 @@ +experimental = { storage_domains = true } \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_enum_contract/json_abi_oracle.storage_domains.json b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_enum_contract/json_abi_oracle.storage_domains.json new file mode 100644 index 00000000000..32bd4e374ca --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_enum_contract/json_abi_oracle.storage_domains.json @@ -0,0 +1,31 @@ +{ + "concreteTypes": [ + { + "concreteTypeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0", + "type": "u64" + } + ], + "configurables": [], + "encodingVersion": "1", + "functions": [ + { + "attributes": [ + { + "arguments": [ + "read", + "write" + ], + "name": "storage" + } + ], + "inputs": [], + "name": "read_write_enums", + "output": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + } + ], + "loggedTypes": [], + "messagesTypes": [], + "metadataTypes": [], + "programType": "contract", + "specVersion": "1" +} \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_enum_contract/json_storage_slots_oracle.storage_domains.json b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_enum_contract/json_storage_slots_oracle.storage_domains.json new file mode 100644 index 00000000000..f2d1ca396cb --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_enum_contract/json_storage_slots_oracle.storage_domains.json @@ -0,0 +1,62 @@ +[ + { + "key": "12f9e955b5b2b5a00c0ebd1320f2cbd0e66c39396b3b3d7ff95c87f4b6e48c0d", + "value": "000000000000000000000000000000cd00000000000000000000000000000000" + }, + { + "key": "23e09d7a09a27d7d9c5c9d0f5191084c19a0a668c60b804a94e99234e6069c7b", + "value": "0000000000000001000000000000aa00000000000000bb00000000000000cc00" + }, + { + "key": "2e7251f5b28dbe052a7f5113d45f3cc2faccf7c955cbc0966089aa0d0059beab", + "value": "0000000000000001000000000000ab00000000000000bc00000000000000cd00" + }, + { + "key": "2e7251f5b28dbe052a7f5113d45f3cc2faccf7c955cbc0966089aa0d0059beac", + "value": "000000000000de00000000000000ef0000000000000000000000000000000000" + }, + { + "key": "2f02e964cd75fddf505a740d9daa11fef5f09b4d17058f893fc0f4e8b2244f53", + "value": "0000000000000000000000000000000100000000000000000000000000000000" + }, + { + "key": "50010301032c3383ef066fbb9ac7c25e3de42bdd5ccaec2d6e0bd26b6531bb0f", + "value": "0000000000000000000000000000000100000000000000000000000000000000" + }, + { + "key": "6b765908aa8ec7bc3a1d73cd252e40fb055de29fb0e9486a16e388cba9fa7c9f", + "value": "00000000000000000000000000000000000000000000000000000000000000ee" + }, + { + "key": "728df923e281e7cb9793c2c2d6419b735161b5e1b8d5ca2065569611418fc194", + "value": "000000000000000100000000000000cd00000000000000000000000000000000" + }, + { + "key": "7ddacb90e6ff09ed9aa4fde095854476123392aab8c73165cc65097b0a2a2578", + "value": "0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "key": "7ddacb90e6ff09ed9aa4fde095854476123392aab8c73165cc65097b0a2a2579", + "value": "000000000000000000000000000000ff00000000000000000000000000000000" + }, + { + "key": "c20357da738934c36211a22c69d4c44bc7a3b500b07d9e7328c3f0a7c2c426c0", + "value": "0000000000000002000000000000000000000000000000000000000000000000" + }, + { + "key": "d60810fb854958d678015228bfbd5a23a3e1763c1ff90f6790f69fbb85b413c6", + "value": "000000000000000000000000000000ab00000000000000000000000000000000" + }, + { + "key": "d71ff2e9ac87ec91301ee89d18b1dc8991b79753f004ce0810661bd5bfa92bd2", + "value": "0000000000000001000000000000bb0000000000000000000000000000000000" + }, + { + "key": "d9149ae8e217ec10a045c9f83c5bc9d227285fe76b9bcdc8245e6a57a23d0229", + "value": "000000000000000000000000000000aa00000000000000000000000000000000" + }, + { + "key": "e7af73ebbf0ab36c9e30283a504e1326febe010a1b2d0deae9252af8302526a1", + "value": "0000000000000002000000000000000000000000000000000000000000000000" + } +] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_enum_contract/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_enum_contract/src/main.sw index e604563d4e2..597bed643ce 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_enum_contract/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_enum_contract/src/main.sw @@ -117,10 +117,6 @@ fn check_s_u8_a(expected: u8) -> u8 { assert(i == expected); return i; }, - _ => { - assert(false); - return 99; - } } } @@ -132,10 +128,6 @@ fn check_s_u64_a(expected: u64) -> u64 { assert(i == expected); return i; }, - _ => { - assert(false); - return 9999; - } } } @@ -147,10 +139,6 @@ fn check_s_bool_a(expected: bool) -> u64 { assert(i == expected); return 171; }, - _ => { - assert(false); - return 9999; - } } } diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_enum_contract/test.storage_domains.toml b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_enum_contract/test.storage_domains.toml new file mode 100644 index 00000000000..24be96bbf31 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_enum_contract/test.storage_domains.toml @@ -0,0 +1 @@ +experimental = { storage_domains = true } \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_namespace/json_abi_oracle.storage_domains.json b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_namespace/json_abi_oracle.storage_domains.json new file mode 100644 index 00000000000..a7b039e5eeb --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_namespace/json_abi_oracle.storage_domains.json @@ -0,0 +1,289 @@ +{ + "concreteTypes": [ + { + "concreteTypeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d", + "type": "()" + }, + { + "concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b", + "type": "b256" + }, + { + "concreteTypeId": "d852149004cc9ec0bbe7dc4e37bffea1d41469b759512b6136f2e865a4c06e7d", + "metadataTypeId": 0, + "type": "enum std::option::Option", + "typeArguments": [ + "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + ] + }, + { + "concreteTypeId": "6906df92e2e485dde893b7d719d621b8910422e7c468f99caa5920e6ac19d9c6", + "metadataTypeId": 3, + "type": "struct basic_storage_abi::Quad" + }, + { + "concreteTypeId": "7880d311d30802b48bd6a100a31adb5af17f94bff12daee556d4f02c1ac5b2ff", + "metadataTypeId": 5, + "type": "struct std::vec::Vec", + "typeArguments": [ + "6906df92e2e485dde893b7d719d621b8910422e7c468f99caa5920e6ac19d9c6" + ] + }, + { + "concreteTypeId": "1b5759d94094368cfd443019e7ca5ec4074300e544e5ea993a979f5da627261e", + "type": "u256" + }, + { + "concreteTypeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0", + "type": "u64" + } + ], + "configurables": [], + "encodingVersion": "1", + "functions": [ + { + "attributes": [ + { + "arguments": [ + "read" + ], + "name": "storage" + } + ], + "inputs": [ + { + "concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b", + "name": "storage_key" + } + ], + "name": "get_u64", + "output": "d852149004cc9ec0bbe7dc4e37bffea1d41469b759512b6136f2e865a4c06e7d" + }, + { + "attributes": [ + { + "arguments": [ + "read" + ], + "name": "storage" + } + ], + "inputs": [ + { + "concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b", + "name": "key" + }, + { + "concreteTypeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0", + "name": "slots" + } + ], + "name": "intrinsic_load_quad", + "output": "7880d311d30802b48bd6a100a31adb5af17f94bff12daee556d4f02c1ac5b2ff" + }, + { + "attributes": [ + { + "arguments": [ + "read" + ], + "name": "storage" + } + ], + "inputs": [ + { + "concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b", + "name": "key" + } + ], + "name": "intrinsic_load_word", + "output": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + }, + { + "attributes": [ + { + "arguments": [ + "write" + ], + "name": "storage" + } + ], + "inputs": [ + { + "concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b", + "name": "key" + }, + { + "concreteTypeId": "7880d311d30802b48bd6a100a31adb5af17f94bff12daee556d4f02c1ac5b2ff", + "name": "values" + } + ], + "name": "intrinsic_store_quad", + "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" + }, + { + "attributes": [ + { + "arguments": [ + "write" + ], + "name": "storage" + } + ], + "inputs": [ + { + "concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b", + "name": "key" + }, + { + "concreteTypeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0", + "name": "value" + } + ], + "name": "intrinsic_store_word", + "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" + }, + { + "attributes": [ + { + "arguments": [ + "write" + ], + "name": "storage" + } + ], + "inputs": [ + { + "concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b", + "name": "key" + }, + { + "concreteTypeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0", + "name": "value" + } + ], + "name": "store_u64", + "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" + }, + { + "attributes": [ + { + "arguments": [ + "read", + "write" + ], + "name": "storage" + } + ], + "inputs": [], + "name": "test_storage_exhaustive", + "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" + } + ], + "loggedTypes": [ + { + "concreteTypeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0", + "logId": "1515152261580153489" + }, + { + "concreteTypeId": "1b5759d94094368cfd443019e7ca5ec4074300e544e5ea993a979f5da627261e", + "logId": "1970142151624111756" + }, + { + "concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b", + "logId": "8961848586872524460" + } + ], + "messagesTypes": [], + "metadataTypes": [ + { + "components": [ + { + "name": "None", + "typeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" + }, + { + "name": "Some", + "typeId": 1 + } + ], + "metadataTypeId": 0, + "type": "enum std::option::Option", + "typeParameters": [ + 1 + ] + }, + { + "metadataTypeId": 1, + "type": "generic T" + }, + { + "metadataTypeId": 2, + "type": "raw untyped ptr" + }, + { + "components": [ + { + "name": "v1", + "typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + }, + { + "name": "v2", + "typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + }, + { + "name": "v3", + "typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + }, + { + "name": "v4", + "typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + } + ], + "metadataTypeId": 3, + "type": "struct basic_storage_abi::Quad" + }, + { + "components": [ + { + "name": "ptr", + "typeId": 2 + }, + { + "name": "cap", + "typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + } + ], + "metadataTypeId": 4, + "type": "struct std::vec::RawVec", + "typeParameters": [ + 1 + ] + }, + { + "components": [ + { + "name": "buf", + "typeArguments": [ + { + "name": "", + "typeId": 1 + } + ], + "typeId": 4 + }, + { + "name": "len", + "typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + } + ], + "metadataTypeId": 5, + "type": "struct std::vec::Vec", + "typeParameters": [ + 1 + ] + } + ], + "programType": "contract", + "specVersion": "1" +} \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_namespace/json_storage_slots_oracle.storage_domains.json b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_namespace/json_storage_slots_oracle.storage_domains.json new file mode 100644 index 00000000000..30e9e240f7c --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_namespace/json_storage_slots_oracle.storage_domains.json @@ -0,0 +1,54 @@ +[ + { + "key": "130875c838ab7f4f039a63d56d8173198d6edade9a61967c93b9d32d93547979", + "value": "6161000000000000000000000000000000000000000000000000000000000000" + }, + { + "key": "1997c0b14a3944421bc909d65cdb7f96023661790725e7a06d0bdf211002f9c0", + "value": "6161610000000000000000000000000000000000000000000000000000000000" + }, + { + "key": "1cb08489095e2318cabf34c2c00b0f2b78c151bf4e3caf2a1762778c1b79c052", + "value": "0000000000000001000000000000000000000000000000000000000000000000" + }, + { + "key": "35338f6734c20524ba70780eae61e4dc5398122eab4a3cad9509a3d3ddc1551b", + "value": "0000000000000000000000000000000000000000000000000000000001234567" + }, + { + "key": "55279c57558d3bb1938f803552769ed7dcb3efacd74d9a16cf71d0cfbaab6c0a", + "value": "6161616161616161616100000000000000000000000000000000000000000000" + }, + { + "key": "5d5895256cdf173ecc135c1a18de5133b00b36e5caae538407a883dd44cc0dac", + "value": "0000000000000000000000000000000000000000000000000000000001234567" + }, + { + "key": "5dbeb0e7fc4c2fa3b01b9873d2a4e23488fb486046b6074b4ae463b7bbacbe89", + "value": "6161616161000000000000000000000000000000000000000000000000000000" + }, + { + "key": "659790a8d5d87a599ab69d1a3e6f48ff00c850fb7d24ccd782b209a52e4be83c", + "value": "6161616161616100000000000000000000000000000000000000000000000000" + }, + { + "key": "7aac1eb5fdc9d977b39721c2ccddb3ae405eecac0d8570e3be2d70fe677db4bd", + "value": "6161616161616161610000000000000000000000000000000000000000000000" + }, + { + "key": "8449d22802f944884dd98b791627c4265f4303014d1975f3da48fde003d77936", + "value": "6161616161616161000000000000000000000000000000000000000000000000" + }, + { + "key": "c2f546e9b4a2a37895f7f563be4610aa580468ddd8ba5d3544513965d79eac8a", + "value": "6100000000000000000000000000000000000000000000000000000000000000" + }, + { + "key": "e1ba0adcc27d3a21cfe72cc296e282f1c4b9f6798f89ac4e4b8ac95e3ee16d81", + "value": "6161616161610000000000000000000000000000000000000000000000000000" + }, + { + "key": "fdcf008347ae968111d6837c46f05f1a9943e76f6998d51ee1220b4069709a51", + "value": "6161616100000000000000000000000000000000000000000000000000000000" + } +] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_namespace/test.storage_domains.toml b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_namespace/test.storage_domains.toml new file mode 100644 index 00000000000..24be96bbf31 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_namespace/test.storage_domains.toml @@ -0,0 +1 @@ +experimental = { storage_domains = true } \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_namespace/test.toml b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_namespace/test.toml index 94671fb72d4..a235275de20 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_namespace/test.toml +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_namespace/test.toml @@ -1,4 +1,4 @@ category = "compile" validate_abi = true validate_storage_slots = true -expected_warnings = 1 +expected_warnings = 1 # TODO-DCA: Set to zero once https://github.com/FuelLabs/sway/issues/5921 is fixed. diff --git a/test/src/ir_generation/mod.rs b/test/src/ir_generation/mod.rs index 8313845fe39..6969ef1c689 100644 --- a/test/src/ir_generation/mod.rs +++ b/test/src/ir_generation/mod.rs @@ -223,7 +223,9 @@ pub(super) async fn run( tracing::info!("Testing {} ...", test_file_name.bold()); let experimental = ExperimentalFeatures { - new_encoding: false, // IR tests still need encoding v1 off + new_encoding: false, // IR tests still need encoding v1 off. + // TODO: Properly support experimental features in IR tests. + ..Default::default() }; // Compile to AST. We need to provide a faux build config otherwise the IR will have