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

[move] Type builder & fix calculation of node count in types #13028

Merged
merged 32 commits into from
Jun 12, 2024

Conversation

georgemitenkov
Copy link
Contributor

@georgemitenkov georgemitenkov commented Apr 25, 2024

Description

Previously the type size was calculated prior to performing the substitution. The calculation accounted for all nodes in non-substituted types and was not well-encapsulated. This PR adds node counting to subst function (in addition to depth) to make sure it is correctly accounted for as well.

No performance regression is expected because the counter is used in existing type traversals. An alternative design to store count and depth with types have been considered, but is significantly more verbose and it is not clear if it is needed before new type representation is designed.

The second change introduced by this PR is a new TypeBuilder struct which should be the only instance which can construct types in a checked fashion (respecting maximum depth and count). All type creation methods have been moved there, including:

  • constant creation
  • creation from type tags
  • creation via substituition
  • creation of vectors and references
  • creation of struct instantiations

Lastly, paranoid mode is made nicer (syntactically), making type explicit and ensuring their creation is gated.

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
  • Other (specify)

How Has This Been Tested?

Replays:

Also, many unit tests gave been added for type creation and substitution.

Key Areas to Review

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

@georgemitenkov georgemitenkov added the CICD:run-e2e-tests when this label is present github actions will run all land-blocking e2e tests from the PR label Apr 25, 2024
Copy link

trunk-io bot commented Apr 25, 2024

⏱️ 87h 23m total CI duration on this PR
Job Cumulative Duration Recent Runs
replay-mainnet / replay-verify (16) 5h 48m 🟩
replay-mainnet / replay-verify (15) 5h 21m 🟩
replay-mainnet / replay-verify (17) 4h 47m 🟩
replay-testnet / replay-verify (16) 4h 27m 🟩
rust-smoke-tests 3h 56m 🟩🟩🟩🟥 (+4 more)
replay-mainnet / replay-verify (12) 3h 55m 🟩
replay-mainnet / replay-verify (11) 3h 15m 🟩
execution-performance / single-node-performance 2h 58m 🟩🟥🟩🟩🟩 (+4 more)
replay-testnet / replay-verify (9) 2h 53m 🟩
rust-targeted-unit-tests 2h 21m 🟥🟥🟥🟥 (+3 more)
replay-mainnet / replay-verify (10) 2h 17m 🟩
rust-move-unit-coverage 2h 15m 🟩🟩🟩🟩 (+3 more)
replay-testnet / replay-verify (10) 2h 10m 🟩
replay-testnet / replay-verify (8) 1h 58m 🟩
replay-mainnet / replay-verify (14) 1h 56m 🟩
forge-e2e-test / forge 1h 45m 🟩🟩🟩🟥🟥 (+5 more)
rust-images / rust-all 1h 44m 🟩🟩🟩🟩🟩 (+5 more)
replay-testnet / replay-verify (17) 1h 42m 🟩
replay-mainnet / replay-verify (3) 1h 40m 🟩
replay-testnet / replay-verify (15) 1h 38m 🟩
forge-compat-test / forge 1h 32m 🟩🟩🟩🟥 (+3 more)
replay-testnet / replay-verify (11) 1h 31m 🟩
rust-move-tests 1h 24m 🟩🟩🟩🟩 (+4 more)
replay-testnet / replay-verify (2) 1h 21m 🟩
replay-testnet / replay-verify (0) 1h 18m 🟩
replay-testnet / replay-verify (6) 1h 16m 🟩
replay-mainnet / replay-verify (9) 1h 16m 🟩
replay-testnet / replay-verify (12) 1h 15m 🟩
replay-mainnet / replay-verify (6) 1h 13m 🟩
replay-mainnet / replay-verify (13) 1h 6m 🟩
replay-testnet / replay-verify (13) 1h 1m 🟩
replay-mainnet / replay-verify (8) 1h 1m 🟩
replay-mainnet / replay-verify (7) 1h 1m 🟩
replay-testnet / replay-verify (1) 59m 🟩
replay-testnet / replay-verify (4) 58m 🟩
replay-testnet / replay-verify (14) 56m 🟩
replay-testnet / replay-verify (5) 53m 🟩
replay-testnet / replay-verify (7) 47m 🟩
replay-mainnet / replay-verify (4) 47m 🟩
replay-testnet / replay-verify (3) 44m 🟩
rust-lints 43m 🟩🟩🟩🟩🟩 (+3 more)
replay-mainnet / replay-verify (5) 43m 🟩
run-tests-main-branch 42m 🟩🟩🟩🟩🟩 (+5 more)
replay-mainnet / replay-verify (2) 36m 🟩
cli-e2e-tests / run-cli-tests 35m 🟩🟩🟩🟩 (+2 more)
rust-build-cached-packages 35m 🟩🟩🟩🟩🟩 (+3 more)
replay-mainnet / replay-verify (0) 35m 🟩
check 32m 🟩🟩🟩🟩🟩 (+3 more)
replay-mainnet / replay-verify (1) 19m 🟩
general-lints 14m 🟩🟩🟩🟩🟩 (+3 more)
check-dynamic-deps 11m 🟩🟩🟩🟩🟩 (+4 more)
indexer-grpc-e2e-tests / test-indexer-grpc-docker-compose 11m 🟥🟩🟥🟩 (+2 more)
node-api-compatibility-tests / node-api-compatibility-tests 6m 🟩🟩🟩🟩 (+2 more)
framework-upgrade-determinator 5m 🟥🟥
semgrep/ci 4m 🟩🟩🟩🟩🟩 (+4 more)
file_change_determinator 2m 🟩🟩🟩🟩🟩 (+5 more)
file_change_determinator 2m 🟩🟩🟩🟩🟩 (+5 more)
execution-performance / file_change_determinator 2m 🟩🟩🟩🟩🟩 (+4 more)
file_change_determinator 2m 🟩🟩🟩🟩🟩 (+3 more)
permission-check 32s 🟩🟩🟩🟩🟩 (+6 more)
permission-check 32s 🟩🟩🟩🟩🟩 (+6 more)
permission-check 31s 🟩🟩🟩🟩🟩 (+5 more)
permission-check 31s 🟩🟩🟩🟩🟩 (+6 more)
determine-docker-build-metadata 24s 🟩🟩🟩🟩🟩 (+5 more)
permission-check 23s 🟩🟩🟩🟩🟩 (+6 more)
determine-test-metadata 7s 🟩

