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

world: make world events only emitable by world #1092

Closed
wants to merge 2 commits into from

Conversation

notV4l
Copy link
Collaborator

@notV4l notV4l commented Oct 24, 2023

No description provided.

@@ -455,6 +467,7 @@ mod world {
/// * `keys` - The keys of the event.
/// * `values` - The data to be logged by the event.
fn emit(self: @ContractState, mut keys: Array<felt252>, values: Span<felt252>) {
assert(keys.len() > 0 && !self.reserved_events.read(*keys.at(0)), 'reserved event name');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would prefer not to add this additional overhead to every emit.

instead, consumers should properly validate events and ensure that the caller address isn't added (see below) for world events

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so the change here should really be in torii server, where we must verify the event data length is what we expect

Copy link
Collaborator Author

@notV4l notV4l Oct 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would prefer not to add this additional overhead to every emit.

instead, consumers should properly validate events and ensure that the caller address isn't added (see below) for world events

still possible to emit fake event for any event where last field is ContractAddress type or even Span / bool

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think so, since the event data will be incorrectly serialized

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes indeed mb, caller_address is added to keys not values

@notV4l notV4l closed this Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants