Skip to content

Conversation

@ceyonur
Copy link
Contributor

@ceyonur ceyonur commented Sep 17, 2025

Why this should be merged

Refactors common parts from acp-176 and acp-226 into common package.

How this works

Uses TargetExcessParam structure to define common functions, so that different implementations/parameters can use the same functions

How this was tested

existing tests

Need to be documented in RELEASES.md?

no

@ceyonur ceyonur mentioned this pull request Sep 17, 2025
@ceyonur ceyonur changed the title Ceyonur/acp 176 226 refactor acp-176/226 refactor to common package Sep 17, 2025
Base automatically changed from ceyonur/acp-176-math-package to master September 18, 2025 13:32
@ceyonur ceyonur changed the base branch from master to ceyonur/acp-226-math-package September 18, 2025 16:25
Base automatically changed from ceyonur/acp-226-math-package to master September 18, 2025 19:35
@ceyonur ceyonur force-pushed the ceyonur/acp-176-226-refactor branch from a9463c2 to 4b1dd83 Compare September 18, 2025 21:00
@ceyonur ceyonur marked this pull request as ready for review September 18, 2025 21:35
Copilot AI review requested due to automatic review settings September 18, 2025 21:35
Copy link
Contributor

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

Refactors common functionality from ACP-176 and ACP-226 implementations into a shared common package to reduce code duplication and improve maintainability.

  • Introduces TargetExcessParams structure to encapsulate parameters and functions for target excess calculations
  • Moves exponential calculation logic from gas package to a new math utility function
  • Updates both ACP implementations to use the shared common package functions

Reviewed Changes

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

Show a summary per file
File Description
vms/evm/upgrades/common/target_excess.go New common package with shared target excess calculation functions and parameters structure
vms/evm/upgrades/acp226/acp226.go Refactored to use common package functions, removing duplicate implementation
vms/evm/upgrades/acp176/acp176.go Refactored to use common package functions, removing duplicate implementation
vms/components/gas/gas.go Simplified to use new math utility function for exponential calculations
utils/math/exponential.go New utility function extracted from gas package for exponential calculations

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

@@ -154,7 +157,7 @@ func (s *State) UpdateTargetExcess(desiredTargetExcess gas.Gas) {
)

// Ensure the gas capacity does not exceed the maximum capacity.
newMaxCapacity := mulWithUpperBound(newTargetPerSecond, TargetToMaxCapacity) // C
newMaxCapacity := gas.Gas(common.MulWithUpperBound(uint64(newTargetPerSecond), TargetToMaxCapacity)) // C
s.Gas.Capacity = min(s.Gas.Capacity, newMaxCapacity)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this now uses golang builtin min, would it be a problem? cc @StephenButtolph

Copy link
Contributor

@michaelkaplan13 michaelkaplan13 left a comment

Choose a reason for hiding this comment

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

One nit, and think we should update/remove the "target" terminology from target_excess.go since it's not just applying to the gas target anymore, but otherwise LGTM.

@joshua-kim joshua-kim moved this to In Progress 🏗️ in avalanchego Sep 29, 2025
@StephenButtolph StephenButtolph moved this from In Progress 🏗️ to In Review 🔎 in avalanchego Sep 30, 2025
@joshua-kim joshua-kim moved this from In Review 🔎 to In Progress 🏗️ in avalanchego Oct 1, 2025
@ceyonur ceyonur marked this pull request as draft October 7, 2025 08:19
@ceyonur ceyonur marked this pull request as ready for review October 7, 2025 18:51
@github-actions
Copy link

github-actions bot commented Nov 9, 2025

This PR has become stale because it has been open for 30 days with no activity. Adding the lifecycle/frozen label will cause this PR to ignore lifecycle events.

@github-actions github-actions bot added the lifecycle/stale Inactive for 60 days label Nov 9, 2025
@ceyonur ceyonur added acp224 and removed lifecycle/stale Inactive for 60 days labels Nov 10, 2025
@ceyonur ceyonur requested a review from ARR4N as a code owner November 10, 2025 13:48
@ceyonur ceyonur removed the acp224 label Nov 10, 2025
@joshua-kim joshua-kim self-requested a review November 10, 2025 15:59
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add tests for this new code?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add tests for new code?

@github-actions
Copy link

This PR has become stale because it has been open for 30 days with no activity. Adding the lifecycle/frozen label will cause this PR to ignore lifecycle events.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: In Progress 🏗️

Development

Successfully merging this pull request may close these issues.

5 participants