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

[CRE-43] fix slicing of events #992

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

agparadiso
Copy link
Contributor

@agparadiso agparadiso commented Jan 10, 2025

Description

The original code was using the actual value of the []byte as an index

outOffset := events[i*eventsLen]
slot := events[outOffset:]

instead we are now calculating the index of the corresponding event and slicing it (given its a fixed lenght)

outOffset := i * eventsLen
slot := events[outOffset : outOffset+eventsLen]

more info in the ticket

CRE-43

Requires

Supports

@agparadiso agparadiso marked this pull request as ready for review January 10, 2025 12:17
@agparadiso agparadiso requested a review from a team as a code owner January 10, 2025 12:17
MStreet3
MStreet3 previously approved these changes Jan 10, 2025
outOffset := events[i*eventsLen]

slot := events[outOffset:]
outOffset := i * eventsLen
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is eventsLen defined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is a const defined here

Copy link
Contributor

@MStreet3 MStreet3 left a comment

Choose a reason for hiding this comment

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

Small nit

@@ -228,3 +231,14 @@ func createRandomGet(cfg *ModuleConfig) func(caller *wasmtime.Caller, buf, bufLe
return ErrnoSuccess
}
}

func getSlot(events []byte, i int32) ([]byte, error) {
outOffset := i * eventsLen
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the prefix out? Offset is simpler to understand

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