Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dal): correct tx_index_in_l1_batch in get_vm_events_for_l1_batch #1463

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions core/lib/dal/src/events_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ impl EventsDal<'_, '_> {
else {
return Ok(None);
};
let mut tx_index_in_l1_batch = -1;
let events = sqlx::query!(
r#"
SELECT
Expand All @@ -349,7 +350,8 @@ impl EventsDal<'_, '_> {
topic2,
topic3,
topic4,
value
value,
event_index_in_tx
FROM
events
WHERE
Expand All @@ -366,8 +368,7 @@ impl EventsDal<'_, '_> {
.fetch_all(self.storage)
.await?
.into_iter()
.enumerate()
.map(|(index_in_l1_batch, row)| {
.map(|row| {
let indexed_topics = vec![row.topic1, row.topic2, row.topic3, row.topic4]
.into_iter()
.filter_map(|topic| {
Expand All @@ -378,8 +379,11 @@ impl EventsDal<'_, '_> {
}
})
.collect();
if row.event_index_in_tx == 0 {
tx_index_in_l1_batch += 1;
}
VmEvent {
location: (l1_batch_number, index_in_l1_batch as u32),
location: (l1_batch_number, tx_index_in_l1_batch as u32),
address: Address::from_slice(&row.address),
indexed_topics,
value: row.value,
Expand Down
Loading