Skip to content

Conversation

@jribbink
Copy link
Contributor

@jribbink jribbink commented Jan 10, 2026

Closes #2251

Description

Screenshot 2026-01-15 at 6 09 09 PM image image

For contributor use:

  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

@github-actions
Copy link

github-actions bot commented Jan 10, 2026

Dependency Review

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

Scanned Files

None

@codecov-commenter
Copy link

codecov-commenter commented Jan 10, 2026

Codecov Report

❌ Patch coverage is 68.30357% with 71 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/transactions/profile.go 68.46% 47 Missing and 23 partials ⚠️
internal/util/util.go 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@jribbink jribbink force-pushed the jribbink/profile-cmd branch 3 times, most recently from 5e4599c to a63c33a Compare January 15, 2026 23:25
@jribbink jribbink changed the title Add profiling command Addflow cadence profile command Jan 16, 2026
@jribbink jribbink marked this pull request as ready for review January 16, 2026 01:58
@jribbink jribbink force-pushed the jribbink/profile-cmd branch from b9e0a97 to 9d57fba Compare January 16, 2026 02:22
@jribbink jribbink changed the title Addflow cadence profile command Add flow cadence profile command Jan 16, 2026
@chasefleming chasefleming requested a review from Copilot January 16, 2026 03:50
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a new flow cadence profile command that enables profiling of transaction execution on Flow networks. The command generates pprof-compatible profile data for analyzing transaction performance and resource usage.

Changes:

  • Implements transaction profiling functionality by replaying transactions using FVM with forked state
  • Adds comprehensive test coverage for validation, result formatting, and integration testing with local emulator
  • Increases gRPC timeout from 5 to 60 seconds to support profiling operations

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
internal/util/util.go Increases GetChainIDFromHost timeout to 60 seconds to accommodate profiling operations
internal/transactions/transactions.go Registers the new profile command with the transaction command group
internal/transactions/profile.go Core implementation of transaction profiling including FVM setup, state forking, and pprof export
internal/transactions/profile_test.go Comprehensive test suite covering validation, result formatting, and integration scenarios

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 270 to 275
func createEmulatorServer(port int) *server.EmulatorServer {
zlog := zerolog.New(zerolog.ConsoleWriter{Out: io.Discard})

restPort := getFreePort(nil)
adminPort := getFreePort(nil)
debuggerPort := getFreePort(nil)
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

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

Calling getFreePort(nil) will panic if an error occurs (line 215), but this is called from createEmulatorServer where no test context is available to fail gracefully. Consider passing a valid test context or handling errors without panicking.

Suggested change
func createEmulatorServer(port int) *server.EmulatorServer {
zlog := zerolog.New(zerolog.ConsoleWriter{Out: io.Discard})
restPort := getFreePort(nil)
adminPort := getFreePort(nil)
debuggerPort := getFreePort(nil)
func mustGetFreePort() int {
l, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil {
panic(fmt.Sprintf("failed to acquire free port: %v", err))
}
defer l.Close()
addr, ok := l.Addr().(*net.TCPAddr)
if !ok {
panic(fmt.Sprintf("listener address is not *net.TCPAddr: %T", l.Addr()))
}
return addr.Port
}
func createEmulatorServer(port int) *server.EmulatorServer {
zlog := zerolog.New(zerolog.ConsoleWriter{Out: io.Discard})
restPort := mustGetFreePort()
adminPort := mustGetFreePort()
debuggerPort := mustGetFreePort()

Copilot uses AI. Check for mistakes.
@jribbink jribbink changed the title Add flow cadence profile command Add flow transactions profile command Jan 16, 2026
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.

Add a flow transactions profile <tx_id> command

3 participants