Skip to content

LES package refactor #20490

Closed
Closed
@rjl493456442

Description

@rjl493456442

LES Protocol(light ethereum sub-protocol) contains two parts specs and relative implementations: LES server and LES client.

Usually LES server refers to a full ethereum node that can offer additional data services for free or not. Basically both server and client share the same protocol definition like protocol message, auxiliary structure definitions and etc. However most of the internal logic of these two parts are totally different.

For LES client, most logic defined is:

  • how to retrieve the specified piece of chain data or state data as well as the corresponding proof.
  • how to manage all connected servers and payment strategy

For LES server, most logic defined is:

  • how to serve requests from clients.
  • how to limit requests from clients
  • how to manage all connected clients and charge strategy

But now in the current implementation, we mix all these parts logic into the same package. It means it's very hard to maintain the code correctly in the long term. So this is a proposal for LES package clean up and refactor.

The approximate structure of les codebase looks like:

les
├── checkpointoracle
│   └── oracle.go
├── flowcontrol
│   ├── control.go
│   ├── logger.go
│   ├── manager.go
│   └── manager_test.go
├── lesclient
│   ├── api_backend.go
│   ├── backend.go
│   ├── bloombits.go
│   ├── common.go
│   ├── distributor
│   │   ├── distributor.go
│   │   └── request.go
│   ├── fetcher
│   │   ├── fetcher.go
│   │   └── ulc.go
│   ├── handler.go
│   ├── odr.go
│   ├── odr_requests.go
│   ├── peer.go
│   ├── retriever.go
│   ├── serverpool
│   │   └── serverpool.go
│   ├── sync.go
│   └── txrelay.go
├── lesserver
│   ├── api.go
│   ├── backend.go
│   ├── clientpool
│   │   ├── balance.go
│   │   ├── balance_test.go
│   │   └── clientpool.go
│   ├── costtracker.go
│   ├── enr_entry.go
│   ├── handler.go
│   ├── misc.go
│   ├── peers.go
│   └── servingqueue.go
├── metrics
│   └── metrics.go
├── protocol
│   ├── costable.go
│   └── protocol.go
├── server
│   ├── backend.go
│   ├── common.go
│   ├── costtracker.go
│   ├── handler.go
│   ├── peer.go
│   └── servingqueue.go
└── utilities
    ├── execqueue.go
    ├── execqueue_test.go
    ├── extendablemap.go
    ├── randselect_test.go
    └── randselector.go

Basically I propose to split a few common utilities used by both server and client in the utilities sub-package. All protocol relative message and structures are all moved to protocol sub-package.

All in all, it's the purposal for cleanup current les package for long term maintenance. Need input from internal team members especially @zsfelfoldi .

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions