Skip to content

Commit f9d860c

Browse files
committed
fix backwards compatibility of timestamp to mc epoch conversion
1 parent 56716fa commit f9d860c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

toolkit/committee-selection/authority-selection-inherents/src/ariadne_inherent_data_provider.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,11 @@ where
143143
// The genesis committee epoch is initialized with 0, so in the very first block we need to provide
144144
// the epoch number based on the current timestamp
145145
if next_unset_epoch == ScEpochNumber(1) {
146-
timestamp_millis
146+
// We first convert the timestamp to PC epoch number and then use the starting time of this
147+
// to ensure that all timestamps within a PC epoch produce the same candidates. This is
148+
// necessary in case the boundaries of PC epochs and MC epochs do not align.
149+
let current_pc_epoch = (timestamp_millis / sc_epoch_duration_millis);
150+
current_pc_epoch / sc_epoch_duration_millis
147151
} else {
148152
next_unset_epoch.0 * sc_epoch_duration_millis
149153
}

0 commit comments

Comments
 (0)