semiotic-ai / timeline-aggregation-protocol

A fast, efficient and trust-minimized unidirectional micro-payments system.
Apache License 2.0
14 stars 3 forks source link

feat(aggregator): basic JSON-RPC API version mgmt #96

Closed aasseman closed 1 year ago

aasseman commented 1 year ago

By API, here we mean specifically the TAP JSON-RPC API version, not the library version.

Maintains a const list of supported API versions, as well as a const list of API versions for which to warn of imminent deprecation. We expect the client to periodically check if its expected API version is deprecated. For all functions, an expected API version is to be supplied as argument. Each function will have to check if the number is supported, and return an error otherwise.

Rationale:

Some of those features may not be needed, but at least there is a low chance that we get stuck when the need to migrate to a new API version arises.

Please comment!

fixes #79 (hopefully!)

aasseman commented 1 year ago

Rebased onto latest main

aasseman commented 1 year ago

What's left at this point:

github-actions[bot] commented 1 year ago

πŸ€– Cargo Audit Report πŸ€–`

Show Report *** Fetching advisory database from `https://github.com/RustSec/advisory-db.git` Loaded 547 security advisories (from /usr/local/cargo/advisory-db) Updating crates.io index Scanning Cargo.lock for vulnerabilities (421 crate dependencies) Crate: atty Version: 0.2.14 Warning: unsound Title: Potential unaligned read Date: 2021-07-04 ID: RUSTSEC-2021-0145 URL: https://rustsec.org/advisories/RUSTSEC-2021-0145 Dependency tree: atty 0.2.14 └── criterion 0.4.0 └── tap_core 0.1.0 └── tap_aggregator 0.1.0 warning: 1 allowed warning found ```

Pusher: @aasseman, Action: pull_request, Working Directory: `, Workflow:tests`

github-actions[bot] commented 1 year ago

Coverage after merging rpc_api_versioning into main will be

80.91%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
tap_aggregator/src
   aggregator.rs92.45%100%100%90.70%40–43, 53–56
   api_versioning.rs93.10%100%88.24%95.12%15
   error_codes.rs0%100%0%0%16, 5
   jsonrpsee_helpers.rs48.78%100%41.67%51.72%44, 51–57, 9
   main.rs3.70%100%6.67%2.56%17, 21–22, 26, 30–31, 35–36, 40–41, 45–46, 49–51, 54–61, 64–69, 72–76, 78
   server.rs86.09%100%100%82.22%101, 113–117, 137, 69–77
tap_core/src
   eip_712_signed_message.rs83.78%100%80%85.19%57
   lib.rs78.57%100%80%77.78%22, 59
   receipt_aggregate_voucher.rs92.50%100%87.50%93.75%23
tap_core/src/adapters/test
   collateral_adapter_mock.rs88.33%100%75%90.38%18, 44–45, 64
   collateral_adapter_test.rs100%100%100%100%
   rav_storage_adapter_mock.rs92%100%71.43%95.35%30
   rav_storage_adapter_test.rs100%100%100%100%
   receipt_checks_adapter_mock.rs97.83%100%100%97.50%61
   receipt_checks_adapter_test.rs95.83%100%100%95%59
   receipt_storage_adapter_mock.rs93.46%100%86.67%94.57%28, 90–92
   receipt_storage_adapter_test.rs100%100%100%100%
tap_core/src/tap_manager
   manager.rs76.76%100%58.33%78.46%107, 126–129, 135, 170–176, 190, 201–202, 213, 95
   rav_request.rs0%100%0%0%9
tap_core/src/tap_manager/test
   manager_test.rs100%100%100%100%
tap_core/src/tap_receipt
   mod.rs41.46%100%36.36%43.33%16, 49–59
   receipt.rs88.46%100%87.50%88.89%19
   receipt_auditor.rs80%100%83.33%79.70%103–105, 115, 121–126, 139, 146, 161–163, 65, 78–80, 87–90
   received_receipt.rs83.06%100%78.05%83.83%119–121, 131, 215–217, 230–232, 238–240, 247–249, 251–253, 282–284, 308, 319, 326, 333–335, 340, 345, 349–350, 359–360, 382, 396–398
github-actions[bot] commented 1 year ago

πŸ€– Cargo Audit Report πŸ€–`

Show Report *** Fetching advisory database from `https://github.com/RustSec/advisory-db.git` Loaded 547 security advisories (from /usr/local/cargo/advisory-db) Updating crates.io index Scanning Cargo.lock for vulnerabilities (421 crate dependencies) Crate: atty Version: 0.2.14 Warning: unsound Title: Potential unaligned read Date: 2021-07-04 ID: RUSTSEC-2021-0145 URL: https://rustsec.org/advisories/RUSTSEC-2021-0145 Dependency tree: atty 0.2.14 └── criterion 0.4.0 └── tap_core 0.1.0 └── tap_aggregator 0.1.0 warning: 1 allowed warning found ```

Pusher: @aasseman, Action: pull_request, Working Directory: `, Workflow:tests`

github-actions[bot] commented 1 year ago

Coverage after merging rpc_api_versioning into main will be

