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

[Bugfix][Compiler-V2] Fix public(package) causing unit test errors #15627

Merged
merged 4 commits into from
Jan 6, 2025

Conversation

fEst1ck
Copy link
Contributor

@fEst1ck fEst1ck commented Dec 17, 2024

Description

Fixes #15618.

The transformation of public(packge) to public(friend) currently is only done for modules in the current package, but not the dependencies. This becomes an issue when the generated bytecode of dependencies is used, say in the case unit tests.

We fix this by also doing the transformation to the dependency modules. For dependencies, we cannot perform the transformation properly, as there is no way tell if two non-primary target modules are in the same package (see #13745). So we may friend modules outside the current package. If a dependency contains public(packge) visibility violation, say package A contains calls function in package B that calls a public(package) function in package C, this will not be captured in the unit test as either a compiler error or runtime error. However, each package is compiled with it set as primary target before deployment, so a package with package visibility errors will never hit the chain.

How Has This Been Tested?

All existing test cases. Manually tested the example #15618.

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 17, 2024

⏱️ 34m total CI duration on this PR
Job Cumulative Duration Recent Runs
rust-move-tests 13m 🟩
check-dynamic-deps 7m 🟩🟩🟩
rust-move-tests 5m
rust-cargo-deny 4m 🟩🟩
general-lints 2m 🟩🟩🟩
semgrep/ci 1m 🟩🟩🟩
rust-move-tests 47s
file_change_determinator 38s 🟩🟩🟩
permission-check 13s 🟩🟩🟩
permission-check 9s 🟩🟩🟩

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

Job Duration vs 7d avg Delta
check-dynamic-deps 5m 1m +319%

settingsfeedbackdocs ⋅ learn more about trunk.io

@@ -490,7 +490,7 @@ impl<'env> ModelBuilder<'env> {
let target_modules = self
.env
.get_modules()
.filter(|module_env| module_env.is_primary_target() && !module_env.is_script_module())
.filter(|module_env| module_env.is_primary_target() || module_env.is_target() && !module_env.is_script_module())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we also need include non targets?

@@ -490,7 +490,7 @@ impl<'env> ModelBuilder<'env> {
let target_modules = self
.env
.get_modules()
.filter(|module_env| module_env.is_primary_target() && !module_env.is_script_module())
.filter(|module_env| module_env.is_primary_target() || module_env.is_target() && !module_env.is_script_module())
Copy link

Choose a reason for hiding this comment

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

The operator precedence in this condition may not be doing what's intended. Currently !module_env.is_script_module() only applies to the second part of the OR condition. To ensure script modules are filtered out in both cases, consider restructuring as:

!module_env.is_script_module() && (module_env.is_primary_target() || module_env.is_target())

Spotted by Graphite Reviewer

Is this helpful? React 👍 or 👎 to let us know.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@vineethk vineethk left a comment

Choose a reason for hiding this comment

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

Have some comments, approving assuming those are addressed.

!self.is_script_module()
&& !other.is_script_module()
&& other.is_primary_target()
// TODO: fix this when we have a way to check if
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// TODO: fix this when we have a way to check if
// TODO(#13745): fix this when we have a way to check if

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@fEst1ck fEst1ck enabled auto-merge (squash) January 6, 2025 16:52

This comment has been minimized.

This comment has been minimized.

Copy link
Contributor

github-actions bot commented Jan 6, 2025

✅ Forge suite realistic_env_max_load success on 09cba32f7ae78d2d328944cb046f1a951d5341e6

two traffics test: inner traffic : committed: 14871.16 txn/s, latency: 2673.31 ms, (p50: 2700 ms, p70: 2700, p90: 2900 ms, p99: 3200 ms), latency samples: 5654460
two traffics test : committed: 99.98 txn/s, latency: 1364.36 ms, (p50: 1300 ms, p70: 1400, p90: 1500 ms, p99: 4000 ms), latency samples: 1800
Latency breakdown for phase 0: ["MempoolToBlockCreation: max: 1.566, avg: 1.515", "ConsensusProposalToOrdered: max: 0.291, avg: 0.287", "ConsensusOrderedToCommit: max: 0.304, avg: 0.296", "ConsensusProposalToCommit: max: 0.592, avg: 0.583"]
Max non-epoch-change gap was: 0 rounds at version 0 (avg 0.00) [limit 4], 0.51s no progress at version 523 (avg 0.19s) [limit 15].
Max epoch-change gap was: 0 rounds at version 0 (avg 0.00) [limit 4], 0.58s no progress at version 2668497 (avg 0.58s) [limit 16].
Test Ok

Copy link
Contributor

github-actions bot commented Jan 6, 2025

✅ Forge suite compat success on 6593fb81261f25490ffddc2252a861c994234c2a ==> 09cba32f7ae78d2d328944cb046f1a951d5341e6

Compatibility test results for 6593fb81261f25490ffddc2252a861c994234c2a ==> 09cba32f7ae78d2d328944cb046f1a951d5341e6 (PR)
1. Check liveness of validators at old version: 6593fb81261f25490ffddc2252a861c994234c2a
compatibility::simple-validator-upgrade::liveness-check : committed: 14918.74 txn/s, latency: 2150.70 ms, (p50: 1700 ms, p70: 1800, p90: 2100 ms, p99: 23100 ms), latency samples: 531400
2. Upgrading first Validator to new version: 09cba32f7ae78d2d328944cb046f1a951d5341e6
compatibility::simple-validator-upgrade::single-validator-upgrading : committed: 5227.61 txn/s, latency: 5864.46 ms, (p50: 6700 ms, p70: 7200, p90: 7300 ms, p99: 7500 ms), latency samples: 103060
compatibility::simple-validator-upgrade::single-validator-upgrade : committed: 4940.16 txn/s, latency: 6906.29 ms, (p50: 7400 ms, p70: 7500, p90: 7600 ms, p99: 7900 ms), latency samples: 178160
3. Upgrading rest of first batch to new version: 09cba32f7ae78d2d328944cb046f1a951d5341e6
compatibility::simple-validator-upgrade::half-validator-upgrading : committed: 6624.65 txn/s, latency: 4512.07 ms, (p50: 5200 ms, p70: 5500, p90: 5700 ms, p99: 5800 ms), latency samples: 125560
compatibility::simple-validator-upgrade::half-validator-upgrade : committed: 6577.64 txn/s, latency: 5168.57 ms, (p50: 5600 ms, p70: 5700, p90: 5900 ms, p99: 6100 ms), latency samples: 226300
4. upgrading second batch to new version: 09cba32f7ae78d2d328944cb046f1a951d5341e6
compatibility::simple-validator-upgrade::rest-validator-upgrading : committed: 10078.91 txn/s, latency: 2893.44 ms, (p50: 2700 ms, p70: 3300, p90: 4600 ms, p99: 4700 ms), latency samples: 184260
compatibility::simple-validator-upgrade::rest-validator-upgrade : committed: 9852.74 txn/s, latency: 3282.12 ms, (p50: 2800 ms, p70: 4100, p90: 5000 ms, p99: 5000 ms), latency samples: 331260
5. check swarm health
Compatibility test for 6593fb81261f25490ffddc2252a861c994234c2a ==> 09cba32f7ae78d2d328944cb046f1a951d5341e6 passed
Test Ok

@fEst1ck fEst1ck merged commit 20e25a4 into aptos-labs:main Jan 6, 2025
80 of 88 checks passed
georgemitenkov pushed a commit that referenced this pull request Jan 6, 2025
…15627)

* tmp fix

* bugfix

* format

* fix bug and comment

---------

Co-authored-by: Zekun Wang <[email protected]>
rahxephon89 pushed a commit that referenced this pull request Jan 7, 2025
…15627)

* tmp fix

* bugfix

* format

* fix bug and comment

---------

Co-authored-by: Zekun Wang <[email protected]>
igor-aptos pushed a commit that referenced this pull request Jan 7, 2025
…15627)

* tmp fix

* bugfix

* format

* fix bug and comment

---------

Co-authored-by: Zekun Wang <[email protected]>
igor-aptos pushed a commit that referenced this pull request Jan 10, 2025
…15627)

* tmp fix

* bugfix

* format

* fix bug and comment

---------

Co-authored-by: Zekun Wang <[email protected]>
igor-aptos pushed a commit that referenced this pull request Jan 10, 2025
…15627)

* tmp fix

* bugfix

* format

* fix bug and comment

---------

Co-authored-by: Zekun Wang <[email protected]>
igor-aptos pushed a commit that referenced this pull request Jan 10, 2025
…15627)

* tmp fix

* bugfix

* format

* fix bug and comment

---------

Co-authored-by: Zekun Wang <[email protected]>
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.

[Bug][compiler-v2] public(package) causes unit test errors
3 participants