-
Notifications
You must be signed in to change notification settings - Fork 27
Remove resource access control #410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: move-rebase-e33
Are you sure you want to change the base?
Changes from all commits
893a59c
eafd329
6369e2c
457ff61
5779834
4528da8
3c00021
d42542c
53b4660
f889b25
3bd8688
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| // Copyright (c) The Move Contributors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| //! Resource access control has been removed, so access specifiers are rejected regardless of | ||
| //! configuration. Only hand-crafted bytecode can still carry them; no compiler emits them. | ||
|
|
||
| use move_binary_format::{ | ||
| file_format::{ | ||
| basic_test_module, empty_script, AccessKind, AccessSpecifier, AddressIdentifierIndex, | ||
| AddressSpecifier, ResourceSpecifier, TableIndex, | ||
| }, | ||
| CompiledModule, | ||
| }; | ||
| use move_bytecode_verifier::VerifierConfig; | ||
| use move_core_types::{account_address::AccountAddress, vm_status::StatusCode}; | ||
|
|
||
| /// An access specifier reading any resource declared at the address added to `addresses`. | ||
| fn reads_any_at_new_address(addresses: &mut Vec<AccountAddress>) -> AccessSpecifier { | ||
| let addr = AddressIdentifierIndex::new(addresses.len() as TableIndex); | ||
| addresses.push(AccountAddress::ONE); | ||
| AccessSpecifier { | ||
| kind: AccessKind::Reads, | ||
| negated: false, | ||
| resource: ResourceSpecifier::DeclaredAtAddress(addr), | ||
| address: AddressSpecifier::Any, | ||
| } | ||
| } | ||
|
|
||
| fn module_with_access_specifiers() -> CompiledModule { | ||
| let mut m = basic_test_module(); | ||
| let specifier = reads_any_at_new_address(&mut m.address_identifiers); | ||
| m.function_handles[0].access_specifiers = Some(vec![specifier]); | ||
| m | ||
| } | ||
|
|
||
| #[test] | ||
| fn module_access_specifiers_are_rejected() { | ||
| let m = module_with_access_specifiers(); | ||
| let err = move_bytecode_verifier::verify_module_with_config(&VerifierConfig::production(), &m) | ||
| .unwrap_err(); | ||
| assert_eq!(err.major_status(), StatusCode::FEATURE_NOT_ENABLED); | ||
| } | ||
|
|
||
| #[test] | ||
| fn script_access_specifiers_are_rejected() { | ||
| let mut s = empty_script(); | ||
| let specifier = reads_any_at_new_address(&mut s.address_identifiers); | ||
| s.access_specifiers = Some(vec![specifier]); | ||
| let err = move_bytecode_verifier::verify_script_with_config(&VerifierConfig::production(), &s) | ||
| .unwrap_err(); | ||
| assert_eq!(err.major_status(), StatusCode::FEATURE_NOT_ENABLED); | ||
| } | ||
|
|
||
| /// The same module without access specifiers must verify, so that the rejections above are | ||
| /// attributable to the specifiers rather than to an unrelated defect in the test fixtures. | ||
| #[test] | ||
| fn module_without_access_specifiers_is_accepted() { | ||
| let mut m = module_with_access_specifiers(); | ||
| m.function_handles[0].access_specifiers = None; | ||
| assert!( | ||
| move_bytecode_verifier::verify_module_with_config(&VerifierConfig::production(), &m) | ||
| .is_ok() | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn script_without_access_specifiers_is_accepted() { | ||
| let s = empty_script(); | ||
| assert!(s.access_specifiers.is_none()); | ||
| assert!( | ||
| move_bytecode_verifier::verify_script_with_config(&VerifierConfig::production(), &s) | ||
| .is_ok() | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,9 +55,9 @@ impl<'a> FeatureVerifier<'a> { | |
| }; | ||
| verifier.verify_signatures()?; | ||
| verifier.verify_function_handles()?; | ||
| if !config.enable_resource_access_control && script.access_specifiers.is_some() { | ||
| if script.access_specifiers.is_some() { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we remove
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is part of the file format already enabled on-chain, so we'd better keep it but ignore the RAC. |
||
| return Err(PartialVMError::new(StatusCode::FEATURE_NOT_ENABLED) | ||
| .with_message("resource access control feature not enabled".to_string())); | ||
| .with_message("resource access control is not supported".to_string())); | ||
| } | ||
| verifier.verify_code(&script.code.code, None) | ||
| } | ||
|
|
@@ -106,20 +106,16 @@ impl<'a> FeatureVerifier<'a> { | |
| } | ||
|
|
||
| fn verify_function_handles(&self) -> PartialVMResult<()> { | ||
| if !self.config.enable_resource_access_control || !self.config.enable_function_values { | ||
| for (idx, function_handle) in self.code.function_handles().iter().enumerate() { | ||
| if !self.config.enable_resource_access_control | ||
| && function_handle.access_specifiers.is_some() | ||
| { | ||
| return Err(PartialVMError::new(StatusCode::FEATURE_NOT_ENABLED) | ||
| .at_index(IndexKind::FunctionHandle, idx as u16) | ||
| .with_message("resource access control feature not enabled".to_string())); | ||
| } | ||
| if !self.config.enable_function_values && !function_handle.attributes.is_empty() { | ||
| return Err(PartialVMError::new(StatusCode::FEATURE_NOT_ENABLED) | ||
| .at_index(IndexKind::FunctionDefinition, idx as u16) | ||
| .with_message("function value feature not enabled".to_string())); | ||
| } | ||
| for (idx, function_handle) in self.code.function_handles().iter().enumerate() { | ||
| if function_handle.access_specifiers.is_some() { | ||
| return Err(PartialVMError::new(StatusCode::FEATURE_NOT_ENABLED) | ||
| .at_index(IndexKind::FunctionHandle, idx as u16) | ||
| .with_message("resource access control is not supported".to_string())); | ||
| } | ||
| if !self.config.enable_function_values && !function_handle.attributes.is_empty() { | ||
| return Err(PartialVMError::new(StatusCode::FEATURE_NOT_ENABLED) | ||
| .at_index(IndexKind::FunctionDefinition, idx as u16) | ||
| .with_message("function value feature not enabled".to_string())); | ||
| } | ||
| } | ||
| Ok(()) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment of the structure says
Though it seems to me it's removable.