aptos-core icon indicating copy to clipboard operation
aptos-core copied to clipboard

[API] Improve metrics, documentation, linting

Open banool opened this issue 3 years ago • 1 comments

Summary

This PR makes various improvements to metrics (per-endpoint logging), docs, spec generation (a new standalone binary), deduplication, and linting (to ensure spec changes are checked in).

I can make the failpoint stuff middleware as well once https://github.com/poem-web/poem/issues/351 goes in.

Test plan

cargo nextest run --package smoke-test --test-threads 8

This change is Reviewable

banool avatar Jul 28 '22 17:07 banool

@rajkaramchedu, for when you look at this next week, a quick guide. With the new API, the spec is generated from the code, vs them being separately written by hand. As such, all the documentation, examples, etc. exist alongside the relevant code (the endpoint handlers, the types, etc).

Some relevant paths include:

  • api/src/poem_backend/, particularly the endpoint files, like events.rs, transactions.rs, etc. In those you'll see large comments above functions like submit_transaction; those are what end up in the spec.
  • api/types/src/, particularly types in derives.rs.

If you want to play around with it, the flow is:

  1. Change code, e.g. the comments above an endpoint handler function
  2. Run the following command from the root of the repo to get a spec out:
cargo run -p aptos-openapi-spec-generator -- -f yaml -o api/doc/v1/spec.yaml

Now that I write this up, I realize this should itself be in the README. As you can see, I haven't filled it in yet for v1 of the API: api/docs/v1/README.md.

banool avatar Jul 30 '22 19:07 banool

@rajkaramchedu I keep running into merge conflicts because things keep changing around this PR, and even more so its child PR here: https://github.com/aptos-labs/aptos-core/pull/2333. I'm going to land this and we can make any docs changes in another PR.

banool avatar Aug 01 '22 15:08 banool

:white_check_mark: Forge test success on 6ebafc774f94fb22e3941bc2a020519ae26774a7

all up : 5066 TPS, 2177 ms latency, 2950 ms p99 latency,no expired txns

github-actions[bot] avatar Aug 01 '22 16:08 github-actions[bot]