Skip to content

Conversation

@tclemos
Copy link
Contributor

@tclemos tclemos commented Oct 21, 2025

closes https://github.com/0xPolygon/devtools/issues/444

This PR adds a Gas Manager to the loadtest command and introduces a new tx-gas-chart visualization tool.

Gas Manager features:

  • Gas Vault: Budget-based throttling that controls transaction flow per block
  • Wave Patterns: Five oscillation patterns (flat, sine, square, triangle, sawtooth) to simulate varying network conditions
  • Gas Pricing Strategies: Three strategies (estimated, fixed, dynamic) for flexible gas price simulation

New tx-gas-chart command:

  • Generates visual PNG charts analyzing transaction gas prices and limits across block ranges
  • Displays four metrics: transaction gas prices, transaction gas limits, block gas limits, and block gas used
  • Supports highlighting transactions from/to specific addresses
  • Configurable scale (logarithmic or linear) for gas price visualization
  • Useful for analyzing gas patterns during load tests or investigating network behavior

Use cases:

  • Simulate realistic network congestion patterns during load tests
  • Run infinite load tests with controlled gas consumption
  • Visualize gas price and usage patterns across blocks
  • Stress test networks with oscillating transaction loads

@tclemos tclemos requested a review from Copilot October 21, 2025 06:45
@tclemos tclemos self-assigned this Oct 21, 2025
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 a gas limiting mechanism for the loadtest command to control transaction flow through configurable gas budgets and oscillation curves. The feature aims to enable running loadtests indefinitely while managing gas consumption patterns.

Key changes:

  • Adds a new gaslimiter package implementing a gas vault system and oscillating gas provider
  • Refactors loadtest functions to return transaction objects instead of transaction hashes
  • Implements gas budget tracking with configurable oscillation curves for dynamic gas limit control

Reviewed Changes

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

Show a summary per file
File Description
cmd/loadtest/gaslimiter/curve.go Defines base curve interface and configuration for gas oscillation patterns
cmd/loadtest/gaslimiter/curve_sine.go Implements sinusoidal curve for oscillating gas budgets
cmd/loadtest/gaslimiter/curve_sine_test.go Tests sine curve implementation with expected values
cmd/loadtest/gaslimiter/gas_vault.go Implements thread-safe gas budget storage with spend/wait mechanism
cmd/loadtest/gaslimiter/gas_provider.go Base gas provider that watches for new block headers
cmd/loadtest/gaslimiter/gas_provider_oscillating.go Oscillating gas provider that adds gas based on curve values per block
cmd/loadtest/gaslimiter/README.md Documentation for gas limiter components and workflow
cmd/loadtest/loadtest.go Integrates gas limiter into main loadtest loop and refactors transaction handling
cmd/loadtest/uniswapv3.go Updates UniswapV3 loadtest to return transaction object instead of hash

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@minhd-vu minhd-vu changed the title [WIP]feat: gas limiter for loadtest [WIP] feat: gas limiter for loadtest Oct 21, 2025
@tclemos tclemos marked this pull request as ready for review November 5, 2025 13:46
@tclemos tclemos changed the title [WIP] feat: gas limiter for loadtest feat: gas limiter for loadtest; add tx-gas-chart Nov 5, 2025
@tclemos tclemos changed the title feat: gas limiter for loadtest; add tx-gas-chart feat: gas manager for loadtest; add tx-gas-chart Nov 5, 2025
tclemos and others added 7 commits November 5, 2025 11:36
Fix panic caused by signing a nil transaction in loadTestContractCall.
The transaction was being built and assigned to `tx`, but the code was
incorrectly trying to sign `rtx` which was declared but never assigned.

This caused a segmentation fault when using the `contract-call` mode:
  panic: runtime error: invalid memory address or nil pointer dereference
  at cmd/loadtest/loadtest.go:1987

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
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.

3 participants