Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: params/extras (coreth a7f7061) #1430

Open
wants to merge 1 commit into
base: libevm
Choose a base branch
from
Open

Conversation

darioush
Copy link
Collaborator

@darioush darioush commented Jan 22, 2025

Applies the same changes as were applied to coreth here: ava-labs/coreth@a7f7061

I realized we could import most of these types back to params if we wanted, but explicit seems clearer + it's already like this in coreth.

@@ -15,8 +16,7 @@ import (

func TestVerifyUpgradeConfig(t *testing.T) {
admins := []common.Address{{1}}
chainConfigCpy := Copy(TestChainConfig)
chainConfig := GetExtra(&chainConfigCpy)
chainConfig := &ChainConfig{}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

note I tried to use the empty ChainConfig (former ChainConfigExtra) where possible
We can switch back to TestChainConfig if others prefer.
Less test setup seems preferred to me, but we could keep it to avoid any risk here.

params/extras/config.go Show resolved Hide resolved
AvalancheContext: AvalancheContext{utils.TestSnowContext()},
FeeConfig: DefaultFeeConfig,
AllowFeeRecipients: false,
NetworkUpgrades: GetDefaultNetworkUpgrades(upgrade.GetConfig(constants.UnitTestID)), // This can be changed to correct network (local, test) via VM.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

note we could unexport this GetDefaultNetworkUpgrades if we had something like GetDefaultExtras(networkID), but seems mostly the same to me.

@darioush darioush marked this pull request as ready for review January 22, 2025 23:07
@darioush darioush requested review from ceyonur and a team as code owners January 22, 2025 23:07
params/config_libevm.go Show resolved Hide resolved
params/extras/config.go Show resolved Hide resolved
params/extras/config.go Show resolved Hide resolved
params/extras/precompile_upgrade_test.go Show resolved Hide resolved
Comment on lines +331 to +335
// IsForkTransition returns true if [fork] activates during the transition from
// [parent] to [current].
// Taking [parent] as a pointer allows for us to pass nil when checking forks
// that activate during genesis.
// Note: [parent] and [current] can be either both timestamp values, or both
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit - maybe out of scope - but brackets only work for type definitions or global variables, they won't work for arguments 🤷 Maybe worth changing to use backticks instead

Suggested change
// IsForkTransition returns true if [fork] activates during the transition from
// [parent] to [current].
// Taking [parent] as a pointer allows for us to pass nil when checking forks
// that activate during genesis.
// Note: [parent] and [current] can be either both timestamp values, or both
// IsForkTransition returns true if `fork` activates during the transition from
// `parent` to `current`.
// Taking `parent` as a pointer allows for us to pass nil when checking forks
// that activate during genesis.
// Note: `parent` and `current` can be either both timestamp values, or both

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Using the brackets seems very specific to the avalanche code bases, I would appreciate if you were able to figure out the best practices here and communicate them with the team, especially for code on a go-forward basis.

Copy link
Collaborator

Choose a reason for hiding this comment

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

See https://go.dev/doc/comment#doclinks - if it's not cmd-clickable, don't use square brackets since it's rather confusing to have clickable elements and some not despite the same brackets syntax.

return nil
}

// IsPrecompileEnabled returns whether precompile with [address] is enabled at [timestamp].
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit

Suggested change
// IsPrecompileEnabled returns whether precompile with [address] is enabled at [timestamp].
// IsPrecompileEnabled returns whether precompile with `address` is enabled at `timestamp`.


// checkForks checks that forks are enabled in order and returns an error if not.
// [blockFork] is true if the fork is a block number fork, false if it is a timestamp fork
// TODO: This code was adapted from CheckConfigForkOrder, consider refactoring to avoid duplication.
Copy link
Collaborator

@qdm12 qdm12 Jan 24, 2025

Choose a reason for hiding this comment

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

New TODO added, just in case it was forgotten - otherwise discard my comment 😉

}

// checkForks checks that forks are enabled in order and returns an error if not.
// [blockFork] is true if the fork is a block number fork, false if it is a timestamp fork
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit brackets don't work for function arguments

Suggested change
// [blockFork] is true if the fork is a block number fork, false if it is a timestamp fork
// `blockFork` is true if the fork is a block number fork, false if it is a timestamp fork

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