Skip to content

Commit

Permalink
remove legacy framework
Browse files Browse the repository at this point in the history
  • Loading branch information
simonjiao committed Dec 13, 2024
1 parent b4b9eb3 commit c732099
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 58 deletions.
34 changes: 9 additions & 25 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,6 @@ starcoin-crypto = { git = "https://github.com/starcoinorg/starcoin-crypto", rev
starcoin-decrypt = { path = "commons/decrypt" }
starcoin-dev = { path = "vm/dev" }
starcoin-executor = { path = "executor" }
starcoin-framework-legacy = { git = "https://github.com/starcoinorg/starcoin-framework", rev = "94bcd77e80232b169cf95754ef4e87775645afcd", package = "starcoin-framework" }
starcoin-framework = { path = "vm/framework" }
starcoin-sdk-builder = { path = "vm/starcoin-sdk-builder" }
starcoin-genesis = { path = "genesis" }
Expand Down
5 changes: 1 addition & 4 deletions vm/stdlib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,13 @@ move-bytecode-verifier = { workspace = true }
move-compiler = { workspace = true }
move-prover = { workspace = true }
once_cell = { workspace = true }
serde = { features = ["derive"], workspace = true }
sha2 = { workspace = true }
simplelog = { workspace = true }
starcoin-crypto = { workspace = true }
starcoin-framework = { workspace = true }
starcoin-move-compiler = { workspace = true }
starcoin-vm-types = { workspace = true }
tempfile = { workspace = true }
walkdir = { workspace = true }
starcoin-framework-legacy = { workspace = true }
starcoin-cached-packages = { workspace = true }

[dev-dependencies]
datatest-stable = { workspace = true }
Expand Down
32 changes: 17 additions & 15 deletions vm/stdlib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ use std::{

mod compat;
pub use compat::*;
pub use starcoin_framework_legacy::SourceFiles;
pub use starcoin_move_compiler::utils::iterate_directory;

pub const NO_USE_COMPILED: &str = "MOVE_NO_USE_COMPILED";
Expand All @@ -57,20 +56,22 @@ pub const ERROR_DESC_EXTENSION: &str = "errmap";
pub const ERROR_DESCRIPTIONS: &[u8] =
std::include_bytes!("../compiled/latest/error_descriptions/error_descriptions.errmap");

// XXX FIXME YSG need to remove
pub const STDLIB_DIR: Dir = starcoin_framework_legacy::SOURCES_DIR;

// The current stdlib that is freshly built. This will never be used in deployment so we don't need
// to pull the same trick here in order to include this in the Rust binary.
static G_FRESH_MOVE_LANG_STDLIB: Lazy<Vec<Vec<u8>>> = Lazy::new(|| {
build_stdlib(STARCOIN_FRAMEWORK_SOURCES.files.as_slice())
.values()
.map(|m| {
let mut blob = vec![];
m.serialize(&mut blob).unwrap();
blob
})
.collect()
build_stdlib(
starcoin_cached_packages::head_release_bundle()
.files()
.unwrap()
.as_slice(),
)
.values()
.map(|m| {
let mut blob = vec![];
m.serialize(&mut blob).unwrap();
blob
})
.collect()
});

// This needs to be a string literal due to restrictions imposed by include_bytes.
Expand Down Expand Up @@ -104,8 +105,6 @@ pub static G_COMPILED_STDLIB: Lazy<HashMap<StdlibVersion, Vec<Vec<u8>>>> = Lazy:

pub const SCRIPT_HASH_LENGTH: usize = HashValue::LENGTH;

pub use starcoin_framework_legacy::STARCOIN_FRAMEWORK_SOURCES;

/// Return all versions of stdlib, include latest.
pub fn stdlib_versions() -> Vec<StdlibVersion> {
G_STDLIB_VERSIONS.clone()
Expand Down Expand Up @@ -163,7 +162,10 @@ pub fn module_to_package(
}

pub fn stdlib_files() -> Vec<String> {
STARCOIN_FRAMEWORK_SOURCES.files.clone()
starcoin_cached_packages::head_release_bundle()
.files()
.unwrap()
.clone()
}

pub fn build_stdlib(targets: &[String]) -> BTreeMap<String, CompiledModule> {
Expand Down
21 changes: 8 additions & 13 deletions vm/stdlib/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use itertools::Itertools;
use log::LevelFilter;
use simplelog::{Config, SimpleLogger};
use starcoin_crypto::hash::PlainCryptoHash;
use starcoin_framework_legacy::STARCOIN_FRAMEWORK_SOURCES;
use starcoin_move_compiler::check_compiled_module_compat;
use starcoin_vm_types::account_config::core_code_address;
use starcoin_vm_types::file_format::CompiledModule;
Expand Down Expand Up @@ -140,11 +139,7 @@ fn full_update_with_version(version_number: u64) -> PathBuf {
dest
}

fn replace_stdlib_by_path(
_source_dir: &Path,
module_path: &Path,
new_modules: BTreeMap<String, CompiledModule>,
) {
fn replace_stdlib_by_path(module_path: &Path, new_modules: BTreeMap<String, CompiledModule>) {
if module_path.exists() {
std::fs::remove_dir_all(module_path).unwrap();
}
Expand Down Expand Up @@ -317,8 +312,12 @@ fn main() {
.join("../../vm/stdlib");
std::env::set_current_dir(base_path).expect("failed to change directory");

let sources = &STARCOIN_FRAMEWORK_SOURCES;
let new_modules = build_stdlib(&sources.files);
let new_modules = build_stdlib(
&starcoin_cached_packages::head_release_bundle()

Check failure on line 316 in vm/stdlib/src/main.rs

View workflow job for this annotation

GitHub Actions / build and test

this expression creates a reference which is immediately dereferenced by the compiler
.files()
.unwrap()
.as_slice(),
);

if !no_check_compatibility {
if let Some((pre_stable_version, pre_stable_modules)) = pre_version
Expand Down Expand Up @@ -367,11 +366,7 @@ fn main() {

// Write the stdlib blob
let module_path = PathBuf::from(LATEST_COMPILED_OUTPUT_PATH).join(STDLIB_DIR_NAME);
replace_stdlib_by_path(
sources.tempdir.path(),
module_path.as_path(),
new_modules.clone(),
);
replace_stdlib_by_path(module_path.as_path(), new_modules.clone());
let stdlib_versions = &stdlib::G_STDLIB_VERSIONS;
for version in stdlib_versions.iter() {
let modules = stdlib::load_compiled_modules(*version);
Expand Down

0 comments on commit c732099

Please sign in to comment.