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

Refactor execution functions with proper error handling #107

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

Conversation

JulianGCalderon
Copy link
Contributor

@JulianGCalderon JulianGCalderon commented Dec 17, 2024

Closes #99, #84, #18
Supersedes #19

This PR refactors the execution functions to make them easier to user, and adds proper error handling. I replaced the old functions with 2 new functions:

  • execute_transaction: Executes a single transaction with a clean state, fetching all needed information.
  • fetch_transaction: Fetches all information needed to execute a transaction. Useful when you need to use a previous state, instead of a clean one. After calling fetch_transaction, you could just call transaction.execute().

The remaining changes on this PR are a side effect of the changes mentioned above.

The Github diff is not useful for reviewing the changes in execution.rs as they have a lot of overlap. I'd suggest reviewing it with an external editor, as the whole file has been changed.

Other Improvements

Given a transaction in block N, we used block N-1 for fetching the transaction contextual information, this would fail when trying to execute a Declare, as block N-1 didn't have the declared class. This PR changes this, so that block N is used to fetch the transaction information, while block N-1 is used as the starting execution state.

This changed the behaviour of some transactions, as the block context contains fields such as gas price. I had to adjust the tests to the new values, which I obtained by comparing with Cairo VM. Some transactions are now emitting more events than before, which I think that indicates that it's now working better.

The replay flag --charge-fee was not being used. This PR fixes it.

@JulianGCalderon JulianGCalderon force-pushed the remove-unwraps branch 2 times, most recently from 684bf06 to da146b6 Compare December 17, 2024 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant