-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
feat(core/header): Consider using a Generic interface instead of a non generic one to define header service and header. #17135
Comments
i like this approach and think it makes sense, @aaronc do you have thoughts? i can pick it up |
I don't think these generic types would work correctly with depinject dependency resolution and actually adds confusion to the type signatures if you want a non-specific version. Celestial should just provide a specialized celestial header service for custom things and that header could of course implement this header interface. |
Take a look at the existing go-header lib developed and used by Celestia and Rollkit teams. The core Header interface enables users to define specific header for their needs, similar to what is described in this issue. Its current focus is to enable syncing, storing, and p2p exchange of user-defined blockchain headers. In other words, it implements generic light client functionality over p2p. According to the interfaces documented on the issue, the only piece A few usages examples:
Docs on the lib are far from being even acceptable, but the code itself is well-documented(check Syncer for example). Worth mentioning that it works together with go-fraud lib enabling similar generic functionality for user-defined fraud/fault proofs(we have design doc to abstract it to support validity and zk proofs). The end goal is evolve to a lib that generically solves all the p2p problems for chains and rollups. @aaronc, generic types works well with reflect which is what depinject is based on. Here is an example with FX, which another reflect based DI(btw, I don't get why SDK went with custom solution): https://github.com/celestiaorg/celestia-node/blob/main/nodebuilder/header/module.go#L33-L43 |
We did experiments with dig and fx and some other tools. There were quite a lot of things that we wanted to do differently from dig, although it looked like the best inspiration. |
closing this as we decided to go a different path |
Any links to the new path? |
https://github.com/cosmos/cosmos-sdk/blob/main/docs/rfc/rfc-006-handlers.md#consensus-messages is the approach for now. but we still may explore generic headers in the future |
Currently if a module wants to specialise to support a specific runtime it will be required to accept an additional service to properly serve that runtime. This makes the code fail at runtime and also can become hard to maintain in the longterm.
Instead we could define the
header.Service
andHeader
as generic interfaces. A module can then decide if to specialise for a specific runtime, and be able to use the concrete type which implements the header.A module which wants to be agnostic to the runtime can instead still use the generic interface.
Full example:
The text was updated successfully, but these errors were encountered: