Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[FVM] Add chain as a parameter to the runtime pool#8302

Merged
janezpodhostnik merged 2 commits into
masteronflow/flow-go:masterfrom
janez/add-chain-to-reusable-runtimeonflow/flow-go:janez/add-chain-to-reusable-runtimeCopy head branch name to clipboard
Jan 9, 2026
Merged

[FVM] Add chain as a parameter to the runtime pool#8302
janezpodhostnik merged 2 commits into
masteronflow/flow-go:masterfrom
janez/add-chain-to-reusable-runtimeonflow/flow-go:janez/add-chain-to-reusable-runtimeCopy head branch name to clipboard

Conversation

@janezpodhostnik

@janezpodhostnik janezpodhostnik commented Jan 6, 2026

Copy link
Copy Markdown
Contributor

ref: #8301.

Chain in the ReusableCadenceRuntimePool is currently unused and will be used for injecting EVM definitions in upcoming PRs.

Summary by CodeRabbit

  • Refactor
    • Enhanced runtime pool initialization to support chain-aware configuration across the system.
    • Reorganized runtime pool infrastructure to improve chain parameter propagation through execution contexts.
    • Updated internal method signatures to accept chain information during runtime setup.

✏️ Tip: You can customize this high-level summary in your review settings.

@janezpodhostnik janezpodhostnik self-assigned this Jan 6, 2026
@janezpodhostnik
janezpodhostnik requested a review from a team as a code owner January 6, 2026 20:47
@coderabbitai

coderabbitai Bot commented Jan 6, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The pull request refactors the Cadence runtime pool initialization across the FVM and execution layers to accept a chain parameter. Pool constructors and runtime parameter initialization functions are updated to include the chain argument, with all call sites modified accordingly. The implementation is reorganized into a dedicated pool file.

Changes

Cohort / File(s) Summary
Runtime Pool Refactoring
fvm/runtime/reusable_cadence_runtime.go, fvm/runtime/reusable_cadence_runtime_pool.go
Extracted pool-based runtime reuse infrastructure from reusable_cadence_runtime.go into new dedicated file. Added chain parameter to ReusableCadenceRuntimePool struct and constructors (NewReusableCadenceRuntimePool, NewCustomReusableCadenceRuntimePool). Pool now retains chain information for runtime creation.
Environment Layer Updates
fvm/environment/env.go, fvm/environment/runtime.go
Updated DefaultRuntimeParams() signature to accept flow.Chain parameter. DefaultEnvironmentParams() now passes chainID.Chain() when calling DefaultRuntimeParams(). Chain flows into pool initialization.
Test & Benchmark Updates
fvm/runtime/reusable_cadence_runtime_test.go, fvm/fvm_test.go, fvm/fvm_bench_test.go, engine/execution/computation/computer_test.go, engine/execution/computation/manager_benchmark_test.go, fvm/environment/system_contracts_test.go
Updated all pool constructor calls to include chain argument (e.g., flow.Testnet.Chain(), chainID.Chain(), b.conf.GetChainID().Chain()). Introduced vmTestDefaultChain variable in FVM tests for consistency.
Execution & Manager Updates
engine/execution/computation/manager.go, integration/internal/emulator/blockchain.go
Added chainID.Chain() to NewReusableCadenceRuntimePool() calls within manager and emulator initialization.
EVM Parameter Rename
fvm/evm/evm.go
Renamed SetupEnvironment parameter from runtimeEnv to cadenceEnv for clarity (type unchanged).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 A chain runs through the pools we weave,
From FVM to runtime, we now believe—
Each pool now knows its home so true,
Testnet or Mainnet, the chain shines through!
Threading parameters with care and grace,
Our reusable runtimes find their place. ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title '[FVM] Add chain as a parameter to the runtime pool' directly and concisely describes the main change across the pull request: adding a chain parameter to ReusableCadenceRuntimePool and propagating it through all call sites.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 216a53f and 5c7a93c.

📒 Files selected for processing (13)
  • engine/execution/computation/computer/computer_test.go
  • engine/execution/computation/manager.go
  • engine/execution/computation/manager_benchmark_test.go
  • fvm/environment/env.go
  • fvm/environment/runtime.go
  • fvm/environment/system_contracts_test.go
  • fvm/evm/evm.go
  • fvm/fvm_bench_test.go
  • fvm/fvm_test.go
  • fvm/runtime/reusable_cadence_runtime.go
  • fvm/runtime/reusable_cadence_runtime_pool.go
  • fvm/runtime/reusable_cadence_runtime_test.go
  • integration/internal/emulator/blockchain.go
🧰 Additional context used
📓 Path-based instructions (7)
**/*.go

📄 CodeRabbit inference engine (.cursor/rules/coding_conventions.mdc)

Follow Go coding conventions as documented in @docs/agents/CodingConventions.md

Follow Go coding standards and conventions as documented in @docs/agents/GoDocs.md

**/*.go: Follow the existing module structure in /module/, /engine/, /model/ and use dependency injection patterns for component composition
Implement proper interfaces before concrete types
Follow Go naming conventions and the project's coding style defined in /docs/CodingConventions.md
Use mock generators: run make generate-mocks after interface changes
All inputs must be considered potentially byzantine; error classification is context-dependent and no code path is safe unless explicitly proven and documented
Use comprehensive error wrapping for debugging; avoid fmt.Errorf, use irrecoverable package for exceptions
NEVER log and continue on best effort basis; ALWAYS explicitly handle errors
Uses golangci-lint with custom configurations (.golangci.yml) and custom linters for Flow-specific conventions (struct write checking)

Files:

  • fvm/fvm_bench_test.go
  • engine/execution/computation/manager_benchmark_test.go
  • engine/execution/computation/manager.go
  • fvm/runtime/reusable_cadence_runtime_test.go
  • fvm/environment/system_contracts_test.go
  • fvm/environment/runtime.go
  • fvm/fvm_test.go
  • fvm/environment/env.go
  • fvm/runtime/reusable_cadence_runtime.go
  • engine/execution/computation/computer/computer_test.go
  • integration/internal/emulator/blockchain.go
  • fvm/evm/evm.go
  • fvm/runtime/reusable_cadence_runtime_pool.go
**/*_test.go

📄 CodeRabbit inference engine (AGENTS.md)

**/*_test.go: Unit tests should be co-located with the code they test
Follow the existing pattern of *_test.go files for test naming
Use fixtures for realistic test data as defined in /utils/unittest/

