Skip to content

Commit

Permalink
move: source service rename SourcePackages -> SourcePackage (MystenLa…
Browse files Browse the repository at this point in the history
…bs#14264)

## Description 

See inline comment.

## Test Plan 

Updated types and semantics-preserving change.

---
If your changes are not user-facing and not a breaking change, you can
skip the following section. Otherwise, please indicate what changed, and
then add to the Release Notes section as highlighted during the release
process.

### Type of Change (Check all that apply)

- [ ] protocol change
- [ ] user-visible impact
- [ ] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration

### Release notes
  • Loading branch information
rvantonder authored and jonas-lj committed Nov 2, 2023
1 parent dcb46cf commit 626eb32
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
18 changes: 9 additions & 9 deletions crates/sui-source-validation-service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ pub fn host_port() -> String {

#[derive(Deserialize, Debug)]
pub struct Config {
pub packages: Vec<PackageSources>,
pub packages: Vec<PackageSource>,
}

#[derive(Deserialize, Debug)]
#[serde(tag = "source", content = "values")]
pub enum PackageSources {
pub enum PackageSource {
Repository(RepositorySource),
Directory(DirectorySource),
}
Expand Down Expand Up @@ -305,8 +305,8 @@ pub async fn initialize(config: &Config, dir: &Path) -> anyhow::Result<NetworkLo
let mut repos = vec![];
for s in &config.packages {
match s {
PackageSources::Repository(r) => repos.push(r),
PackageSources::Directory(_) => (), /* skip cloning */
PackageSource::Repository(r) => repos.push(r),
PackageSource::Directory(_) => (), /* skip cloning */
}
}
clone_repositories(repos, dir).await?;
Expand All @@ -317,7 +317,7 @@ pub async fn verify_packages(config: &Config, dir: &Path) -> anyhow::Result<Netw
let mut tasks = vec![];
for p in &config.packages {
match p {
PackageSources::Repository(r) => {
PackageSource::Repository(r) => {
let repo_name = repo_name_from_url(&r.repository)?;
let network_name = r.network.clone().unwrap_or_default().to_string();
let packages_dir = dir.join(network_name).join(repo_name);
Expand All @@ -329,7 +329,7 @@ pub async fn verify_packages(config: &Config, dir: &Path) -> anyhow::Result<Netw
tasks.push(t)
}
}
PackageSources::Directory(packages_dir) => {
PackageSource::Directory(packages_dir) => {
for p in &packages_dir.packages {
let package_path = PathBuf::from(p.path.clone());
let network = packages_dir.network.clone().unwrap_or_default();
Expand Down Expand Up @@ -368,15 +368,15 @@ pub async fn verify_packages(config: &Config, dir: &Path) -> anyhow::Result<Netw
// falsely report outdated sources for a package. Pass an optional `channel` to observe the upgrade transaction(s).
// The `channel` parameter exists for testing.
pub async fn watch_for_upgrades(
packages: Vec<PackageSources>,
packages: Vec<PackageSource>,
app_state: Arc<RwLock<AppState>>,
channel: Option<Sender<SuiTransactionBlockEffects>>,
) -> anyhow::Result<()> {
let mut watch_ids = ArrayParams::new();
for s in packages {
let packages = match s {
PackageSources::Repository(RepositorySource { packages, .. }) => packages,
PackageSources::Directory(DirectorySource { packages, .. }) => packages,
PackageSource::Repository(RepositorySource { packages, .. }) => packages,
PackageSource::Directory(DirectorySource { packages, .. }) => packages,
};
for p in packages {
if let Some(id) = p.watch {
Expand Down
6 changes: 3 additions & 3 deletions crates/sui-source-validation-service/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use move_core_types::account_address::AccountAddress;
use move_symbol_pool::Symbol;
use sui_source_validation_service::{
host_port, initialize, serve, verify_packages, watch_for_upgrades, AppState, CloneCommand,
Config, DirectorySource, ErrorResponse, Network, NetworkLookup, Package, PackageSources,
Config, DirectorySource, ErrorResponse, Network, NetworkLookup, Package, PackageSource,
RepositorySource, SourceInfo, SourceLookup, SourceResponse,
SUI_SOURCE_VALIDATION_VERSION_HEADER,
};
Expand Down Expand Up @@ -79,7 +79,7 @@ async fn test_end_to_end() -> anyhow::Result<()> {

// Set up source service config to watch the upgrade cap.
let config = Config {
packages: vec![PackageSources::Directory(DirectorySource {
packages: vec![PackageSource::Directory(DirectorySource {
packages: vec![Package {
path: "unused".into(),
watch: Some(cap.reference.object_id), // watch the upgrade cap
Expand Down Expand Up @@ -121,7 +121,7 @@ async fn test_end_to_end() -> anyhow::Result<()> {
// Test verify_packages
//////////////////////////
let config = Config {
packages: vec![PackageSources::Repository(RepositorySource {
packages: vec![PackageSource::Repository(RepositorySource {
repository: "https://github.com/mystenlabs/sui".into(),
branch: "main".into(),
packages: vec![Package {
Expand Down

0 comments on commit 626eb32

Please sign in to comment.