Skip to content

Commit

Permalink
[native bridge move code 1/n] - native bridge move package (#16259)
Browse files Browse the repository at this point in the history
## Description

Describe the changes or additions included in this PR.

## Test Plan

How did you test the new or updated feature?

---
If your changes are not user-facing and do not break anything, you can
skip the following section. Otherwise, please briefly describe what has
changed under the Release Notes section.

### 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
patrickkuo committed May 9, 2024
1 parent 537950f commit f24c965
Show file tree
Hide file tree
Showing 20 changed files with 1,572 additions and 7 deletions.
4 changes: 3 additions & 1 deletion crates/sui-framework-snapshot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ use std::{fs, io::Read, path::PathBuf};
use sui_framework::SystemPackage;
use sui_types::base_types::ObjectID;
use sui_types::{
DEEPBOOK_PACKAGE_ID, MOVE_STDLIB_PACKAGE_ID, SUI_FRAMEWORK_PACKAGE_ID, SUI_SYSTEM_PACKAGE_ID,
BRIDGE_PACKAGE_ID, DEEPBOOK_PACKAGE_ID, MOVE_STDLIB_PACKAGE_ID, SUI_FRAMEWORK_PACKAGE_ID,
SUI_SYSTEM_PACKAGE_ID,
};

pub type SnapshotManifest = BTreeMap<u64, SingleSnapshot>;
Expand All @@ -34,6 +35,7 @@ const SYSTEM_PACKAGE_PUBLISH_ORDER: &[ObjectID] = &[
SUI_FRAMEWORK_PACKAGE_ID,
SUI_SYSTEM_PACKAGE_ID,
DEEPBOOK_PACKAGE_ID,
BRIDGE_PACKAGE_ID,
];

pub fn load_bytecode_snapshot_manifest() -> SnapshotManifest {
Expand Down
31 changes: 30 additions & 1 deletion crates/sui-framework/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,18 @@ fn main() {
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
let packages_path = Path::new(env!("CARGO_MANIFEST_DIR")).join("packages");

let bridge_path = packages_path.join("bridge");
let deepbook_path = packages_path.join("deepbook");
let sui_system_path = packages_path.join("sui-system");
let sui_framework_path = packages_path.join("sui-framework");
let bridge_path_clone = bridge_path.clone();
let deepbook_path_clone = deepbook_path.clone();
let sui_system_path_clone = sui_system_path.clone();
let sui_framework_path_clone = sui_framework_path.clone();
let move_stdlib_path = packages_path.join("move-stdlib");

build_packages(
bridge_path_clone,
deepbook_path_clone,
sui_system_path_clone,
sui_framework_path_clone,
Expand All @@ -46,6 +49,14 @@ fn main() {
"cargo:rerun-if-changed={}",
deepbook_path.join("sources").display()
);
println!(
"cargo:rerun-if-changed={}",
bridge_path.join("Move.toml").display()
);
println!(
"cargo:rerun-if-changed={}",
bridge_path.join("sources").display()
);
println!(
"cargo:rerun-if-changed={}",
sui_system_path.join("Move.toml").display()
Expand Down Expand Up @@ -73,6 +84,7 @@ fn main() {
}

fn build_packages(
bridge_path: PathBuf,
deepbook_path: PathBuf,
sui_system_path: PathBuf,
sui_framework_path: PathBuf,
Expand All @@ -88,10 +100,12 @@ fn build_packages(
};
debug_assert!(!config.test_mode);
build_packages_with_move_config(
bridge_path.clone(),
deepbook_path.clone(),
sui_system_path.clone(),
sui_framework_path.clone(),
out_dir.clone(),
"bridge",
"deepbook",
"sui-system",
"sui-framework",
Expand All @@ -109,10 +123,12 @@ fn build_packages(
..Default::default()
};
build_packages_with_move_config(
bridge_path,
deepbook_path,
sui_system_path,
sui_framework_path,
out_dir,
"bridge-test",
"deepbook-test",
"sui-system-test",
"sui-framework-test",
Expand All @@ -123,10 +139,12 @@ fn build_packages(
}

fn build_packages_with_move_config(
bridge_path: PathBuf,
deepbook_path: PathBuf,
sui_system_path: PathBuf,
sui_framework_path: PathBuf,
out_dir: PathBuf,
bridge_dir: &str,
deepbook_dir: &str,
system_dir: &str,
framework_dir: &str,
Expand All @@ -149,16 +167,24 @@ fn build_packages_with_move_config(
.build(sui_system_path)
.unwrap();
let deepbook_pkg = BuildConfig {
config,
config: config.clone(),
run_bytecode_verifier: true,
print_diags_to_stderr: false,
}
.build(deepbook_path)
.unwrap();
let bridge_pkg = BuildConfig {
config,
run_bytecode_verifier: true,
print_diags_to_stderr: false,
}
.build(bridge_path)
.unwrap();

let sui_system = system_pkg.get_sui_system_modules();
let sui_framework = framework_pkg.get_sui_framework_modules();
let deepbook = deepbook_pkg.get_deepbook_modules();
let bridge = bridge_pkg.get_bridge_modules();
let move_stdlib = framework_pkg.get_stdlib_modules();

let sui_system_members =
Expand All @@ -167,6 +193,7 @@ fn build_packages_with_move_config(
serialize_modules_to_file(sui_framework, &out_dir.join(framework_dir)).unwrap();
let deepbook_members =
serialize_modules_to_file(deepbook, &out_dir.join(deepbook_dir)).unwrap();
let bridge_members = serialize_modules_to_file(bridge, &out_dir.join(bridge_dir)).unwrap();
let stdlib_members = serialize_modules_to_file(move_stdlib, &out_dir.join(stdlib_dir)).unwrap();

// write out generated docs
Expand All @@ -182,6 +209,7 @@ fn build_packages_with_move_config(
&deepbook_pkg.package.compiled_docs.unwrap(),
&mut files_to_write,
);
relocate_docs(bridge_dir);
relocate_docs(
system_dir,
&system_pkg.package.compiled_docs.unwrap(),
Expand All @@ -203,6 +231,7 @@ fn build_packages_with_move_config(
sui_system_members.join("\n"),
sui_framework_members.join("\n"),
deepbook_members.join("\n"),
bridge_members.join("\n"),
stdlib_members.join("\n"),
]
.join("\n");
Expand Down
11 changes: 11 additions & 0 deletions crates/sui-framework/packages/bridge/Move.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "Bridge"
version = "0.0.1"
published-at = "0xb"

[dependencies]
MoveStdlib = { local = "../move-stdlib" }
Sui = { local = "../sui-framework" }

[addresses]
bridge = "0xb"
Loading

0 comments on commit f24c965

Please sign in to comment.