tracer.py
Updated Opcode Costs: Adjusted the cu_costs dictionary to reflect Python 3.11's opcodes using opcode names to ensure compatibility.
Instruction Cache Management: Added code to clear the instruction cache after execution to prevent holding contracts in memory.
Static Imports Enforcement: Ensured that only code within contracts is traced, enforcing static imports and preventing dynamic imports during execution.
Memory Usage Limit: Strictly enforced a memory usage limit and tracked incremental changes to prevent unexpected memory spikes.
runtime.py
Module Cache Clearing: Modified Runtime.clean_up() to clear the module cache, preventing all contracts from being held in memory.
Context Resetting: Ensured proper resetting of the execution context to avoid residual state affecting subsequent executions.
Compatibility Updates: Adjusted code for compatibility with Python 3.11 and optimized for performance.
executor.py
Module Cache Clearing: Added code to clear the module cache after contract execution to free up memory.
Static Imports Enforcement: Adjusted code to ensure that contracts cannot perform dynamic imports at runtime.
Exception Handling Optimization: Streamlined exception handling to ensure resources are properly cleaned up.
module.py
Restricted Imports Enforcement: Modified the restricted_import function to prevent dynamic imports within contracts, enforcing static imports.
Module Cache Management: Changed the module cache to an instance variable and ensured it's cleared after execution to prevent memory buildup.
Compatibility Adjustments: Updated module loading mechanisms to be compatible with Python 3.11's import system.
Type of change
Please delete options that are not relevant.
[x] Breaking change (fix or feature that would require a resync of blockchain state)
Checklist
[x] I have performed a self-review of my own code
[x] I have tested this change in my development environment.
[ ] I have added tests to prove that this change works
[ ] All existing tests pass after this change
[ ] I have added / updated documentation related to this change
Description
Improvements and Optimizations:
tracer.py Updated Opcode Costs: Adjusted the cu_costs dictionary to reflect Python 3.11's opcodes using opcode names to ensure compatibility. Instruction Cache Management: Added code to clear the instruction cache after execution to prevent holding contracts in memory. Static Imports Enforcement: Ensured that only code within contracts is traced, enforcing static imports and preventing dynamic imports during execution. Memory Usage Limit: Strictly enforced a memory usage limit and tracked incremental changes to prevent unexpected memory spikes.
runtime.py Module Cache Clearing: Modified Runtime.clean_up() to clear the module cache, preventing all contracts from being held in memory. Context Resetting: Ensured proper resetting of the execution context to avoid residual state affecting subsequent executions. Compatibility Updates: Adjusted code for compatibility with Python 3.11 and optimized for performance.
executor.py Module Cache Clearing: Added code to clear the module cache after contract execution to free up memory. Static Imports Enforcement: Adjusted code to ensure that contracts cannot perform dynamic imports at runtime. Exception Handling Optimization: Streamlined exception handling to ensure resources are properly cleaned up.
module.py Restricted Imports Enforcement: Modified the restricted_import function to prevent dynamic imports within contracts, enforcing static imports. Module Cache Management: Changed the module cache to an instance variable and ensured it's cleared after execution to prevent memory buildup. Compatibility Adjustments: Updated module loading mechanisms to be compatible with Python 3.11's import system.
Type of change
Please delete options that are not relevant.
Checklist