tweak: Reduce non-required pub visibility.#81
Conversation
…me-ir-file Remove duplicate runtime IR files
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Analyzed three conflicting layouts for execution context:
1. Rust runtime: inline 32KB memory array
2. LLVM IR: inline 1KB memory array (incorrect size)
3. Compiler types: pointer-based {ptr, len, cap} struct
Key findings:
- Memory field has three different representations
- Total struct sizes: 65,568 vs 33,824 vs 32,808 bytes
- Field offsets misaligned causing memory corruption
- GEP instructions access wrong memory locations
Recommendation: Adopt pointer-based memory uniformly
- Supports dynamic growth (EVM requirement)
- Standard {ptr, len, cap} pattern
- More memory efficient
- Eliminates layout mismatch bugs
Document includes pros/cons analysis, specific changes needed,
and migration path for fixing this critical bug.
https://claude.ai/code/session_01MBuZwAnjesPK17GtMHPZ5d
Documented the strategy for EVM word representation and runtime implementation, including decisions on type representation, runtime functions, and safety layers.
* Initial plan * docs: add Copilot onboarding instructions Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * Update .github/copilot-instructions.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix: resolve master merge in contract builder Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> Co-authored-by: Tyler Smith <mail@tcry.pt> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…iltins (#19) * Initial plan * Phase 1 complete: Create jet_ir crate with unified Types and update memory layout Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * Phase 2 complete: Create runtime builder to generate IR instead of handwritten LLVM Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * Add documentation and layout verification tests Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * Address code review feedback: improve memory handling and add clarifying comments Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * Final refinement: simplify return_data slice creation and add implementation summary Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * Remove excessive comments and create ADR-002 for pointer-based memory decision Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * Refactor layout tests to use enums instead of magic numbers Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * Implement runtime builtins as generated LLVM IR instead of compiled Rust - Generate all stack operations (push, pop, peek, swap) as LLVM IR - Generate all memory operations (load, store word, store byte) as LLVM IR - Keep contract calls and crypto operations as external Rust functions - Remove Rust implementations of stack/memory ops from builtins.rs - Update engine to only link external functions, not IR-generated ones - This fulfills the core requirement of ADR-001 Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * Fix function name mismatch and update documentation - Fix jet.stack.push.word -> jet.stack.push.ptr to match symbol constant - Update IMPLEMENTATION_COMPLETE.md to list all 8 IR-generated functions - Update architecture-refactoring-summary.md to list all 8 IR-generated functions Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * Remove transition documentation and unnecessary comments - Remove IMPLEMENTATION_COMPLETE.md (doesn't belong in repo) - Remove runtime-ir/DEPRECATED.md and runtime-ir/jet.ll (no longer used) - Rewrite architecture-refactoring-summary.md to describe current state not transition - Remove "backward compatibility" comment from lib.rs - Change comment in exec.rs from "Changed to" to simply state current state Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * Clean up redundant project name mentions in documentation Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com>
* ci: add GitHub Actions workflow with cargo-nextest Add comprehensive CI setup with single sequential job to minimize runner costs. - GitHub Actions workflow with efficient sequential execution - Use nightly Rust for formatting and linting (fail fast) - Use stable Rust for building and testing - Install cargo-nextest for faster test execution - Setup LLVM 21 and dependency caching - Enhanced Makefile with nextest and CI targets - Add test, test-all, doctest targets using nextest - Add fmt, fmt-check, clippy, clippy-fix targets - Add ci and commit-check targets for pre-commit validation - Add install-tools target for cargo-nextest setup - Add .nextest.toml for test runner configuration - Add rust-toolchain.toml specifying stable as default - Add DEVELOPMENT.md with comprehensive developer guide Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * style: apply rustfmt formatting Fix formatting issues identified by CI: - Reorder imports alphabetically - Format long function calls and method chains - Apply consistent line wrapping Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * docs: fix documentation inconsistencies and improve CI configuration Address PR review feedback to fix documentation accuracy and improve CI workflow reliability. Makefile changes: - Add +nightly back to fmt/clippy targets for explicit toolchain control - Update target descriptions to reflect nightly usage CI workflow improvements: - Use scripts/install-llvm.sh instead of duplicating installation logic - Remove libpolly-21-dev (not used by the project) - Replace manual caching with Swatinem/rust-cache for better optimization - Add explicit +stable to build/test commands for clarity Documentation fixes (DEVELOPMENT.md): - Fix install-tools description to match actual behavior (only installs nextest) - Update CI section to accurately describe single sequential job - Clarify that Makefile uses cargo +nightly for fmt/clippy - Update configuration file descriptions Configuration improvements: - Remove rustfmt/clippy from rust-toolchain.toml (using nightly versions) - Simplify .nextest.toml by removing unused CI profile - Update comments to reflect actual usage Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * style: apply rustfmt formatting after rebase Fix formatting issues detected by CI after rebasing onto master. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix: remove empty line after doc comment in constants.rs Fix clippy error: empty line after doc comment. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix: replace deprecated ptr_type with Context::ptr_type Fix clippy deprecation warnings by using Context::ptr_type instead of StructType::ptr_type as required by LLVM 15+. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * style: apply rustfmt formatting to runtime_builder Format runtime_builder.rs after ptr_type changes. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix: add unsafe block and allow dead_code for IR-called methods - Wrap unsafe function call in unsafe block (edition 2024 requirement) - Add #[allow(dead_code)] to stack methods called from generated IR Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * style: apply rustfmt formatting Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix: clippy errors in layout_tests - Remove empty line after doc comment - Convert BasicTypeEnum to AnyTypeEnum with .into() Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix: clippy errors - function casts and lifetime elision - Cast functions to *const () before usize per clippy - Add explicit '_ lifetimes to avoid elision confusion Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * style: apply rustfmt Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix: resolve unused import, type conversion, and clippy lints - Remove unused 'error' import from engine/mod.rs - Fix BasicTypeEnum to AnyTypeEnum conversion in layout_tests.rs by matching on enum variants - Remove unnecessary let binding in ops.rs (clippy::let-and-return) - Add explicit '_ lifetime to iter() return type (mismatched-lifetime-syntaxes) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix: add ScalableVectorType variant to match expression Add missing ScalableVectorType case in BasicTypeEnum match to handle all possible variants and fix non-exhaustive pattern error. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix: correct coinbase address size in jetdbg Change coinbase from 20-byte to 2-byte array to match ADDRESS_SIZE_BYTES constant defined in jet_runtime. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * chore: simplify CI to use stable Rust only Remove nightly toolchain usage and use stable Rust for all operations: - Formatting (rustfmt) - Linting (clippy) - Building - Testing This avoids toolchain-specific issues and simplifies the CI workflow. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix: install Polly library for LLVM static linking Add libpolly-21-dev package to LLVM installation to provide the Polly static library required for linking. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix: correct function names in runtime_builder test Update test_runtime_builder_creates_module to check for the actual function names generated by the builder: - "jet.stack.push.ptr" instead of "jet.stack.push.word" - Add checks for all generated stack and memory functions Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix: add JIT_ENGINE global to runtime module Add the jet.jit_engine global variable to the runtime module so that the Symbols loader can find all required runtime functions and globals. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix: ensure memory is expanded before writing return data Expand memory_len to accommodate writes when copying return data from contract calls. This fixes out-of-bounds panics when writing to memory that hasn't been expanded yet. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Document type-driven design patterns in Atlas, focusing on safety, clarity, and performance using Rust's type system.
* ci: auto-apply rustfmt and commit formatting fixes Replace the formatting check with cargo fmt --all and use the shared commit-changes composite action to push any fixes back to the branch. Add contents: write permission so the token can push commits. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix * ci: gate rustfmt commit step to trusted contexts Skip the commit-changes step and downgrade contents permission to read on fork PRs where GITHUB_TOKEN cannot push. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * ci: fix permissions expression (must be static) GitHub Actions does not support expressions in the permissions block. Revert to static contents: write — the if: condition on the commit step is sufficient to prevent pushes on fork PRs. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
* Add error handling to jet_runtime and jet crates Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * Address code review feedback - optimize unreachable error checks Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * Improve safety comments and error logging per code review Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * Replace unwrap_unchecked with regular unwrap and document error codes Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * Address PR review comments: remove unwrap, add pointer validation, fix error codes Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * Convert error codes to enums and fix duplicate -1 values Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * fix * style: apply rustfmt formatting 🤖 * fix: remove unused jet_runtime self import in engine/mod.rs * fix: remove unused Style import in builder/manager.rs * fix: remove invalid memory_len bounds check in return_data_copy_impl MSTORE does not update memory_len, so checking ret_offset + ret_len <= memory_len always fails. This check was deliberately omitted in the original code with a TODO comment. Restore the TODO until memory tracking is implemented. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
* Initial plan * ci: add LLVM 21 installation caching Cache LLVM 21 installation to reduce CI time. The installation currently takes ~30 seconds on each run. This change: - Uses GitHub Actions cache to store LLVM installation as tarball - Only installs LLVM when cache miss occurs - Restores from cache when available - Cache key includes install scripts to invalidate on changes Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * ci: use $RUNNER_TEMP for tarball and add ImageOS to cache key - Move tarball to $RUNNER_TEMP to avoid polluting workspace - Add runner.arch and env.ImageOS to cache key for binary compatibility - Ensures cache invalidates when runner image changes Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> Co-authored-by: Tyler Smith <mail@tcry.pt>
* fix build on non-termux. * add and organize docs. * fix Makefile. * Remove libpolly. * Useshared libs.
* Initial plan * Add memory length tracking writeup Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * Refine opcode naming in writeup Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * Update docs/tasks/memory-length-tracking-mstore.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> Co-authored-by: Tyler Smith <mail@tcry.pt> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Add EXP. * style: apply rustfmt formatting 🤖 * fixes * ci: force LLVM cache invalidation for dynamic linking The cache was hitting old entries built for static linking, causing "unable to find library -lLLVM-21" errors after adding the llvm21-1-prefer-dynamic feature to inkwell. Adding v2 prefix to force a fresh LLVM installation with dynamic libraries. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix: install libllvm21 for dynamic linking support The llvm-21-dev package only provides static libraries and headers. When inkwell uses llvm21-1-prefer-dynamic, the linker needs the shared library libLLVM-21.so, which comes from the libllvm21 package. This was causing intermittent "unable to find library -lLLVM-21" errors because the cached LLVM installations didn't include the shared library. Changes: - Add libllvm21 to apt-get install in scripts/install-llvm.sh - Bump CI cache key to v3 to force fresh installation with shared lib Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * feat: implement memory expansion tracking for MSTORE and MSTORE8 Track EVM memory length correctly by expanding memory before writes and updating memory_len to match EVM semantics (32-byte word-aligned). Implementation: - Add jet_mem_expand builtin that: * Checks for offset + size overflow * Rounds up to 32-byte boundaries * Updates memory_len monotonically * Reallocates and zeros new memory if needed - Hook MSTORE (32 bytes) and MSTORE8 (1 byte) to call expansion before write - Add memory_len field to TestContractRun for validation Tests (all passing): - MSTORE at offsets 0, 31, 32 expands to 32, 64, 64 bytes - MSTORE8 at offsets 0, 31, 32 expands to 32, 32, 64 bytes - Memory expansion is word-aligned and monotonic Closes #41 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * ci: bump LLVM cache to v4 * fix: use div_ceil for memory expansion rounding * docs: Add process doc for adding opcodes. --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
* Fix LLVM include path mismatch in CI workflow
* tweak: Better utilize comp-time work.
* Better rom building.
* Initial plan * Add jet_push_macros crate and integrate with test_roms Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * Add allow(unused_macros) and format code Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * Fix Cargo.toml formatting Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * Replace panics with proper compile errors in proc macro Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com>
* Remove vstack code from builder and tests Deletes all vstack infrastructure: the `vstack` option from `Options`, the `_vstack` field and methods from `BuildCtx`, the `__sync_vstack` helper and all its call sites, and all commented-out vstack branches in the stack push/pop helpers and `push` opcode. Also cleans up `use_vstack` CLI arguments in jetdbg and the disabled vstack test variant in `rom_tests!`. https://claude.ai/code/session_015PYMujjEHLtp7nkvCHF5PK * Remove __ prefix from private identifiers and move them below public fns Strips the double-underscore convention from all private helpers in ops.rs (e.g. __stack_pop_2 → stack_pop_2, __call_stack_push_i256 → call_stack_push_i256) and from the two pub(crate) entry points (__build_return → build_return, __invalid_jump_return → invalid_jump_return). Reorders the file so all pub(crate) opcode implementations appear first, followed by a clearly-marked "Private helpers" section. Updates the one external call site in contract.rs. https://claude.ai/code/session_015PYMujjEHLtp7nkvCHF5PK * chore: CI change 🤖 * Fix extra argument in invalid_opcode test Options::new takes (mode, emit_llvm, assert); remove the stray `false` that was inserted before the `assert` argument. https://claude.ai/code/session_015PYMujjEHLtp7nkvCHF5PK * Remove unused invalid_jump_return function Dead code with no call sites; flagged by clippy -D warnings. https://claude.ai/code/session_015PYMujjEHLtp7nkvCHF5PK * Remove vstack references from docs The vstack infrastructure and Options flag were removed in this PR. Update architecture.md, architecture-notes.md, and manifesto.md to: - Drop the BuildCtx _vstack field from struct snippets - Rename the "Hybrid Stack Model" section to "Real Stack Model" and remove the vstack-enabled code example and planned-optimization prose - Remove __sync_vstack from the control flow pattern snippet - Update helper function names to match the renamed (no-__ prefix) API - Remove vstack from Known TODOs, Future Opportunities, Suggested Next Steps, Options description, and the Glossary - Remove the "Virtual Stack Optimization" and "The Virtual Stack" caution-zone sections from the manifesto https://claude.ai/code/session_015PYMujjEHLtp7nkvCHF5PK --------- Co-authored-by: Claude <noreply@anthropic.com>
…ering (#64) * Initial plan * Add comprehensive technical documentation for EVM bytecode to LLVM blocks lowering Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * Update docs/bytecode-to-llvm-blocks.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update docs/bytecode-to-llvm-blocks.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update docs/bytecode-to-llvm-blocks.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Clarify block lifecycle documentation for zero-length blocks Address feedback that "empty rom == open" doesn't hold for consecutive JUMPDESTs, which create closed blocks with zero-length rom slices. Update Block Lifecycle section to accurately describe the implementation's use of is_empty() as a reassignment guard rather than state indicator. Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> Co-authored-by: Tyler Smith <mail@tcry.pt> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* fix: Handle in-instruction branches.
* Initial plan * Remove all nightly references from DEVELOPMENT.md and rust-toolchain.toml Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * Update CI workflow steps to match actual workflow more precisely Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * Clarify CI auto-formatting behavior in documentation Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com>
… of truth jet_runtime/src/lib.rs defined ADDRESS_SIZE_BYTES = 2, shadowing the correct value (20) from jet_ir::constants via `pub use jet_ir::*`. This caused all address operations (binding, builtins, exec Address type) to silently truncate every 20-byte EVM address to 2 bytes. Fix: remove the entire duplicate constants block from jet_runtime/src/lib.rs. All constants are already in jet_ir/src/constants.rs and re-exported via `pub use jet_ir::*`. Update coinbase fixtures in jetdbg.rs and roms/mod.rs to use the correct 20-byte length. Also: update docs/TREE.md to reflect current crate structure (adds jet_ir, jet_push_macros, new runtime files; removes defunct scratch/ and crates-bk/). Delete examples/temp.ll scratch file. Closes #68 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Updated the MIT License with correct year and author.
* fix: call jet_mem_expand before jet.mem.load in MLOAD MLOAD was not calling jet_mem_expand before reading from memory, unlike MSTORE and MSTORE8 which both expand first. If MLOAD was executed with an offset at or near the current memory capacity, jet.mem.load would compute memory_ptr + offset and jet.stack.push.ptr would then read 32 bytes (i256) from that address — potentially outside the allocated region — causing an intermittent segfault. The fix mirrors the existing pattern: call jet_mem_expand(ctx, offset, 32) first so the buffer is guaranteed to cover [offset, offset+32). Since jet_mem_expand may reallocate and update ctx.memory_ptr, jet.mem.load then re-reads the fresh pointer from the context struct, so no dangling pointer is ever used. https://claude.ai/code/session_01XcNd32HQupXsdnVd4KmX6f * fix: update test framework and CALL bytecode to use 20-byte addresses After ADDRESS_SIZE_BYTES was corrected from 2 to 20 (commit 595cf27), the test harness still registered contracts with 2-byte addresses ("0x0000", "0x0001"), while jet_contract_call now reads 20 bytes from the EVM stack word to build the lookup key — producing a 40-hex-char address that never matched. The mismatch caused jet_contract_fn_lookup to return 0 (not found), so jet_contract_call returned early without initialising ctx.sub_call. With sub_call still None (null), the subsequent RETURNDATASIZE instruction dereferenced a null pointer → SIGSEGV. Fix: - _test_rom_body now generates 20-byte zero-padded addresses for both contract registration and the run_contract entry point, using ADDRESS_SIZE_BYTES as the single source of truth. - basic_call_with_return_data upgrades PUSH2 to PUSH20 so the callee address on the EVM stack matches what jet_contract_call looks up. https://claude.ai/code/session_01XcNd32HQupXsdnVd4KmX6f * fix: check jet_mem_expand return value in MLOAD, MSTORE, MSTORE8 All three memory ops were ignoring the i8 return code from jet_mem_expand. If expansion fails (ArithmeticOverflow=-2, AllocationFailed=-3), the JIT code proceeded to read/write through an unexpanded pointer, leading to out-of-bounds memory access. Add call_mem_expand_checked: emits the expand call, compares the result to 0, and on error branches to a new block that returns ReturnCode::Invalid from the contract function immediately. On success execution continues in a new ok block. MLOAD, MSTORE, and MSTORE8 all use this helper instead of the unchecked build_call. https://claude.ai/code/session_01XcNd32HQupXsdnVd4KmX6f --------- Co-authored-by: Claude <noreply@anthropic.com>
* chore: Cleanup docs.
* Initial plan * Add stack bounds checking to prevent memory corruption Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * Fix Use-After-Free vulnerability in memory pointer handling Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * Fix ADDMOD and MULMOD to use 512-bit precision for EVM compliance Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * Add symbol mappings for ADDMOD and MULMOD builtins Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * Refactor ADDMOD/MULMOD helpers to reduce code duplication Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * chore: CI change 🤖 --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> Co-authored-by: tcrypt25519 <mail@tcry.pt>
* feat: introduce Address newtype to replace raw [u8; 20] (closes #75) Replace the private `type Address = [u8; ADDRESS_SIZE_BYTES]` alias with a proper `Address([u8; 20])` newtype in `jet_runtime::address`. Key properties of the new type: - `#[repr(transparent)]` over `[u8; 20]` — identical memory layout, compatible with `#[repr(C)]` structs like `BlockInfo` - Derives `Clone`, `Copy`, `PartialEq`, `Eq`, `Hash`, `Default` - `Display` / `Debug` emit lowercase `0x`-prefixed hex - `FromStr` / `TryFrom<&str>` parse hex strings with optional `0x` prefix and left-pad short forms (e.g. `"0x1234"`) to 20 bytes - `From<[u8; 20]>` / `Into<[u8; 20]>` and `AsRef<[u8]>` for zero-cost interop with existing byte-slice APIs - `Address::ZERO` constant and `as_bytes_mut` for in-place mutation Updated across the codebase: - `BlockInfo::coinbase` field and getter now use `Address` - `mangle_contract_fn` takes `&Address`; `jet_contract_fn_lookup` builds an `Address` from the little-endian stack bytes (fixing an implicit reversal that previously produced inconsistent names) - `Engine::build_contract` / `run_contract` take `Address` by value - `Manager::add_contract_function` / `verify_contract` take `Address` - Test helpers and `jetdbg` construct addresses via `Address::new`, `Address::ZERO`, and `str::parse::<Address>()` Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * chore: CI change 🤖 * fix: update invalid_opcode test to use Address Missed in the initial pass — the test called build_contract with a bare &str; update it to pass Address::ZERO instead. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix: address review feedback — panic safety, alloc-free parsing, LEN constant Three issues raised in code review: 1. jet_contract_fn_lookup: add .take(ADDRESS_SIZE_BYTES) so a 32-byte EVM stack word cannot index past the 20-byte `bytes` array and panic. The address lives in the low bytes of the word, so after reversing (little- to big-endian) we only need the first 20 bytes. 2. FromStr: replace format! + hex::decode (two heap allocations) with a stack-allocated [u8; 40] padding buffer and hex::decode_to_slice, making address parsing allocation-free. 3. Address::LEN: source from jet_ir::ADDRESS_SIZE_BYTES instead of a duplicated literal so the canonical address length is defined once. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * chore: CI change 🤖 * refactor: self-referential LEN constant as single source of truth Address::LEN = 20 is now the sole definition of address width. Every use of the literal 20 (or 40 for hex) inside the type and its impls is replaced: - struct field: [u8; Self::LEN] - ZERO constant: [0u8; Self::LEN] - new / as_bytes*: [u8; Self::LEN] - From impls: [u8; Address::LEN] - FromStr stack bufs: Address::HEX_LEN (= Self::LEN * 2, private const) - tests: Address::LEN / Address::HEX_LEN Removes the previous jet_ir::ADDRESS_SIZE_BYTES dependency; the canonical length now lives in Address itself. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * chore: CI change 🤖 --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
* fix: keccak. * fix: add null checks and return code validation for KECCAK256 (#79) * Initial plan * fix: add null check and return code validation for KECCAK256 - Add null pointer check for ctx in jet_ops_keccak256 - Check return code from jet_ops_keccak256 and propagate errors via Invalid return code - Use minimal unsafe scopes with SAFETY comments per Rust 2024 edition requirements Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * refactor: consolidate unsafe blocks in jet_ops_keccak256 Consolidate multiple unsafe blocks for accessing ctx fields into a single unsafe block that dereferences ctx once, improving readability while maintaining the same safety guarantees. Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * docs: clarify safety requirements and add SAFETY comment - Clarify safety documentation for ctx parameter (valid if non-null) - Add SAFETY comment for IntValue::new call for consistency Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * docs: improve safety documentation clarity - Clarify undefined behavior when result pointer is null - Expand SAFETY comment for IntValue::new to explain the contract Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * chore: CI change 🤖 * docs: validate u32 safety for EVM memory operations (ADR-004) (#80) * Initial plan * docs: add ADR-004 explaining why u32 is safe for EVM memory operations Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * docs: remove line numbers and clarify implemented opcodes in ADR-004 Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com>
* Initial plan * docs: Update .github/copilot-instructions.md with comprehensive onboarding guide Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * docs: Address PR feedback on copilot-instructions.md - Remove resolved known issues (test segfaults, SDIV overflow, KECCAK256 fixed) - Update stack helper function names (remove leading underscores) - Remove references to deleted docs/ext/evm/*.mdx files - Add evm-spec-lookup skill as EVM spec reference - Add docs/process/segfault-troubleshooting.md for P0 segfault handling - Emphasize agents must NOT add #[allow] pragmas without permission - Link to docs/process/new-opcode.md instead of duplicating content - Add memory-based stack and jump tables as architecture limitations - Update last updated date to 2026-02-16 Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * docs: Fix code examples and CI step count in copilot-instructions.md - Correct CI pipeline steps from 15 to 16 (missing "Log LLVM shared libraries") - Fix division by zero example: mark select pattern as "ALSO WRONG" - Update basic block creation API to correct form: bctx.env.context().append_basic_block() - Fix function names: stack_push_int() without leading underscores - Add reference to build_zero_guard() helper function - Clarify that explicit branching is the ONLY correct approach for div-by-zero Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> Co-authored-by: Tyler Smith <mail@tcry.pt>
Changed Files
|
Summary of ChangesHello @tcrypt25519, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refactors the Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request reduces the visibility of several modules to limit the public API surface, which is a good practice. My review includes a suggestion to restore the crate-level documentation in jet_ir that was removed, as it provides important context for the crate.
| mod constants; | ||
| mod types; |
There was a problem hiding this comment.
The crate-level documentation was removed. It's good practice to keep it to explain the purpose of the crate. Please restore it as inner documentation comments (//!) at the top of the file.
| mod constants; | |
| mod types; | |
| //! Shared LLVM IR types and constants. | |
| //! This crate contains the unified type system used by both the runtime builder | |
| //! and contract builder to ensure consistent memory layouts. | |
| mod constants; | |
| mod types; |
There was a problem hiding this comment.
Pull request overview
This pull request improves API encapsulation by reducing unnecessary pub visibility on internal modules. The changes make three modules private while maintaining their public APIs through re-exports, following Rust best practices for clean API design.
Changes:
- Made
jet_runtime::bindingmodule private (contains only Display trait implementations) - Made
jet_ir::constantsandjet_ir::typesmodules private while maintaining their public items via re-exports
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
crates/jet_runtime/src/lib.rs |
Changed binding module from pub mod to mod - contains only trait implementations, not part of public API |
crates/jet_ir/src/lib.rs |
Changed constants and types modules from pub mod to mod, removed redundant documentation comments - all items remain accessible via pub use re-exports |
No description provided.