Skip to content

Commit

Permalink
Fixed missing initial validators for Songbird networks
Browse files Browse the repository at this point in the history
  • Loading branch information
Marko Boben committed Sep 18, 2024
1 parent 8cd96d1 commit 667d7dd
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 36 deletions.
1 change: 0 additions & 1 deletion avalanchego/genesis/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ func (c Config) Unparse() (UnparsedConfig, error) {
}

func (c *Config) InitialSupply() (uint64, error) {
// SGB-MERGE
// For songbird, coston and local networks, the initial supply is 1
if c.NetworkID == constants.SongbirdID || c.NetworkID == constants.CostonID || c.NetworkID == constants.LocalID {
return 1, nil
Expand Down
23 changes: 1 addition & 22 deletions avalanchego/snow/validators/custom.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package validators

// SGB-MERGE

import (
"errors"
"fmt"
Expand Down Expand Up @@ -151,26 +149,7 @@ func loadSongbirdValidators(timestamp time.Time) []Validator {
return nil
}
nodeIDs := []string{
"NodeID-3M9KVT6ixi4gVMisbm5TnPXYXgFN5LHuv",
"NodeID-NnX4fajAmyvpL9RLfheNdc47FKKDuQW8i",
"NodeID-AzdF8JNU468uwZYGquHt7bhDrsggZpK67",
"NodeID-FqeGcnLAXbDTthd382aP9uyu1i47paRRh",
"NodeID-B9HuZ5hDkRodyRRsiMEHWgMmmMF7xSKbj",
"NodeID-Jx3E1F7mfkseZmqnFgDUFV3eusMxVdT6Z",
"NodeID-FnvWuwvJGezs4uaBLujkfeM8U3gmAUY3Z",
"NodeID-LhVs6hzHjBcEkzA1Eu8Qxb9nEQAk1Qbgf",
"NodeID-9SqDo3MxpvEDN4bE4rLTyM7HkkKAw4h96",
"NodeID-4tStYRTi3KDxFmv1YHTZAQxbzeyMA7z52",
"NodeID-8XnMh17zo6pB8Pa2zptRBi9TbbMZgij2t",
"NodeID-Cn9P5wgg7d9RNLqm4dFLCUV2diCxpkj7f",
"NodeID-PEDdah7g7Efiii1xw8ex2dH58oMfByzjb",
"NodeID-QCt9AxMPt5nn445CQGoA3yktqkChnKmPY",
"NodeID-9bWz6J61B8WbQtzeSyA1jsXosyVbuUJd1",
"NodeID-DLMnewsEwtSH8Qk7p9RGzUVyZAaZVMKsk",
"NodeID-7meEpyjmGbL577th58dm4nvvtVZiJusFp",
"NodeID-JeYnnrUkuArAAe2Sjo47Z3X5yfeF7cw43",
"NodeID-Fdwp9Wtjh5rxzuTCF9z4zrSM31y7ZzBQS",
"NodeID-JdEBRLS98PansyFKQUzFKqk4xqrVZ41nC",
"NodeID-HaZ4HpanjndqSuN252chFsTysmdND5meA",
}
return createValidators(nodeIDs, uint64(songbirdValidatorWeight))
}
Expand Down
1 change: 0 additions & 1 deletion avalanchego/vms/platformvm/state/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ type Diff interface {
}

type diff struct {
// SGB-MERGE
networkID uint32

parentID ids.ID
Expand Down
1 change: 0 additions & 1 deletion avalanchego/vms/platformvm/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ type Chain interface {
UTXOGetter
UTXODeleter

// SGB-MERGE
GetNetworkID() uint32

GetTimestamp() time.Time
Expand Down
6 changes: 3 additions & 3 deletions avalanchego/vms/platformvm/txs/executor/inflation_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,16 @@ func getSongbirdInflationSettings(currentTimestamp time.Time, config *config.Con
default:
// Phase 2
return InflationSettings{
MinValidatorStake: 1 * units.MegaAvax,
MinValidatorStake: 10 * units.Avax,
MaxValidatorStake: 200 * units.MegaAvax,
MinDelegatorStake: 50 * units.KiloAvax,
MinDelegatorStake: 1 * units.Avax,
MinDelegationFee: 0,
MinStakeDuration: 60 * 24 * time.Hour,
MinDelegateDuration: 2 * 7 * 24 * time.Hour,
MaxStakeDuration: 365 * 24 * time.Hour,
MinFutureStartTimeOffset: MaxFutureStartTime,
MaxValidatorWeightFactor: 15,
MinStakeStartTime: time.Date(2024, time.September, 3, 0, 0, 0, 0, time.UTC),
MinStakeStartTime: time.Date(2024, time.September, 5, 12, 30, 0, 0, time.UTC),
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ var (
errAdvanceTimeTxIssuedAfterBanff = errors.New("AdvanceTimeTx issued after Banff")
)

var (
songbirdLatestStakingTime = time.Date(2024, time.December, 31, 0, 0, 0, 0, time.UTC)
)

type ProposalTxExecutor struct {
// inputs, to be filled before visitor methods are called
*Backend
Expand Down Expand Up @@ -572,6 +576,9 @@ func GetNextStakerChangeTime(state state.Chain) (time.Time, error) {
case hasPendingStaker:
return pendingStakerIterator.Value().NextTime, nil
default:
if state.GetNetworkID() == constants.SongbirdID || state.GetNetworkID() == constants.CostonID || state.GetNetworkID() == constants.LocalID {
return songbirdLatestStakingTime, nil
}
return time.Time{}, database.ErrNotFound
}
}
Expand Down
2 changes: 1 addition & 1 deletion avalanchego/vms/platformvm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ func (vm *VM) updateValidators() error {
return err
}

// SGB-MERGE: This are new lines of code
// Songbird (coston, local) had a fixed set of validators at genesis
for _, v := range validators.DefaultValidatorList() {
err := primaryValidators.AddWeight(v.ID(), v.Weight())
if err != nil {
Expand Down
12 changes: 5 additions & 7 deletions coreth/params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,11 @@ var (
ApricotPhase3BlockTimestamp: big.NewInt(time.Date(2022, time.March, 7, 14, 0, 0, 0, time.UTC).Unix()),
ApricotPhase4BlockTimestamp: big.NewInt(time.Date(2022, time.March, 7, 15, 0, 0, 0, time.UTC).Unix()),
ApricotPhase5BlockTimestamp: big.NewInt(time.Date(2022, time.March, 7, 16, 0, 0, 0, time.UTC).Unix()),
ApricotPhasePre6BlockTimestamp: big.NewInt(time.Date(10000, time.January, 1, 0, 0, 0, 0, time.UTC).Unix()),
ApricotPhase6BlockTimestamp: big.NewInt(time.Date(10000, time.January, 1, 0, 0, 0, 0, time.UTC).Unix()),
ApricotPhasePost6BlockTimestamp: big.NewInt(time.Date(10000, time.January, 1, 0, 0, 0, 0, time.UTC).Unix()),
SongbirdTransitionTimestamp: big.NewInt(time.Date(2024, time.August, 20, 12, 0, 0, 0, time.UTC).Unix()),
BanffBlockTimestamp: big.NewInt(time.Date(10000, time.January, 1, 0, 0, 0, 0, time.UTC).Unix()),
ApricotPhasePre6BlockTimestamp: big.NewInt(time.Date(2024, time.September, 17, 16, 20, 0, 0, time.UTC).Unix()),
ApricotPhase6BlockTimestamp: big.NewInt(time.Date(2024, time.September, 17, 16, 30, 0, 0, time.UTC).Unix()),
ApricotPhasePost6BlockTimestamp: big.NewInt(time.Date(2024, time.September, 17, 16, 40, 0, 0, time.UTC).Unix()),
SongbirdTransitionTimestamp: big.NewInt(time.Date(2024, time.September, 5, 12, 0, 0, 0, time.UTC).Unix()),
BanffBlockTimestamp: big.NewInt(time.Date(2024, time.September, 17, 16, 50, 0, 0, time.UTC).Unix()),
}

TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0)}
Expand Down Expand Up @@ -428,7 +428,6 @@ func (c *ChainConfig) String() string {
return banner
}

// SGB-MERGE
// Code for songbird network (songbird, coston, local id)
func (c *ChainConfig) IsSongbirdCode() bool {
return c.ChainID != nil && (c.ChainID.Cmp(SongbirdChainID) == 0 || c.ChainID.Cmp(CostonChainID) == 0 || c.ChainID.Cmp(LocalChainID) == 0)
Expand Down Expand Up @@ -792,7 +791,6 @@ type Rules struct {
IsCortina bool
IsClementine bool

// SGB-MERGE
// Songbird (coston, local)
IsSongbirdCode bool
IsSongbirdTransition bool
Expand Down

0 comments on commit 667d7dd

Please sign in to comment.