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

Implement warp sync request handler #4052

Open
3 tasks
EclesioMeloJunior opened this issue Jun 19, 2024 · 0 comments · May be fixed by #4186
Open
3 tasks

Implement warp sync request handler #4052

EclesioMeloJunior opened this issue Jun 19, 2024 · 0 comments · May be fixed by #4186
Assignees
Labels
A-design issue requires design work to think about how it would best be accomplished. C-complex Complex changes across multiple modules. Possibly will require additional research. S-network issues related to the dot/network package. T-feat this issue/pr is a new feature or functionality.

Comments

@EclesioMeloJunior
Copy link
Member

EclesioMeloJunior commented Jun 19, 2024

Description

The warp sync request handler will respond request that arrives from the sync/warp protocol. The handler has as one dependency the WarpSyncProvider which is an interface that generates the proofs.

The MAX_RESPONSE_SIZE is 16 * 1024 * 1024

ref WarpSyncProvider trait

type WarpSyncProvider interface {
    // Generate proof starting at given block hash. The proof is accumulated until maximum proof
    // size is reached.
    generate(startHeader: *types.Header) (encodedProof []byte, err error)
    
    // Get current list of authorities. This is supposed to be genesis authorities when starting sync.
    current_authorities() []types.Authorities
}

The Warp Proof Request is a SCALE codec structure send through the wire.

Here's a impl suggestion based on substrate

type OutgoingResponse struct {
    payload []byte
}

type Request struct {
  peer peer.ID
  payload []byte
  pendingResponse chan OutgoingResponse
}

type WarpSyncRequestHandler struct {
  backend WarpSyncProvider
  // receive is a channel where the requests acquired in the network
  // layer reaches the handler
  receiver chan Request
}

func (w *WarpSyncRequestHandler) handleRequest(payload []byte, pendingResponse chan OutgoingResponse) error {
    // unmarshal the payload
    // use the backend to generate the warp proof
    // send the response through pendingResponse channel
} 

func (w *WarpSyncRequestHandler) Run() {
   for request := w.receiver {
        err := w.handleRequest(request.payload, request.pendingResponse)
        ...
   }
}

Acceptance Criteria

  • Create the p2p protocol using the template /{genesis_hash}/sync/warp
  • Handling messages that arrives from the network
  • Creating tests mocking the WarpSyncProvider (backend)
@EclesioMeloJunior EclesioMeloJunior added S-network issues related to the dot/network package. C-complex Complex changes across multiple modules. Possibly will require additional research. A-design issue requires design work to think about how it would best be accomplished. T-feat this issue/pr is a new feature or functionality. labels Jun 19, 2024
@dimartiro dimartiro linked a pull request Sep 18, 2024 that will close this issue
4 tasks
@dimartiro dimartiro linked a pull request Sep 18, 2024 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-design issue requires design work to think about how it would best be accomplished. C-complex Complex changes across multiple modules. Possibly will require additional research. S-network issues related to the dot/network package. T-feat this issue/pr is a new feature or functionality.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants