-
Notifications
You must be signed in to change notification settings - Fork 81
Add flow transactions profile command
#2254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
5e4599c to
a63c33a
Compare
b9e0a97 to
9d57fba
Compare
flow cadence profile commandflow cadence profile command
There was a problem hiding this 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.
| func createEmulatorServer(port int) *server.EmulatorServer { | ||
| zlog := zerolog.New(zerolog.ConsoleWriter{Out: io.Discard}) | ||
|
|
||
| restPort := getFreePort(nil) | ||
| adminPort := getFreePort(nil) | ||
| debuggerPort := getFreePort(nil) |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
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.
| 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() |
flow cadence profile commandflow transactions profile command
Closes #2251
Description
For contributor use:
masterbranchFiles changedin the Github PR explorer