Skip to main content
The kona-executor crate offers a to-spec, stateless implementation of the OP Stack STF. However, due to the power of alloy-evm’s factory abstractions, the logic of the STF can be easily customized. To customize the EVM behavior, for example to add a custom precompile, modify the behavior of an EVM opcode, or change the fee handling, you can implement a custom EvmFactory. The factory is responsible for creating EVM instances with your desired customizations.

Example - Custom Precompile

Migration from the old API

Prior to the integration of alloy-evm, kona-executor used a builder pattern with StatelessL2BlockExecutorBuilder::with_handle_register for EVM customization. The new approach using EvmFactory provides better composability and aligns with the broader Alloy ecosystem.

Key Changes:

  1. Direct construction: Use StatelessL2Builder::new() instead of a builder pattern
  2. Factory-based customization: Implement EvmFactory instead of registering handlers
  3. Type safety: The factory approach provides better compile-time guarantees
  4. Ecosystem alignment: Leverages the standard alloy-evm interfaces

Benefits:

  • Composability: Custom EVM factories can be easily shared and reused
  • Flexibility: Full control over EVM creation and configuration
  • Performance: Reduced indirection compared to the handler approach
  • Maintainability: Cleaner separation of concerns between execution and customization
For more complex customizations involving multiple precompiles, custom opcodes, or specialized execution logic, refer to the FpvmOpEvmFactory implementation in the kona-client for a comprehensive example.