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

Improved event syscall API #1637

Closed
Stebalien opened this issue Feb 3, 2023 · 2 comments · Fixed by #1807
Closed

Improved event syscall API #1637

Stebalien opened this issue Feb 3, 2023 · 2 comments · Fixed by #1807
Assignees
Milestone

Comments

@Stebalien
Copy link
Member

Currently, events are emitted as CBOR objects. Unfortunately, this makes it hard to accurately charge gas for parsing.

Proposal:

Emit three buffers:

  • entries: An array of [(flags: u64, codec: u64, key_len: u32, value_len: u32), ...] (packed). I.e., 24 bytes per event.
  • keys: A buffer of all keys, concatenated.
  • values: A buffer of all values, concatenated.

The FVM will:

  1. Compute the number of entries as entries.len() / 24 (or return an error if not a multiple of 24).
  2. Charge gas based on the number of entries, the length of keys, and the length of values.
  3. Reconstruct the events from these parameters.

Importantly, this means the FVM can accurately charge gas before parsing anything.

@Stebalien Stebalien added this to the M2.2 milestone Feb 3, 2023
@Stebalien Stebalien modified the milestones: M2.2, NV19, NV20 Feb 27, 2023
@aashidham
Copy link

Does this have any product implications with the emission of events? What about event listeners?

Will this generally make sending events to the event log more or less expensive?

@Stebalien
Copy link
Member Author

This won't have any user-facing implications.

This issue is purely security/performance related. Although it may make emitting events less expensive as it may be less expensive to validate them? But that's unclear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants