forest icon indicating copy to clipboard operation
forest copied to clipboard

Refactor the RPC API

Open aatifsyed opened this issue 2 years ago • 1 comments

The current state

  • Types are defined here, using a naming scheme: https://github.com/ChainSafe/forest/blob/d6c96279addda1aea800654d9c12b9f8b2ce08ee/src/rpc_api/mod.rs#L192-L206
  • Logic is defined in a separate file: https://github.com/ChainSafe/forest/blob/b3057ba599d285b5306c9c636ef08facb1f2ea42/src/rpc/chain_api.rs#L25-L39

I'd think we need a tower-compatible API:

pub trait RPCMethod<Ctx> {
    type Params: HasLotusJson;
    type Return: HasLotusJson;
    (async?) fn call(&mut self, ctx: Ctx, params: Self::Params) -> Result<Self::Return, RPCError>;
}

We can then layer things like rate limiting, permissions, etc

aatifsyed avatar Jun 20 '23 22:06 aatifsyed

Partially implemented in #3625

aatifsyed avatar Oct 30 '23 15:10 aatifsyed

#4038 #4067

aatifsyed avatar Mar 15 '24 16:03 aatifsyed