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

refactor: Refactor error variants and usage of them #112

Closed ozgrakkurt closed 1 year ago

ozgrakkurt commented 1 year ago

closes https://github.com/semiotic-ai/timeline-aggregation-protocol/issues/73.

I found issues mostly about InvalidCheckError which was used as a generic error in the aggregator crate. I think I got all the cases.

github-actions[bot] commented 1 year ago

Coverage after merging error-variant-refactor into main will be

81.84%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
tap_aggregator/src
   aggregator.rs94.06%100%100%92.59%39, 49–53
   api_versioning.rs86.21%100%76.47%90.24%15–16
   error_codes.rs0%100%0%0%13, 27
   jsonrpsee_helpers.rs43.90%100%33.33%48.28%44, 51–57, 9
   lib.rs100%100%100%100%
   main.rs3.70%100%6.67%2.56%13, 17–18, 22, 26–27, 31–32, 36–37, 41–42, 45–47, 50–57, 60–65, 68–72, 74
   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%58
   error.rs50%100%50%50%
   lib.rs83.33%100%87.50%81.25%26
   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
   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.rs78.87%100%58.33%80.77%107, 126–129, 135, 170–176, 190, 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.rs46.34%100%45.45%46.67%49–59
   receipt.rs88.46%100%87.50%88.89%19
   receipt_auditor.rs84.83%100%83.33%84.96%103–105, 115, 139, 161–163, 65, 78–80, 87–90
   received_receipt.rs83.71%100%78.05%84.59%119–121, 131, 215–217, 230–232, 238–240, 247–249, 251–253, 282–284, 319, 333–335, 340, 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 553 security advisories (from /usr/local/cargo/advisory-db) Updating crates.io index Scanning Cargo.lock for vulnerabilities (420 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_integration_tests 0.1.0 └── tap_aggregator 0.1.0 └── tap_integration_tests 0.1.0 warning: 1 allowed warning found ```

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

github-actions[bot] commented 1 year ago

🤖 Cargo Audit Report 🤖`

Show Report *** Fetching advisory database from `https://github.com/RustSec/advisory-db.git` Loaded 553 security advisories (from /usr/local/cargo/advisory-db) Updating crates.io index Scanning Cargo.lock for vulnerabilities (420 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_integration_tests 0.1.0 └── tap_aggregator 0.1.0 └── tap_integration_tests 0.1.0 warning: 1 allowed warning found ```

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

github-actions[bot] commented 1 year ago

Coverage after merging error-variant-refactor into main will be

80.32%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
tap_aggregator/src
   aggregator.rs94.06%100%100%92.59%39, 49–53
   api_versioning.rs86.21%100%76.47%90.24%15–16
   error_codes.rs0%100%0%0%13, 27
   jsonrpsee_helpers.rs43.90%100%33.33%48.28%44, 51–57, 9
   lib.rs100%100%100%100%
   main.rs3.70%100%6.67%2.56%13, 17–18, 22, 26–27, 31–32, 36–37, 41–42, 45–47, 50–57, 60–65, 68–72, 74
   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%58
   error.rs50%100%50%50%
   lib.rs83.33%100%87.50%81.25%26
   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
   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.rs71.78%100%57.14%74.14%111, 130, 134–136, 148, 163–177, 29, 43, 57, 75, 93
   receipt_storage_adapter_test.rs100%100%100%100%
tap_core/src/tap_manager
   manager.rs82.50%100%61.54%84.35%107, 126–129, 136, 185, 200–203, 209, 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.rs46.34%100%45.45%46.67%49–59
   receipt.rs88.46%100%87.50%88.89%19
   receipt_auditor.rs84.83%100%83.33%84.96%103–105, 115, 139, 161–163, 65, 78–80, 87–90
   received_receipt.rs83.71%100%78.05%84.59%119–121, 131, 215–217, 230–232, 238–240, 247–249, 251–253, 282–284, 319, 333–335, 340, 349–350, 359–360, 382, 396–398
aasseman commented 1 year ago

Also, are we OK with bundling all errors into a JSON-RPC -32002 error (current situation), or should we do something more fine-grained? I'm fine with the current state of affairs, but maybe I'm wrong :shrug:

ozgrakkurt commented 1 year ago

Also, are we OK with bundling all errors into a JSON-RPC -32002 error (current situation), or should we do something more fine-grained? I'm fine with the current state of affairs, but maybe I'm wrong 🤷

should be different issue I think

aasseman commented 1 year ago

Merge branch 'main' into error-variant-refactor

Could you rebase instead?

ozgrakkurt commented 1 year ago

Merge branch 'main' into error-variant-refactor

Could you rebase instead?

Actually wanted to just squash at the end into one commit but commit message checker is not gonna let me do it I think

github-actions[bot] commented 1 year ago

🤖 Cargo Audit Report 🤖`

Show Report *** Fetching advisory database from `https://github.com/RustSec/advisory-db.git` Loaded 553 security advisories (from /usr/local/cargo/advisory-db) Updating crates.io index Scanning Cargo.lock for vulnerabilities (420 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_integration_tests 0.1.0 └── tap_aggregator 0.1.0 └── tap_integration_tests 0.1.0 warning: 1 allowed warning found ```

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

github-actions[bot] commented 1 year ago

Coverage after merging error-variant-refactor into main will be

80.28%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
tap_aggregator/src
   aggregator.rs93.88%100%100%92.31%39, 49–53
   api_versioning.rs86.21%100%76.47%90.24%15–16
   error_codes.rs0%100%0%0%13, 27
   jsonrpsee_helpers.rs43.90%100%33.33%48.28%44, 51–57, 9
   lib.rs100%100%100%100%
   main.rs3.70%100%6.67%2.56%13, 17–18, 22, 26–27, 31–32, 36–37, 41–42, 45–47, 50–57, 60–65, 68–72, 74
   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%58
   error.rs50%100%50%50%
   lib.rs83.33%100%87.50%81.25%26
   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
   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.rs71.78%100%57.14%74.14%111, 130, 134–136, 148, 163–177, 29, 43, 57, 75, 93
   receipt_storage_adapter_test.rs100%100%100%100%
tap_core/src/tap_manager
   manager.rs82.50%100%61.54%84.35%107, 126–129, 136, 185, 200–203, 209, 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.rs46.34%100%45.45%46.67%49–59
   receipt.rs88.46%100%87.50%88.89%19
   receipt_auditor.rs84.83%100%83.33%84.96%103–105, 115, 139, 161–163, 65, 78–80, 87–90
   received_receipt.rs83.71%100%78.05%84.59%119–121, 131, 215–217, 230–232, 238–240, 247–249, 251–253, 282–284, 319, 333–335, 340, 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 553 security advisories (from /usr/local/cargo/advisory-db) Updating crates.io index Scanning Cargo.lock for vulnerabilities (420 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_integration_tests 0.1.0 └── tap_aggregator 0.1.0 └── tap_integration_tests 0.1.0 warning: 1 allowed warning found ```

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

github-actions[bot] commented 1 year ago

🤖 Cargo Audit Report 🤖`

Show Report *** Fetching advisory database from `https://github.com/RustSec/advisory-db.git` Loaded 553 security advisories (from /usr/local/cargo/advisory-db) Updating crates.io index Scanning Cargo.lock for vulnerabilities (420 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_integration_tests 0.1.0 └── tap_aggregator 0.1.0 └── tap_integration_tests 0.1.0 warning: 1 allowed warning found ```

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

github-actions[bot] commented 1 year ago

Coverage after merging error-variant-refactor into main will be

80.28%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
tap_aggregator/src
   aggregator.rs93.88%100%100%92.31%39, 49–53
   api_versioning.rs86.21%100%76.47%90.24%15–16
   error_codes.rs0%100%0%0%13, 27
   jsonrpsee_helpers.rs43.90%100%33.33%48.28%44, 51–57, 9
   lib.rs100%100%100%100%
   main.rs3.70%100%6.67%2.56%13, 17–18, 22, 26–27, 31–32, 36–37, 41–42, 45–47, 50–57, 60–65, 68–72, 74
   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%58
   error.rs50%100%50%50%
   lib.rs83.33%100%87.50%81.25%26
   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
   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.rs71.78%100%57.14%74.14%111, 130, 134–136, 148, 163–177, 29, 43, 57, 75, 93
   receipt_storage_adapter_test.rs100%100%100%100%
tap_core/src/tap_manager
   manager.rs82.50%100%61.54%84.35%107, 126–129, 136, 185, 200–203, 209, 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.rs46.34%100%45.45%46.67%49–59
   receipt.rs88.46%100%87.50%88.89%19
   receipt_auditor.rs84.83%100%83.33%84.96%103–105, 115, 139, 161–163, 65, 78–80, 87–90
   received_receipt.rs83.71%100%78.05%84.59%119–121, 131, 215–217, 230–232, 238–240, 247–249, 251–253, 282–284, 319, 333–335, 340, 349–350, 359–360, 382, 396–398
github-actions[bot] commented 1 year ago

Coverage after merging error-variant-refactor into main will be

80.28%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
tap_aggregator/src
   aggregator.rs93.88%100%100%92.31%39, 49–53
   api_versioning.rs86.21%100%76.47%90.24%15–16
   error_codes.rs0%100%0%0%13, 27
   jsonrpsee_helpers.rs43.90%100%33.33%48.28%44, 51–57, 9
   lib.rs100%100%100%100%
   main.rs3.70%100%6.67%2.56%13, 17–18, 22, 26–27, 31–32, 36–37, 41–42, 45–47, 50–57, 60–65, 68–72, 74
   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%58
   error.rs50%100%50%50%
   lib.rs83.33%100%87.50%81.25%26
   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
   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.rs71.78%100%57.14%74.14%111, 130, 134–136, 148, 163–177, 29, 43, 57, 75, 93
   receipt_storage_adapter_test.rs100%100%100%100%
tap_core/src/tap_manager
   manager.rs82.50%100%61.54%84.35%107, 126–129, 136, 185, 200–203, 209, 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.rs46.34%100%45.45%46.67%49–59
   receipt.rs88.46%100%87.50%88.89%19
   receipt_auditor.rs84.83%100%83.33%84.96%103–105, 115, 139, 161–163, 65, 78–80, 87–90
   received_receipt.rs83.71%100%78.05%84.59%119–121, 131, 215–217, 230–232, 238–240, 247–249, 251–253, 282–284, 319, 333–335, 340, 349–350, 359–360, 382, 396–398
ozgrakkurt commented 1 year ago

@aasseman can you re-check? should be ok to merge

github-actions[bot] commented 1 year ago

🤖 Cargo Audit Report 🤖`

Show Report *** Fetching advisory database from `https://github.com/RustSec/advisory-db.git` Loaded 553 security advisories (from /usr/local/cargo/advisory-db) Updating crates.io index Scanning Cargo.lock for vulnerabilities (423 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_integration_tests 0.1.0 └── tap_aggregator 0.1.0 └── tap_integration_tests 0.1.0 warning: 1 allowed warning found ```

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

github-actions[bot] commented 1 year ago

Coverage after merging error-variant-refactor into main will be

80.25%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
tap_aggregator/src
   aggregator.rs93.62%100%100%92.11%39, 49–53
   api_versioning.rs86.21%100%76.47%90.24%15–16
   error_codes.rs0%100%0%0%13, 27
   jsonrpsee_helpers.rs43.90%100%33.33%48.28%44, 51–57, 9
   lib.rs100%100%100%100%
   main.rs3.70%100%6.67%2.56%13, 17–18, 22, 26–27, 31–32, 36–37, 41–42, 45–47, 50–57, 60–65, 68–72, 74
   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%58
   error.rs50%100%50%50%
   lib.rs83.33%100%87.50%81.25%26
   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
   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.rs71.78%100%57.14%74.14%111, 130, 134–136, 148, 163–177, 29, 43, 57, 75, 93
   receipt_storage_adapter_test.rs100%100%100%100%
tap_core/src/tap_manager
   manager.rs82.50%100%61.54%84.35%107, 126–129, 136, 185, 200–203, 209, 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.rs46.34%100%45.45%46.67%49–59
   receipt.rs88.46%100%87.50%88.89%19
   receipt_auditor.rs84.83%100%83.33%84.96%103–105, 115, 139, 161–163, 65, 78–80, 87–90
   received_receipt.rs83.71%100%78.05%84.59%119–121, 131, 215–217, 230–232, 238–240, 247–249, 251–253, 282–284, 319, 333–335, 340, 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 553 security advisories (from /usr/local/cargo/advisory-db) Updating crates.io index Scanning Cargo.lock for vulnerabilities (417 crate dependencies) ```

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

github-actions[bot] commented 1 year ago

Coverage after merging error-variant-refactor into main will be

80.25%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
tap_aggregator/src
   aggregator.rs93.62%100%100%92.11%39, 49–53
   api_versioning.rs86.21%100%76.47%90.24%15–16
   error_codes.rs0%100%0%0%13, 27
   jsonrpsee_helpers.rs43.90%100%33.33%48.28%44, 51–57, 9
   lib.rs100%100%100%100%
   main.rs3.70%100%6.67%2.56%13, 17–18, 22, 26–27, 31–32, 36–37, 41–42, 45–47, 50–57, 60–65, 68–72, 74
   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%58
   error.rs50%100%50%50%
   lib.rs83.33%100%87.50%81.25%26
   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
   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.rs71.78%100%57.14%74.14%111, 130, 134–136, 148, 163–177, 29, 43, 57, 75, 93
   receipt_storage_adapter_test.rs100%100%100%100%
tap_core/src/tap_manager
   manager.rs82.50%100%61.54%84.35%107, 126–129, 136, 185, 200–203, 209, 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.rs46.34%100%45.45%46.67%49–59
   receipt.rs88.46%100%87.50%88.89%19
   receipt_auditor.rs84.83%100%83.33%84.96%103–105, 115, 139, 161–163, 65, 78–80, 87–90
   received_receipt.rs83.71%100%78.05%84.59%119–121, 131, 215–217, 230–232, 238–240, 247–249, 251–253, 282–284, 319, 333–335, 340, 349–350, 359–360, 382, 396–398