🚨 1 job on the last run was significantly faster/slower than expected

Job Duration vs 7d avg Delta
rust-targeted-unit-tests 22m 16m +35%

settingsfeedbackdocs ⋅ learn more about trunk.io

This comment has been minimized.

This comment has been minimized.

Copy link

codecov bot commented Apr 25, 2024

Codecov Report

Attention: Patch coverage is 90.11544% with 137 lines in your changes missing coverage. Please review.

Project coverage is 58.6%. Comparing base (bbce0f1) to head (1f99379).
Report is 1 commits behind head on main.

Files Patch % Lines
...ove/move-vm/types/src/loaded_data/runtime_types.rs 94.9% 50 Missing ⚠️
aptos-move/aptos-vm/src/move_vm_ext/vm.rs 0.0% 22 Missing ⚠️
aptos-move/aptos-vm/src/aptos_vm.rs 0.0% 19 Missing ⚠️
...ptos-vm/src/verifier/transaction_arg_validation.rs 0.0% 19 Missing ⚠️
...aptos-gas-schedule/src/gas_schedule/transaction.rs 0.0% 10 Missing ⚠️
third_party/move/move-vm/runtime/src/loader/mod.rs 92.2% 8 Missing ⚠️
third_party/move/move-vm/runtime/src/session.rs 0.0% 3 Missing ⚠️
types/src/on_chain_config/aptos_features.rs 25.0% 3 Missing ⚠️
types/src/vm/configs.rs 0.0% 2 Missing ⚠️
aptos-move/aptos-vm/src/gas.rs 0.0% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             main   #13028     +/-   ##
=========================================
+ Coverage    58.4%    58.6%   +0.1%     
=========================================
  Files         823      823             
  Lines      197664   198412    +748     
=========================================
+ Hits       115603   116369    +766     
+ Misses      82061    82043     -18     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

Copy link
Contributor

@vgao1996 vgao1996 left a comment

Choose a reason for hiding this comment

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

As we discussed offline

  1. The core logic looks good
  2. Both the old and new checks need feature-gating
  3. Better make the limits configurable (can store those as part of the gas schedule, and then pass those values into the vm config)
  4. It sounds like a good idea to incorporate your type builder work into this, providing a context that can carry the configs

@runtian-zhou
Copy link
Contributor

Are we going to bundle this change with type builder then?

@georgemitenkov georgemitenkov changed the title [move] Fix calculation of instantiation nodes in substitution [move] Type builder & fix calculation of node count in types Apr 29, 2024

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

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 1f99379161e1734836e2940192b98405516be43c

