Skip to content

refactor(gastime): Remove hooks imports#5288

Merged
StephenButtolph merged 11 commits intomasterfrom
alarso16/gastime-hook-imports
Apr 17, 2026
Merged

refactor(gastime): Remove hooks imports#5288
StephenButtolph merged 11 commits intomasterfrom
alarso16/gastime-hook-imports

Conversation

@alarso16
Copy link
Copy Markdown
Contributor

@alarso16 alarso16 commented Apr 15, 2026

Why this should be merged

It is somewhat nonsensical that gastime has to import hooks. @StephenButtolph may make a conflicting PR, but either is acceptable to me as long as I can import gastime in the hooks package.

How this works

moves any hook import out of the gastime package. The hooks aren't strictly needed by the ACP176 stuff, and there's two gaspriceconfigs for scoping reasons (but that seems insufficient for deduplication).

How this was tested

CI, plus now we import gastime in hooks (which was the goal)

Need to be documented in RELEASES.md?

No

@alarso16 alarso16 force-pushed the alarso16/gastime-hook-imports branch from dd5b380 to b48c47b Compare April 16, 2026 14:15
@alarso16 alarso16 moved this to In Progress 🏗️ in avalanchego Apr 16, 2026
@alarso16 alarso16 self-assigned this Apr 16, 2026
@alarso16 alarso16 added go Pull requests that update Go code evm Related to EVM functionality labels Apr 16, 2026
@alarso16 alarso16 changed the title Alarso16/gastime hook imports refactor(gastime): Remove hooks imports Apr 16, 2026
@alarso16 alarso16 marked this pull request as ready for review April 16, 2026 14:38
Copilot AI review requested due to automatic review settings April 16, 2026 14:38
Copy link
Copy Markdown
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

This PR refactors SAEVM gas-time accounting to remove gastime’s dependency on the hook package, enabling gastime to be imported from within hook (as described in the PR motivation).

Changes:

  • Moved GasPriceConfig from vms/saevm/hook into vms/saevm/gastime and updated hook interfaces/callers accordingly.
  • Updated gastime.Time.BeforeBlock/AfterBlock to accept explicit timestamp/config inputs instead of a hook.Points + header, and rewired call sites in execution and worst-case tracking.
  • Updated tests and Bazel deps to reflect the new package boundaries.

Reviewed changes

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

Show a summary per file
File Description
vms/saevm/worstcase/state_test.go Updates worst-case tests to call gastime.Time with explicit timestamp/config inputs.
vms/saevm/worstcase/state.go Rewires worst-case block accounting to pass SubSecondBlockTime and (target,cfg) explicitly.
vms/saevm/saexec/execution.go Updates execution-time gas clock updates to use the new BeforeBlock/AfterBlock signatures.
vms/saevm/hook/hookstest/stub.go Switches stub config type to gastime.GasPriceConfig and uses gastime.DefaultGasPriceConfig().
vms/saevm/hook/hookstest/BUILD.bazel Adds //vms/saevm/gastime dep for hookstest.
vms/saevm/hook/hook.go Changes Points.GasConfigAfter to return gastime.GasPriceConfig; removes old hook.GasPriceConfig.
vms/saevm/hook/BUILD.bazel Adds //vms/saevm/gastime dep for hook.
vms/saevm/gastime/gastime_test.go Updates tests to use gastime.GasPriceConfig and new error expectations.
vms/saevm/gastime/gastime.go Removes hook/types imports, inlines validation, updates SubSecond signature and config handling.
vms/saevm/gastime/config.go Introduces exported gastime.GasPriceConfig with validation and equality helper.
vms/saevm/gastime/config.canoto.go Regenerated canoto bindings for the renamed/exported config type.
vms/saevm/gastime/cmpopt.go Updates cmp options for the new GasPriceConfig type and canoto cache type.
vms/saevm/gastime/acp176_test.go Refactors tests/fuzzing to use the new explicit BeforeBlock/AfterBlock APIs.
vms/saevm/gastime/acp176.go Refactors core ACP-176 transition logic to take explicit inputs (no hooks import).
vms/saevm/gastime/BUILD.bazel Removes hook/libevm types deps now that gastime no longer imports them.
vms/saevm/blocks/time.go Updates gastime.SubSecond call site to pass a time.Duration directly.
vms/saevm/blocks/execution_test.go Updates helper signature to use gastime.GasPriceConfig.

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

