Skip to content

Commit f454c3a

Browse files
committed
respond to comments
1 parent bdf7519 commit f454c3a

File tree

2 files changed

+15
-23
lines changed

2 files changed

+15
-23
lines changed

external-crates/move/crates/move-vm-runtime/src/native_functions.rs

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -163,40 +163,30 @@ impl<'b> NativeContext<'_, 'b> {
163163
// used in test scenarios so we have some special knowledge that makes this work. In the new VM
164164
// however this is _MUCH_ nicer as we don't need to pass the datastore as the VM's linkage
165165
// tables must have the type present.
166-
pub fn type_tag_to_fully_annotated_layout(
166+
pub fn type_tag_to_fully_annotated_layout_for_test_scenario_only(
167167
&self,
168168
tag: &TypeTag,
169169
store: &impl DataStore,
170-
) -> PartialVMResult<Option<A::MoveTypeLayout>> {
171-
match self
172-
.resolver
170+
) -> PartialVMResult<A::MoveTypeLayout> {
171+
self.resolver
173172
.loader()
174173
.get_fully_annotated_type_layout(tag, store)
175-
{
176-
Ok(ty_layout) => Ok(Some(ty_layout)),
177-
Err(e) if e.major_status().status_type() == StatusType::InvariantViolation => {
178-
Err(e.to_partial())
179-
}
180-
Err(_) => Ok(None),
181-
}
174+
.map_err(|e| e.to_partial())
182175
}
183176

184177
// TODO: This is a bit hacky right now since we need to pass the store, however this is only
185178
// used in test scenarios so we have some special knowledge that makes this work. In the new VM
186179
// however this is _MUCH_ nicer as we don't need to pass the datastore as the VM's linkage
187180
// tables must have the type present.
188-
pub fn type_tag_to_layout(
181+
pub fn type_tag_to_layout_for_test_scenario_only(
189182
&self,
190183
tag: &TypeTag,
191184
store: &impl DataStore,
192-
) -> PartialVMResult<Option<R::MoveTypeLayout>> {
193-
match self.resolver.loader().get_type_layout(tag, store) {
194-
Ok(ty_layout) => Ok(Some(ty_layout)),
195-
Err(e) if e.major_status().status_type() == StatusType::InvariantViolation => {
196-
Err(e.to_partial())
197-
}
198-
Err(_) => Ok(None),
199-
}
185+
) -> PartialVMResult<R::MoveTypeLayout> {
186+
self.resolver
187+
.loader()
188+
.get_type_layout(tag, store)
189+
.map_err(|e| e.to_partial())
200190
}
201191

202192
pub fn type_to_abilities(&self, ty: &Type) -> PartialVMResult<AbilitySet> {

sui-execution/latest/sui-move-natives/src/test_scenario.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,13 +1007,15 @@ fn find_all_wrapped_objects<'a, 'i>(
10071007
// associated with all of these types must be in the type/module cache in the VM -- THIS IS
10081008
// BECAUSE WE ARE IN TEST SCENARIO ONLY AND THIS DOES NOT GENERALLY HOLD IN A
10091009
// MULTI-TRANSACTION SETTING.
1010-
let Ok(Some(layout)) = context.type_tag_to_layout(&type_tag, &EmptyDataStore) else {
1010+
let Ok(layout) =
1011+
context.type_tag_to_layout_for_test_scenario_only(&type_tag, &EmptyDataStore)
1012+
else {
10111013
debug_assert!(false);
10121014
continue;
10131015
};
10141016

1015-
let Ok(Some(annotated_layout)) =
1016-
context.type_tag_to_fully_annotated_layout(&type_tag, &EmptyDataStore)
1017+
let Ok(annotated_layout) = context
1018+
.type_tag_to_fully_annotated_layout_for_test_scenario_only(&type_tag, &EmptyDataStore)
10171019
else {
10181020
debug_assert!(false);
10191021
continue;

0 commit comments

Comments
 (0)