Skip to content

Commit

Permalink
Fix phase timestamp inconsistency (#396)
Browse files Browse the repository at this point in the history
  • Loading branch information
evlekht authored Nov 18, 2024
1 parent e6f3689 commit da9e010
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
2 changes: 1 addition & 1 deletion chains/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ func (m *manager) createAvalancheChain(
VM: vm,
DB: vertexDB,
Log: ctx.Log,
CortinaTime: version.GetCortinaTime(ctx.NetworkID),
CortinaTime: version.GetPreCortinaTime(ctx.NetworkID),
},
)

Expand Down
42 changes: 27 additions & 15 deletions version/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ var (
DefaultUpgradeTime = time.Date(2020, time.December, 5, 5, 0, 0, 0, time.UTC)
unreachableFutureTime = time.Date(10000, time.January, 1, 0, 0, 0, 0, time.UTC)

caminoEarliestTime = time.Date(2022, time.May, 16, 8, 0, 0, 0, time.UTC)
columbusEarliestTime = time.Date(2022, time.May, 16, 8, 0, 0, 0, time.UTC)
kopernikusEarliestTime = time.Date(2022, time.May, 16, 8, 0, 0, 0, time.UTC)
caminoEarliestTime = time.Date(2020, time.December, 5, 5, 0, 0, 0, time.UTC)
columbusEarliestTime = time.Date(2020, time.December, 5, 5, 0, 0, 0, time.UTC)
kopernikusEarliestTime = time.Date(2020, time.December, 5, 5, 0, 0, 0, time.UTC)

ApricotPhase1Times = map[uint32]time.Time{
constants.MainnetID: time.Date(2021, time.March, 31, 14, 0, 0, 0, time.UTC),
Expand Down Expand Up @@ -147,12 +147,6 @@ var (
constants.KopernikusID: kopernikusEarliestTime,
}

SunrisePhase0Times = map[uint32]time.Time{
constants.CaminoID: caminoEarliestTime,
constants.ColumbusID: columbusEarliestTime,
constants.KopernikusID: kopernikusEarliestTime,
}

ApricotPhase6Times = map[uint32]time.Time{
constants.MainnetID: time.Date(2022, time.September, 6, 20, 0, 0, 0, time.UTC),
constants.FujiID: time.Date(2022, time.September, 6, 20, 0, 0, 0, time.UTC),
Expand Down Expand Up @@ -182,27 +176,38 @@ var (
}
BanffDefaultTime = time.Date(2020, time.December, 5, 5, 0, 0, 0, time.UTC)

SunrisePhase0Times = map[uint32]time.Time{
constants.CaminoID: time.Date(2022, time.May, 16, 8, 0, 0, 0, time.UTC),
constants.ColumbusID: time.Date(2022, time.May, 16, 8, 0, 0, 0, time.UTC),
constants.KopernikusID: time.Date(2022, time.May, 16, 8, 0, 0, 0, time.UTC),
}

AthensPhaseTimes = map[uint32]time.Time{
constants.KopernikusID: time.Date(2023, time.July, 4, 13, 0, 0, 0, time.UTC),
constants.ColumbusID: time.Date(2023, time.July, 7, 8, 0, 0, 0, time.UTC),
constants.CaminoID: time.Date(2023, time.July, 17, 8, 0, 0, 0, time.UTC),
}

PreCortinaTimes = map[uint32]time.Time{
constants.CaminoID: caminoEarliestTime,
constants.ColumbusID: columbusEarliestTime,
constants.KopernikusID: kopernikusEarliestTime,
}

// TODO @evlekht update this before release
BerlinPhaseTimes = map[uint32]time.Time{
constants.KopernikusID: time.Date(2024, time.November, 14, 10, 0, 0, 0, time.UTC),
constants.ColumbusID: time.Date(2024, time.November, 14, 10, 0, 0, 0, time.UTC),
constants.KopernikusID: time.Date(2024, time.November, 15, 10, 0, 0, 0, time.UTC),
constants.ColumbusID: time.Date(2024, time.November, 15, 10, 0, 0, 0, time.UTC),
constants.CaminoID: unreachableFutureTime,
}

// TODO @evlekht update this before release, must be exactly the same as Berlin
CortinaTimes = map[uint32]time.Time{
constants.MainnetID: time.Date(2023, time.April, 25, 15, 0, 0, 0, time.UTC),
constants.FujiID: time.Date(2023, time.April, 6, 15, 0, 0, 0, time.UTC),

constants.KopernikusID: time.Date(2024, time.November, 14, 10, 0, 0, 0, time.UTC),
constants.ColumbusID: time.Date(2024, time.November, 14, 10, 0, 0, 0, time.UTC),
constants.CaminoID: unreachableFutureTime,
constants.KopernikusID: BerlinPhaseTimes[constants.KopernikusID],
constants.ColumbusID: BerlinPhaseTimes[constants.ColumbusID],
constants.CaminoID: BerlinPhaseTimes[constants.CaminoID],
}
CortinaDefaultTime = time.Date(2020, time.December, 5, 5, 0, 0, 0, time.UTC)

Expand Down Expand Up @@ -283,6 +288,13 @@ func GetCortinaTime(networkID uint32) time.Time {
return CortinaDefaultTime
}

func GetPreCortinaTime(networkID uint32) time.Time {
if genesisTime, exists := PreCortinaTimes[networkID]; exists {
return genesisTime
}
return CortinaDefaultTime
}

func GetSunrisePhase0Time(networkID uint32) time.Time {
if upgradeTime, exists := SunrisePhase0Times[networkID]; exists {
return upgradeTime
Expand Down
2 changes: 1 addition & 1 deletion vms/avm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ func (vm *VM) LastAccepted(context.Context) (ids.ID, error) {
*/

func (vm *VM) Linearize(_ context.Context, stopVertexID ids.ID, toEngine chan<- common.Message) error {
time := version.GetCortinaTime(vm.ctx.NetworkID)
time := version.GetPreCortinaTime(vm.ctx.NetworkID)
err := vm.state.InitializeChainState(stopVertexID, time)
if err != nil {
return err
Expand Down

0 comments on commit da9e010

Please sign in to comment.