nervosnetwork / fiber

19 stars 10 forks source link

Don't expose all internal commands to http rpc endpoint #28

Closed contrun closed 5 months ago

contrun commented 5 months ago

Currently we almost directly expose the network actor commands to http endpoint https://github.com/contrun/ckb-pcn-node/blob/e62bf994c2b0c7abfc368f3662172f97ee12f17e/src/rpc/mod.rs#L123-L156

This will cause several problems.

  1. The naming and request data format convention is confusing to end users. For example, below request having several naming conventions including CamelCase and snake_case. https://github.com/contrun/ckb-pcn-node/blob/e62bf994c2b0c7abfc368f3662172f97ee12f17e/tests/bruno/e2e/open-use-close-a-channel/09-send-commitment_signed-message.bru#L19-L28 To make things worse, the deserialization of request data is not stable. When we slightly change the data types, the json request data may change completely. We need to expose stable API to end users.
  2. Some requests are not really intended for end users. They are used internally. For example, end users should never send SendPcnMessage command to us, as they may not be aware of current state and don't know how to assemble correct message.

We should stabilize some user-facing APIs and clearly separate external API from internal network commands.

contrun commented 5 months ago

38 Takes care of this

contrun commented 5 months ago

Closing since #38 is merged.