Skip to content

Commit

Permalink
commit devnetv1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MangoNetworkOs committed Dec 11, 2024
1 parent 7e589cb commit fc7a735
Show file tree
Hide file tree
Showing 72 changed files with 15,972 additions and 91 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Move.lock
!crates/mgo-framework/packages/move-stdlib/Move.lock
!crates/mgo-framework/packages/mgo-framework/Move.lock
!crates/mgo-framework/packages/mgo-system/Move.lock
!crates/mgo-framework/packages/mgo-inscription/Move.lock
.trace
.coverage_map.mvcov

Expand Down
30 changes: 15 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions consensus/config/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use fastcrypto::{
bls12381, ed25519,
hash::{Blake2b256, HashFunction},
hash::{Keccak256, HashFunction},
};
use shared_crypto::intent::INTENT_PREFIX_LENGTH;

Expand Down Expand Up @@ -31,6 +31,6 @@ pub type ProtocolPrivateKey = bls12381::min_sig::BLS12381PrivateKey;
pub type ProtocolKeyPair = bls12381::min_sig::BLS12381KeyPair;

/// For block digest.
pub type DefaultHashFunction = Blake2b256;
pub type DefaultHashFunction = Keccak256;
pub const DIGEST_LENGTH: usize = DefaultHashFunction::OUTPUT_SIZE;
pub const INTENT_MESSAGE_LENGTH: usize = INTENT_PREFIX_LENGTH + DIGEST_LENGTH;
25 changes: 20 additions & 5 deletions crates/data-transform/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,30 @@ impl ModuleResolver for GrootModuleResolver {
fn get_module(&self, id: &ModuleId) -> Result<Option<Vec<u8>>, Self::Error> {
let address = id.address();
println!("address = {}", address);
let mapped_address = map_typus_address(address);
let module_id = ModuleId::new(mapped_address, id.name().to_owned());
if &module_id != id {
println!("remapped module from {:#?} to {:#?}", id, module_id);
if is_move_inscription(address) {
let module_name = id.name().to_string();
println!("i am groot, module_name: {}", module_name);
Ok(self.module_map.get(&module_name).cloned())
} else {
let mapped_address = map_typus_address(address);
let module_id = ModuleId::new(mapped_address, id.name().to_owned());
if &module_id != id {
println!("remapped module from {:#?} to {:#?}", id, module_id);
}
self.original.get_module(&module_id)
}
self.original.get_module(&module_id)
}
}

static MOVE_INSCRIPTION: Lazy<AccountAddress> = Lazy::new(|| {
AccountAddress::from_str("0x0000000000000000000000000000000000000000000000000000000000000004")
.unwrap()
});

fn is_move_inscription(address: &AccountAddress) -> bool {
address == &*MOVE_INSCRIPTION
}

static TYPUS_LATEST: Lazy<AccountAddress> = Lazy::new(|| {
AccountAddress::from_str("0xec2cc88cc1ba1da7a936ece33417634e18618e6898e496a3493d8f58d97e705b")
.unwrap()
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
9 changes: 9 additions & 0 deletions crates/mgo-framework-snapshot/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,14 @@
"0x0000000000000000000000000000000000000000000000000000000000000002",
"0x0000000000000000000000000000000000000000000000000000000000000003"
]
},
"3": {
"git_revision": "659ef78-dirty",
"package_ids": [
"0x0000000000000000000000000000000000000000000000000000000000000001",
"0x0000000000000000000000000000000000000000000000000000000000000002",
"0x0000000000000000000000000000000000000000000000000000000000000003",
"0x0000000000000000000000000000000000000000000000000000000000000004"
]
}
}
3 changes: 2 additions & 1 deletion crates/mgo-framework-snapshot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::collections::BTreeMap;
use std::{fs, io::Read, path::PathBuf};
use mgo_framework::SystemPackage;
use mgo_types::base_types::ObjectID;
use mgo_types::{MOVE_STDLIB_PACKAGE_ID, MGO_FRAMEWORK_PACKAGE_ID, MGO_SYSTEM_PACKAGE_ID, };
use mgo_types::{MOVE_STDLIB_PACKAGE_ID, MGO_FRAMEWORK_PACKAGE_ID, MGO_SYSTEM_PACKAGE_ID, MGO_INSCRIPTION_PACKAGE_ID};

pub type SnapshotManifest = BTreeMap<u64, SingleSnapshot>;

Expand All @@ -22,6 +22,7 @@ const SYSTEM_PACKAGE_PUBLISH_ORDER: &[ObjectID] = &[
MOVE_STDLIB_PACKAGE_ID,
MGO_FRAMEWORK_PACKAGE_ID,
MGO_SYSTEM_PACKAGE_ID,
MGO_INSCRIPTION_PACKAGE_ID,
];

pub fn load_bytecode_snapshot_manifest() -> SnapshotManifest {
Expand Down
10 changes: 10 additions & 0 deletions crates/mgo-framework-tests/src/unit_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ fn run_mgo_system_tests() {
});
}

#[test]
#[cfg_attr(msim, ignore)]
fn run_mgo_inscription_tests() {
check_move_unit_tests({
let mut buf = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
buf.extend(["..", "mgo-framework", "packages", "mgo-inscription"]);
buf
});
}

#[test]
#[cfg_attr(msim, ignore)]
fn run_examples_move_unit_tests() {
Expand Down
45 changes: 40 additions & 5 deletions crates/mgo-framework/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ fn main() {
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
let packages_path = Path::new(env!("CARGO_MANIFEST_DIR")).join("packages");

let mgo_inscription_path = packages_path.join("mgo-inscription");
let mgo_system_path = packages_path.join("mgo-system");
let mgo_framework_path = packages_path.join("mgo-framework");
let mgo_inscription_path_clone = mgo_inscription_path.clone();
let mgo_system_path_clone = mgo_system_path.clone();
let mgo_framework_path_clone = mgo_framework_path.clone();
let move_stdlib_path = packages_path.join("move-stdlib");
Expand All @@ -30,6 +32,7 @@ fn main() {
.stack_size(16 * 1024 * 1024) // build_packages require bigger stack size on windows.
.spawn(move || {
build_packages(
mgo_inscription_path_clone,
mgo_system_path_clone,
mgo_framework_path_clone,
out_dir,
Expand All @@ -40,6 +43,14 @@ fn main() {
.unwrap();

println!("cargo:rerun-if-changed=build.rs");
println!(
"cargo:return-if-changed={}",
mgo_inscription_path.join("Move.toml").display()
);
println!(
"cargo:return-if-changed={}",
mgo_inscription_path.join("sources").display()
);
println!(
"cargo:rerun-if-changed={}",
mgo_system_path.join("Move.toml").display()
Expand Down Expand Up @@ -67,6 +78,7 @@ fn main() {
}

fn build_packages(
mgo_inscription_path: PathBuf,
mgo_system_path: PathBuf,
mgo_framework_path: PathBuf,
out_dir: PathBuf,
Expand All @@ -80,9 +92,11 @@ fn build_packages(
};
debug_assert!(!config.test_mode);
build_packages_with_move_config(
mgo_inscription_path.clone(),
mgo_system_path.clone(),
mgo_framework_path.clone(),
out_dir.clone(),
"mgo-inscription",
"mgo-system",
"mgo-framework",
"move-stdlib",
Expand All @@ -98,9 +112,11 @@ fn build_packages(
..Default::default()
};
build_packages_with_move_config(
mgo_inscription_path,
mgo_system_path,
mgo_framework_path,
out_dir,
"mgo-inscription-test",
"mgo-system-test",
"mgo-framework-test",
"move-stdlib-test",
Expand All @@ -110,9 +126,11 @@ fn build_packages(
}

fn build_packages_with_move_config(
mgo_inscription_path: PathBuf,
mgo_system_path: PathBuf,
mgo_framework_path: PathBuf,
out_dir: PathBuf,
mgo_inscription_dir: &str,
system_dir: &str,
framework_dir: &str,
stdlib_dir: &str,
Expand All @@ -124,26 +142,43 @@ fn build_packages_with_move_config(
run_bytecode_verifier: true,
print_diags_to_stderr: false,
}
.build(mgo_framework_path)
.unwrap();
.build(mgo_framework_path)
.unwrap();
let system_pkg = BuildConfig {
config: config.clone(),
run_bytecode_verifier: true,
print_diags_to_stderr: false,
}
.build(mgo_system_path)
.unwrap();
.build(mgo_system_path)
.unwrap();

let mgo_inscription_pkg = BuildConfig {
config,
run_bytecode_verifier: true,
print_diags_to_stderr: false,
}
.build(mgo_inscription_path)
.unwrap();

let mgo_system = system_pkg.get_mgo_system_modules();
let mgo_framework = framework_pkg.get_mgo_framework_modules();
let mgo_inscription = mgo_inscription_pkg.get_mgo_inscription_modules();
let move_stdlib = framework_pkg.get_stdlib_modules();

serialize_modules_to_file(mgo_system, &out_dir.join(system_dir)).unwrap();
serialize_modules_to_file(mgo_framework, &out_dir.join(framework_dir)).unwrap();
serialize_modules_to_file(mgo_inscription, &out_dir.join(mgo_inscription_dir)).unwrap();
serialize_modules_to_file(move_stdlib, &out_dir.join(stdlib_dir)).unwrap();
// write out generated docs
// TODO: remove docs of deleted files
if write_docs {
for (fname, doc) in mgo_inscription_pkg.package.compiled_docs.unwrap() {
let mut dst_path = PathBuf::from(DOCS_DIR);
dst_path.push(mgo_inscription_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 All @@ -162,7 +197,7 @@ fn build_packages_with_move_config(
}

fn serialize_modules_to_file<'a>(
modules: impl Iterator<Item = &'a CompiledModule>,
modules: impl Iterator<Item=&'a CompiledModule>,
file: &Path,
) -> Result<()> {
let mut serialized_modules = Vec::new();
Expand Down
Loading

0 comments on commit fc7a735

Please sign in to comment.