Skip to content

🔴 [Critical] Performance EVM: Frame coupled to DefaultEvm type breaks custom configs #852

@roninjin10

Description

@roninjin10

Summary

The performance EVM's Frame is hardcoded to use DefaultEvm type, which breaks when using custom EvmConfig configurations.

Location

src/frame/frame.zig:21 and src/frame/frame.zig:372-374

Current Code

// Line 21
const DefaultEvm = @import("../evm.zig").Evm(.{});

// Lines 372-374
pub inline fn getEvm(self: *const Self) *DefaultEvm {
    return @as(*DefaultEvm, @ptrCast(@alignCast(self.evm_ptr)));
}

Problem

The code has a comment acknowledging this issue (lines 366-370):

/// FIXME: This currently assumes DefaultEvm type which is incorrect for non-default configurations.
/// The proper fix requires either:
/// 1. Adding EvmType to FrameConfig (circular dependency issue)
/// 2. Using comptime type resolution (complex)
/// 3. Keeping as anyopaque and having callers cast (requires refactoring all handlers)

Impact

  • Custom hardfork configurations may not work correctly
  • Custom gas settings could be ignored
  • Type safety is compromised through @ptrCast

Recommended Fix

Consider using a trait/interface pattern:

pub fn Frame(comptime EvmType: type, _config: FrameConfig) type {
    return struct {
        evm_ptr: *EvmType,
        // ...
        pub inline fn getEvm(self: *const Self) *EvmType {
            return self.evm_ptr;
        }
    };
}

Or use comptime type resolution through the config.


Note: This issue was created by Claude AI assistant during code review, not @roninjin10 or @fucory

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions