Skip to content

Commit

Permalink
[cleanup] Removed CompiledScript (MystenLabs#17113)
Browse files Browse the repository at this point in the history
## Description 

- Most usages of it have already been removed, just finally removing it
from the file format

## Test plan 

- CI

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
  • Loading branch information
tnowacki authored Apr 10, 2024
1 parent c692273 commit 9b734af
Show file tree
Hide file tree
Showing 70 changed files with 267 additions and 3,240 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ fn empty_module_no_errors() {
BoundsChecker::verify_module(&basic_test_module()).unwrap();
}

#[test]
fn empty_script_no_errors() {
BoundsChecker::verify_script(&basic_test_script()).unwrap();
}

#[test]
fn invalid_default_module() {
BoundsChecker::verify_module(&CompiledModule {
Expand Down Expand Up @@ -71,19 +66,6 @@ fn invalid_type_param_in_fn_parameters() {
);
}

#[test]
fn invalid_type_param_in_script_parameters() {
use SignatureToken::*;

let mut s = basic_test_script();
s.parameters = SignatureIndex(1);
s.signatures.push(Signature(vec![TypeParameter(0)]));
assert_eq!(
BoundsChecker::verify_script(&s).unwrap_err().major_status(),
StatusCode::INDEX_OUT_OF_BOUNDS
);
}

#[test]
fn invalid_struct_in_fn_return_() {
use SignatureToken::*;
Expand Down Expand Up @@ -139,8 +121,10 @@ fn invalid_struct_with_actuals_in_field() {
let mut m = basic_test_module();
match &mut m.struct_defs[0].field_information {
StructFieldInformation::Declared(ref mut fields) => {
fields[0].signature.0 =
StructInstantiation(Box::new((StructHandleIndex::new(0), vec![TypeParameter(0)])));
fields[0].signature.0 = StructInstantiation(Box::new((
StructHandleIndex::new(0),
vec![TypeParameter(0)],
)));
assert_eq!(
BoundsChecker::verify_module(&m).unwrap_err().major_status(),
StatusCode::NUMBER_OF_TYPE_ARGUMENTS_MISMATCH
Expand All @@ -167,23 +151,6 @@ fn invalid_locals_id_in_call() {
);
}

#[test]
fn script_invalid_locals_id_in_call() {
use Bytecode::*;

let mut s = basic_test_script();
s.function_instantiations.push(FunctionInstantiation {
handle: FunctionHandleIndex::new(0),
type_parameters: SignatureIndex::new(1),
});
let func_inst_idx = FunctionInstantiationIndex(s.function_instantiations.len() as u16 - 1);
s.code.code = vec![CallGeneric(func_inst_idx)];
assert_eq!(
BoundsChecker::verify_script(&s).unwrap_err().major_status(),
StatusCode::INDEX_OUT_OF_BOUNDS
);
}

#[test]
fn invalid_type_param_in_call() {
use Bytecode::*;
Expand All @@ -203,25 +170,6 @@ fn invalid_type_param_in_call() {
);
}

#[test]
fn script_invalid_type_param_in_call() {
use Bytecode::*;
use SignatureToken::*;

let mut s = basic_test_script();
s.signatures.push(Signature(vec![TypeParameter(0)]));
s.function_instantiations.push(FunctionInstantiation {
handle: FunctionHandleIndex::new(0),
type_parameters: SignatureIndex::new(1),
});
let func_inst_idx = FunctionInstantiationIndex(s.function_instantiations.len() as u16 - 1);
s.code.code = vec![CallGeneric(func_inst_idx)];
assert_eq!(
BoundsChecker::verify_script(&s).unwrap_err().major_status(),
StatusCode::INDEX_OUT_OF_BOUNDS
);
}

#[test]
fn invalid_struct_as_type_actual_in_exists() {
use Bytecode::*;
Expand All @@ -242,26 +190,6 @@ fn invalid_struct_as_type_actual_in_exists() {
);
}

#[test]
fn script_invalid_struct_as_type_argument_in_exists() {
use Bytecode::*;
use SignatureToken::*;

let mut s = basic_test_script();
s.signatures
.push(Signature(vec![Struct(StructHandleIndex::new(3))]));
s.function_instantiations.push(FunctionInstantiation {
handle: FunctionHandleIndex::new(0),
type_parameters: SignatureIndex::new(1),
});
let func_inst_idx = FunctionInstantiationIndex(s.function_instantiations.len() as u16 - 1);
s.code.code = vec![CallGeneric(func_inst_idx)];
assert_eq!(
BoundsChecker::verify_script(&s).unwrap_err().major_status(),
StatusCode::INDEX_OUT_OF_BOUNDS
);
}

#[test]
fn invalid_friend_module_address() {
let mut m = basic_test_module();
Expand All @@ -288,19 +216,6 @@ fn invalid_friend_module_name() {
);
}

#[test]
fn script_missing_signature() {
// The basic test script includes parameters pointing to an empty signature.
let mut s = basic_test_script();
// Remove the empty signature from the script.
s.signatures.clear();
// Bounds-checking the script should now result in an out-of-bounds error.
assert_eq!(
BoundsChecker::verify_script(&s).unwrap_err().major_status(),
StatusCode::INDEX_OUT_OF_BOUNDS
);
}

#[test]
fn invalid_signature_for_vector_operation() {
use Bytecode::*;
Expand Down
Loading

0 comments on commit 9b734af

Please sign in to comment.