Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NFT Metadata Crawler] Asset Uploader API, Worker, Throttler #14837

Merged
merged 6 commits into from
Oct 22, 2024

Conversation

just-in-chang
Copy link
Contributor

@just-in-chang just-in-chang commented Oct 2, 2024

Description

Adaptation of the old Asset Uploader to the Asset Uploader Worker from the new design.

Design: https://www.notion.so/aptoslabs/WIP-Asset-Uploader-cb33138051324d1fa03115ef1b55ed0b

How Has This Been Tested?

image

image

Key Areas to Review

The service is even simpler than before. Please just look at overall logic and critique my coding style for Rust best practices.

Type of Change

  • New feature
  • Bug fix
  • Breaking change
  • Performance improvement
  • Refactoring
  • Dependency update
  • Documentation update
  • Tests

Which Components or Systems Does This Change Impact?

  • Validator Node
  • Full Node (API, Indexer, etc.)
  • Move/Aptos Virtual Machine
  • Aptos Framework
  • Aptos CLI/SDK
  • Developer Infrastructure
  • Move Compiler
  • Other (specify)

Checklist

  • I have read and followed the CONTRIBUTING doc
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I identified and added all stakeholders and component owners affected by this change as reviewers
  • I tested both happy and unhappy path of the functionality
  • I have made corresponding changes to the documentation

@just-in-chang just-in-chang requested review from jillxuu and a team October 2, 2024 01:17
Copy link

trunk-io bot commented Oct 2, 2024

⏱️ 1h 30m total CI duration on this PR
Slowest 15 Jobs Cumulative Duration Recent Runs
rust-cargo-deny 16m 🟩🟩🟩🟩🟩 (+4 more)
check-dynamic-deps 12m 🟩🟩🟩🟩🟩 (+4 more)
rust-move-tests 10m 🟩
rust-move-tests 10m 🟩
rust-move-tests 10m 🟩
rust-move-tests 9m 🟩
rust-move-tests 5m
general-lints 4m 🟩🟩🟩🟩🟩 (+4 more)
semgrep/ci 4m 🟩🟩🟩🟩🟩 (+4 more)
rust-move-tests 2m 🟩
rust-move-tests 2m 🟩
rust-move-tests 2m
file_change_determinator 2m 🟩🟩🟩🟩🟩 (+4 more)
rust-move-tests 2m 🟩
permission-check 27s 🟩🟩🟩🟩🟩 (+4 more)

settingsfeedbackdocs ⋅ learn more about trunk.io

Base automatically changed from justin/remove-parser to main October 3, 2024 01:24
@just-in-chang just-in-chang requested a review from a team as a code owner October 3, 2024 01:24
@just-in-chang just-in-chang force-pushed the justin/asset-uploader-worker branch from b06b02d to 44bfd22 Compare October 3, 2024 07:23
) -> impl IntoResponse {
match context.upload_asset(&request.url).await {
Ok(res) => {
let res = res.into_response(); // TODO: How to log response body?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait which service is updating the db for request status and response? is it throttler or worker?

btw do we need to log the response if postgresdb will maintain request status and response?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the throttler that performs the db updates, and it's just nice to log the body to help with debugging

async fn upload_asset(&self, url: &Url) -> anyhow::Result<impl IntoResponse> {
let hashed_url = sha256::digest(url.to_string());
let client = Client::builder()
.timeout(Duration::from_secs(MAX_ASSET_UPLOAD_RETRY_SECONDS))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this live in the config instead of const var? we might not know right away what's the best seconds to retry for

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just an arbitrarily high number. Theoretically, we should be nowhere near this limit because of the size limit for cloudflare.

Comment on lines +101 to +233
/// Converts a reqwest response to an axum response
/// Only copies the response status, response body, and Content-Type header
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wondering is it worth having these two libraries for incoming and outgoing http requests? what if we just a single rust library for requests? chatgpt suggested hyper?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we previously used reqwest in nft netadata crawler, which is why i used reqwest here. Also hyper makes it very hard to submit multipart requests bc hyper too low level and doesnt support it out of the box

@just-in-chang just-in-chang changed the title [NFT Metadata Crawler] Asset Uploader Worker [NFT Metadata Crawler] Asset Uploader Oct 22, 2024
@just-in-chang just-in-chang changed the title [NFT Metadata Crawler] Asset Uploader [NFT Metadata Crawler] Asset Uploader API, Worker, Throttler Oct 22, 2024
just-in-chang and others added 4 commits October 21, 2024 18:13
* s

* fix

* edits

* update model

* upd oop

* [NFT Metadata Crawler] Asset Uploader Throttler (#14904)

* yay

* upsert

* awesome

* AHHHHHHHHHHHHHHHHHHHHHHH

* boom

* boom

* lint

* lint
@just-in-chang just-in-chang force-pushed the justin/asset-uploader-worker branch from 6cc119e to 7ec2b26 Compare October 22, 2024 01:14
@just-in-chang just-in-chang enabled auto-merge (squash) October 22, 2024 01:22

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

Copy link
Contributor

✅ Forge suite realistic_env_max_load success on 8e1d8ccf9cb0d83bf280c7a142961e4a56f851f7

two traffics test: inner traffic : committed: 14362.37 txn/s, latency: 2764.01 ms, (p50: 2700 ms, p70: 2700, p90: 3000 ms, p99: 3000 ms), latency samples: 5460960
two traffics test : committed: 100.06 txn/s, latency: 1591.95 ms, (p50: 1400 ms, p70: 1500, p90: 1600 ms, p99: 8300 ms), latency samples: 1760
Latency breakdown for phase 0: ["QsBatchToPos: max: 0.241, avg: 0.220", "QsPosToProposal: max: 1.165, avg: 1.137", "ConsensusProposalToOrdered: max: 0.333, avg: 0.295", "ConsensusOrderedToCommit: max: 0.390, avg: 0.377", "ConsensusProposalToCommit: max: 0.684, avg: 0.672"]
Max non-epoch-change gap was: 0 rounds at version 0 (avg 0.00) [limit 4], 0.91s no progress at version 2928888 (avg 0.20s) [limit 15].
Max epoch-change gap was: 0 rounds at version 0 (avg 0.00) [limit 4], 8.59s no progress at version 2928886 (avg 8.59s) [limit 15].
Test Ok

Copy link
Contributor

✅ Forge suite framework_upgrade success on b29f09f57e898d8d211c8bc3e303f6e50bba2266 ==> 8e1d8ccf9cb0d83bf280c7a142961e4a56f851f7

Compatibility test results for b29f09f57e898d8d211c8bc3e303f6e50bba2266 ==> 8e1d8ccf9cb0d83bf280c7a142961e4a56f851f7 (PR)
Upgrade the nodes to version: 8e1d8ccf9cb0d83bf280c7a142961e4a56f851f7
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 1173.61 txn/s, submitted: 1177.60 txn/s, failed submission: 3.99 txn/s, expired: 3.99 txn/s, latency: 2675.21 ms, (p50: 2400 ms, p70: 2700, p90: 4800 ms, p99: 6300 ms), latency samples: 106020
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 1209.46 txn/s, submitted: 1212.90 txn/s, failed submission: 3.44 txn/s, expired: 3.44 txn/s, latency: 2566.03 ms, (p50: 2400 ms, p70: 2900, p90: 3900 ms, p99: 5400 ms), latency samples: 105480
5. check swarm health
Compatibility test for b29f09f57e898d8d211c8bc3e303f6e50bba2266 ==> 8e1d8ccf9cb0d83bf280c7a142961e4a56f851f7 passed
Upgrade the remaining nodes to version: 8e1d8ccf9cb0d83bf280c7a142961e4a56f851f7
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 1070.18 txn/s, submitted: 1072.63 txn/s, failed submission: 2.44 txn/s, expired: 2.44 txn/s, latency: 2775.10 ms, (p50: 2400 ms, p70: 3000, p90: 4500 ms, p99: 6100 ms), latency samples: 96400
Test Ok

Copy link
Contributor

✅ Forge suite compat success on b29f09f57e898d8d211c8bc3e303f6e50bba2266 ==> 8e1d8ccf9cb0d83bf280c7a142961e4a56f851f7

Compatibility test results for b29f09f57e898d8d211c8bc3e303f6e50bba2266 ==> 8e1d8ccf9cb0d83bf280c7a142961e4a56f851f7 (PR)
1. Check liveness of validators at old version: b29f09f57e898d8d211c8bc3e303f6e50bba2266
compatibility::simple-validator-upgrade::liveness-check : committed: 14488.58 txn/s, latency: 2336.98 ms, (p50: 2000 ms, p70: 2100, p90: 3000 ms, p99: 7800 ms), latency samples: 468800
2. Upgrading first Validator to new version: 8e1d8ccf9cb0d83bf280c7a142961e4a56f851f7
compatibility::simple-validator-upgrade::single-validator-upgrading : committed: 6643.95 txn/s, latency: 4291.02 ms, (p50: 4900 ms, p70: 5200, p90: 5400 ms, p99: 5400 ms), latency samples: 122760
compatibility::simple-validator-upgrade::single-validator-upgrade : committed: 6762.51 txn/s, latency: 4795.18 ms, (p50: 5200 ms, p70: 5400, p90: 6000 ms, p99: 6600 ms), latency samples: 227120
3. Upgrading rest of first batch to new version: 8e1d8ccf9cb0d83bf280c7a142961e4a56f851f7
compatibility::simple-validator-upgrade::half-validator-upgrading : committed: 6044.79 txn/s, latency: 4454.38 ms, (p50: 5100 ms, p70: 5200, p90: 5400 ms, p99: 5900 ms), latency samples: 122880
compatibility::simple-validator-upgrade::half-validator-upgrade : committed: 6602.29 txn/s, latency: 4926.51 ms, (p50: 5300 ms, p70: 5400, p90: 6300 ms, p99: 7000 ms), latency samples: 227380
4. upgrading second batch to new version: 8e1d8ccf9cb0d83bf280c7a142961e4a56f851f7
compatibility::simple-validator-upgrade::rest-validator-upgrading : committed: 9271.15 txn/s, latency: 3035.36 ms, (p50: 3300 ms, p70: 3600, p90: 3900 ms, p99: 4100 ms), latency samples: 170340
compatibility::simple-validator-upgrade::rest-validator-upgrade : committed: 8972.94 txn/s, latency: 3572.21 ms, (p50: 3700 ms, p70: 3900, p90: 5100 ms, p99: 5500 ms), latency samples: 293280
5. check swarm health
Compatibility test for b29f09f57e898d8d211c8bc3e303f6e50bba2266 ==> 8e1d8ccf9cb0d83bf280c7a142961e4a56f851f7 passed
Test Ok

@just-in-chang just-in-chang merged commit bb6b5c7 into main Oct 22, 2024
48 checks passed
@just-in-chang just-in-chang deleted the justin/asset-uploader-worker branch October 22, 2024 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants