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

[Feature] [Package System] Add option to override standard library version #13318

Merged
merged 12 commits into from
Jun 12, 2024

Conversation

fEst1ck
Copy link
Contributor

@fEst1ck fEst1ck commented May 17, 2024

Description

Closes #13326

Implements a --override-std mainnet/testnet/dev option for overriding the version of standard library (aptos framework, aptos stdlib, move stdlib) as dependencies. For example, if --override-std mainnet is specified, a dependency

[dependencies]
AptosFramework = { ... }

will effectively be overridden by the one from the well-know location for stdlib with the specified version

[dependency]
AptosFramework = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "mainnet", subdir = "aptos-move/framework/aptos-framework" }

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?

Two new tests third_pary/move/tools/move-package/tests/test_sources/compilation/std-lib-{conflicts, override} one showing the problem, one showing the solution.

Copy link

trunk-io bot commented May 17, 2024

⏱️ 2h 16m total CI duration on this PR
Job Cumulative Duration Recent Runs
rust-move-unit-coverage 36m 🟩🟩
rust-targeted-unit-tests 32m 🟥🟩
rust-move-tests 29m 🟩🟥
rust-lints 15m 🟥🟩
run-tests-main-branch 13m 🟩🟩🟩
general-lints 6m 🟩🟩🟩
check-dynamic-deps 4m 🟩🟩🟩
semgrep/ci 1m 🟩🟩🟩
file_change_determinator 31s 🟩🟩🟩
file_change_determinator 30s 🟩🟩🟩
permission-check 9s 🟩🟩🟩
permission-check 7s 🟩🟩🟩
permission-check 7s 🟩🟩🟩
permission-check 6s 🟩🟩🟩

settingsfeedbackdocs ⋅ learn more about trunk.io

@fEst1ck fEst1ck marked this pull request as ready for review May 23, 2024 06:43
@fEst1ck fEst1ck requested review from vgao1996 and removed request for davidiw, gregnazario, banool and movekevin May 23, 2024 18:14
} else {
bail!(
"Invalid verion for standard libraries to override: {}",
version_str
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we say here the expected strings? See also my remark about ValueEnum derive below.

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

}

/// Represents a standard library version.
pub enum StdVersion {
Copy link
Contributor

Choose a reason for hiding this comment

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

You could use #[derive(ValueEnum)] here and then use that type directly in the clap fields instead of strings. I believe this will give an error message about what are the allowed variants.

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

Some(version)
} else {
bail!(
"Invalid verion for standard libraries to override: {}",
Copy link
Contributor

Choose a reason for hiding this comment

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

s/verion/version

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no longer needed

/// Returns the dependency for the standard library with the given version.
pub fn dependency(&self, version: &StdVersion) -> Dependency {
let local =
PathBuf::from(MOVE_HOME.clone()).join(format!("{}_{}", self.as_str(), version.rev()));
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this the same location which is chosen if someone explicitly uses the github dep in their Move.toml? I'm worried that we are potentially double caching the package here. The local path should be the same to avoid this.

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

@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.

(1/2)

Sorry for the delay. Looks great to me so far!

Let me play with the code locally and see if it handles certain details correctly (e.g. the local path).

@@ -109,6 +109,10 @@ pub struct BuildConfig {
#[clap(name = "test-mode", long = "test", global = true)]
pub test_mode: bool,

/// Whether to override the standard library with the given version.
#[clap(long = "override-std", global = true, value_parser)]
pub override_std: Option<String>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah as @wrwg mentioned, you could change this to pub override_std: Option<StdVersion> if you implement the required traits for StdVersion.

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

subdir = "aptos-move/framework/aptos-framework"

[dependencies.B]
local = "./deps_only"
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: the directory name "deps_only" seems a bit confusing to me. Wonder if it would be better to rename this to "intermediate_dep".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The test runner checks for directories containing "deps_only", and doesn't build the packages under that directory.

subst: None,
version: None,
digest: None,
git_info: Some(GitInfo {
Copy link
Contributor

Choose a reason for hiding this comment

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

@wrwg Just to double check: what is the local caching behavior of the git dependencies? Do we update every time the build command is run, or it has to be triggered by some other events?

Specifically I want to understand what's going to happen when we update the branches in the repo.

Copy link
Contributor Author

@fEst1ck fEst1ck Jun 5, 2024

Choose a reason for hiding this comment

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

It depends on whether you set the skip_fetch_latest_git_deps command line argument. If we set it and the local cache exists, we will update the local cache. By default, we don't update the cache and only download if a local copy does not exist. This is implemented in download_and_update_if_remote in resolution_graph.rs.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think its a bit different, skip will actually skip checks, and otherwise we do update. The code is quite convoluted here. https://github.com/aptos-labs/aptos-core/blob/main/third_party/move/tools/move-package/src/resolution/resolution_graph.rs#L558

@fEst1ck
Copy link
Contributor Author

fEst1ck commented Jun 5, 2024

All comments addressed. PTAL @wrwg @vgao1996

@fEst1ck fEst1ck requested review from vgao1996 and wrwg June 5, 2024 08:43
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.

Tried the tool. Seemed to work well. Good job on the work!

@fEst1ck fEst1ck enabled auto-merge (squash) June 12, 2024 00:33

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 compat success on a68e71c05caebf01504d4499110f3fba213fb53d ==> 102ad37137a737d4605c0de885d4a9418d1f5197

Compatibility test results for a68e71c05caebf01504d4499110f3fba213fb53d ==> 102ad37137a737d4605c0de885d4a9418d1f5197 (PR)
1. Check liveness of validators at old version: a68e71c05caebf01504d4499110f3fba213fb53d
compatibility::simple-validator-upgrade::liveness-check : committed: 9604.839707762943 txn/s, latency: 3440.395897622073 ms, (p50: 2600 ms, p90: 6000 ms, p99: 25200 ms), latency samples: 330540
2. Upgrading first Validator to new version: 102ad37137a737d4605c0de885d4a9418d1f5197
compatibility::simple-validator-upgrade::single-validator-upgrade : committed: 1190.6345177417654 txn/s, latency: 19826.48739424704 ms, (p50: 21100 ms, p90: 35200 ms, p99: 38300 ms), latency samples: 59100
3. Upgrading rest of first batch to new version: 102ad37137a737d4605c0de885d4a9418d1f5197
compatibility::simple-validator-upgrade::half-validator-upgrade : committed: 7053.601010095194 txn/s, latency: 4221.626500934276 ms, (p50: 4100 ms, p90: 6100 ms, p99: 6500 ms), latency samples: 246180
4. upgrading second batch to new version: 102ad37137a737d4605c0de885d4a9418d1f5197
compatibility::simple-validator-upgrade::rest-validator-upgrade : committed: 11191.77146612375 txn/s, latency: 2856.9598209939973 ms, (p50: 2700 ms, p90: 5100 ms, p99: 6500 ms), latency samples: 369820
5. check swarm health
Compatibility test for a68e71c05caebf01504d4499110f3fba213fb53d ==> 102ad37137a737d4605c0de885d4a9418d1f5197 passed
Test Ok

Copy link
Contributor

✅ Forge suite realistic_env_max_load success on 102ad37137a737d4605c0de885d4a9418d1f5197

two traffics test: inner traffic : committed: 9466.722947114686 txn/s, latency: 4151.551665051537 ms, (p50: 4100 ms, p90: 4500 ms, p99: 5700 ms), latency samples: 4086360
two traffics test : committed: 100.07957906095359 txn/s, latency: 2050.9255813953487 ms, (p50: 1900 ms, p90: 2100 ms, p99: 6700 ms), latency samples: 1720
Latency breakdown for phase 0: ["QsBatchToPos: max: 0.233, avg: 0.215", "QsPosToProposal: max: 1.973, avg: 1.880", "ConsensusProposalToOrdered: max: 0.312, avg: 0.283", "ConsensusOrderedToCommit: max: 0.370, avg: 0.356", "ConsensusProposalToCommit: max: 0.651, avg: 0.639"]
Max round gap was 1 [limit 4] at version 1969345. Max no progress secs was 5.44278 [limit 15] at version 1969345.
Test Ok

Copy link
Contributor

✅ Forge suite framework_upgrade success on a68e71c05caebf01504d4499110f3fba213fb53d ==> 102ad37137a737d4605c0de885d4a9418d1f5197

Compatibility test results for a68e71c05caebf01504d4499110f3fba213fb53d ==> 102ad37137a737d4605c0de885d4a9418d1f5197 (PR)
Upgrade the nodes to version: 102ad37137a737d4605c0de885d4a9418d1f5197
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 1207.1423830371305 txn/s, submitted: 1209.6229670486023 txn/s, failed submission: 2.4805840114717794 txn/s, expired: 2.4805840114717794 txn/s, latency: 2681.19278909023 ms, (p50: 1800 ms, p90: 4800 ms, p99: 12300 ms), latency samples: 107060
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 1197.073613175412 txn/s, submitted: 1198.023294740803 txn/s, failed submission: 0.9496815653910449 txn/s, expired: 0.9496815653910449 txn/s, latency: 2667.077905593019 ms, (p50: 2100 ms, p90: 4200 ms, p99: 8100 ms), latency samples: 100840
5. check swarm health
Compatibility test for a68e71c05caebf01504d4499110f3fba213fb53d ==> 102ad37137a737d4605c0de885d4a9418d1f5197 passed
Upgrade the remaining nodes to version: 102ad37137a737d4605c0de885d4a9418d1f5197
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 1163.324780666772 txn/s, submitted: 1166.0370202952938 txn/s, failed submission: 2.7122396285217145 txn/s, expired: 2.7122396285217145 txn/s, latency: 2606.9580046629103 ms, (p50: 2100 ms, p90: 4500 ms, p99: 9100 ms), latency samples: 102940
Test Ok

@fEst1ck fEst1ck merged commit bbce0f1 into aptos-labs:main Jun 12, 2024
51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants