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

enhancement: store blocks while crawling transactions and chain #190

Merged
merged 4 commits into from
Dec 17, 2024

Conversation

joel-u410
Copy link
Contributor

No description provided.

@joel-u410
Copy link
Contributor Author

Working on fixing tests here -- it's failing because in this branch there is now a foreign key constraint between balance_changes --> blocks and the tests need to insert blocks before inserting balances.

@mateuszjasiuk
Copy link
Collaborator

@joel-u410 hello, can you point this to 1.0.0-maint ?

@joel-u410
Copy link
Contributor Author

@joel-u410 hello, can you point this to 1.0.0-maint ?

Yep, will do!

@joel-u410 joel-u410 changed the base branch from main to 1.0.0-maint December 13, 2024 15:48
@joel-u410 joel-u410 force-pushed the joel/record-block-details branch from 203c0b9 to d6a58c9 Compare December 13, 2024 15:48
@joel-u410
Copy link
Contributor Author

So, in #203 I have added code that resolves tm_addr -> namada_addr for block proposers.

I'm wondering now if we should do the same here, and store the namada_address for block proposers into the blocks table instead of the tendermint address as it's currently doing?

@mateuszjasiuk @Fraccaman what do you think?

@Fraccaman
Copy link
Member

Uhmmm so, in future we will need to have a fk to the validator table, so we can join block and validator. Maybe this is something we can do now too? Or do you think it would be too much?

@joel-u410
Copy link
Contributor Author

joel-u410 commented Dec 13, 2024

Uhmmm so, in future we will need to have a fk to the validator table, so we can join block and validator. Maybe this is something we can do now too? Or do you think it would be too much?

That makes sense, especially if blocks.proposer_address were storing the namada_address of the validator. (which it isn't, yet)

Although, I would be concerned about failing to insert a block if its validator hadn't previously been indexed. I suppose we could insert a stubbed record in that case, to keep the fk happy.

I'd like to rebase this one & revisit the fk idea after #203 is merged, since then we will easily have the namada_address available for the proposer in each block and I can switch this to storing that instead of the tm_addr.

@mateuszjasiuk
Copy link
Collaborator

mateuszjasiuk commented Dec 16, 2024

Cool! I'd prefer to merge this sooner than later as this is needed for shieled sync improvements in namadillo, so maybe let's do fk thing later.

Edit:
I tried to test it, but I had some compilation errors. I think it's because you forgot to regenerate diesel schema(the fields in block should be nullable except for height). There was also a problem with initial query for empty db, I think we have to seed db with empty blocks first. With those changes it seems to work fine, but please check if it makes sense :D

@joel-u410
Copy link
Contributor Author

@mateuszjasiuk I'll take a look today

@joel-u410
Copy link
Contributor Author

joel-u410 commented Dec 16, 2024

Edit: I tried to test it, but I had some compilation errors. I think it's because you forgot to regenerate diesel schema(the fields in block should be nullable except for height).

Really weird, I didn't have any issues compiling. But makes sense though -- I did change the schema to make those columns nullable, so the diesel schema should indeed be regenerated.

Edit: I see now -- I didn't need to update the diesel schema with Nullable because in my branch I was never actually inserting a block with any null values, however there could certainly be a problem with querying blocks that contain nulls, which I never did on my branch.

There was also a problem with initial query for empty db, I think we have to seed db with empty blocks first.

Hmm .. actually it's probably better in that case to query the actual initial block instead of seeding with an empty block. I'll take a closer look.

@joel-u410 joel-u410 force-pushed the joel/record-block-details branch from d6a58c9 to 593ef20 Compare December 16, 2024 23:23
@joel-u410
Copy link
Contributor Author

ok @mateuszjasiuk please test again, it should be good to merge now, I made the following changes:

  • Rebased to latest 1.0.0-maint
  • Incorporated your updates to the diesel schema
  • During initial_query, fetches & upserts the actual block instead of a blank one
  • Uses the namada_address for block.proposer instead of the tendermint address

@mateuszjasiuk
Copy link
Collaborator

Nice! This works. Thanks for quick response :)

@mateuszjasiuk mateuszjasiuk added this pull request to the merge queue Dec 17, 2024
Merged via the queue into anoma:1.0.0-maint with commit e6ec420 Dec 17, 2024
8 checks passed
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.

3 participants