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

[script-composer] Add infer functionality, fix multiple return values #15438

Conversation

runtian-zhou
Copy link
Contributor

@runtian-zhou runtian-zhou commented Dec 2, 2024

Description

Fixes two issues for the script composer:

  1. The current code handled call convention incorrectly. The returned values are stored in the reverse order.
  2. Infer the operation type for copyable and droppable values, so that caller wouldn't need to distinguish between copy and move for those primitive values.

How Has This Been Tested?

Added three test cases:

  1. Created a function to return two values and make sure it can be stored properly.
  2. Created a transaction that invokes a function that returned a copyable and droppable value, and use the destructor twice. This can be built properly (positive case)
  3. Created a transaction that invokes a function that returned a droppable but not copyable value, and use the destructor twice. Builder will complain on this case (negative case)

Key Areas to Review

Whether we tested the two features sufficiently.

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

Copy link

trunk-io bot commented Dec 2, 2024

⏱️ 1h 14m total CI duration on this PR
Slowest 15 Jobs Cumulative Duration Recent Runs
rust-move-tests 13m 🟩
rust-move-tests 13m
rust-move-tests 13m 🟩
rust-cargo-deny 6m 🟩🟩🟩
rust-doc-tests 5m 🟩
check-dynamic-deps 5m 🟩🟩🟩🟩
execution-performance / test-target-determinator 4m 🟩
test-target-determinator 4m 🟩
check 4m 🟩
fetch-last-released-docker-image-tag 2m 🟩
general-lints 2m 🟩🟩🟩🟩
semgrep/ci 1m 🟩🟩🟩🟩
file_change_determinator 40s 🟩🟩🟩🟩
rust-move-tests 30s
file_change_determinator 11s 🟩

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

Job Duration vs 7d avg Delta
execution-performance / single-node-performance 10s 22m -99%

settingsfeedbackdocs ⋅ learn more about trunk.io

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@runtian-zhou runtian-zhou force-pushed the 12-02-_script-composer_add_infer_functionality_fix_multiple_return_values branch from c573176 to 7f016d4 Compare December 2, 2024 12:46
@runtian-zhou runtian-zhou marked this pull request as ready for review December 2, 2024 12:49
script
.code
.code
.push(Bytecode::StLoc((arg + parameters_count) as u8));
.push(Bytecode::StLoc((*arg + parameters_count) as u8));
Copy link
Contributor

Choose a reason for hiding this comment

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

Although not part of this PR, do we check for "returns + parameters < 255", or does that happen later when running the script?

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 will be checked by the bytecode verifier. But I added a check so that the user can be prompted earlier and not having to see the lengthy bytecode verifier error.

Copy link
Contributor

Choose a reason for hiding this comment

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

@runtian-zhou There are a bunch of as u* casts in this file, but it is not clear if all of those are safe casts. E.g., num_of_calls unconditionally cast to u16.

For example, in the case above, without the check for u8::MAX, the value would get silently truncated and have incorrect code generated. It is likely that something downstream (like the bytecode verifier) would catch it, but might be good to add checks here in the builder (unless some of these are checked earlier somewhere).

@runtian-zhou runtian-zhou force-pushed the 12-02-_script-composer_add_infer_functionality_fix_multiple_return_values branch from 7f016d4 to 8994fd1 Compare December 4, 2024 01:56
@runtian-zhou runtian-zhou enabled auto-merge (squash) December 4, 2024 01:57

This comment has been minimized.

This comment has been minimized.

Copy link
Contributor

github-actions bot commented Dec 4, 2024

✅ Forge suite realistic_env_max_load success on 8994fd1709b8e712adb8e7db8d3a1fa0456f673f

