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

Two questions regarding Besu's P2P network and snap sync #7426

Open
thinkAfCod opened this issue Aug 5, 2024 · 2 comments
Open

Two questions regarding Besu's P2P network and snap sync #7426

thinkAfCod opened this issue Aug 5, 2024 · 2 comments

Comments

@thinkAfCod
Copy link
Contributor

First, does Besu currently support discV5?
When I add the --Xv5-discovery-enabled startup parameter, it prints logs:

Discovery Protocol v5 is not available

It makes me feel a bit confused.

And Second, why does selectNewPivotBlock use safeBlockHash instead of directly using HeadBlockHash like go-ethereum?

block := api.eth.BlockChain().GetBlockByHash(update.HeadBlockHash)
if block == nil {
	// If this block was previously invalidated, keep rejecting it here too
	if res := api.checkInvalidAncestor(update.HeadBlockHash, update.HeadBlockHash); res != nil {
		return engine.ForkChoiceResponse{PayloadStatus: *res, PayloadID: nil}, nil
	}
	// If the head hash is unknown (was not given to us in a newPayload request),
	// we cannot resolve the header, so not much to do. This could be extended in
	// the future to resolve from the `eth` network, but it's an unexpected case
	// that should be fixed, not papered over.
	header := api.remoteBlocks.get(update.HeadBlockHash)
	if header == nil {
		log.Warn("Forkchoice requested unknown head", "hash", update.HeadBlockHash)
		return engine.STATUS_SYNCING, nil
	}
	// If the finalized hash is known, we can direct the downloader to move
	// potentially more data to the freezer from the get go.
	finalized := api.remoteBlocks.get(update.FinalizedBlockHash)

	// Header advertised via a past newPayload request. Start syncing to it.
	context := []interface{}{"number", header.Number, "hash", header.Hash()}
	if update.FinalizedBlockHash != (common.Hash{}) {
		if finalized == nil {
			context = append(context, []interface{}{"finalized", "unknown"}...)
		} else {
			context = append(context, []interface{}{"finalized", finalized.Number}...)
		}
	}
	log.Info("Forkchoice requested sync to new head", context...)
	if err := api.eth.Downloader().BeaconSync(api.eth.SyncMode(), header, finalized); err != nil {
		return engine.STATUS_SYNCING, err
	}
	return engine.STATUS_SYNCING, nil
}

The snap sync downloader only needs the head block hash information to start syncing data.
And,In a besu node, when a node is syncing data using snap sync, and there is no data before the sync, when will it update its own safe block?
Or are there other details that I have overlooked?

@jframe
Copy link
Contributor

jframe commented Aug 19, 2024

@thinkAfCod discV5 is not currently available in Besu. There has been some discussion on adding discv5 in the Besu contributors channel in discord.

@jframe
Copy link
Contributor

jframe commented Aug 19, 2024

@thinkAfCod Good question on using a head hash instead of the safe block hash. This is something we discussing internally, will let you know our thoughts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants