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

[native bridge move code 1/n] - native bridge move package #16259

Merged
merged 7 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -25,6 +26,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
36 changes: 35 additions & 1 deletion crates/sui-framework/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,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 @@ -43,6 +46,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 @@ -70,6 +81,7 @@ fn main() {
}

fn build_packages(
bridge_path: PathBuf,
deepbook_path: PathBuf,
sui_system_path: PathBuf,
sui_framework_path: PathBuf,
Expand All @@ -84,10 +96,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 @@ -104,10 +118,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 @@ -118,10 +134,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 @@ -144,21 +162,30 @@ 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();

serialize_modules_to_file(sui_system, &out_dir.join(system_dir)).unwrap();
serialize_modules_to_file(sui_framework, &out_dir.join(framework_dir)).unwrap();
serialize_modules_to_file(deepbook, &out_dir.join(deepbook_dir)).unwrap();
serialize_modules_to_file(bridge, &out_dir.join(bridge_dir)).unwrap();
serialize_modules_to_file(move_stdlib, &out_dir.join(stdlib_dir)).unwrap();
// write out generated docs
// TODO: remove docs of deleted files
Expand All @@ -170,6 +197,13 @@ fn build_packages_with_move_config(
fs::create_dir_all(dst_path.parent().unwrap()).unwrap();
fs::write(dst_path, doc).unwrap();
}
for (fname, doc) in bridge_pkg.package.compiled_docs.unwrap() {
let mut dst_path = PathBuf::from(DOCS_DIR);
dst_path.push(bridge_dir);
dst_path.push(fname);
fs::create_dir_all(dst_path.parent().unwrap()).unwrap();
fs::write(dst_path, doc).unwrap();
}
for (fname, doc) in system_pkg.package.compiled_docs.unwrap() {
let mut dst_path = PathBuf::from(DOCS_DIR);
dst_path.push(system_dir);
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
Loading