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

Use generated framework mrb #4359

Merged
merged 5 commits into from
Dec 25, 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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ build/
mold

# ignore framework release bundle file
**/*.mrb
*.mrb
1 change: 1 addition & 0 deletions Cargo.lock

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

Binary file modified genesis/generated/barnard/genesis
Binary file not shown.
Binary file modified genesis/generated/halley/genesis
Binary file not shown.
Binary file modified genesis/generated/main/genesis
Binary file not shown.
Binary file modified genesis/generated/proxima/genesis
Binary file not shown.
Binary file modified genesis/generated/vega/genesis
Binary file not shown.
4 changes: 3 additions & 1 deletion genesis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use starcoin_types::startup_info::{ChainInfo, StartupInfo};
use starcoin_types::transaction::Package;
use starcoin_types::transaction::TransactionInfo;
use starcoin_types::{block::Block, transaction::Transaction};
use starcoin_vm_types::genesis_config::StdlibVersion;
use starcoin_vm_types::{
account_config::CORE_CODE_ADDRESS,
state_store::StateView,
Expand Down Expand Up @@ -147,7 +148,8 @@ impl Genesis {
if net.is_test() || net.is_dag_test() {
StdLibOptions::Fresh
} else {
StdLibOptions::Compiled(net.stdlib_version())
// todo: currently only support latest stdlib version.
StdLibOptions::Compiled(StdlibVersion::Latest)
},
)?;
Self::build_genesis_transaction_with_package(net, package)
Expand Down
2 changes: 1 addition & 1 deletion genesis/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn main() {
info!("Start generate network: {:?}", id);
// skip test && dev network generate.
if id.is_test() || id.is_dev() || id.is_dag_test() {
info!("End generate network: {:?}, it is test network", id);
info!("skip generating network: {:?}, it is test network", id);
continue;
}
if !id.genesis_config().is_ready() {
Expand Down
Binary file modified vm/framework/releases/testnet.mrb
Binary file not shown.
2 changes: 1 addition & 1 deletion vm/starcoin-transactional-test-harness/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1504,7 +1504,7 @@ pub fn print_help(task_name: Option<String>) -> Result<()> {
//TODO(simon): construct PackagePaths properly
pub static G_PRECOMPILED_STARCOIN_FRAMEWORK: Lazy<(FullyCompiledProgram, Vec<PackagePaths>)> =
Lazy::new(|| {
let sources = starcoin_cached_packages::head_release_bundle()
let sources = starcoin_framework::testnet_release_bundle()
.files()
.unwrap();
let package_paths = vec![PackagePaths {
Expand Down
Binary file not shown.
Binary file modified vm/stdlib/compiled/latest/stdlib/008_features.mv
Binary file not shown.
Binary file modified vm/stdlib/compiled/latest/stdlib/021_create_signer.mv
Binary file not shown.
Binary file modified vm/stdlib/compiled/latest/stdlib/046_coin.mv
Binary file not shown.
Binary file modified vm/stdlib/compiled/latest/stdlib/050_dao.mv
Binary file not shown.
Binary file not shown.
Binary file not shown.
27 changes: 5 additions & 22 deletions vm/stdlib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,6 @@ pub const ERROR_DESC_EXTENSION: &str = "errmap";
pub const ERROR_DESCRIPTIONS: &[u8] =
std::include_bytes!("../compiled/latest/error_descriptions/error_descriptions.errmap");

// 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_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.
/// The compiled library needs to be included in the Rust binary due to Docker deployment issues.
/// This is why we include it here.
Expand Down Expand Up @@ -130,12 +112,13 @@ pub enum StdLibOptions {
/// Returns a reference to the standard library. Depending upon the `option` flag passed in
/// either a compiled version of the standard library will be returned or a new freshly built stdlib
/// will be used.
pub fn stdlib_modules(option: StdLibOptions) -> &'static [Vec<u8>] {
pub fn stdlib_modules(option: StdLibOptions) -> Vec<Vec<u8>> {
match option {
StdLibOptions::Fresh => &G_FRESH_MOVE_LANG_STDLIB,
StdLibOptions::Fresh => starcoin_cached_packages::head_release_bundle().legacy_copy_code(),
StdLibOptions::Compiled(version) => G_COMPILED_STDLIB
.get(&version)
.unwrap_or_else(|| panic!("Stdlib version {:?} not exist.", version)),
.unwrap_or_else(|| panic!("Stdlib version {:?} not exist.", version))
.to_vec(),
}
}

Expand All @@ -162,7 +145,7 @@ pub fn module_to_package(
}

pub fn stdlib_files() -> Vec<String> {
starcoin_cached_packages::head_release_bundle()
starcoin_framework::testnet_release_bundle()
.files()
.unwrap()
.clone()
Expand Down
2 changes: 1 addition & 1 deletion vm/stdlib/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ fn main() {
std::env::set_current_dir(base_path).expect("failed to change directory");

let new_modules = build_stdlib(
starcoin_cached_packages::head_release_bundle()
starcoin_framework::testnet_release_bundle()
.files()
.unwrap()
.as_slice(),
Expand Down
1 change: 1 addition & 0 deletions vm/transaction-builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ starcoin-logger = { workspace = true }
starcoin-vm-types = { workspace = true }
starcoin-types = { workspace = true }
stdlib = { workspace = true }
starcoin-framework = { workspace = true }
starcoin-cached-packages = { workspace = true }

[dev-dependencies]
Expand Down
6 changes: 3 additions & 3 deletions vm/transaction-builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,9 @@ pub fn create_signed_txn_with_association_account(
.expect("Sign txn should work.")
}

pub fn build_stdlib_package(net: &ChainNetwork, _stdlib_option: StdLibOptions) -> Result<Package> {
let modules = starcoin_cached_packages::head_release_bundle().legacy_copy_code();
build_stdlib_package_with_modules(net, modules)
pub fn build_stdlib_package(net: &ChainNetwork, stdlib_option: StdLibOptions) -> Result<Package> {
let init_script = build_init_script(net);
stdlib_package(stdlib_option, Some(init_script))
}

pub fn build_stdlib_package_with_modules(
Expand Down
2 changes: 1 addition & 1 deletion vm/vm-runtime/tests/test_native_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::collections::{HashMap, HashSet};

#[test]
pub fn test_native_function_matches() -> Result<()> {
let modules = starcoin_cached_packages::head_release_bundle().compiled_modules();
let modules = starcoin_framework::testnet_release_bundle().compiled_modules();
let runtime_metadata = modules
.iter()
.filter_map(|m| {
Expand Down
Loading