massa icon indicating copy to clipboard operation
massa copied to clipboard

Massa Json(g)RPC API V2

Open aoudiamoncef opened this issue 2 years ago • 1 comments

This issue tracks the work in progress on the newer Massa JsonRPC API.

Refactor the API:

1 - Specify the business needs with Core, the Innovation team, direct users (eg. Dusa) and the community Builders. Try to split endpoints as much as possible. Use snake_case everywhere (https://github.com/massalabs/massa/pull/2823). Decide if we fuse the private/public APIs and allow finer access control through other means.

2 - Write a new API that uses https://github.com/paritytech/jsonrpsee crate and:

  • [ ] enable HTTPS and optional client authentication
  • [ ] add HTTP GET proxying #3376
  • [ ] decide if we enable more advanced per-endpoint access control
  • [ ] enable call batching to read/write time-consistent information
  • [ ] allow websocket streaming to enable https://github.com/massalabs/massa/discussions/2895 and stream events for SC applications (@BatiGencho)
  • [ ] enable rate limiting
  • [ ] enable health checking
  • [ ] add pagination. see paginate crate #3428
  • [ ] support for binary format instead of Json(text)

3 - Let's also add the following endpoints:

  • [ ] send_endorsements #3423
  • [ ] send_blocks #3420
  • [ ] get_selector_draws #3421
  • [ ] get_best_parent #3419
  • [ ] get_latest_block
  • [ ] get_latest_operation
  • [ ] get_latest_endorsement
  • [ ] get_blocks_by_slots #3425
  • [ ] get_executed_operations
  • [ ] get_largest_wallets #3427
  • [ ] get_largest_stakers
  • [ ] get_transactions_throughput #3426
  • [ ] get_balances
  • [ ] get_slots
  • [ ] get_rolls
  • [ ] get_health
  • [ ] get_staking_activation
  • [ ] get_staking_infos
  • [ ] get_token_infos
  • [ ] simulate_operation
  • [x] get_version
  • [x] rpc.discover eip-1901

4 - As well as JsonRPC WebSocket streaming for:

  • [x] subscribe_new_blocks/unsubscribe_new_blocks
  • [x] subscribe_new_blocks_headers/unsubscribe_new_blocks_headers
  • [x] subscribe_new_filled_blocks/unsubscribe_new_filled_blocks
  • [x] subscribe_new_operations/unsubscribe_new_operations
  • [ ] subscribe_new_endorsements/unsubscribe_new_endorsements
  • [ ] subscribe_execution_events_changes/unsubscribe_execution_events_changes
  • [ ] subscribe_transactions_throughput/unsubscribe_transactions_throughput #3426
  • [ ] subscribe_state_events_changes/unsubscribe_state_events_changes

5 - There is an active discussion about gRPC support

This will pave the way towards https://github.com/massalabs/massa/issues/2903 in particular, and also help @BatiGencho with execution event streaming for web3

previously #2799 #3076

aoudiamoncef avatar Jan 05 '23 16:01 aoudiamoncef

Hi @massalabs/core-team,

As we are going to accelerate the development of Massa API V2, we are gathering all enhancements proposals in this issue.

Based on clients feedbacks, I made the list of methods/subscriptions/features above, we should select, drop and prioritise what's really add a value to Massa.

I'm waiting for feedbacks, feel free to update and/or comment issue.

Thanks 👍🏻

aoudiamoncef avatar Jan 13 '23 09:01 aoudiamoncef

I see you have ticked off "Support gateway annotations", how are you planning to implement that given it isn't supported in the underlying libraries?

banool avatar Apr 19 '23 14:04 banool

Hi @banool

We added gateway annotations in our gRPC service definition to be used by reverse proxies Eg Envoy and other languages E.g in go

In the future, if Prost/Tonic adds support for a Rust based gateway, we're already ready.

aoudiamoncef avatar Apr 20 '23 09:04 aoudiamoncef