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

Add timestamp to meta block #3738

Merged
merged 2 commits into from
Aug 24, 2022
Merged

Add timestamp to meta block #3738

merged 2 commits into from
Aug 24, 2022

Conversation

mangas
Copy link
Contributor

@mangas mangas commented Jul 14, 2022

Fixes: #3060

This change should add a timestamp for EVM chains, should work well for both RPC and firehose ingestors.
The fact the query depends heavily on the format of the block means it will not work for any block format that doesn't add the expected timestamp field inside a top level block field.

To solve this further we could ensure that all block formats have the necessary timestamp or alternative we could extract/duplicate that field outside the block and run some migrations. The downside of the migration approach is that it needs to be communicated more widely. This migration would also be potentially long due to the size of the block cache tables.

@mangas mangas force-pushed the filipe/block-timestamp branch 7 times, most recently from c90a78d to 3c0f2fb Compare July 18, 2022 12:13
@mangas mangas marked this pull request as ready for review July 18, 2022 12:14
store/postgres/src/chain_store.rs Outdated Show resolved Hide resolved
@tilacog tilacog self-requested a review July 18, 2022 12:37
@mangas mangas requested a review from lutter July 18, 2022 13:24
@mangas mangas force-pushed the filipe/block-timestamp branch from 3c0f2fb to 167861a Compare July 18, 2022 13:55
@mangas mangas force-pushed the filipe/block-timestamp branch from 167861a to 96a3955 Compare July 18, 2022 14:21
@leoyvens
Copy link
Collaborator

Has this been tested on a firehose block stream?

@mangas
Copy link
Contributor Author

mangas commented Jul 18, 2022

@leoyvens on a firehose stream is the thing I was testing locally but the blocks look the same on the database. The firehose ingestor I didn't test because as far as I can tell it is not wired (for eth) but the types are the same so should be fine as well

@mangas mangas force-pushed the filipe/block-timestamp branch from 8297527 to 48c0a31 Compare July 20, 2022 11:50
@mangas mangas marked this pull request as draft July 20, 2022 11:51
@mangas mangas force-pushed the filipe/block-timestamp branch from 48c0a31 to b8b71c7 Compare July 20, 2022 14:59
@mangas mangas force-pushed the filipe/block-timestamp branch from b8b71c7 to 088f567 Compare August 3, 2022 17:54
@mangas mangas marked this pull request as ready for review August 3, 2022 17:55
@mangas mangas requested review from leoyvens and lutter August 3, 2022 17:55
@mangas mangas force-pushed the filipe/block-timestamp branch 2 times, most recently from e3c50b0 to b4c40b7 Compare August 17, 2022 15:49
fn block_number(
&self,
hash: &BlockHash,
) -> Result<Option<(String, BlockNumber, Option<String>)>, StoreError>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tuple is getting too complex, seems worth introducing a struct. Also there might be a better name than block_number since this also returns other info.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this refactoring should go on the same PR though. I'm happy to make the changes and raise a new PR for it

fn block_number_with_timestamp(
&self,
block_hash: &BlockHash,
) -> Result<Option<(BlockNumber, Option<String>)>, StoreError>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have a struct BlockPtrTs (not a fan of the name but ok), we could also return it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's an package internal name, I went with I thought was an accurate description 😛 happy to rename if you have suggestions

fn block_number(
&self,
hash: &BlockHash,
) -> Result<Option<(String, BlockNumber, Option<String>)>, StoreError> {
let conn = self.get_conn()?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would ideally be asyncified to use with_conn.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one is also used in a few places so I'd rather take that as a separate PR

@mangas mangas force-pushed the filipe/block-timestamp branch from b4c40b7 to 07fb4fc Compare August 24, 2022 09:32
@mangas mangas merged commit 9211241 into master Aug 24, 2022
@mangas mangas deleted the filipe/block-timestamp branch August 24, 2022 11:54
kaiwetlesen pushed a commit to kaiwetlesen/graph-node that referenced this pull request Sep 7, 2022
* Add timestamp to meta block

* expose timestamp on meta block
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add timestamp to _meta.block
4 participants