Skip to content

Commit 1bf3f26

Browse files
apollo_storage: add transaction_events table for event storage (#13461)
* apollo_storage: add transaction_events table for event storage Events are now written to a dedicated transaction_events table in addition to the events index table. Event iterators read from the new table instead of deserializing transaction outputs from mmap files. This eliminates redundant file I/O during event iteration and prepares for separating events from TransactionOutput in a follow-up change. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * apollo_storage: store events in mmap file instead of MDBX The transaction_events table now stores LocationInFile pointers into a dedicated events.dat mmap file, rather than serializing Vec<Event> directly into MDBX. This matches the pattern used for transaction outputs and avoids MDBX size overhead for large event payloads. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f533c54 commit 1bf3f26

8 files changed

Lines changed: 345 additions & 136 deletions

File tree

crates/apollo_reverts/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ pub fn revert_block(storage_writer: &mut StorageWriter, target_block_marker: Blo
127127
.revert_header(target_block_marker)
128128
.unwrap()
129129
.0
130+
.revert_events(target_block_marker)
131+
.unwrap()
130132
.revert_body(target_block_marker)
131133
.unwrap()
132134
.0

crates/apollo_storage/src/body/body_test.rs

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,16 @@ async fn revert_body_state_only(storage_scope: StorageScope) {
215215
.unwrap()
216216
.commit()
217217
.unwrap();
218-
writer.begin_rw_txn().unwrap().revert_body(BlockNumber(0)).unwrap().0.commit().unwrap();
218+
writer
219+
.begin_rw_txn()
220+
.unwrap()
221+
.revert_events(BlockNumber(0))
222+
.unwrap()
223+
.revert_body(BlockNumber(0))
224+
.unwrap()
225+
.0
226+
.commit()
227+
.unwrap();
219228
}
220229

221230
#[tokio::test]
@@ -236,7 +245,16 @@ async fn revert_body_updates_marker(storage_scope: StorageScope) {
236245
// Verify that the body marker before revert is 2.
237246
assert_eq!(reader.begin_ro_txn().unwrap().get_body_marker().unwrap(), BlockNumber(2));
238247

239-
writer.begin_rw_txn().unwrap().revert_body(BlockNumber(1)).unwrap().0.commit().unwrap();
248+
writer
249+
.begin_rw_txn()
250+
.unwrap()
251+
.revert_events(BlockNumber(1))
252+
.unwrap()
253+
.revert_body(BlockNumber(1))
254+
.unwrap()
255+
.0
256+
.commit()
257+
.unwrap();
240258
assert_eq!(reader.begin_ro_txn().unwrap().get_body_marker().unwrap(), BlockNumber(1));
241259
}
242260

@@ -266,7 +284,16 @@ async fn get_reverted_body_returns_none() {
266284
.is_some()
267285
);
268286

269-
writer.begin_rw_txn().unwrap().revert_body(BlockNumber(1)).unwrap().0.commit().unwrap();
287+
writer
288+
.begin_rw_txn()
289+
.unwrap()
290+
.revert_events(BlockNumber(1))
291+
.unwrap()
292+
.revert_body(BlockNumber(1))
293+
.unwrap()
294+
.0
295+
.commit()
296+
.unwrap();
270297
assert!(
271298
reader.begin_ro_txn().unwrap().get_block_transactions(BlockNumber(1)).unwrap().is_none()
272299
);
@@ -335,7 +362,16 @@ async fn revert_transactions() {
335362
.is_some()
336363
);
337364

338-
writer.begin_rw_txn().unwrap().revert_body(BlockNumber(0)).unwrap().0.commit().unwrap();
365+
writer
366+
.begin_rw_txn()
367+
.unwrap()
368+
.revert_events(BlockNumber(0))
369+
.unwrap()
370+
.revert_body(BlockNumber(0))
371+
.unwrap()
372+
.0
373+
.commit()
374+
.unwrap();
339375

340376
// Check that all the transactions were deleted.
341377
for (offset, tx_hash) in body.transaction_hashes.into_iter().enumerate() {

0 commit comments

Comments
 (0)