Skip to content

Conversation

@sasurobert
Copy link
Contributor

I've analyzed the vmhost folder to understand its functions, their call relationships, and opportunities for simplification.

As part of my analysis, I generated a call graph of the vmhost functions and included it in this commit as vmhost-call-graph.svg. I've also included the script I used to generate the graph, vmhost/hosttest/tools/vmhost_call_graph.go.txt, so you can see how it was made.

Based on my findings, I propose the following simplifications:

  • Refactor ExecuteOnDestContext and ExecuteOnSameContext to reduce code duplication.
  • Introduce a parameter object for prepareIndirectContractCallInput.
  • Simplify the transferValueExecute and TransferESDTNFTExecute hooks.
  • Consolidate the doRun... methods in execution.go.

I've analyzed the `vmhost` folder to understand its functions, their call relationships, and opportunities for simplification.

As part of my analysis, I generated a call graph of the `vmhost` functions and included it in this commit as `vmhost-call-graph.svg`. I've also included the script I used to generate the graph, `vmhost/hosttest/tools/vmhost_call_graph.go.txt`, so you can see how it was made.

Based on my findings, I propose the following simplifications:
- Refactor `ExecuteOnDestContext` and `ExecuteOnSameContext` to reduce code duplication.
- Introduce a parameter object for `prepareIndirectContractCallInput`.
- Simplify the `transferValueExecute` and `TransferESDTNFTExecute` hooks.
- Consolidate the `doRun...` methods in `execution.go`.
@codecov
Copy link

codecov bot commented Jul 31, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 36.22%. Comparing base (05006fc) to head (b6b7ecb).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #949      +/-   ##
==========================================
- Coverage   36.23%   36.22%   -0.01%     
==========================================
  Files          87       87              
  Lines       20589    20589              
==========================================
- Hits         7460     7459       -1     
- Misses      12462    12463       +1     
  Partials      667      667              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@andreibancioiu andreibancioiu requested a review from Copilot July 31, 2025 10:10
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 introduces analysis tools for the vmhost module, generating a visual call graph to understand function relationships and identify simplification opportunities. The analysis aims to improve code maintainability by proposing consolidation of duplicated code patterns.

Key changes include:

  • Addition of a call graph generation script to analyze vmhost function relationships
  • Creation of a DOT file for the generated call graph visualization

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
vmhost/hosttest/tools/vmhost_call_graph.go.txt Script to generate call graph visualization of vmhost functions
vmhost-call-graph.dot Generated Graphviz DOT file representing the vmhost call graph


import (
"fmt"
"io/ioutil"
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

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

The io/ioutil package is deprecated since Go 1.16. Use os.ReadFile and os.WriteFile from the os package instead.

Suggested change
"io/ioutil"

Copilot uses AI. Check for mistakes.
dotFileName := "vmhost-call-graph.dot"
svgFileName := "vmhost-call-graph.svg"

err := ioutil.WriteFile(dotFileName, []byte(graphvizGraph.String()), 0644)
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

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

Replace ioutil.WriteFile with os.WriteFile since io/ioutil is deprecated.

Suggested change
err := ioutil.WriteFile(dotFileName, []byte(graphvizGraph.String()), 0644)
err := os.WriteFile(dotFileName, []byte(graphvizGraph.String()), 0644)

Copilot uses AI. Check for mistakes.
@sasurobert sasurobert closed this Aug 6, 2025
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.

2 participants