Skip to content

Commit

Permalink
config: use pre-compiled sui-framework
Browse files Browse the repository at this point in the history
  • Loading branch information
bmwill committed May 23, 2022
1 parent a93b850 commit 8d0ab63
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 28 deletions.
33 changes: 15 additions & 18 deletions crates/sui-config/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ use base64ct::Encoding;
use move_binary_format::CompiledModule;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use serde_with::{serde_as, DeserializeAs, SerializeAs};
use std::path::PathBuf;
use sui_framework::DEFAULT_FRAMEWORK_PATH;
use sui_types::{base_types::TxContext, crypto::PublicKeyBytes, object::Object};
use tracing::info;

Expand Down Expand Up @@ -80,8 +78,8 @@ impl<'de> DeserializeAs<'de, CompiledModule> for SerdeCompiledModule {
}

pub struct Builder {
sui_framework: PathBuf,
move_framework: PathBuf,
sui_framework: Option<Vec<CompiledModule>>,
move_framework: Option<Vec<CompiledModule>>,
move_modules: Vec<Vec<CompiledModule>>,
objects: Vec<Object>,
genesis_ctx: TxContext,
Expand All @@ -91,24 +89,22 @@ pub struct Builder {
impl Builder {
pub fn new(genesis_ctx: TxContext) -> Self {
Self {
sui_framework: PathBuf::from(DEFAULT_FRAMEWORK_PATH),
move_framework: PathBuf::from(DEFAULT_FRAMEWORK_PATH)
.join("deps")
.join("move-stdlib"),
sui_framework: None,
move_framework: None,
move_modules: vec![],
objects: vec![],
genesis_ctx,
validators: vec![],
}
}

pub fn sui_framework(mut self, path: PathBuf) -> Self {
self.sui_framework = path;
pub fn sui_framework(mut self, sui_framework: Vec<CompiledModule>) -> Self {
self.sui_framework = Some(sui_framework);
self
}

pub fn move_framework(mut self, path: PathBuf) -> Self {
self.move_framework = path;
pub fn move_framework(mut self, move_framework: Vec<CompiledModule>) -> Self {
self.move_framework = Some(move_framework);
self
}

Expand Down Expand Up @@ -144,15 +140,19 @@ impl Builder {

// Load Move Framework
info!("Loading Move framework lib from {:?}", self.move_framework);
let move_modules = sui_framework::get_move_stdlib_modules(&self.move_framework).unwrap();
let move_modules = self
.move_framework
.unwrap_or_else(sui_framework::get_move_stdlib);
// let move_framework =
// Object::new_package(move_modules.clone(), TransactionDigest::genesis());
modules.push(move_modules);
// objects.push(move_framework);

// Load Sui Framework
info!("Loading Sui framework lib from {:?}", self.sui_framework);
let sui_modules = sui_framework::get_sui_framework_modules(&self.sui_framework).unwrap();
let sui_modules = self
.sui_framework
.unwrap_or_else(sui_framework::get_sui_framework);
// let sui_framework = Object::new_package(sui_modules.clone(), TransactionDigest::genesis());
modules.push(sui_modules);
// objects.push(sui_framework);
Expand All @@ -170,14 +170,11 @@ impl Builder {

#[cfg(test)]
mod test {
use sui_framework::DEFAULT_FRAMEWORK_PATH;

use super::Genesis;

#[test]
fn roundtrip() {
let sui_lib =
sui_framework::get_sui_framework_modules(DEFAULT_FRAMEWORK_PATH.as_ref()).unwrap();
let sui_lib = sui_framework::get_sui_framework();

let genesis = Genesis {
modules: vec![sui_lib],
Expand Down
11 changes: 4 additions & 7 deletions crates/sui-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use std::fs;
use std::net::SocketAddr;
use std::num::NonZeroUsize;
use std::path::{Path, PathBuf};
use sui_framework::DEFAULT_FRAMEWORK_PATH;
use sui_types::base_types::{ObjectID, SuiAddress, TxContext};
use sui_types::committee::{Committee, EpochId};
use sui_types::crypto::{get_key_pair_from_rng, KeyPair, PublicKeyBytes};
Expand Down Expand Up @@ -257,8 +256,8 @@ pub struct GenesisConfig {
pub committee_size: usize,
pub accounts: Vec<AccountConfig>,
pub move_packages: Vec<PathBuf>,
pub sui_framework_lib_path: PathBuf,
pub move_framework_lib_path: PathBuf,
pub sui_framework_lib_path: Option<PathBuf>,
pub move_framework_lib_path: Option<PathBuf>,
}

impl Config for GenesisConfig {}
Expand Down Expand Up @@ -455,10 +454,8 @@ impl Default for GenesisConfig {
committee_size: DEFAULT_NUMBER_OF_AUTHORITIES,
accounts: vec![],
move_packages: vec![],
sui_framework_lib_path: PathBuf::from(DEFAULT_FRAMEWORK_PATH),
move_framework_lib_path: PathBuf::from(DEFAULT_FRAMEWORK_PATH)
.join("deps")
.join("move-stdlib"),
sui_framework_lib_path: None,
move_framework_lib_path: None,
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions sui/src/bin/bench_configure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,8 @@ fn main() {
committee_size: bch.host_port_stake_triplets.len(),
accounts: accounts.clone(),
move_packages: vec![],
sui_framework_lib_path: Path::new("../../sui_programmability/framework").to_path_buf(),
move_framework_lib_path: Path::new("../../sui_programmability/framework/deps/move-stdlib")
.to_path_buf(),
sui_framework_lib_path: None,
move_framework_lib_path: None,
};

let path_str = "distributed_bench_genesis.conf";
Expand Down

0 comments on commit 8d0ab63

Please sign in to comment.