diff --git a/go.mod b/go.mod index f440ad419e1..bc1e96772e8 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/DataDog/zstd v1.5.2 github.com/NYTimes/gziphandler v1.1.1 github.com/antithesishq/antithesis-sdk-go v0.3.8 - github.com/ava-labs/coreth v0.13.8-0.20240802110637-b3e5088d062d + github.com/ava-labs/coreth v0.13.8-fix-genesis-upgrade github.com/ava-labs/ledger-avalanche/go v0.0.0-20240610153809-9c955cc90a95 github.com/btcsuite/btcd/btcutil v1.1.3 github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 @@ -34,7 +34,7 @@ require ( github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d github.com/onsi/ginkgo/v2 v2.13.1 github.com/pires/go-proxyproto v0.6.2 - github.com/prometheus/client_golang v1.14.0 + github.com/prometheus/client_golang v1.16.0 github.com/prometheus/client_model v0.3.0 github.com/prometheus/common v0.42.0 github.com/rs/cors v1.7.0 @@ -156,7 +156,7 @@ require ( github.com/zondax/ledger-go v0.14.3 // indirect go.opentelemetry.io/otel/metric v1.22.0 // indirect go.opentelemetry.io/proto/otlp v1.0.0 // indirect - go.uber.org/multierr v1.10.0 // indirect + go.uber.org/multierr v1.11.0 // indirect golang.org/x/sys v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.17.0 // indirect diff --git a/go.sum b/go.sum index 4f50be7c1b7..1f06a819fe3 100644 --- a/go.sum +++ b/go.sum @@ -62,8 +62,8 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax github.com/antithesishq/antithesis-sdk-go v0.3.8 h1:OvGoHxIcOXFJLyn9IJQ5DzByZ3YVAWNBc394ObzDRb8= github.com/antithesishq/antithesis-sdk-go v0.3.8/go.mod h1:IUpT2DPAKh6i/YhSbt6Gl3v2yvUZjmKncl7U91fup7E= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/ava-labs/coreth v0.13.8-0.20240802110637-b3e5088d062d h1:klPTcKVvqfA2KSKaRvQAO56Pd4XAqGhwgMTQ6/W+w7w= -github.com/ava-labs/coreth v0.13.8-0.20240802110637-b3e5088d062d/go.mod h1:tXDujonxXFOF6oK5HS2EmgtSXJK3Gy6RpZxb5WzR9rM= +github.com/ava-labs/coreth v0.13.8-fix-genesis-upgrade h1:xWsvSGtZcGna3B2BLU2BvK3qskbcc9ZNtgC0ck91CkI= +github.com/ava-labs/coreth v0.13.8-fix-genesis-upgrade/go.mod h1:Ouul9dJouniUIJVX1gDqx8CrHyGvmwZkK28mrgKb/4I= github.com/ava-labs/ledger-avalanche/go v0.0.0-20240610153809-9c955cc90a95 h1:dOVbtdnZL++pENdTCNZ1nu41eYDQkTML4sWebDnnq8c= github.com/ava-labs/ledger-avalanche/go v0.0.0-20240610153809-9c955cc90a95/go.mod h1:pJxaT9bUgeRNVmNRgtCHb7sFDIRKy7CzTQVi8gGNT6g= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= @@ -498,8 +498,8 @@ github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qR github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= -github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= +github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8= +github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= @@ -644,8 +644,8 @@ go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= -go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ= -go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= golang.org/x/crypto v0.0.0-20170613210332-850760c427c5/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= diff --git a/tests/fixture/tmpnet/genesis.go b/tests/fixture/tmpnet/genesis.go index a9c85fe8b44..aa308be6ee7 100644 --- a/tests/fixture/tmpnet/genesis.go +++ b/tests/fixture/tmpnet/genesis.go @@ -16,6 +16,7 @@ import ( "github.com/ava-labs/avalanchego/genesis" "github.com/ava-labs/avalanchego/ids" + "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/crypto/secp256k1" "github.com/ava-labs/avalanchego/utils/formatting/address" @@ -149,7 +150,8 @@ func NewTestGenesis( // Define C-Chain genesis cChainGenesis := &core.Genesis{ Config: params.AvalancheLocalChainConfig, - Difficulty: big.NewInt(0), // Difficulty is a mandatory field + Difficulty: big.NewInt(0), // Difficulty is a mandatory field + Timestamp: uint64(upgrade.InitiallyActiveTime.Unix()), // This time enables Avalanche upgrades by default GasLimit: defaultGasLimit, Alloc: cChainBalances, } diff --git a/tests/fixture/tmpnet/network.go b/tests/fixture/tmpnet/network.go index 695017c0620..5230d2f22f0 100644 --- a/tests/fixture/tmpnet/network.go +++ b/tests/fixture/tmpnet/network.go @@ -295,18 +295,7 @@ func (n *Network) Create(rootDir string) error { } if n.NetworkID == 0 && n.Genesis == nil { - // Pre-fund known legacy keys to support ad-hoc testing. Usage of a legacy key will - // require knowing the key beforehand rather than retrieving it from the set of pre-funded - // keys exposed by a network. Since allocation will not be exclusive, a test using a - // legacy key is unlikely to be a good candidate for parallel execution. - keysToFund := []*secp256k1.PrivateKey{ - genesis.VMRQKey, - genesis.EWOQKey, - HardhatKey, - } - keysToFund = append(keysToFund, n.PreFundedKeys...) - - genesis, err := NewTestGenesis(defaultNetworkID, n.Nodes, keysToFund) + genesis, err := n.DefaultGenesis() if err != nil { return err } @@ -325,6 +314,21 @@ func (n *Network) Create(rootDir string) error { return n.Write() } +func (n *Network) DefaultGenesis() (*genesis.UnparsedConfig, error) { + // Pre-fund known legacy keys to support ad-hoc testing. Usage of a legacy key will + // require knowing the key beforehand rather than retrieving it from the set of pre-funded + // keys exposed by a network. Since allocation will not be exclusive, a test using a + // legacy key is unlikely to be a good candidate for parallel execution. + keysToFund := []*secp256k1.PrivateKey{ + genesis.VMRQKey, + genesis.EWOQKey, + HardhatKey, + } + keysToFund = append(keysToFund, n.PreFundedKeys...) + + return NewTestGenesis(defaultNetworkID, n.Nodes, keysToFund) +} + // Starts the specified nodes func (n *Network) StartNodes(ctx context.Context, w io.Writer, nodesToStart ...*Node) error { if len(nodesToStart) == 0 { diff --git a/tests/upgrade/upgrade_test.go b/tests/upgrade/upgrade_test.go index 32c76fd6dd0..374af3385f8 100644 --- a/tests/upgrade/upgrade_test.go +++ b/tests/upgrade/upgrade_test.go @@ -4,15 +4,18 @@ package upgrade import ( + "encoding/json" "flag" "fmt" "testing" + "github.com/ava-labs/coreth/core" "github.com/onsi/ginkgo/v2" "github.com/stretchr/testify/require" "github.com/ava-labs/avalanchego/tests/fixture/e2e" "github.com/ava-labs/avalanchego/tests/fixture/tmpnet" + "github.com/ava-labs/avalanchego/upgrade" ) func TestUpgrade(t *testing.T) { @@ -45,6 +48,25 @@ var _ = ginkgo.Describe("[Upgrade]", func() { ginkgo.It("can upgrade versions", func() { network := tmpnet.NewDefaultNetwork("avalanchego-upgrade") + + { + // Get the default genesis so we can modify it + genesis, err := network.DefaultGenesis() + require.NoError(err) + network.Genesis = genesis + // Etna enables Cancun which modifies the outcome of the C-Chain genesis + // This is because of new header fields that modify the genesis block hash. + // This code can be removed once the Etna upgrade is activated. + cChainGenesis := new(core.Genesis) + cChainGenesisStr := network.Genesis.CChainGenesis + require.NoError(json.Unmarshal([]byte(cChainGenesisStr), cChainGenesis)) + unscheduledActivationTime := uint64(upgrade.UnscheduledActivationTime.Unix()) + cChainGenesis.Config.EUpgradeTime = &unscheduledActivationTime + cChainGenesisBytes, err := json.Marshal(cChainGenesis) + require.NoError(err) + network.Genesis.CChainGenesis = string(cChainGenesisBytes) + } + e2e.StartNetwork(tc, network, avalancheGoExecPath, "" /* pluginDir */, 0 /* shutdownDelay */, false /* reuseNetwork */) tc.By(fmt.Sprintf("restarting all nodes with %q binary", avalancheGoExecPathToUpgradeTo)) diff --git a/version/constants.go b/version/constants.go index 0c682ffcc61..a18d2f13c44 100644 --- a/version/constants.go +++ b/version/constants.go @@ -8,9 +8,6 @@ import ( "time" _ "embed" - - "github.com/ava-labs/avalanchego/upgrade" - "github.com/ava-labs/avalanchego/utils/constants" ) const ( @@ -67,78 +64,6 @@ var ( // set of avalanchego versions that supported that version. This is not used // by avalanchego, but is useful for downstream libraries. RPCChainVMProtocolCompatibility map[uint][]*Semantic - - // Deprecated: This will be removed once coreth no longer uses it. - ApricotPhase1Times = map[uint32]time.Time{ - constants.MainnetID: upgrade.Mainnet.ApricotPhase1Time, - constants.FujiID: upgrade.Fuji.ApricotPhase1Time, - } - - // Deprecated: This will be removed once coreth no longer uses it. - ApricotPhase2Times = map[uint32]time.Time{ - constants.MainnetID: upgrade.Mainnet.ApricotPhase2Time, - constants.FujiID: upgrade.Fuji.ApricotPhase2Time, - } - - // Deprecated: This will be removed once coreth no longer uses it. - ApricotPhase3Times = map[uint32]time.Time{ - constants.MainnetID: upgrade.Mainnet.ApricotPhase3Time, - constants.FujiID: upgrade.Fuji.ApricotPhase3Time, - } - - // Deprecated: This will be removed once coreth no longer uses it. - ApricotPhase4Times = map[uint32]time.Time{ - constants.MainnetID: upgrade.Mainnet.ApricotPhase4Time, - constants.FujiID: upgrade.Fuji.ApricotPhase4Time, - } - - // Deprecated: This will be removed once coreth no longer uses it. - ApricotPhase5Times = map[uint32]time.Time{ - constants.MainnetID: upgrade.Mainnet.ApricotPhase5Time, - constants.FujiID: upgrade.Fuji.ApricotPhase5Time, - } - - // Deprecated: This will be removed once coreth no longer uses it. - ApricotPhasePre6Times = map[uint32]time.Time{ - constants.MainnetID: upgrade.Mainnet.ApricotPhasePre6Time, - constants.FujiID: upgrade.Fuji.ApricotPhasePre6Time, - } - - // Deprecated: This will be removed once coreth no longer uses it. - ApricotPhase6Times = map[uint32]time.Time{ - constants.MainnetID: upgrade.Mainnet.ApricotPhase6Time, - constants.FujiID: upgrade.Fuji.ApricotPhase6Time, - } - - // Deprecated: This will be removed once coreth no longer uses it. - ApricotPhasePost6Times = map[uint32]time.Time{ - constants.MainnetID: upgrade.Mainnet.ApricotPhasePost6Time, - constants.FujiID: upgrade.Fuji.ApricotPhasePost6Time, - } - - // Deprecated: This will be removed once coreth no longer uses it. - BanffTimes = map[uint32]time.Time{ - constants.MainnetID: upgrade.Mainnet.BanffTime, - constants.FujiID: upgrade.Fuji.BanffTime, - } - - // Deprecated: This will be removed once coreth no longer uses it. - CortinaTimes = map[uint32]time.Time{ - constants.MainnetID: upgrade.Mainnet.CortinaTime, - constants.FujiID: upgrade.Fuji.CortinaTime, - } - - // Deprecated: This will be removed once coreth no longer uses it. - DurangoTimes = map[uint32]time.Time{ - constants.MainnetID: upgrade.Mainnet.DurangoTime, - constants.FujiID: upgrade.Fuji.DurangoTime, - } - - // Deprecated: This will be removed once coreth no longer uses it. - EUpgradeTimes = map[uint32]time.Time{ - constants.MainnetID: upgrade.Mainnet.EtnaTime, - constants.FujiID: upgrade.Fuji.EtnaTime, - } ) func init() {