two traffics test: inner traffic : committed: 9400.268190577093 txn/s, latency: 4183.229495239363 ms, (p50: 4200 ms, p90: 4500 ms, p99: 7500 ms), latency samples: 4056180
two traffics test : committed: 100.0003799910461 txn/s, latency: 2017.1208791208792 ms, (p50: 1900 ms, p90: 2200 ms, p99: 4900 ms), latency samples: 1820
Latency breakdown for phase 0: ["QsBatchToPos: max: 0.233, avg: 0.213", "QsPosToProposal: max: 1.990, avg: 1.930", "ConsensusProposalToOrdered: max: 0.304, avg: 0.284", "ConsensusOrderedToCommit: max: 0.368, avg: 0.359", "ConsensusProposalToCommit: max: 0.651, avg: 0.642"]
Max round gap was 1 [limit 4] at version 1878579. Max no progress secs was 5.295248 [limit 15] at version 1878579.
Test Ok

Copy link
Contributor

✅ Forge suite compat success on a68e71c05caebf01504d4499110f3fba213fb53d ==> 1f99379161e1734836e2940192b98405516be43c

Compatibility test results for a68e71c05caebf01504d4499110f3fba213fb53d ==> 1f99379161e1734836e2940192b98405516be43c (PR)
1. Check liveness of validators at old version: a68e71c05caebf01504d4499110f3fba213fb53d
compatibility::simple-validator-upgrade::liveness-check : committed: 9851.572614374585 txn/s, latency: 3411.027865528282 ms, (p50: 2600 ms, p90: 6600 ms, p99: 21400 ms), latency samples: 374800
2. Upgrading first Validator to new version: 1f99379161e1734836e2940192b98405516be43c
compatibility::simple-validator-upgrade::single-validator-upgrade : committed: 6054.119942842393 txn/s, latency: 5002.675812156754 ms, (p50: 4900 ms, p90: 7300 ms, p99: 8400 ms), latency samples: 214860
3. Upgrading rest of first batch to new version: 1f99379161e1734836e2940192b98405516be43c
compatibility::simple-validator-upgrade::half-validator-upgrade : committed: 7007.379690657908 txn/s, latency: 4291.523570204781 ms, (p50: 4200 ms, p90: 6000 ms, p99: 6500 ms), latency samples: 245140
4. upgrading second batch to new version: 1f99379161e1734836e2940192b98405516be43c
compatibility::simple-validator-upgrade::rest-validator-upgrade : committed: 10059.237951597886 txn/s, latency: 3039.5250381213787 ms, (p50: 2700 ms, p90: 5100 ms, p99: 6000 ms), latency samples: 327900
5. check swarm health
Compatibility test for a68e71c05caebf01504d4499110f3fba213fb53d ==> 1f99379161e1734836e2940192b98405516be43c passed
Test Ok

Copy link
Contributor

✅ Forge suite framework_upgrade success on a68e71c05caebf01504d4499110f3fba213fb53d ==> 1f99379161e1734836e2940192b98405516be43c

Compatibility test results for a68e71c05caebf01504d4499110f3fba213fb53d ==> 1f99379161e1734836e2940192b98405516be43c (PR)
Upgrade the nodes to version: 1f99379161e1734836e2940192b98405516be43c
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 1308.8385833929256 txn/s, submitted: 1313.1823271631379 txn/s, failed submission: 4.343743770212329 txn/s, expired: 4.343743770212329 txn/s, latency: 2442.0712751091705 ms, (p50: 1800 ms, p90: 3900 ms, p99: 9600 ms), latency samples: 114500
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 1100.3376235420958 txn/s, submitted: 1101.522055860225 txn/s, failed submission: 1.1844323181292742 txn/s, expired: 1.1844323181292742 txn/s, latency: 2902.248040904198 ms, (p50: 2100 ms, p90: 5400 ms, p99: 10500 ms), latency samples: 92900
5. check swarm health
Compatibility test for a68e71c05caebf01504d4499110f3fba213fb53d ==> 1f99379161e1734836e2940192b98405516be43c passed
Upgrade the remaining nodes to version: 1f99379161e1734836e2940192b98405516be43c
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 1150.9964029119078 txn/s, submitted: 1153.6628038452943 txn/s, failed submission: 2.666400933386659 txn/s, expired: 2.666400933386659 txn/s, latency: 2718.3374613899614 ms, (p50: 2100 ms, p90: 4500 ms, p99: 10200 ms), latency samples: 103600
Test Ok

@georgemitenkov georgemitenkov merged commit ac636d2 into main Jun 12, 2024
47 checks passed
@georgemitenkov georgemitenkov deleted the george/types branch June 12, 2024 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CICD:run-e2e-tests when this label is present github actions will run all land-blocking e2e tests from the PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants