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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a flag --delay-sync that delays syncing by a specific number of blocks #13870

Open
MarcusWentz opened this issue Apr 11, 2024 · 2 comments
Open

Comments

@MarcusWentz
Copy link

MarcusWentz commented Apr 11, 2024

馃殌 Feature Request

Description

Have a way to delay syncing by a specific amount of blocks.

1. Designing the Delayed Sync Mechanism:

The first step would be to design a delayed sync mechanism that allows the node to only sync up to a certain block, which is "n" blocks behind the current head of the chain. This design must consider the implications of not participating in the propagation of the most recent blocks, including potential impacts on network health and security.

2. Modifications to the Beacon Node:

  • Custom Sync Strategy: Implement a custom sync strategy in the Beacon node that supports syncing to a block that is "n" blocks behind the head. This strategy would need to periodically update which block is considered the "delayed head" as new blocks are finalized.
  • API for Block Retrieval: Enhance the Beacon node's API to allow retrieval of blocks up to the "delayed head" only, ensuring that clients connected to the Beacon node cannot access or propagate blocks beyond this point.

3. Execution Layer Adjustments:

  • Compliance with Delayed Sync: Ensure that the execution layer client (e.g., Geth) can operate in a mode that respects the delayed sync strategy, only processing and executing transactions up to the "delayed head."
  • Disabling the Transaction Pool: Implement an option to disable the transaction pool to prevent the node from propagating transactions, addressing part of the compliance requirement.

4. Peer Management and Gossip Protocol:

  • Modified Gossip Behavior: Adjust the P2P gossip protocol to prevent the node from receiving or propagating blocks newer than the "delayed head." This may involve modifications to the libp2p gossipsub protocol used by Ethereum nodes.
  • Peer Connectivity: Implement logic to manage peer connections effectively, ensuring that the node does not become a poor network participant due to its inability to propagate the latest blocks.

Describe the solution you'd like

Have a flag called --delay-sync that takes an input integer argument to specify the number of blocks to delay syncing.

Describe alternatives you've considered

We are open to using any consensus layer client interested in supporting this feature.

@MarcusWentz
Copy link
Author

Based on the Prysm documentation:

https://docs.prylabs.network/docs/how-prysm-works/beacon-node#sync-service

It appears this feature would need to take place potentially in Sync Services with function Start():

https://github.com/prysmaticlabs/prysm/blob/develop/beacon-chain/sync/service.go#L217-L242

// Start the regular sync service.
func (s *Service) Start() {
	v, err := s.verifierWaiter.WaitForInitializer(s.ctx)
	if err != nil {
		log.WithError(err).Error("Could not get verification initializer")
		return
	}
	s.newBlobVerifier = newBlobVerifierFromInitializer(v)

	go s.verifierRoutine()
	go s.registerHandlers()

	s.cfg.p2p.AddConnectionHandler(s.reValidatePeer, s.sendGoodbye)
	s.cfg.p2p.AddDisconnectionHandler(func(_ context.Context, _ peer.ID) error {
		// no-op
		return nil
	})
	s.cfg.p2p.AddPingMethod(s.sendPingRequest)
	s.processPendingBlocksQueue()
	s.processPendingAttsQueue()
	s.maintainPeerStatuses()
	s.resyncIfBehind()

	// Update sync metrics.
	async.RunEvery(s.ctx, syncMetricsInterval, s.updateMetrics)
}

@MarcusWentz
Copy link
Author

MarcusWentz commented May 24, 2024

Would we just modify

https://github.com/prysmaticlabs/prysm/blob/develop/beacon-chain/sync/service.go#L62C1-L62C45

const syncMetricsInterval = 10 * time.Second

to be multiplied by the number of blocks we want to delay the sync by?

Example where we want to delay the sync by 6 blocks away from the latest block:

const syncMetricsInterval = 10 * time.Second * 6

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

No branches or pull requests

1 participant