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

Upgrade StarcoinFramework to latest #3718

Closed
wants to merge 3 commits into from
Closed
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
2 changes: 1 addition & 1 deletion Cargo.lock

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

Binary file modified genesis/generated/halley/genesis
Binary file not shown.
2 changes: 1 addition & 1 deletion vm/stdlib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ serde = {version = "1.0.130", default-features = false}
sha2 = "0.10.2"
simplelog = "0.9.0"
starcoin-crypto = {git = "https://github.com/starcoinorg/starcoin-crypto", rev = "d871dfb4216f034ee334a575926c101574d9d6dc"}
starcoin-framework = {git = "https://github.com/starcoinorg/starcoin-framework", rev = "a981f67391256afe1c40ca90938c105b2981a29e"}
starcoin-framework = {git = "https://github.com/starcoinorg/starcoin-framework", rev = "6cccb7395721be0d5037b799830dd85b84658129"}
starcoin-move-compiler = {path = "../../vm/compiler"}
starcoin-vm-types = {path = "../types"}
tempfile = "3.2.0"
Expand Down
Binary file not shown.
Binary file added vm/stdlib/compiled/latest/stdlib/014_Token.mv
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added vm/stdlib/compiled/latest/stdlib/035_Account.mv
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added vm/stdlib/compiled/latest/stdlib/046_TypeInfo.mv
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added vm/stdlib/compiled/latest/stdlib/095_Signature.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/latest/stdlib/14_Token.mv
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed vm/stdlib/compiled/latest/stdlib/35_Account.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/latest/stdlib/39_SnapshotUtil.mv
Binary file not shown.
Binary file not shown.
Binary file removed vm/stdlib/compiled/latest/stdlib/46_DAOAccount.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/latest/stdlib/49_DAOSpace.mv
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed vm/stdlib/compiled/latest/stdlib/88_Signature.mv
Binary file not shown.
Binary file not shown.
37 changes: 28 additions & 9 deletions vm/stdlib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use anyhow::{bail, ensure, format_err, Result};
use include_dir::{include_dir, Dir};
use log::{info, LevelFilter};
use log::{debug, info, LevelFilter};
use move_bytecode_verifier::{dependencies, verify_module};
use move_compiler::command_line::compiler::construct_pre_compiled_lib_from_compiler;
use move_compiler::FullyCompiledProgram;
Expand Down Expand Up @@ -93,11 +93,11 @@ pub static G_STDLIB_VERSIONS: Lazy<Vec<StdlibVersion>> = Lazy::new(|| {
versions
});

static G_COMPILED_STDLIB: Lazy<HashMap<StdlibVersion, Vec<Vec<u8>>>> = Lazy::new(|| {
pub static G_COMPILED_STDLIB: Lazy<HashMap<StdlibVersion, Vec<Vec<u8>>>> = Lazy::new(|| {
let mut map = HashMap::new();
for version in &*G_STDLIB_VERSIONS {
let modules = read_compiled_modules(*version);
verify_compiled_modules(&modules);
verify_compiled_modules(*version, &modules);
map.insert(*version, modules);
}
map
Expand Down Expand Up @@ -213,7 +213,8 @@ pub fn build_stdlib(targets: &[String]) -> BTreeMap<String, CompiledModule> {
.expect("stdlib module dependency failed to verify");
// Tag each module with its index in the module dependency order. Needed for
// when they are deserialized and verified later on.
modules.insert(format!("{:02}_{}", i, name), module);
//TODO use a dependency analyzer method to do this.
modules.insert(format!("{:03}_{}", i, name), module);
}
CompiledUnit::Script(_) => panic!("Unexpected Script in stdlib"),
}
Expand Down Expand Up @@ -289,21 +290,39 @@ pub fn read_compiled_modules(stdlib_version: StdlibVersion) -> Vec<Vec<u8>> {
}

/// verify modules blob.
pub fn verify_compiled_modules(modules: &[Vec<u8>]) -> Vec<CompiledModule> {
pub fn verify_compiled_modules(
stdlib_version: StdlibVersion,
modules: &[Vec<u8>],
) -> Vec<CompiledModule> {
debug!(
"verify modules version:{}, modules: {}",
stdlib_version,
modules.len()
);
let mut verified_modules = vec![];
for module in modules {
let module = CompiledModule::deserialize(module).expect("module deserialize should be ok");
verify_module(&module).expect("stdlib module failed to verify");
dependencies::verify_module(&module, &verified_modules)
.expect("stdlib module dependency failed to verify");
debug!("verify module {}", module.self_id());
if let Err(e) = verify_module(&module) {
eprintln!("verify module {} failed: {:?}", module.self_id(), e);
panic!("verify module failed");
}
if let Err(e) = dependencies::verify_module(&module, &verified_modules) {
eprintln!(
"verify module {} dependencies failed: {:?}",
module.self_id(),
e
);
panic!("verify module dependencies failed");
}
verified_modules.push(module)
}
verified_modules
}

pub fn load_compiled_modules(stdlib_version: StdlibVersion) -> Vec<CompiledModule> {
let modules = read_compiled_modules(stdlib_version);
verify_compiled_modules(modules.as_slice())
verify_compiled_modules(stdlib_version, modules.as_slice())
}

pub fn modules_diff(
Expand Down
24 changes: 22 additions & 2 deletions vm/stdlib/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,18 @@ fn replace_stdlib_by_path(
// modules/scripts, and changes in the Move compiler will not be reflected in the stdlib used for
// genesis, and everywhere else across the code-base unless otherwise specified.
fn main() {
SimpleLogger::init(LevelFilter::Info, Config::default()).expect("init logger failed.");
// pass argument 'version' to generate new release
// for example, "cargo run -- --version 1"
let cli = Command::new("stdlib")
.name("Move standard library")
.author("The Starcoin Core Contributors")
.after_help("this command can be used to generate an incremental package, with init script included.")
.arg(
Arg::new("debug")
.long("debug")
.takes_value(false)
.help("print debug log")
)
.arg(
Arg::new("version")
.short('v')
Expand Down Expand Up @@ -223,6 +228,13 @@ fn main() {
);

let matches = cli.get_matches();
let log_level = if matches.is_present("debug") {
LevelFilter::Debug
} else {
LevelFilter::Info
};
SimpleLogger::init(log_level, Config::default()).expect("init logger failed.");

let mut generate_new_version = false;
let mut version_number: u64 = 0;
if matches.is_present("version") {
Expand Down Expand Up @@ -352,7 +364,15 @@ fn main() {
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);
println!(
"Check compiled stdlib version: {}, modules:{}",
version,
modules.len()
);
}
if generate_new_version {
let dest_dir = full_update_with_version(version_number);
if let Some(pre_version) = pre_version {
Expand Down