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

feat: SIM-BE-expose GenVM errors on RPC #1022

Merged
merged 3 commits into from
Mar 31, 2025

Conversation

kstroobants
Copy link
Contributor

@kstroobants kstroobants commented Mar 25, 2025

Fixes #771

What

  • Added genvm_result to the Receipt class to include stdout and stderr from the genvm execution.
  • Updated the to_dict and from_dict methods in the Receipt class to handle the new genvm_result field.

Why

  • To provide more detailed information about the genvm execution in the receipt, which can help in debugging and understanding the execution flow.

Testing done

  • Executed transaction in studio.
  • Verified that the genvm_result is correctly populated in the Receipt object.
  • Tested the serialization and deserialization of the Receipt object to ensure genvm_result is handled properly.

Decisions made

  • Decided to use a dictionary to store stdout and stderr for flexibility and ease of access.

Checks

  • I have tested this code
  • I have reviewed my own PR
  • I have created an issue for this PR
  • I have set a descriptive PR title compliant with conventional commits

Reviewing tips

  • Focus on the changes in the Receipt class and ensure that the genvm_result is correctly integrated.

User facing release notes

The receipt now includes detailed genvm execution results.

@kstroobants kstroobants requested a review from cristiam86 March 25, 2025 16:03
@kstroobants kstroobants self-assigned this Mar 25, 2025
@kstroobants kstroobants linked an issue Mar 25, 2025 that may be closed by this pull request
Copy link

codecov bot commented Mar 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 14.81%. Comparing base (d056d34) to head (8f69dd7).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1022   +/-   ##
=======================================
  Coverage   14.81%   14.81%           
=======================================
  Files         123      123           
  Lines        7364     7364           
  Branches      254      254           
=======================================
  Hits         1091     1091           
  Misses       6194     6194           
  Partials       79       79           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kstroobants
Copy link
Contributor Author

Now the receipt looks like this when I write an error in the contract code:

{
appeal_failed:0
appeal_processing_time:0
appeal_undetermined:false
appealed:false
blockHash:null
blockNumber:null
chainId:null
config_rotation_rounds:3
consensus_data:{
leader_receipt:{
calldata:{...}
contract_state:{...}
eq_outputs:{}
execution_result:"ERROR"
gas_used:0
genvm_result:{
stderr:"Traceback (most recent call last):
File "<string>", line 1, in <module>
import contract; import genlayer.std._internal.runner
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/py/libs/genlayer/std/_internal/runner.py", line 148, in <module>
_handle_call(__known_contact__, mem[len(CALL) :])
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/py/libs/genlayer/std/_internal/runner.py", line 112, in _handle_call
_give_result(
~~~~~~~~~~~~^
lambda: meth(
^^^^^^^^^^^^^
contract_instance, *calldata.get('args', []), **calldata.get('kwargs', {})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
)
^
File "/py/libs/genlayer/std/_internal/runner.py", line 19, in _give_result
res = res_fn()
File "/py/libs/genlayer/std/_internal/runner.py", line 113, in <lambda>
lambda: meth(
~~~~^
contract_instance, *calldata.get('args', []), **calldata.get('kwargs', {})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/contract.py", line 23, in update_storage
print(new_storage.type)
^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'type'
"
stdout:""
}
mode:"leader"
node_config:{...}
pending_transactions:[]
result:{...}
vote:"agree"
}
validators:[
{
calldata:"FgRhcmdzDRRhYQZtZXRob2R0dXBkYXRlX3N0b3JhZ2U="
contract_state:{...}
eq_outputs:{}
execution_result:"ERROR"
gas_used:0
genvm_result:{
stderr:"Traceback (most recent call last):
File "<string>", line 1, in <module>
import contract; import genlayer.std._internal.runner
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/py/libs/genlayer/std/_internal/runner.py", line 148, in <module>
_handle_call(__known_contact__, mem[len(CALL) :])
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/py/libs/genlayer/std/_internal/runner.py", line 112, in _handle_call
_give_result(
~~~~~~~~~~~~^
lambda: meth(
^^^^^^^^^^^^^
contract_instance, *calldata.get('args', []), **calldata.get('kwargs', {})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
)
^
File "/py/libs/genlayer/std/_internal/runner.py", line 19, in _give_result
res = res_fn()
File "/py/libs/genlayer/std/_internal/runner.py", line 113, in <lambda>
lambda: meth(
~~~~^
contract_instance, *calldata.get('args', []), **calldata.get('kwargs', {})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/contract.py", line 23, in update_storage
print(new_storage.type)
^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'type'
"
stdout:""
}
mode:"validator"
node_config:{...}
pending_transactions:[]
result:"AmV4aXRfY29kZSAx"
vote:"agree"
}
{...}
{...}
{...}

@cristiam86 cristiam86 merged commit 6ecca46 into main Mar 31, 2025
13 checks passed
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.

SIM-BE-expose GenVM errors on RPC
2 participants