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

p2p/sentry: StatusDataProvider ReadCurrentHeader error #9890

Merged
merged 1 commit into from
Apr 11, 2024

Conversation

battlmonstr
Copy link
Collaborator

@battlmonstr battlmonstr commented Apr 9, 2024

P2P fails on restart because rawdb.ReadCurrentHeader returns a nil header. It looks like ReadHeadHeaderHash fails to find the current header hash. However the correct hash is returned by ReadHeadBlockHash.

IMG_0901

@@ -284,6 +288,16 @@ func ReadCurrentHeader(db kv.Getter) *types.Header {
return ReadHeader(db, headHash, *headNumber)
}

// ReadCurrentHeader2 reads the current canonical head header.
func ReadCurrentHeader2(db kv.Getter) *types.Header {
Copy link
Contributor

Choose a reason for hiding this comment

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

rename to ReadCurrentBlockHeader?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'd like to understand the difference between the 2 tables before renaming. I've asked on discord.

@@ -76,6 +76,9 @@ func (s *StatusDataProvider) GetStatusData(ctx context.Context) (*proto_sentry.S

func ReadChainHeadWithTx(tx kv.Tx) (ChainHead, error) {
header := rawdb.ReadCurrentHeader(tx)
if header == nil {
header = rawdb.ReadCurrentHeader2(tx)
Copy link
Contributor

@taratorio taratorio Apr 9, 2024

Choose a reason for hiding this comment

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

can we just call this directly instead of calling ReadCurrentHeader first? what matters to us is the which is the last block that has been sync-ed and get its header

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

👍

Copy link
Collaborator

Choose a reason for hiding this comment

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

The only reason I originally did the patch like this was that I found the first call was failing and like Daniel I don't know what the difference is between the data in the tables.

Once this is merged I'll overwrite my local fix before completing my PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've removed the ReadCurrentHeader call. One problem with it is that during initial sync (which can take a week) we will report to P2P that we are still on genesis, because HeadBlockKey is only updated at stage_finish. I think that conceptually it is correct (that we only report confirmed state blocks), but it is not nice for the P2P (because we are leeching for many days).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ideally we should report the last committed body. I'll make a follow-up with this later.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@mh0lt I will merge it now, because it fixes a production issue. I can help to rebase your PR and fix conflicts.

@@ -76,6 +76,9 @@ func (s *StatusDataProvider) GetStatusData(ctx context.Context) (*proto_sentry.S

func ReadChainHeadWithTx(tx kv.Tx) (ChainHead, error) {
header := rawdb.ReadCurrentHeader(tx)
if header == nil {
header = rawdb.ReadCurrentHeader2(tx)
Copy link
Collaborator

Choose a reason for hiding this comment

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

The only reason I originally did the patch like this was that I found the first call was failing and like Daniel I don't know what the difference is between the data in the tables.

Once this is merged I'll overwrite my local fix before completing my PR.

P2P fails on restart because rawdb.ReadCurrentHeader returns a nil header.
It looks like ReadHeadHeaderHash fails to find the current header hash.
However the correct hash is returned by ReadHeadBlockHash.
@battlmonstr battlmonstr enabled auto-merge (squash) April 11, 2024 07:15
@battlmonstr battlmonstr merged commit 63c7118 into devel Apr 11, 2024
7 checks passed
@battlmonstr battlmonstr deleted the pr/sentry_status_bug branch April 11, 2024 07:35
@ghost ghost mentioned this pull request Jun 3, 2024
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.

None yet

3 participants