two traffics test: inner traffic : committed: 14021.38 txn/s, latency: 2833.90 ms, (p50: 2700 ms, p70: 2700, p90: 3000 ms, p99: 5700 ms), latency samples: 5331260
two traffics test : committed: 100.10 txn/s, latency: 1606.55 ms, (p50: 1400 ms, p70: 1500, p90: 2000 ms, p99: 6800 ms), latency samples: 1780
Latency breakdown for phase 0: ["MempoolToBlockCreation: max: 2.325, avg: 1.419", "ConsensusProposalToOrdered: max: 0.326, avg: 0.295", "ConsensusOrderedToCommit: max: 0.381, avg: 0.368", "ConsensusProposalToCommit: max: 0.673, avg: 0.664"]
Max non-epoch-change gap was: 0 rounds at version 0 (avg 0.00) [limit 4], 0.98s no progress at version 2775649 (avg 0.20s) [limit 15].
Max epoch-change gap was: 0 rounds at version 0 (avg 0.00) [limit 4], 15.79s no progress at version 2775647 (avg 15.79s) [limit 16].
Test Ok

Copy link
Contributor

github-actions bot commented Dec 4, 2024

✅ Forge suite compat success on 3527aa2e299553b759c515d9843586bad48c802c ==> 8994fd1709b8e712adb8e7db8d3a1fa0456f673f

Compatibility test results for 3527aa2e299553b759c515d9843586bad48c802c ==> 8994fd1709b8e712adb8e7db8d3a1fa0456f673f (PR)
1. Check liveness of validators at old version: 3527aa2e299553b759c515d9843586bad48c802c
compatibility::simple-validator-upgrade::liveness-check : committed: 14695.33 txn/s, latency: 2315.59 ms, (p50: 2100 ms, p70: 2100, p90: 2300 ms, p99: 6900 ms), latency samples: 475540
2. Upgrading first Validator to new version: 8994fd1709b8e712adb8e7db8d3a1fa0456f673f
compatibility::simple-validator-upgrade::single-validator-upgrading : committed: 6775.68 txn/s, latency: 4233.22 ms, (p50: 4800 ms, p70: 5100, p90: 5200 ms, p99: 5300 ms), latency samples: 123240
compatibility::simple-validator-upgrade::single-validator-upgrade : committed: 6347.82 txn/s, latency: 5132.77 ms, (p50: 5200 ms, p70: 5400, p90: 6800 ms, p99: 7300 ms), latency samples: 223760
3. Upgrading rest of first batch to new version: 8994fd1709b8e712adb8e7db8d3a1fa0456f673f
compatibility::simple-validator-upgrade::half-validator-upgrading : committed: 4792.33 txn/s, latency: 6181.34 ms, (p50: 6900 ms, p70: 7300, p90: 7400 ms, p99: 7500 ms), latency samples: 96560
compatibility::simple-validator-upgrade::half-validator-upgrade : committed: 4859.99 txn/s, latency: 6681.42 ms, (p50: 7300 ms, p70: 7500, p90: 7600 ms, p99: 8000 ms), latency samples: 173920
4. upgrading second batch to new version: 8994fd1709b8e712adb8e7db8d3a1fa0456f673f
compatibility::simple-validator-upgrade::rest-validator-upgrading : committed: 11137.77 txn/s, latency: 2509.58 ms, (p50: 2600 ms, p70: 2900, p90: 3300 ms, p99: 3500 ms), latency samples: 193940
compatibility::simple-validator-upgrade::rest-validator-upgrade : committed: 10924.30 txn/s, latency: 2895.16 ms, (p50: 2800 ms, p70: 3200, p90: 3700 ms, p99: 4800 ms), latency samples: 355760
5. check swarm health
Compatibility test for 3527aa2e299553b759c515d9843586bad48c802c ==> 8994fd1709b8e712adb8e7db8d3a1fa0456f673f passed
Test Ok

@runtian-zhou runtian-zhou merged commit c0b97e2 into main Dec 4, 2024
84 of 88 checks passed
@runtian-zhou runtian-zhou deleted the 12-02-_script-composer_add_infer_functionality_fix_multiple_return_values branch December 4, 2024 02:29
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