-
Notifications
You must be signed in to change notification settings - Fork 2.7k
contracts: add events to ContractResult #13807
Changes from 1 commit
47200ff
a534758
28a9643
cf43686
08db645
7ca1b4b
5ad0868
dbd8735
1718400
782aba7
74d4b70
45e6eab
4426bbe
0de45b6
8d36e91
02c41d3
5d4fd5c
b9cb4ef
a8b0c8b
160cfb3
dacdc53
e7fa394
337e54e
b9838b1
fca001f
a8da1ff
af6587a
9919fd1
51894be
1e09bdb
eef0f97
3023dfd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,8 +71,8 @@ pub struct ContractResult<R, Balance, EventRecord> { | |
| pub debug_message: Vec<u8>, | ||
| /// The execution result of the wasm code. | ||
| pub result: R, | ||
| /// The events that were emitted during execution. During on-chain execution these events are | ||
| /// None to avoid putting all the Events emitted in the block so far into the PoV. | ||
| /// The events that were emitted during execution. It is an options as event collection is | ||
| /// optional. | ||
| pub events: Option<Vec<EventRecord>>, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Even if
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This has been tested against Contracts UI and it works just fine.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
SCALE is not really well defined by a spec or something. Whether you ignore trailing data or not is up to the implementation. See That said, I suspect the default behavior is to ignore trailing data. Hence we can safely extend the struct in new versions. But if you think about it this means we don't even need a new version in this case because we can just always emit the events since they will be ignored by older code as trailing data. If they ignore a single I suggest we do away with the new version and two type aliases and just extend the struct. Should work the same way.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have removed the new version and implemented it all in the original
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a |
||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -932,26 +932,31 @@ struct InstantiateInput<T: Config> { | |||||
| salt: Vec<u8>, | ||||||
| } | ||||||
|
|
||||||
| /// Determines whether events should be collected during execution. | ||||||
| #[derive(PartialEq)] | ||||||
| pub enum CollectEvents { | ||||||
juangirini marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| /// Collect events. | ||||||
| /// | ||||||
| /// # Note | ||||||
| /// | ||||||
| /// Events should only be collected when called off-chain, as this would | ||||||
| /// collect all the Events emitted in the block so far and put them in them into the PoV. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
missed that earlier |
||||||
| /// | ||||||
| /// **Never** use this mode for on-chain execution. | ||||||
| UnsafeCollect, | ||||||
| /// Events should not be collected. | ||||||
| /// Skip event collection. | ||||||
| Skip, | ||||||
| } | ||||||
|
|
||||||
| #[derive(PartialEq)] | ||||||
| pub enum DebugInfo { | ||||||
juangirini marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| /// Collect debug messages. | ||||||
| /// # Note | ||||||
juangirini marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| /// | ||||||
| /// This should only ever be set to `UnsafeDebug` when executing as an RPC because | ||||||
| /// it adds allocations and could be abused to drive the runtime into an OOM panic. | ||||||
| UnsafeDebug, | ||||||
| /// Skip collection of debug messages. | ||||||
| Skip, | ||||||
juangirini marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| } | ||||||
|
|
||||||
|
|
@@ -1135,7 +1140,7 @@ impl<T: Config> Pallet<T> { | |||||
| /// information. | ||||||
| /// | ||||||
| /// If `collect_events` is set to `CollectEvents::UnsafeCollect` it collects all the Events | ||||||
| /// emitted in the block so far. | ||||||
| /// emitted in the block so far and the ones emitted during the execution of this contract. | ||||||
| pub fn bare_call( | ||||||
| origin: T::AccountId, | ||||||
| dest: T::AccountId, | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.