Skip to content
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

[RPC] Merge the state API and refactor event API #984

Merged
merged 5 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 10 additions & 16 deletions crates/rooch-executor/src/actor/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ use async_trait::async_trait;
use coerce::actor::{context::ActorContext, message::Handler, Actor};
use move_core_types::account_address::AccountAddress;
use move_core_types::vm_status::VMStatus;
use move_resource_viewer::{AnnotatedMoveValue, MoveValueAnnotator};
use move_resource_viewer::MoveValueAnnotator;
use moveos::moveos::MoveOS;
use moveos::vm::vm_status_explainer::explain_vm_status;
use moveos_store::transaction_store::TransactionStore;
use moveos_store::MoveOSStore;
use moveos_types::event::AnnotatedMoveOSEvent;
use moveos_types::event::AnnotatedEvent;
use moveos_types::event::EventHandle;
use moveos_types::function_return_value::AnnotatedFunctionResult;
use moveos_types::function_return_value::AnnotatedFunctionReturnValue;
Expand Down Expand Up @@ -306,10 +306,10 @@ impl Handler<ExecuteViewFunctionMessage> for ExecutorActor {
values
.into_iter()
.map(|v| {
let move_value = resoler.view_value(&v.type_tag, &v.value)?;
let decoded_value = resoler.view_value(&v.type_tag, &v.value)?;
Ok(AnnotatedFunctionReturnValue {
value: v,
move_value,
decoded_value,
})
})
.collect::<Result<Vec<AnnotatedFunctionReturnValue>, anyhow::Error>>()?,
Expand Down Expand Up @@ -385,7 +385,7 @@ impl Handler<GetEventsByEventHandleMessage> for ExecutorActor {
&mut self,
msg: GetEventsByEventHandleMessage,
_ctx: &mut ActorContext,
) -> Result<Vec<AnnotatedMoveOSEvent>> {
) -> Result<Vec<AnnotatedEvent>> {
let GetEventsByEventHandleMessage {
event_handle_type,
cursor,
Expand All @@ -400,12 +400,9 @@ impl Handler<GetEventsByEventHandleMessage> for ExecutorActor {
events
.into_iter()
.map(|event| {
let state = State::new(event.event_data.clone(), event.type_tag.clone());
let event_move_value = MoveValueAnnotator::new(resolver)
.view_resource(&event_handle_type, state.value.as_slice())?;
let annotated_event_data =
AnnotatedState::new(state, AnnotatedMoveValue::Struct(event_move_value));
Ok(AnnotatedMoveOSEvent::new(event, annotated_event_data))
.view_resource(&event_handle_type, event.event_data())?;
Ok(AnnotatedEvent::new(event, event_move_value))
})
.collect::<Result<Vec<_>>>()
}
Expand All @@ -417,7 +414,7 @@ impl Handler<GetEventsMessage> for ExecutorActor {
&mut self,
msg: GetEventsMessage,
_ctx: &mut ActorContext,
) -> Result<Vec<AnnotatedMoveOSEvent>> {
) -> Result<Vec<AnnotatedEvent>> {
let GetEventsMessage { filter } = msg;
let event_store = self.moveos.event_store();
let resolver = self.moveos.moveos_resolver();
Expand All @@ -426,13 +423,10 @@ impl Handler<GetEventsMessage> for ExecutorActor {
events
.into_iter()
.map(|event| {
let state = State::new(event.event_data.clone(), event.type_tag.clone());
let struct_tag = as_struct_tag(event.type_tag.clone())?;
let event_move_value = MoveValueAnnotator::new(resolver)
.view_resource(&struct_tag, state.value.as_slice())?;
let annotated_event_data =
AnnotatedState::new(state, AnnotatedMoveValue::Struct(event_move_value));
Ok(AnnotatedMoveOSEvent::new(event, annotated_event_data))
.view_resource(&struct_tag, event.event_data())?;
Ok(AnnotatedEvent::new(event, event_move_value))
})
.collect::<Result<Vec<_>>>()
}
Expand Down
6 changes: 3 additions & 3 deletions crates/rooch-executor/src/actor/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use coerce::actor::message::Message;
use move_core_types::account_address::AccountAddress;
use move_core_types::language_storage::StructTag;
use moveos_types::access_path::AccessPath;
use moveos_types::event::AnnotatedMoveOSEvent;
use moveos_types::event::AnnotatedEvent;
use moveos_types::event_filter::EventFilter;
use moveos_types::function_return_value::AnnotatedFunctionResult;
use moveos_types::h256::H256;
Expand Down Expand Up @@ -112,7 +112,7 @@ pub struct GetEventsByEventHandleMessage {
}

impl Message for GetEventsByEventHandleMessage {
type Result = Result<Vec<AnnotatedMoveOSEvent>>;
type Result = Result<Vec<AnnotatedEvent>>;
}

#[derive(Debug, Serialize, Deserialize)]
Expand All @@ -121,7 +121,7 @@ pub struct GetEventsMessage {
}

impl Message for GetEventsMessage {
type Result = Result<Vec<AnnotatedMoveOSEvent>>;
type Result = Result<Vec<AnnotatedEvent>>;
}

#[derive(Debug, Serialize, Deserialize)]
Expand Down
6 changes: 3 additions & 3 deletions crates/rooch-executor/src/proxy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use moveos_types::transaction::TransactionExecutionInfo;
use moveos_types::transaction::TransactionOutput;
use moveos_types::{access_path::AccessPath, transaction::VerifiedMoveOSTransaction};
use moveos_types::{
event::AnnotatedMoveOSEvent,
event::AnnotatedEvent,
event_filter::EventFilter,
state::{AnnotatedState, State},
};
Expand Down Expand Up @@ -117,7 +117,7 @@ impl ExecutorProxy {
event_handle_type: StructTag,
cursor: Option<u64>,
limit: u64,
) -> Result<Vec<AnnotatedMoveOSEvent>> {
) -> Result<Vec<AnnotatedEvent>> {
self.actor
.send(GetEventsByEventHandleMessage {
event_handle_type,
Expand All @@ -127,7 +127,7 @@ impl ExecutorProxy {
.await?
}

pub async fn get_events(&self, filter: EventFilter) -> Result<Vec<AnnotatedMoveOSEvent>> {
pub async fn get_events(&self, filter: EventFilter) -> Result<Vec<AnnotatedEvent>> {
self.actor.send(GetEventsMessage { filter }).await?
}

Expand Down
Loading
Loading