Skip to content

Conversation

geoff-vball
Copy link

@geoff-vball geoff-vball commented Sep 30, 2025

Why this should be merged

Updates warp gas fees for granite upgrade. (Final numbers still TBD).

How this works

How this was tested

Unit tests in precompile/procompiletest that use granite-specific gas costs also run for granite now.

Need to be documented?

Need to update RELEASES.md?

@geoff-vball geoff-vball marked this pull request as ready for review October 1, 2025 16:50
@geoff-vball geoff-vball requested a review from a team as a code owner October 1, 2025 16:50
@JonathanOppenheimer JonathanOppenheimer added the granite Items related to the granite release. label Oct 1, 2025
@geoff-vball geoff-vball changed the title Gstuart/warp gas costs granite Warp gas costs granite Oct 1, 2025
Copy link
Contributor

@StephenButtolph StephenButtolph left a comment

Choose a reason for hiding this comment

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

The structure seems reasonable to me

Comment on lines 80 to 81
// IsGranite returns true if the time is after Granite.
IsGranite(time uint64) bool
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we ever use this?

Copy link
Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

@ceyonur ceyonur Oct 1, 2025

Choose a reason for hiding this comment

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

I think we can return the rules with the GetRules from env.rules to consolidate these two.

more specifically the interface here and the implemtnation

but it probably requires a bigger refactor that changes other files

}

func GetWarpPredicateGasConfig(isGraniteActivated bool) GasConfig {
if isGraniteActivated {
Copy link
Collaborator

Choose a reason for hiding this comment

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

did we add any test for this case?

Copy link
Author

Choose a reason for hiding this comment

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

Added now

Comment on lines +354 to +358
return GasConfig{
PerWarpSigner: 250,
PerWarpMessageChunk: 3_200,
PerSignatureVerification: 100_000,
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: we can just define them as constants just for a better visibility

Copy link
Collaborator

@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.

Small point on readability, and I see it's pretty similar to another comment that Stephen left. Otherwise LGTM

return statefulContract
}

func GetWarpPredicateGasConfig(isGraniteActivated bool) GasConfig {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
func GetWarpPredicateGasConfig(isGraniteActivated bool) GasConfig {
func CurrentGasConfig(rules precompileconfig.Rules) GasConfig {

Rationale re readability / maintainability:

  • The "get" prefix doesn't communicate anything of value; "current" tells the reader that the function changes what it returns over time.
  • We're already in the warp package so warp.GetWarp... is jarring when called from outside, and unnecessary when called from inside the package.
  • "Predicate" could possibly remain, but is unnecessary and may not always be where this is used (e.g. under SAE the gas charge is the same but it's done in a different place).
  • Raw booleans lend themselves to hard-to-read call sites, often requiring comments like config := CurrentGasConfig(false /*isGranite*/) (e.g. your first change to TestGetVerifiedWarpMessage is opaque). Across geth/libevm, Rules are the point-in-time carriers of these booleans, so accepting them as the argument makes code self-explanatory and less brittle if changed (e.g. in a future fork where there would be two booleans).

Co-authored-by: Michael Kaplan <[email protected]>
Signed-off-by: Geoff Stuart <[email protected]>
Copy link
Collaborator

@ceyonur ceyonur left a comment

Choose a reason for hiding this comment

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

Overall lgtm, just few nits for comments and renaming etc

}

func (a accessibleState) GetRules() precompileconfig.Rules {
extra := GetExtra(a.GetPrecompileEnv().ChainConfig())
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: can we rename this to chainConfigExtra as there are actual extras package which can be confusing

return GetExtra(a.env.ChainConfig())
}

func (a accessibleState) GetRules() precompileconfig.Rules {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for refactoring this.

IsGranite bool
}

func (a AvalancheRules) IsGraniteActivated() bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we add a comment why this is required (to make it clear this is called from precompile environment etc)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
acp181 granite Items related to the granite release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants