-
Notifications
You must be signed in to change notification settings - Fork 714
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
Remove duplicate fork definitions #3304
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
edfddbc
Remove duplicate fork definitions
StephenButtolph 700b9af
nits
StephenButtolph eecb49e
more cleanup
StephenButtolph f685c70
comments
StephenButtolph 9443588
add comment
StephenButtolph 80a7f2f
nit
StephenButtolph 39d48f6
fix comment
StephenButtolph ac0375a
standardize to time.Time{}
StephenButtolph 49cb2e7
Skip populating zero values
StephenButtolph File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE for licensing terms. | ||
|
||
package upgradetest | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/ava-labs/avalanchego/upgrade" | ||
) | ||
|
||
// GetConfig returns an upgrade config with the provided fork scheduled to have | ||
// been initially activated and all other forks to be unscheduled. | ||
func GetConfig(fork Fork) upgrade.Config { | ||
return GetConfigWithUpgradeTime(fork, upgrade.InitiallyActiveTime) | ||
} | ||
|
||
// GetConfigWithUpgradeTime returns an upgrade config with the provided fork | ||
// scheduled to be activated at the provided upgradeTime and all other forks to | ||
// be unscheduled. | ||
func GetConfigWithUpgradeTime(fork Fork, upgradeTime time.Time) upgrade.Config { | ||
c := upgrade.Config{} | ||
// Initialize all forks to be unscheduled | ||
SetTimesTo(&c, Latest, upgrade.UnscheduledActivationTime) | ||
// Schedule the requested forks at the provided upgrade time | ||
SetTimesTo(&c, fork, upgradeTime) | ||
return c | ||
} | ||
|
||
// SetTimesTo sets the upgrade time of the provided fork, and all prior forks, | ||
// to the provided upgradeTime. | ||
func SetTimesTo(c *upgrade.Config, fork Fork, upgradeTime time.Time) { | ||
switch fork { | ||
case Etna: | ||
c.EtnaTime = upgradeTime | ||
fallthrough | ||
case Durango: | ||
c.DurangoTime = upgradeTime | ||
fallthrough | ||
case Cortina: | ||
c.CortinaTime = upgradeTime | ||
fallthrough | ||
case Banff: | ||
c.BanffTime = upgradeTime | ||
fallthrough | ||
case ApricotPhasePost6: | ||
c.ApricotPhasePost6Time = upgradeTime | ||
fallthrough | ||
case ApricotPhase6: | ||
c.ApricotPhase6Time = upgradeTime | ||
fallthrough | ||
case ApricotPhasePre6: | ||
c.ApricotPhasePre6Time = upgradeTime | ||
fallthrough | ||
case ApricotPhase5: | ||
c.ApricotPhase5Time = upgradeTime | ||
fallthrough | ||
case ApricotPhase4: | ||
c.ApricotPhase4Time = upgradeTime | ||
fallthrough | ||
case ApricotPhase3: | ||
c.ApricotPhase3Time = upgradeTime | ||
fallthrough | ||
case ApricotPhase2: | ||
c.ApricotPhase2Time = upgradeTime | ||
fallthrough | ||
case ApricotPhase1: | ||
c.ApricotPhase1Time = upgradeTime | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE for licensing terms. | ||
|
||
package upgradetest | ||
|
||
const ( | ||
NoUpgrades Fork = iota | ||
ApricotPhase1 | ||
ApricotPhase2 | ||
ApricotPhase3 | ||
ApricotPhase4 | ||
ApricotPhase5 | ||
ApricotPhasePre6 | ||
ApricotPhase6 | ||
ApricotPhasePost6 | ||
Banff | ||
Cortina | ||
Durango | ||
Etna | ||
|
||
Latest = Etna | ||
) | ||
|
||
// Fork is an enum of all the major network upgrades. | ||
type Fork int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,6 @@ import ( | |
"encoding/json" | ||
"math/rand" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
|
@@ -21,14 +20,13 @@ import ( | |
"github.com/ava-labs/avalanchego/snow/engine/common" | ||
"github.com/ava-labs/avalanchego/snow/engine/enginetest" | ||
"github.com/ava-labs/avalanchego/snow/snowtest" | ||
"github.com/ava-labs/avalanchego/upgrade" | ||
"github.com/ava-labs/avalanchego/upgrade/upgradetest" | ||
"github.com/ava-labs/avalanchego/utils/constants" | ||
"github.com/ava-labs/avalanchego/utils/crypto/secp256k1" | ||
"github.com/ava-labs/avalanchego/utils/formatting" | ||
"github.com/ava-labs/avalanchego/utils/formatting/address" | ||
"github.com/ava-labs/avalanchego/utils/logging" | ||
"github.com/ava-labs/avalanchego/utils/sampler" | ||
"github.com/ava-labs/avalanchego/utils/timer/mockable" | ||
"github.com/ava-labs/avalanchego/vms/avm/block/executor" | ||
"github.com/ava-labs/avalanchego/vms/avm/config" | ||
"github.com/ava-labs/avalanchego/vms/avm/fxs" | ||
|
@@ -42,14 +40,7 @@ import ( | |
keystoreutils "github.com/ava-labs/avalanchego/vms/components/keystore" | ||
) | ||
|
||
type fork uint8 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1 |
||
|
||
const ( | ||
durango fork = iota | ||
etna | ||
|
||
latest = durango | ||
|
||
testTxFee uint64 = 1000 | ||
startBalance uint64 = 50000 | ||
|
||
|
@@ -95,7 +86,7 @@ type user struct { | |
} | ||
|
||
type envConfig struct { | ||
fork fork | ||
fork upgradetest.Fork | ||
isCustomFeeAsset bool | ||
keystoreUsers []*user | ||
vmStaticConfig *config.Config | ||
|
@@ -155,7 +146,11 @@ func setup(tb testing.TB, c *envConfig) *environment { | |
require.NoError(keystoreUser.Close()) | ||
} | ||
|
||
vmStaticConfig := staticConfig(tb, c.fork) | ||
vmStaticConfig := config.Config{ | ||
Upgrades: upgradetest.GetConfig(c.fork), | ||
TxFee: testTxFee, | ||
CreateAssetTxFee: testTxFee, | ||
} | ||
if c.vmStaticConfig != nil { | ||
vmStaticConfig = *c.vmStaticConfig | ||
} | ||
|
@@ -230,26 +225,6 @@ func setup(tb testing.TB, c *envConfig) *environment { | |
return env | ||
} | ||
|
||
func staticConfig(tb testing.TB, f fork) config.Config { | ||
c := config.Config{ | ||
Upgrades: upgrade.Config{ | ||
EtnaTime: mockable.MaxTime, | ||
}, | ||
TxFee: testTxFee, | ||
CreateAssetTxFee: testTxFee, | ||
} | ||
|
||
switch f { | ||
case etna: | ||
c.Upgrades.EtnaTime = time.Time{} | ||
case durango: | ||
default: | ||
require.FailNow(tb, "unhandled fork", f) | ||
} | ||
|
||
return c | ||
} | ||
|
||
// Returns: | ||
// | ||
// 1. tx in genesis that creates asset | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Elegant 😍