Skip to content

Commit

Permalink
fix: parentHash in websocket blocks subscription is shown as 0x0 (#1946)
Browse files Browse the repository at this point in the history
## What ❔

<!-- What are the changes this PR brings about? -->
<!-- Example: This PR adds a PR template to the repo. -->
<!-- (For bigger PRs adding more context is appreciated) -->

## Why ❔

<!-- Why are these changes done? What goal do they contribute to? What
are the principles behind them? -->
<!-- Example: PR templates ensure PR reviewers, observers, and future
iterators are in context about the evolution of repos. -->

## Checklist

<!-- Check your PR fulfills the following items. -->
<!-- For draft PRs check the boxes as you complete them. -->

- [ ] PR title corresponds to the body of PR (we generate changelog
entries from PRs).
- [ ] Tests for the changes have been added / updated.
- [ ] Documentation comments have been added / updated.
- [ ] Code has been formatted via `zk fmt` and `zk lint`.
- [ ] Spellcheck has been run via `zk spellcheck`.
  • Loading branch information
AnastasiiaVashchuk authored May 16, 2024
1 parent bab4d65 commit fc2efad
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 40 deletions.

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

This file was deleted.

17 changes: 11 additions & 6 deletions core/lib/dal/src/blocks_web3_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,17 @@ impl BlocksWeb3Dal<'_, '_> {
let rows = sqlx::query!(
r#"
SELECT
hash,
number,
timestamp
miniblocks.hash,
miniblocks.number,
prev_miniblock.hash AS "parent_hash?",
miniblocks.timestamp
FROM
miniblocks
LEFT JOIN miniblocks prev_miniblock ON prev_miniblock.number = miniblocks.number - 1
WHERE
number > $1
miniblocks.number > $1
ORDER BY
number ASC
miniblocks.number ASC
"#,
i64::from(from_block.0),
)
Expand All @@ -187,7 +189,10 @@ impl BlocksWeb3Dal<'_, '_> {

let blocks = rows.into_iter().map(|row| BlockHeader {
hash: Some(H256::from_slice(&row.hash)),
parent_hash: H256::zero(),
parent_hash: row
.parent_hash
.as_deref()
.map_or_else(H256::zero, H256::from_slice),
uncles_hash: EMPTY_UNCLES_HASH,
author: H160::zero(),
state_root: H256::zero(),
Expand Down

0 comments on commit fc2efad

Please sign in to comment.