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

Restructure Event to be cheap to clone and allow it to be rolled back #662

Merged
merged 10 commits into from
Feb 10, 2023

Conversation

jayz22
Copy link
Contributor

@jayz22 jayz22 commented Feb 3, 2023

What

Resolves #648 and #647.

Restructure the Event:

  • Make it an internal structure that is cheap to clone. The buffer is using a MeteredVector such that metering is taken care of automatically.
  • Converts to the external Event struct only by demand 1. when host is finished 2. when an error arises.

Include InternalEventsBuffer in the RollbackPointand roll backContractEvents (keeping DebugEvent`s) on contract failure.

Here is the sample output of a failed cross-contract call (contracts A->B and B failed):

=======Start of events=======
Debug event: rolled-back contract event: type I32(1), id Object(Bytes(#18)), topics Object(Vec(#13)), data Object(Vec(#17))
Debug event: rolled-back contract event: type I32(1), id Object(Bytes(#27)), topics Object(Vec(#23)), data Object(Vec(#26))
Debug event: TrapUnreachable
Debug event: U32(1) contract events rolled back. Rollback start pos = U32(1)
Debug event: contract call invocation resulted in error Status(VmError(TrapUnreachable))
Debug event: escalating error '' to VM trap
Debug event: VM trapped with host error
Debug event: U32(1) contract events rolled back. Rollback start pos = U32(0)
Debug event: contract call invocation resulted in error Status(VmError(TrapUnreachable))
========End of events========

Why

[TODO: Why this change is being made. Include any context required to understand the why.]

Known limitations

[TODO or N/A]

soroban-env-host/src/host.rs Outdated Show resolved Hide resolved
@jayz22 jayz22 marked this pull request as ready for review February 7, 2023 16:00
@jayz22 jayz22 requested review from sisuresh and a team as code owners February 7, 2023 16:00
@graydon graydon enabled auto-merge (squash) February 10, 2023 05:40
@graydon graydon self-requested a review February 10, 2023 05:40
@graydon graydon merged commit 90f361b into stellar:main Feb 10, 2023
@jayz22 jayz22 deleted the events branch February 13, 2023 17:03
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.

Split out contract event validation from conversion. Have event buffer contain Val references only.
3 participants