Skip to content

Commit 72ed824

Browse files
fix rebase: restore correct database/main.zig (remove residual FallbackFns)
1 parent 8736992 commit 72ed824

File tree

1 file changed

+0
-78
lines changed

1 file changed

+0
-78
lines changed

src/database/main.zig

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -226,12 +226,6 @@ pub const InMemoryDB = struct {
226226
/// Count of non-zero storage entries per address.
227227
/// Maintained by putStorage for O(1) hasNonZeroStorageForAddress lookups.
228228
nonzero_storage_count: std.AutoHashMap(primitives.Address, u32),
229-
/// Optional fallback: called on cache miss for account/storage/code/blockHash.
230-
fallback: ?FallbackFns = null,
231-
/// Addresses that were explicitly OOG-untracked via untrackAddress().
232-
/// Used by BaTracker.computeHash() to exclude CALL gas-calc phantoms from the BAL.
233-
/// Populated by untrackAddress(); never cleared between transactions (block-scoped).
234-
oog_addresses: std.AutoHashMap(primitives.Address, void),
235229

236230
const Self = @This();
237231

@@ -242,7 +236,6 @@ pub const InMemoryDB = struct {
242236
.storage_map = std.HashMap(struct { primitives.Address, primitives.StorageKey }, primitives.StorageValue, StorageKeyContext, std.hash_map.default_max_load_percentage).init(allocator),
243237
.block_hashes = std.AutoHashMap(u64, primitives.Hash).init(allocator),
244238
.nonzero_storage_count = std.AutoHashMap(primitives.Address, u32).init(allocator),
245-
.oog_addresses = std.AutoHashMap(primitives.Address, void).init(allocator),
246239
};
247240
}
248241

@@ -252,7 +245,6 @@ pub const InMemoryDB = struct {
252245
self.storage_map.deinit();
253246
self.block_hashes.deinit();
254247
self.nonzero_storage_count.deinit();
255-
self.oog_addresses.deinit();
256248
}
257249

258250
/// Insert or update a storage slot, maintaining the nonzero_storage_count index.
@@ -291,82 +283,12 @@ pub const InMemoryDB = struct {
291283
return self.block_hashes.get(number) orelse [_]u8{0} ** 32;
292284
}
293285

294-
/// Notify the fallback that a transaction committed successfully.
295-
/// No-op if no fallback or fallback has no commit_tx callback.
296-
pub fn commitTracking(self: *Self) void {
297-
if (self.fallback) |fb| if (fb.commit_tx) |f| f(fb.ctx);
298-
}
299-
300-
/// Notify the fallback that a transaction was discarded (reverted / invalid).
301-
/// No-op if no fallback or fallback has no discard_tx callback.
302-
pub fn discardTracking(self: *Self) void {
303-
if (self.fallback) |fb| if (fb.discard_tx) |f| f(fb.ctx);
304-
}
305-
306-
/// Notify the fallback that a new execution frame opened a journal checkpoint.
307-
pub fn snapshotFrame(self: *Self) void {
308-
if (self.fallback) |fb| if (fb.snapshot_frame) |f| f(fb.ctx);
309-
}
310-
311-
/// Notify the fallback that the current execution frame committed successfully.
312-
pub fn commitFrame(self: *Self) void {
313-
if (self.fallback) |fb| if (fb.commit_frame) |f| f(fb.ctx);
314-
}
315-
316-
/// Notify the fallback that the current execution frame was reverted.
317-
pub fn revertFrame(self: *Self) void {
318-
if (self.fallback) |fb| if (fb.revert_frame) |f| f(fb.ctx);
319-
}
320-
321-
/// Un-record a pending address access.
322-
/// Called when a CALL loaded an address for gas calculation but then went OOG.
323-
/// Marks the address as an OOG phantom so BaTracker can exclude it from the BAL.
324-
pub fn untrackAddress(self: *Self, address: primitives.Address) void {
325-
self.oog_addresses.put(address, {}) catch {};
326-
if (self.fallback) |fb| if (fb.untrack_address) |f| f(fb.ctx, address);
327-
}
328-
329-
/// Returns true if the address was OOG-untracked (loaded only for CALL gas calculation).
330-
/// Used by BaTracker.computeHash() to exclude phantom accounts from the BAL.
331-
pub fn isOogAddress(self: *const Self, address: primitives.Address) bool {
332-
return self.oog_addresses.contains(address);
333-
}
334-
335-
/// Force-add an address to the current-tx access log regardless of witness state.
336-
/// Called for EIP-7702 delegation targets that execute but are not in the witness.
337-
pub fn forceTrackAddress(self: *Self, address: primitives.Address) void {
338-
if (self.fallback) |fb| if (fb.force_track_address) |f| f(fb.ctx, address);
339-
}
340-
341-
/// Notify the fallback about a storage slot being committed with a changed value,
342-
/// called BEFORE commitTx() resets original_value. Only called when present_value
343-
/// differs from original_value (i.e., the slot was actually modified this tx).
344-
pub fn notifyStorageSlotCommit(self: *Self, address: primitives.Address, slot: primitives.StorageKey, committed_value: primitives.StorageValue) void {
345-
if (self.fallback) |fb| if (fb.pre_commit_tx_slot) |f| f(fb.ctx, address, slot, committed_value);
346-
}
347-
348-
/// Notify the fallback that a storage slot was read from a newly-created account.
349-
/// The EVM returns 0 for all such reads without consulting the database; this hook
350-
/// lets the fallback record the access for EIP-7928 BAL tracking.
351-
pub fn notifyStorageRead(self: *Self, address: primitives.Address, slot: primitives.StorageKey) void {
352-
if (self.fallback) |fb| if (fb.notify_storage_read) |f| f(fb.ctx, address, slot);
353-
}
354-
355-
356286
/// Returns true if the address has any non-zero storage entry (O(1)).
357287
pub fn hasNonZeroStorageForAddress(self: *const Self, address: primitives.Address) bool {
358288
const count = self.nonzero_storage_count.get(address) orelse return false;
359289
return count > 0;
360290
}
361291

362-
/// Returns true if the address was committed to the permanent access log in the fallback.
363-
/// Used by BaTracker to distinguish legitimately-accessed nonexistent accounts
364-
/// from those only loaded for OOG gas calculation.
365-
pub fn isTrackedAddress(self: *Self, address: primitives.Address) bool {
366-
if (self.fallback) |fb| if (fb.is_tracked_address) |f| return f(fb.ctx, address);
367-
return false;
368-
}
369-
370292
pub fn basicRef(self: Self, address: primitives.Address) !?state.AccountInfo {
371293
return self.accounts.get(address);
372294
}

0 commit comments

Comments
 (0)