80.91%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
tap_aggregator/src
   aggregator.rs92.45%100%100%90.70%40–43, 53–56
   api_versioning.rs93.10%100%88.24%95.12%15
   error_codes.rs0%100%0%0%16, 5
   jsonrpsee_helpers.rs48.78%100%41.67%51.72%44, 51–57, 9
   main.rs3.70%100%6.67%2.56%17, 21–22, 26, 30–31, 35–36, 40–41, 45–46, 49–51, 54–61, 64–69, 72–76, 78
   server.rs86.09%100%100%82.22%101, 113–117, 137, 69–77
tap_core/src
   eip_712_signed_message.rs83.78%100%80%85.19%57
   lib.rs78.57%100%80%77.78%22, 59
   receipt_aggregate_voucher.rs92.50%100%87.50%93.75%23
tap_core/src/adapters/test
   collateral_adapter_mock.rs88.33%100%75%90.38%18, 44–45, 64
   collateral_adapter_test.rs100%100%100%100%
   rav_storage_adapter_mock.rs92%100%71.43%95.35%30
   rav_storage_adapter_test.rs100%100%100%100%
   receipt_checks_adapter_mock.rs97.83%100%100%97.50%61
   receipt_checks_adapter_test.rs95.83%100%100%95%59
   receipt_storage_adapter_mock.rs93.46%100%86.67%94.57%28, 90–92
   receipt_storage_adapter_test.rs100%100%100%100%
tap_core/src/tap_manager
   manager.rs76.76%100%58.33%78.46%107, 126–129, 135, 170–176, 190, 201–202, 213, 95
   rav_request.rs0%100%0%0%9
tap_core/src/tap_manager/test
   manager_test.rs100%100%100%100%
tap_core/src/tap_receipt
   mod.rs41.46%100%36.36%43.33%16, 49–59
   receipt.rs88.46%100%87.50%88.89%19
   receipt_auditor.rs80%100%83.33%79.70%103–105, 115, 121–126, 139, 146, 161–163, 65, 78–80, 87–90
   received_receipt.rs83.06%100%78.05%83.83%119–121, 131, 215–217, 230–232, 238–240, 247–249, 251–253, 282–284, 308, 319, 326, 333–335, 340, 345, 349–350, 359–360, 382, 396–398
github-actions[bot] commented 1 year ago

πŸ€– Cargo Audit Report πŸ€–`

Show Report *** Fetching advisory database from `https://github.com/RustSec/advisory-db.git` Loaded 548 security advisories (from /usr/local/cargo/advisory-db) Updating crates.io index Scanning Cargo.lock for vulnerabilities (421 crate dependencies) Crate: atty Version: 0.2.14 Warning: unsound Title: Potential unaligned read Date: 2021-07-04 ID: RUSTSEC-2021-0145 URL: https://rustsec.org/advisories/RUSTSEC-2021-0145 Dependency tree: atty 0.2.14 └── criterion 0.4.0 └── tap_core 0.1.0 └── tap_aggregator 0.1.0 warning: 1 allowed warning found ```

Pusher: @aasseman, Action: pull_request, Working Directory: `, Workflow:tests`

github-actions[bot] commented 1 year ago

Coverage after merging rpc_api_versioning into main will be

80.66%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
tap_aggregator/src
   aggregator.rs92.45%100%100%90.70%40–43, 53–56
   api_versioning.rs86.21%100%76.47%90.24%15–16
   error_codes.rs0%100%0%0%16, 5
   jsonrpsee_helpers.rs43.90%100%33.33%48.28%44, 51–57, 9
   main.rs3.70%100%6.67%2.56%17, 21–22, 26, 30–31, 35–36, 40–41, 45–46, 49–51, 54–61, 64–69, 72–76, 78
   server.rs86.09%100%100%82.22%101, 113–117, 137, 69–77
tap_core/src
   eip_712_signed_message.rs83.78%100%80%85.19%57
   lib.rs78.57%100%80%77.78%22, 59
   receipt_aggregate_voucher.rs92.50%100%87.50%93.75%23
tap_core/src/adapters/test
   collateral_adapter_mock.rs88.33%100%75%90.38%18, 44–45, 64
   collateral_adapter_test.rs100%100%100%100%
   rav_storage_adapter_mock.rs92%100%71.43%95.35%30
   rav_storage_adapter_test.rs100%100%100%100%
   receipt_checks_adapter_mock.rs97.83%100%100%97.50%61
   receipt_checks_adapter_test.rs95.83%100%100%95%59
   receipt_storage_adapter_mock.rs93.46%100%86.67%94.57%28, 90–92
   receipt_storage_adapter_test.rs100%100%100%100%
tap_core/src/tap_manager
   manager.rs76.76%100%58.33%78.46%107, 126–129, 135, 170–176, 190, 201–202, 213, 95
   rav_request.rs0%100%0%0%9
tap_core/src/tap_manager/test
   manager_test.rs100%100%100%100%
tap_core/src/tap_receipt
   mod.rs41.46%100%36.36%43.33%16, 49–59
   receipt.rs88.46%100%87.50%88.89%19
   receipt_auditor.rs80%100%83.33%79.70%103–105, 115, 121–126, 139, 146, 161–163, 65, 78–80, 87–90
   received_receipt.rs83.06%100%78.05%83.83%119–121, 131, 215–217, 230–232, 238–240, 247–249, 251–253, 282–284, 308, 319, 326, 333–335, 340, 345, 349–350, 359–360, 382, 396–398