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

Fix transaction implementation in LogState::validate. #243

Merged

Conversation

peterhuene
Copy link
Member

This PR removes the incorrect transaction implementation for LogState::validate.

Now validate takes ownership of self and returns Result<Self, ValidationError>.

This means that callers that expect to keep the log state following an invalid log entry must clone the state prior to validation.

As the in-memory data store is the only store that persists the log state in memory, it now clones the state before validation and updates the log state upon successful validation.

For the postgres data store, the log state was loaded from the database and is discarded on error, so no clone is necessary.

Fixes #242.

This commit removes the incorrect transaction implementation for
`LogState::validate`.

Now `validate` takes ownership of `self` and returns `Result<Self,
ValidationError>`.

This means that callers that expect to keep the log state following an invalid
log entry must clone the state prior to validation.

As the in-memory data store is the only store that persists the log state in
memory, it now clones the state before validation and updates the log state
upon successful validation.

For the postgres data store, the log state was loaded from the database and is
discarded on error, so no clone is necessary.

Fixes bytecodealliance#242.
@calvinrp calvinrp self-requested a review February 7, 2024 20:24
@peterhuene peterhuene merged commit cf62106 into bytecodealliance:main Feb 7, 2024
6 checks passed
@peterhuene peterhuene deleted the fix-log-state-transaction branch February 7, 2024 20:27
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.

LogState methods snapshot and rollback are not implemented correctly
2 participants