Skip to content

Commit

Permalink
chore: rebase on main
Browse files Browse the repository at this point in the history
  • Loading branch information
willemneal committed Mar 15, 2023
1 parent 058b2e5 commit df523d0
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 22 deletions.
2 changes: 1 addition & 1 deletion soroban-env-host/src/events/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl InternalEventsBuffer {
pub fn dump_to_debug_log(&self) {
use log::debug;
debug!("=======Start of events=======");
for e in self.vec.iter() {
for e in &self.vec {
match &e.0 {
InternalEvent::Contract(c) => debug!("Contract event: {:?}", c),
InternalEvent::Debug(d) => debug!("Debug event: {}", d),
Expand Down
20 changes: 7 additions & 13 deletions soroban-env-host/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,13 @@ pub struct LedgerInfo {
pub base_reserve: u32,
}

#[derive(Clone)]
#[derive(Clone, Default)]
pub enum DiagnosticLevel {
#[default]
None,
Debug,
}

impl Default for DiagnosticLevel {
fn default() -> Self {
DiagnosticLevel::None
}
}

#[derive(Clone, Default)]
pub(crate) struct HostImpl {
source_account: RefCell<Option<AccountId>>,
Expand Down Expand Up @@ -1026,7 +1021,7 @@ impl Host {
}
}

self.fn_call_diagnostics(&id, &func, args)?;
self.fn_call_diagnostics(id, &func, args)?;

// "testutils" is not covered by budget metering.
#[cfg(any(test, feature = "testutils"))]
Expand Down Expand Up @@ -1110,14 +1105,13 @@ impl Host {
}
}

let res = self.call_contract_fn(&id, &func, args);
let res = self.call_contract_fn(id, &func, args);

match &res {
Ok(res) => self.fn_return_diagnostics(id, &func, &res)?,
Err(err) => {}
if let Ok(res) = &res {
self.fn_return_diagnostics(id, &func, res)?;
}

return res;
res
}

// Notes on metering: covered by the called components.
Expand Down
6 changes: 2 additions & 4 deletions soroban-env-host/src/host/diagnostics_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ impl Host {
self.record_system_debug_contract_event(
ContractEventType::Diagnostic,
calling_contract,
self.add_host_object(HostVec::from_vec(topics)?)?
.try_into()?,
self.add_host_object(HostVec::from_vec(topics)?)?,
self.vec_new_from_slice(args)?.into(),
)
})
Expand All @@ -102,8 +101,7 @@ impl Host {
self.record_system_debug_contract_event(
ContractEventType::Diagnostic,
Some(self.hash_to_bytesobj(contract_id)?),
self.add_host_object(HostVec::from_vec(topics)?)?
.try_into()?,
self.add_host_object(HostVec::from_vec(topics)?)?,
*res,
)
})
Expand Down
6 changes: 3 additions & 3 deletions soroban-env-host/src/host/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ impl Debug for HostError {
ev.0.iter()
.rev()
.filter_map(|ev| match ev.event.clone() {
Event::Debug(e) => Some(format!("Debug {:}", e)),
Event::StructuredDebug(e) => Some(format!("StructuredDebug {:?}", e)),
_ => None,
Event::Debug(e) => Some(format!("Debug {e:}")),
Event::StructuredDebug(e) => Some(format!("StructuredDebug {e:?}")),
Event::Contract(_) => None,
})
.take(MAX_DEBUG_EVENTS)
.enumerate()
Expand Down
2 changes: 1 addition & 1 deletion soroban-env-host/src/test/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ fn test_event_rollback() -> Result<(), HostError> {
let args = host.test_vec_obj::<i32>(&[1, 2])?;
host.register_test_contract(id, test_contract)?;
assert_eq!(
host.call(id, sym.into(), args.into())?.get_payload(),
host.call(id, sym, args)?.get_payload(),
RawVal::from_void().to_raw().get_payload()
);
host.0.events.borrow_mut().rollback(1)?;
Expand Down

0 comments on commit df523d0

Please sign in to comment.