Files:

  • fvm/fvm_bench_test.go
  • engine/execution/computation/manager_benchmark_test.go
  • fvm/runtime/reusable_cadence_runtime_test.go
  • fvm/environment/system_contracts_test.go
  • fvm/fvm_test.go
  • engine/execution/computation/computer/computer_test.go
{crypto,fvm,ledger,storage}/**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

Security checks for cryptographic misuse must be enforced using gosec

Files:

  • fvm/fvm_bench_test.go
  • fvm/runtime/reusable_cadence_runtime_test.go
  • fvm/environment/system_contracts_test.go
  • fvm/environment/runtime.go
  • fvm/fvm_test.go
  • fvm/environment/env.go
  • fvm/runtime/reusable_cadence_runtime.go
  • fvm/evm/evm.go
  • fvm/runtime/reusable_cadence_runtime_pool.go
{crypto,fvm,ledger,access,engine}/**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

Cryptographic operations require careful handling; refer to crypto library documentation for proper implementation

Files:

  • fvm/fvm_bench_test.go
  • engine/execution/computation/manager_benchmark_test.go
  • engine/execution/computation/manager.go
  • fvm/runtime/reusable_cadence_runtime_test.go
  • fvm/environment/system_contracts_test.go
  • fvm/environment/runtime.go
  • fvm/fvm_test.go
  • fvm/environment/env.go
  • fvm/runtime/reusable_cadence_runtime.go
  • engine/execution/computation/computer/computer_test.go
  • fvm/evm/evm.go
  • fvm/runtime/reusable_cadence_runtime_pool.go
{storage,ledger,execution,fvm}/**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

State consistency is paramount; use proper synchronization primitives

Files:

  • fvm/fvm_bench_test.go
  • fvm/runtime/reusable_cadence_runtime_test.go
  • fvm/environment/system_contracts_test.go
  • fvm/environment/runtime.go
  • fvm/fvm_test.go
  • fvm/environment/env.go
  • fvm/runtime/reusable_cadence_runtime.go
  • fvm/evm/evm.go
  • fvm/runtime/reusable_cadence_runtime_pool.go
{module,engine,cmd}/**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

All major processing components must implement the Component interface from /module/component/component.go to ensure consistent lifecycle management and graceful shutdown patterns

Files:

  • engine/execution/computation/manager_benchmark_test.go
  • engine/execution/computation/manager.go
  • engine/execution/computation/computer/computer_test.go
{network,engine,consensus}/**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

Network messages must be authenticated and validated

Files:

  • engine/execution/computation/manager_benchmark_test.go
  • engine/execution/computation/manager.go
  • engine/execution/computation/computer/computer_test.go
🧬 Code graph analysis (10)
engine/execution/computation/manager_benchmark_test.go (1)
model/flow/chain.go (1)
  • Chain (263-275)
engine/execution/computation/manager.go (1)
model/flow/chain.go (1)
  • Chain (263-275)
fvm/runtime/reusable_cadence_runtime_test.go (2)
fvm/runtime/reusable_cadence_runtime_pool.go (1)
  • NewReusableCadenceRuntimePool (49-60)
model/flow/chain.go (2)
  • Mainnet (19-19)
  • Chain (263-275)
fvm/environment/system_contracts_test.go (1)
model/flow/chain.go (1)
  • Chain (263-275)
fvm/environment/runtime.go (2)
fvm/runtime/reusable_cadence_runtime_pool.go (2)
  • ReusableCadenceRuntimePool (11-28)
  • NewReusableCadenceRuntimePool (49-60)
model/flow/chain.go (1)
  • Chain (263-275)
fvm/fvm_test.go (2)
model/flow/chain.go (2)
  • Testnet (24-24)
  • Chain (263-275)
fvm/context.go (3)
  • Context (32-54)
  • Option (89-89)
  • WithChain (92-97)
fvm/environment/env.go (2)
fvm/environment/runtime.go (2)
  • RuntimeParams (10-12)
  • DefaultRuntimeParams (14-22)
model/flow/chain.go (1)
  • Chain (263-275)
engine/execution/computation/computer/computer_test.go (1)
model/flow/chain.go (1)
  • Chain (263-275)
integration/internal/emulator/blockchain.go (1)
model/flow/chain.go (1)
  • Chain (263-275)
fvm/evm/evm.go (2)
fvm/environment/env.go (1)
  • Environment (13-85)
fvm/runtime/reusable_cadence_runtime.go (1)
  • Environment (12-18)
🔇 Additional comments (21)
fvm/environment/system_contracts_test.go (1)

60-69: LGTM! Chain parameter added correctly.

The chain parameter is correctly passed to NewCustomReusableCadenceRuntimePool using chainID.Chain(). This aligns with the PR objective to make the runtime pool chain-aware.

fvm/evm/evm.go (2)

25-29: LGTM! Parameter renamed for clarity.

The parameter rename from runtimeEnv to cadenceEnv improves clarity without changing functionality. The type remains runtime.Environment.


58-62: LGTM! Updated call reflects parameter rename.

The call to stdlib.SetupEnvironment correctly uses the renamed cadenceEnv parameter.

fvm/fvm_bench_test.go (1)

167-173: LGTM! Chain parameter added correctly.

The chain parameter is correctly passed to NewReusableCadenceRuntimePool using the chain variable from the function scope. This aligns with the PR objective to make runtime pools chain-aware.

integration/internal/emulator/blockchain.go (1)

130-135: LGTM! Chain parameter added correctly.

The chain parameter is correctly passed to NewReusableCadenceRuntimePool using b.conf.GetChainID().Chain(). This aligns with the PR objective to make runtime pools chain-aware for future EVM definition injection.

Note: The pool size of 0 is intentional for the emulator environment, differing from the production pool size of 1000 used elsewhere.

engine/execution/computation/manager.go (1)

226-237: LGTM! Chain parameter correctly added to all call sites.

All 16 calls to NewReusableCadenceRuntimePool and NewCustomReusableCadenceRuntimePool throughout the codebase have been properly updated with the chain parameter, including in integration tests, unit tests, benchmarks, and production code across multiple modules (fvm, engine/execution/computation). The function signatures have been correctly updated to include chain flow.Chain as the second parameter, and every invocation properly passes the chain information.

engine/execution/computation/manager_benchmark_test.go (1)

162-167: LGTM! Chain parameter correctly threaded to pool constructor.

The addition of chainID.Chain() as the second parameter to NewReusableCadenceRuntimePool is correct and aligns with the PR's objective to add chain awareness to the runtime pool.

fvm/environment/env.go (1)

110-123: LGTM! Chain correctly propagated to runtime parameters.

The update to pass chainID.Chain() to DefaultRuntimeParams is correct and maintains consistency with the chain-aware runtime initialization pattern.

fvm/environment/runtime.go (1)

14-22: LGTM! Function signature and implementation correctly updated.

The signature change to accept a chain flow.Chain parameter and its propagation to NewReusableCadenceRuntimePool is correct. This change aligns with the PR's objective to make the runtime pool chain-aware.

fvm/runtime/reusable_cadence_runtime_test.go (3)

14-14: LGTM! Test correctly updated for new pool signature.

The addition of flow.Mainnet.Chain() parameter is correct and consistent with the updated NewReusableCadenceRuntimePool signature.


29-29: LGTM! Test correctly updated for new pool signature.

The addition of flow.Mainnet.Chain() parameter is correct and consistent with the updated NewReusableCadenceRuntimePool signature.


56-56: LGTM! Test correctly updated for new pool signature.

The addition of flow.Mainnet.Chain() parameter is correct and consistent with the updated NewReusableCadenceRuntimePool signature.

engine/execution/computation/computer/computer_test.go (3)

703-712: LGTM! Custom runtime pool correctly instantiated with chain parameter.

The addition of execCtx.Chain as the second parameter to NewCustomReusableCadenceRuntimePool is correct. Using the chain from the execution context is appropriate for this test scenario.


818-826: LGTM! Custom runtime pool correctly instantiated with chain parameter.

The addition of execCtx.Chain as the second parameter to NewCustomReusableCadenceRuntimePool is correct and consistent with the updated signature.


933-941: LGTM! Custom runtime pool correctly instantiated with chain parameter.

The addition of execCtx.Chain as the second parameter to NewCustomReusableCadenceRuntimePool is correct and consistent with the updated signature.

fvm/fvm_test.go (2)

81-82: Good refactoring for test consistency.

Introducing vmTestDefaultChain as a shared default improves test maintainability by centralizing the default chain configuration. This makes it easier to update the default chain for all tests in the future.


2552-2562: LGTM! Chain parameter correctly passed to pool constructor.

The test correctly passes vmTestDefaultChain to NewReusableCadenceRuntimePool, aligning with the new chain-aware pool design.

fvm/runtime/reusable_cadence_runtime_pool.go (4)

9-28: Well-designed pool structure with clear documentation.

The ReusableCadenceRuntimePool design is sound:

  • Thread-safe buffered channel for pooling
  • Chain-awareness properly documented with usage warnings
  • Custom constructor pattern enables test-time flexibility

The comment on Lines 23-27 appropriately warns that the pool should not be used cross-chain, which is important given that the chain field is currently unused (per PR description).


30-74: Constructor pattern correctly implements factory design.

The layered constructor approach is clean:

  • Private constructor handles all initialization logic
  • Public constructors provide convenient APIs for different use cases
  • Proper handling of zero poolSize (disables pooling)
  • Chain parameter consistently propagated through all constructors

103-113: Proper cleanup and overflow handling in Return method.

The Return method correctly:

  • Clears the FVM environment reference to avoid leaks
  • Uses non-blocking channel send to avoid deadlock
  • Gracefully handles pool overflow by discarding entries

83-101: No issue found.

WrappedCadenceRuntime is properly defined in fvm/runtime/wrapped_cadence_runtime.go within the same runtime package as the Borrow method. No import is needed, and the type is correctly used at lines 92-94.

Likely an incorrect or invalid review comment.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@janezpodhostnik janezpodhostnik changed the title Add chain as a parameter to the runtime pool [FVM] Add chain as a parameter to the runtime pool Jan 6, 2026
@janezpodhostnik

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jan 6, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Base automatically changed from janez/transaction-index-in-cadence to master January 7, 2026 15:03
@github-actions

github-actions Bot commented Jan 8, 2026

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@codecov-commenter

codecov-commenter commented Jan 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.39216% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
fvm/runtime/reusable_cadence_runtime_pool.go 80.00% 8 Missing and 1 partial ⚠️
integration/internal/emulator/blockchain.go 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@janezpodhostnik
janezpodhostnik requested review from a team, holyfuchs and zhangchiqing January 8, 2026 20:50

@turbolent turbolent left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@janezpodhostnik
janezpodhostnik added this pull request to the merge queue Jan 9, 2026
Merged via the queue into master with commit 2665c29 Jan 9, 2026
61 checks passed
@janezpodhostnik
janezpodhostnik deleted the janez/add-chain-to-reusable-runtime branch January 9, 2026 13:39
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.

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.