@@ -197,6 +197,9 @@ pub fn run(seed: u64, args: *std.process.ArgIterator) !void {
197
197
var largest_rooted_slot : Slot = 0 ;
198
198
var slot : Slot = 0 ;
199
199
200
+ var ancestors : sig.core.Ancestors = .EMPTY ;
201
+ defer ancestors .deinit (allocator );
202
+
200
203
// get/put a bunch of accounts
201
204
while (true ) {
202
205
if (maybe_max_slots ) | max_slots | if (slot >= max_slots ) {
@@ -207,6 +210,7 @@ pub fn run(seed: u64, args: *std.process.ArgIterator) !void {
207
210
0 = > slot += random .intRangeAtMost (Slot , 1 , 2 ),
208
211
1 , 2 , 3 = > {},
209
212
};
213
+ try ancestors .addSlot (allocator , slot );
210
214
211
215
const action = random .enumValue (enum { put , get });
212
216
switch (action ) {
@@ -261,16 +265,34 @@ pub fn run(seed: u64, args: *std.process.ArgIterator) !void {
261
265
262
266
break :blk .{ key , tracked_accounts .get (key ).? };
263
267
};
264
- const account , const ref =
265
- try accounts_db .getAccountAndReference (& tracked_account .pubkey );
268
+
269
+ var ancestors_sub = try ancestors .clone (allocator );
270
+ defer ancestors_sub .deinit (allocator );
271
+ for (ancestors_sub .ancestors .keys ()) | other_slot | {
272
+ if (other_slot <= tracked_account .slot ) continue ;
273
+ _ = ancestors_sub .ancestors .swapRemove (other_slot );
274
+ }
275
+ ancestors_sub .ancestors .sort (struct {
276
+ ancestors_sub : []Slot ,
277
+ pub fn lessThan (ctx : @This (), a : usize , b : usize ) bool {
278
+ return ctx .ancestors_sub [a ] < ctx .ancestors_sub [b ];
279
+ }
280
+ }{ .ancestors_sub = ancestors_sub .ancestors .keys () });
281
+
282
+ const account =
283
+ try accounts_db .getAccountWithAncestors (& pubkey , & ancestors_sub ) orelse {
284
+ logger .err ().logf ("accounts_db missing tracked account '{}': {}" , .{ pubkey , tracked_account });
285
+ return error .MissingAccount ;
286
+ };
266
287
defer account .deinit (allocator );
267
288
268
289
if (! account .data .eqlSlice (& tracked_account .data )) {
269
- std . debug . panic (
290
+ logger . err (). logf (
270
291
"found account {} with different data: " ++
271
- "tracked: {any} vs found: {any} ({}) \n " ,
272
- .{ pubkey , tracked_account .data , account .data , ref },
292
+ "tracked: {any} vs found: {any}\n " ,
293
+ .{ pubkey , tracked_account .data , account .data },
273
294
);
295
+ return error .TrackedAccountMismatch ;
274
296
}
275
297
},
276
298
}
0 commit comments