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

consensus: save block metadata #646

Merged
merged 12 commits into from
Sep 16, 2024
Merged

consensus: save block metadata #646

merged 12 commits into from
Sep 16, 2024

Conversation

pro-wh
Copy link
Collaborator

@pro-wh pro-wh commented Feb 22, 2024

image

proposer and signers

@pro-wh pro-wh force-pushed the pro-wh/feature/genesisbatch branch from 92aa008 to 7af6e38 Compare February 23, 2024 01:29
@pro-wh pro-wh force-pushed the pro-wh/feature/blockmeta branch from 7e329ef to c38d8f2 Compare February 23, 2024 01:29
@pro-wh pro-wh force-pushed the pro-wh/feature/genesisbatch branch from 7af6e38 to faf3cbd Compare March 1, 2024 00:07
@pro-wh pro-wh force-pushed the pro-wh/feature/blockmeta branch 2 times, most recently from 09b62ae to 79bdda4 Compare March 4, 2024 21:15
@pro-wh pro-wh force-pushed the pro-wh/feature/genesisbatch branch 2 times, most recently from f67bc7b to 943a172 Compare March 6, 2024 00:36
@pro-wh pro-wh force-pushed the pro-wh/feature/blockmeta branch 2 times, most recently from ffeb35d to 04b1c2c Compare March 6, 2024 22:30
@pro-wh pro-wh marked this pull request as ready for review March 6, 2024 23:08
@pro-wh pro-wh changed the title (unfinished) consensus: save block metadata consensus: save block metadata Mar 6, 2024
Copy link
Contributor

@mitjat mitjat left a comment

Choose a reason for hiding this comment

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

Thank you thank you for figuring these out!
Generally LGTM. Most of my comments are about explaining the semantics to our API consumers (and to future nexus code maintainers).

storage/migrations/00_consensus.up.sql Outdated Show resolved Hide resolved
analyzer/consensus/consensus.go Outdated Show resolved Hide resolved
analyzer/consensus/consensus.go Show resolved Hide resolved
api/spec/v1.yaml Outdated Show resolved Hide resolved
api/spec/v1.yaml Outdated Show resolved Hide resolved
storage/client/client.go Show resolved Hide resolved
api/spec/v1.yaml Outdated Show resolved Hide resolved
storage/client/queries/queries.go Outdated Show resolved Hide resolved
@@ -66,6 +65,7 @@ require (
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.5.0 // indirect
github.com/go-git/go-git/v5 v5.11.0 // indirect
github.com/go-kit/kit v0.12.0 // indirect
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you understand how this was added? We're not using it directly, and the only other depedendency change is that cometbft went from being an implicit dep to an explicit one. Maybe Go only adds indirect deps when they are actually used, rather than all transitive deps?

api/spec/v1.yaml Show resolved Hide resolved
@pro-wh pro-wh force-pushed the pro-wh/feature/blockmeta branch from 04b1c2c to 627e4d0 Compare March 12, 2024 23:34
@pro-wh pro-wh force-pushed the pro-wh/feature/genesisbatch branch 2 times, most recently from 8457396 to 1e6aa7e Compare March 18, 2024 23:16
@pro-wh pro-wh force-pushed the pro-wh/feature/blockmeta branch 2 times, most recently from 003826c to 07fc1af Compare March 18, 2024 23:18
@pro-wh pro-wh force-pushed the pro-wh/feature/genesisbatch branch from b44e84b to 2487e50 Compare March 21, 2024 22:53
@pro-wh pro-wh force-pushed the pro-wh/feature/blockmeta branch 3 times, most recently from 640bdb7 to 89331f8 Compare March 26, 2024 23:00
@pro-wh pro-wh force-pushed the pro-wh/feature/genesisbatch branch 2 times, most recently from 944e7a8 to 24cbe24 Compare March 27, 2024 23:41
@pro-wh pro-wh force-pushed the pro-wh/feature/blockmeta branch from 89331f8 to d1f3ce3 Compare March 27, 2024 23:41
@pro-wh pro-wh force-pushed the pro-wh/feature/genesisbatch branch from 24cbe24 to 8a8fbb1 Compare March 29, 2024 22:53
@pro-wh pro-wh force-pushed the pro-wh/feature/blockmeta branch from d1f3ce3 to 5e9bbf1 Compare March 29, 2024 22:53
@jberci jberci force-pushed the pro-wh/feature/blockmeta branch 2 times, most recently from dee5dc1 to e0ea8d8 Compare August 30, 2024 21:18
Copy link
Collaborator

@Andrew7234 Andrew7234 left a comment

Choose a reason for hiding this comment

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

Looks good! There's a few remaining comments from ptrus/mitja which need to be addressed, but hopefully those are minor changes. Thanks

analyzer/queries/queries.go Outdated Show resolved Hide resolved
@jberci jberci force-pushed the pro-wh/feature/blockmeta branch from 0f3b539 to aa9edaf Compare September 4, 2024 14:44
@jberci jberci force-pushed the pro-wh/feature/blockmeta branch from aa9edaf to 0ba038a Compare September 12, 2024 16:47
@jberci jberci merged commit 68bb393 into main Sep 16, 2024
16 checks passed
@jberci jberci deleted the pro-wh/feature/blockmeta branch September 16, 2024 16:42

ALTER TABLE chain.blocks
ADD COLUMN proposer_entity_id base64_ed25519_pubkey,
ADD COLUMN signer_entity_ids base64_ed25519_pubkey[];
Copy link
Member

@ptrus ptrus Oct 1, 2024

Choose a reason for hiding this comment

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

What was the reasoning for storing Entity IDs instead of Node IDs here?

A validator entity can have multiple validator nodes registered. In that case, we lose information about which exact node signed the block.

In practice, only a single node per entity will be active at any given epoch (since the network limits to one at this point), so this shouldn't be that problematic. However, I feel we could easily have used node IDs here to avoid this.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, it probably makes sense/is fine, since we mostly don't care about individual validator nodes in other places/in the API.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah, it's for reasons of API simplicity like that. the general style of nexus is to have analysis precompute stuff that the API side will need, even sometimes at the cost of lossiness

Copy link
Collaborator

Choose a reason for hiding this comment

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

we mostly don't care about individual validator nodes in other places/in the API.

Yeah it was a combination of this, also because we don't track historical validator entity<>node mappings (though it is possible to add now in the history.validators table).

block_hash HEX64 NOT NULL,
time TIMESTAMP WITH TIME ZONE NOT NULL,
num_txs UINT31 NOT NULL,
block_hash HEX64 NOT NULL, -- NULL in 32_block_meta.up.sql
Copy link
Member

Choose a reason for hiding this comment

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

These comments are wrong 32_block_meta.up.sql does not make these fields NULL-able.

prevSigners = append(prevSigners, entity.String())
}
batch.Queue(
queries.ConsensusBlockAddSigners,
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't work correctly in the fast-sync case. When in fast-sync, blocks are not processed in order, so the previous block (cmtMeta.LastCommit.Height) might not exist, and therefore this query won't insert any singers.

Some quick suggestion on how to fix this:

  • doing an Upsert, and making all other fields NULL-able (I think a previous version of this PR was done in that way)
  • storing the signers in a separate table

I noticed this in E2E tests of #764 since some blocks are missing signers in the edenfast test case.

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.

5 participants