@@ -1045,20 +1045,25 @@ fn testExecuteBlock(allocator: Allocator, config: struct {
10451045 try dep_stubs .accounts_db_state .db .put (snapshot_slot , address , account );
10461046 }
10471047
1048+ // NOTE: The manifests used to run this unit have empty `stakes` and a single epoch stakes for
1049+ // the current epoch. As a result, when we call `updateEpochStakes` in `trackNewSlots` we will
1050+ // attempt to create a new `EpochInfo` for the next epoch. This involves a leader schedule
1051+ // calculation which will fail if `stakes` is empty.
1052+ //
1053+ // To get around this for the existing manifests, we copy the current epoch stakes into an entry
1054+ // for the next epoch in `bank_extra.versioned_epoch_stakes`. This is loaded into `EpochInfo`
1055+ // in the MagicTracker when initialised from the snapshot, thus preventing `updateEpochStakes`
1056+ // from attempting to compute an `EpochInfo` entry with empty `stakes`.
10481057 var epoch_stakes = manifest .bank_extra .versioned_epoch_stakes .get (
10491058 manifest .bank_fields .epoch ,
10501059 ).? .current ;
1051-
10521060 epoch_stakes .stakes .epoch += 1 ;
10531061 try manifest .bank_extra .versioned_epoch_stakes .put (
10541062 fba .allocator (),
10551063 manifest .bank_fields .epoch + 1 ,
10561064 .{ .current = try epoch_stakes .clone (fba .allocator ()) },
10571065 );
10581066
1059- manifest .bank_fields .stakes .deinit (fba .allocator ());
1060- manifest .bank_fields .stakes = try epoch_stakes .stakes .convert (fba .allocator (), .delegation );
1061-
10621067 // init replay
10631068 var replay_state = try dep_stubs .mockedState (
10641069 allocator ,
0 commit comments