Skip to content

Commit

Permalink
remove unsed Move type in events (MystenLabs#8207)
Browse files Browse the repository at this point in the history
This removes unused Move Type in user events. Which should reduce the
resource footprint.
  • Loading branch information
oxade authored Feb 10, 2023
1 parent c3fc012 commit 60e50c0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/sui-adapter/src/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ fn execute_internal<
.map_err(|e| convert_vm_error(e, vm, state_view))?;
let user_events = user_events
.into_iter()
.map(|(_ty, tag, value)| {
.map(|(tag, value)| {
let layout = session.get_type_layout(&TypeTag::Struct(Box::new(tag.clone())))?;
let bytes = value.simple_serialize(&layout).unwrap();
Ok((tag, bytes))
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-framework/src/natives/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ pub fn emit(
};

let obj_runtime: &mut ObjectRuntime = context.extensions_mut().get_mut();
obj_runtime.emit_event(ty, *tag, event)?;
obj_runtime.emit_event(*tag, event)?;
Ok(NativeResult::ok(cost, smallvec![]))
}
8 changes: 4 additions & 4 deletions crates/sui-framework/src/natives/object_runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub(crate) struct TestInventories {
pub struct RuntimeResults {
pub writes: LinkedHashMap<ObjectID, (WriteKind, Owner, Type, StructTag, Value)>,
pub deletions: LinkedHashMap<ObjectID, DeleteKind>,
pub user_events: Vec<(Type, StructTag, Value)>,
pub user_events: Vec<(StructTag, Value)>,
// loaded child objects and their versions
pub loaded_child_objects: BTreeMap<ObjectID, SequenceNumber>,
}
Expand All @@ -74,7 +74,7 @@ pub(crate) struct ObjectRuntimeState {
// transfers to a new owner (shared, immutable, object, or account address)
// TODO these struct tags can be removed if type_to_type_tag was exposed in the session
transfers: LinkedHashMap<ObjectID, (Owner, Type, StructTag, Value)>,
events: Vec<(Type, StructTag, Value)>,
events: Vec<(StructTag, Value)>,
}

#[derive(Tid)]
Expand Down Expand Up @@ -207,7 +207,7 @@ impl<'a> ObjectRuntime<'a> {
Ok(transfer_result)
}

pub fn emit_event(&mut self, ty: Type, tag: StructTag, event: Value) -> PartialVMResult<()> {
pub fn emit_event(&mut self, tag: StructTag, event: Value) -> PartialVMResult<()> {
if self.state.events.len() == (MAX_NUM_EVENT_EMIT as usize) {
return Err(PartialVMError::new(StatusCode::MEMORY_LIMIT_EXCEEDED)
.with_message(format!(
Expand All @@ -217,7 +217,7 @@ impl<'a> ObjectRuntime<'a> {
VMMemoryLimitExceededSubStatusCode::EVENT_COUNT_LIMIT_EXCEEDED as u64,
));
}
self.state.events.push((ty, tag, event));
self.state.events.push((tag, event));
Ok(())
}

Expand Down

0 comments on commit 60e50c0

Please sign in to comment.