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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

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.

}

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

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

/// 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

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

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

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.

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