Comment thread vms/saevm/gastime/acp176.go Outdated
@alarso16 alarso16 moved this from In Progress 🏗️ to Ready 🚦 in avalanchego Apr 16, 2026
Copy link
Copy Markdown
Contributor

@ARR4N ARR4N left a comment

Choose a reason for hiding this comment

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

I know that @StephenButtolph is also doing a lot of work in these files right now. I'll DM the two of you to figure out the ordering.

Comment thread vms/saevm/gastime/gastime.go Outdated
Comment thread vms/saevm/gastime/acp176.go Outdated
Comment thread vms/saevm/gastime/gastime.go Outdated
Comment thread vms/saevm/blocks/time.go Outdated
Comment thread vms/saevm/gastime/gastime.go Outdated
Comment on lines +87 to +88
// DefaultGasPriceConfig returns the default [GasPriceConfig] values.
func DefaultGasPriceConfig() GasPriceConfig {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I know this really isn't related to this PR, but DefaultGasPriceConfig (and the corresponding DefaultTargetToExcessScaling and DefaultMinPrice) feel odd to me.

They aren't actually defaults, we will error if the zero values are provided (rather than defaulting to them).

Not required for this PR, (and someone else could push back on this) but I feel like these should be removed / moved into a test file.

Comment thread vms/saevm/saexec/execution.go Outdated
Comment thread vms/saevm/blocks/time.go Outdated
Comment thread vms/saevm/gastime/gastime.go Outdated
@alarso16 alarso16 force-pushed the alarso16/gastime-hook-imports branch from c52797d to d11bf40 Compare April 16, 2026 17:48
@alarso16 alarso16 force-pushed the alarso16/gastime-hook-imports branch from d11bf40 to 9bcdd8e Compare April 16, 2026 18:07
Comment thread vms/saevm/gastime/acp176_test.go Outdated
Comment thread vms/saevm/gastime/config.go Outdated
Comment thread vms/saevm/hook/hookstest/stub.go Outdated
Comment thread vms/saevm/hook/hook.go Outdated
Comment thread vms/saevm/gastime/acp176.go Outdated
@alarso16 alarso16 force-pushed the alarso16/gastime-hook-imports branch from ac57791 to 3302a34 Compare April 16, 2026 20:53
@StephenButtolph StephenButtolph requested a review from a team April 16, 2026 21:15
Copy link
Copy Markdown
Contributor

@ARR4N ARR4N left a comment

Choose a reason for hiding this comment

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

Assuming my understanding of the deletions of blocks.PreciseTime() and GasTime() are correct then I don't need to re-review how you address my comments.

Comment thread vms/saevm/hook/hook.go
Comment thread vms/saevm/blocks/time.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Confirming my understanding: PreciseTime() is replaced by hook.Points.BlockTime() and GasTime() is just proxytime.Of(hook.Points.BlockTime())?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PreciseTime is replaced by the hook 👍.
GasTime was never used.

Comment thread vms/saevm/gastime/acp176.go Outdated
Comment thread vms/saevm/gastime/acp176_test.go
@alarso16 alarso16 force-pushed the alarso16/gastime-hook-imports branch from 6227847 to 9cb28cc Compare April 17, 2026 13:55
@StephenButtolph StephenButtolph added this pull request to the merge queue Apr 17, 2026
@StephenButtolph StephenButtolph removed this pull request from the merge queue due to a manual request Apr 17, 2026
Comment thread vms/saevm/gastime/acp176.go
@StephenButtolph StephenButtolph added this pull request to the merge queue Apr 17, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 17, 2026
@StephenButtolph StephenButtolph merged commit 238c99e into master Apr 17, 2026
60 checks passed
@github-project-automation github-project-automation Bot moved this from Ready 🚦 to Done 🎉 in avalanchego Apr 17, 2026
@StephenButtolph StephenButtolph deleted the alarso16/gastime-hook-imports branch April 17, 2026 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

evm Related to EVM functionality go Pull requests that update Go code

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants