aptos-core
aptos-core copied to clipboard
[API] Add X-Aptos-Gas-Used header
Description
This PR makes the simulate and view function endpoints return how much gas they used. We will use this for compute unit based ratelimiting in API Gateway.
Type of Change
- [x] New feature
- [ ] Bug fix
- [ ] Breaking change
- [ ] Performance improvement
- [ ] Refactoring
- [ ] Dependency update
- [ ] Documentation update
- [ ] Tests
Which Components or Systems Does This Change Impact?
- [ ] Validator Node
- [x] Full Node (API, Indexer, etc.)
- [ ] Move/Aptos Virtual Machine
- [ ] Aptos Framework
- [ ] Aptos CLI/SDK
- [ ] Developer Infrastructure
- [ ] Other (specify)
How Has This Been Tested?
New API test. I can add one for simulation too if we want.
curl -v --request POST --url 127.0.0.1:8080/v1/view --header 'Accept: application/json' --header 'Content-Type: application/json' --data '{
"function": "0x1::coin::balance",
"type_arguments": [
"0x1::aptos_coin::AptosCoin"
],
"arguments": ["0x1"]
}'
x-aptos-gas-cost: 1
Key Areas to Review
Consider if there is a better, easier way to do this than with a header.
Checklist
- [x] I have read and followed the CONTRIBUTING doc
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I identified and added all stakeholders and component owners affected by this change as reviewers
- [x] I tested both happy and unhappy path of the functionality
- [x] I have made corresponding changes to the documentation
⏱️ 11h 28m total CI duration on this PR
🚨 4 jobs on the last run were significantly faster/slower than expected
Job | Duration | vs 7d avg | Delta |
---|---|---|---|
rust-build-cached-packages | 8m | 5m | |
rust-lints | 10m | 7m | |
rust-targeted-unit-tests | 14m | 19m | |
rust-move-tests | 7m | 12m |
Forge is running suite compat
on 01b24e7e3548382dd25440b39a0438a993387f12
==> 528ad6ce6a910083b3cf2af86a52a5e3c45fafc8
- Grafana dashboard (auto-refresh)
- Humio Logs
- Axiom Logs
- Validator CPU Profile
- Fullnode CPU Profile
- Test runner output
- Test run is land-blocking
Forge is running suite realistic_env_max_load
on 528ad6ce6a910083b3cf2af86a52a5e3c45fafc8
- Grafana dashboard (auto-refresh)
- Humio Logs
- Axiom Logs
- Validator CPU Profile
- Fullnode CPU Profile
- Test runner output
- Test run is land-blocking
Forge is running suite framework_upgrade
on 01b24e7e3548382dd25440b39a0438a993387f12
==> 528ad6ce6a910083b3cf2af86a52a5e3c45fafc8
- Grafana dashboard (auto-refresh)
- Humio Logs
- Axiom Logs
- Validator CPU Profile
- Fullnode CPU Profile
- Test runner output
- Test run is land-blocking
:white_check_mark: Forge suite compat
success on 01b24e7e3548382dd25440b39a0438a993387f12
==> 528ad6ce6a910083b3cf2af86a52a5e3c45fafc8
Compatibility test results for 01b24e7e3548382dd25440b39a0438a993387f12 ==> 528ad6ce6a910083b3cf2af86a52a5e3c45fafc8 (PR)
1. Check liveness of validators at old version: 01b24e7e3548382dd25440b39a0438a993387f12
compatibility::simple-validator-upgrade::liveness-check : committed: 6820 txn/s, latency: 4872 ms, (p50: 4800 ms, p90: 8100 ms, p99: 10000 ms), latency samples: 238700
2. Upgrading first Validator to new version: 528ad6ce6a910083b3cf2af86a52a5e3c45fafc8
compatibility::simple-validator-upgrade::single-validator-upgrade : committed: 1637 txn/s, latency: 16587 ms, (p50: 19600 ms, p90: 23800 ms, p99: 25100 ms), latency samples: 88440
3. Upgrading rest of first batch to new version: 528ad6ce6a910083b3cf2af86a52a5e3c45fafc8
compatibility::simple-validator-upgrade::half-validator-upgrade : committed: 1824 txn/s, latency: 15763 ms, (p50: 19200 ms, p90: 22200 ms, p99: 22900 ms), latency samples: 89420
4. upgrading second batch to new version: 528ad6ce6a910083b3cf2af86a52a5e3c45fafc8
compatibility::simple-validator-upgrade::rest-validator-upgrade : committed: 3600 txn/s, latency: 8814 ms, (p50: 9600 ms, p90: 12700 ms, p99: 13000 ms), latency samples: 144000
5. check swarm health
Compatibility test for 01b24e7e3548382dd25440b39a0438a993387f12 ==> 528ad6ce6a910083b3cf2af86a52a5e3c45fafc8 passed
Test Ok
- Grafana dashboard
- Humio Logs
- Axiom Logs
- Validator CPU Profile
- Fullnode CPU Profile
- Test runner output
- Test run is land-blocking
:white_check_mark: Forge suite realistic_env_max_load
success on 528ad6ce6a910083b3cf2af86a52a5e3c45fafc8
two traffics test: inner traffic : committed: 7942 txn/s, latency: 4935 ms, (p50: 4800 ms, p90: 5700 ms, p99: 11100 ms), latency samples: 3431220
two traffics test : committed: 100 txn/s, latency: 1928 ms, (p50: 1800 ms, p90: 2000 ms, p99: 7100 ms), latency samples: 1700
Latency breakdown for phase 0: ["QsBatchToPos: max: 0.207, avg: 0.201", "QsPosToProposal: max: 0.308, avg: 0.227", "ConsensusProposalToOrdered: max: 0.438, avg: 0.412", "ConsensusOrderedToCommit: max: 0.399, avg: 0.367", "ConsensusProposalToCommit: max: 0.837, avg: 0.779"]
Max round gap was 1 [limit 4] at version 1651190. Max no progress secs was 4.985512 [limit 15] at version 1651190.
Test Ok
- Grafana dashboard
- Humio Logs
- Axiom Logs
- Validator CPU Profile
- Fullnode CPU Profile
- Test runner output
- Test run is land-blocking
:white_check_mark: Forge suite framework_upgrade
success on 01b24e7e3548382dd25440b39a0438a993387f12
==> 528ad6ce6a910083b3cf2af86a52a5e3c45fafc8
Compatibility test results for 01b24e7e3548382dd25440b39a0438a993387f12 ==> 528ad6ce6a910083b3cf2af86a52a5e3c45fafc8 (PR)
Upgrade the nodes to version: 528ad6ce6a910083b3cf2af86a52a5e3c45fafc8
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 1353 txn/s, submitted: 1356 txn/s, failed submission: 2 txn/s, expired: 2 txn/s, latency: 2419 ms, (p50: 2100 ms, p90: 4400 ms, p99: 5700 ms), latency samples: 111000
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 1267 txn/s, submitted: 1269 txn/s, failed submission: 2 txn/s, expired: 2 txn/s, latency: 2607 ms, (p50: 2100 ms, p90: 4500 ms, p99: 6300 ms), latency samples: 110280
5. check swarm health
Compatibility test for 01b24e7e3548382dd25440b39a0438a993387f12 ==> 528ad6ce6a910083b3cf2af86a52a5e3c45fafc8 passed
Upgrade the remaining nodes to version: 528ad6ce6a910083b3cf2af86a52a5e3c45fafc8
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 1245 txn/s, submitted: 1249 txn/s, failed submission: 3 txn/s, expired: 3 txn/s, latency: 2495 ms, (p50: 2100 ms, p90: 4200 ms, p99: 6000 ms), latency samples: 109600
Test Ok
- Grafana dashboard
- Humio Logs
- Axiom Logs
- Validator CPU Profile
- Fullnode CPU Profile
- Test runner output
- Test run is land-blocking
Forge is running suite realistic_env_max_load
on aa3785c84e334da36c7a3f9c246669469db2cc8a
- Grafana dashboard (auto-refresh)
- Humio Logs
- Axiom Logs
- Validator CPU Profile
- Fullnode CPU Profile
- Test runner output
- Test run is land-blocking
Forge is running suite compat
on 01b24e7e3548382dd25440b39a0438a993387f12
==> aa3785c84e334da36c7a3f9c246669469db2cc8a
- Grafana dashboard (auto-refresh)
- Humio Logs
- Axiom Logs
- Validator CPU Profile
- Fullnode CPU Profile
- Test runner output
- Test run is land-blocking
Forge is running suite framework_upgrade
on 01b24e7e3548382dd25440b39a0438a993387f12
==> aa3785c84e334da36c7a3f9c246669469db2cc8a
- Grafana dashboard (auto-refresh)
- Humio Logs
- Axiom Logs
- Validator CPU Profile
- Fullnode CPU Profile
- Test runner output
- Test run is land-blocking
:white_check_mark: Forge suite realistic_env_max_load
success on aa3785c84e334da36c7a3f9c246669469db2cc8a
two traffics test: inner traffic : committed: 7547.132901414482 txn/s, latency: 5171.9997392716705 ms, (p50: 5100 ms, p90: 6000 ms, p99: 10200 ms), latency samples: 3275440
two traffics test : committed: 99.88504902082137 txn/s, latency: 1947.276404494382 ms, (p50: 1900 ms, p90: 2200 ms, p99: 3600 ms), latency samples: 1780
Latency breakdown for phase 0: ["QsBatchToPos: max: 0.205, avg: 0.201", "QsPosToProposal: max: 0.264, avg: 0.244", "ConsensusProposalToOrdered: max: 0.485, avg: 0.433", "ConsensusOrderedToCommit: max: 0.375, avg: 0.359", "ConsensusProposalToCommit: max: 0.803, avg: 0.792"]
Max round gap was 1 [limit 4] at version 1605469. Max no progress secs was 4.517688 [limit 15] at version 1605469.
Test Ok
- Grafana dashboard
- Humio Logs
- Axiom Logs
- Validator CPU Profile
- Fullnode CPU Profile
- Test runner output
- Test run is land-blocking
:white_check_mark: Forge suite compat
success on 01b24e7e3548382dd25440b39a0438a993387f12
==> aa3785c84e334da36c7a3f9c246669469db2cc8a
Compatibility test results for 01b24e7e3548382dd25440b39a0438a993387f12 ==> aa3785c84e334da36c7a3f9c246669469db2cc8a (PR)
1. Check liveness of validators at old version: 01b24e7e3548382dd25440b39a0438a993387f12
compatibility::simple-validator-upgrade::liveness-check : committed: 5861.178817007249 txn/s, latency: 5416.137746999077 ms, (p50: 5100 ms, p90: 8700 ms, p99: 15000 ms), latency samples: 216600
2. Upgrading first Validator to new version: aa3785c84e334da36c7a3f9c246669469db2cc8a
compatibility::simple-validator-upgrade::single-validator-upgrade : committed: 1804.7078912934946 txn/s, latency: 15949.636307007786 ms, (p50: 19900 ms, p90: 22900 ms, p99: 23300 ms), latency samples: 89900
3. Upgrading rest of first batch to new version: aa3785c84e334da36c7a3f9c246669469db2cc8a
compatibility::simple-validator-upgrade::half-validator-upgrade : committed: 1534.2240808099648 txn/s, latency: 18771.26283218504 ms, (p50: 19900 ms, p90: 22400 ms, p99: 22900 ms), latency samples: 81280
4. upgrading second batch to new version: aa3785c84e334da36c7a3f9c246669469db2cc8a
compatibility::simple-validator-upgrade::rest-validator-upgrade : committed: 3544.6656623751337 txn/s, latency: 8816.541157356194 ms, (p50: 9600 ms, p90: 12600 ms, p99: 12700 ms), latency samples: 144640
5. check swarm health
Compatibility test for 01b24e7e3548382dd25440b39a0438a993387f12 ==> aa3785c84e334da36c7a3f9c246669469db2cc8a passed
Test Ok
- Grafana dashboard
- Humio Logs
- Axiom Logs
- Validator CPU Profile
- Fullnode CPU Profile
- Test runner output
- Test run is land-blocking
:white_check_mark: Forge suite framework_upgrade
success on 01b24e7e3548382dd25440b39a0438a993387f12
==> aa3785c84e334da36c7a3f9c246669469db2cc8a
Compatibility test results for 01b24e7e3548382dd25440b39a0438a993387f12 ==> aa3785c84e334da36c7a3f9c246669469db2cc8a (PR)
Upgrade the nodes to version: aa3785c84e334da36c7a3f9c246669469db2cc8a
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 1374.7883860655768 txn/s, submitted: 1376.6065885930234 txn/s, failed submission: 1.8182025274466216 txn/s, expired: 1.8182025274466216 txn/s, latency: 2363.2069680939 ms, (p50: 1800 ms, p90: 4200 ms, p99: 5700 ms), latency samples: 120980
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 1133.325097967686 txn/s, submitted: 1135.7500300971635 txn/s, failed submission: 2.4249321294776394 txn/s, expired: 2.4249321294776394 txn/s, latency: 2615.6350807235945 ms, (p50: 2100 ms, p90: 4500 ms, p99: 6300 ms), latency samples: 102820
5. check swarm health
Compatibility test for 01b24e7e3548382dd25440b39a0438a993387f12 ==> aa3785c84e334da36c7a3f9c246669469db2cc8a passed
Upgrade the remaining nodes to version: aa3785c84e334da36c7a3f9c246669469db2cc8a
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 1176.853573465486 txn/s, submitted: 1179.3618837363872 txn/s, failed submission: 2.5083102709010556 txn/s, expired: 2.5083102709010556 txn/s, latency: 2612.5839856616935 ms, (p50: 2100 ms, p90: 4500 ms, p99: 6600 ms), latency samples: 103220
Test Ok
- Grafana dashboard
- Humio Logs
- Axiom Logs
- Validator CPU Profile
- Fullnode CPU Profile
- Test runner output
- Test run is land-blocking