Skip to content

Commit

Permalink
genesis: remove ability to inject gas objects
Browse files Browse the repository at this point in the history
  • Loading branch information
bmwill committed Apr 1, 2023
1 parent 1cb1420 commit 5411066
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 52 deletions.
29 changes: 2 additions & 27 deletions crates/sui-config/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use crate::ValidatorInfo;
use anyhow::{bail, Context, Result};
use camino::Utf8Path;
use fastcrypto::encoding::{Base64, Encoding, Hex};
use fastcrypto::encoding::{Base64, Encoding};
use fastcrypto::hash::HashFunction;
use fastcrypto::traits::KeyPair;
use move_binary_format::CompiledModule;
Expand Down Expand Up @@ -1085,20 +1085,6 @@ impl Builder {
None
};

// Load Objects
let mut objects = BTreeMap::new();
for entry in path.join(GENESIS_BUILDER_OBJECT_DIR).read_dir_utf8()? {
let entry = entry?;
if entry.file_name().starts_with('.') {
continue;
}

let path = entry.path();
let object_bytes = fs::read(path)?;
let object: Object = serde_yaml::from_slice(&object_bytes)?;
objects.insert(object.id(), object);
}

// Load validator infos
let mut committee = BTreeMap::new();
for entry in path.join(GENESIS_BUILDER_COMMITTEE_DIR).read_dir_utf8()? {
Expand Down Expand Up @@ -1133,7 +1119,7 @@ impl Builder {
let mut builder = Self {
parameters,
token_distribution_schedule,
objects,
objects: Default::default(),
validators: committee,
signatures,
built_genesis: None, // Leave this as none, will build and compare below
Expand Down Expand Up @@ -1182,16 +1168,6 @@ impl Builder {
)?)?;
}

// Write Objects
let object_dir = path.join(GENESIS_BUILDER_OBJECT_DIR);
fs::create_dir_all(&object_dir)?;

for (_id, object) in self.objects {
let object_bytes = serde_yaml::to_vec(&object)?;
let hex_digest = Hex::encode(object.id());
fs::write(object_dir.join(hex_digest), object_bytes)?;
}

// Write Signatures
let signature_dir = path.join(GENESIS_BUILDER_SIGNATURE_DIR);
std::fs::create_dir_all(&signature_dir)?;
Expand Down Expand Up @@ -1661,7 +1637,6 @@ pub fn generate_genesis_system_object(
Ok(())
}

const GENESIS_BUILDER_OBJECT_DIR: &str = "objects";
const GENESIS_BUILDER_COMMITTEE_DIR: &str = "committee";
const GENESIS_BUILDER_PARAMETERS_FILE: &str = "parameters";
const GENESIS_BUILDER_TOKEN_DISTRIBUTION_SCHEDULE_FILE: &str = "token-distribution-schedule";
Expand Down
26 changes: 1 addition & 25 deletions crates/sui/src/genesis_ceremony.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ use sui_config::{
};
use sui_types::multiaddr::Multiaddr;
use sui_types::{
base_types::{ObjectID, SuiAddress},
base_types::SuiAddress,
committee::ProtocolVersion,
crypto::{
generate_proof_of_possession, AuthorityKeyPair, KeypairTraits, NetworkKeyPair, SuiKeyPair,
},
message_envelope::Message,
object::Object,
};

use sui_keys::keypair_file::{
Expand Down Expand Up @@ -80,15 +79,6 @@ pub enum CeremonyCommand {

ListValidators,

AddGasObject {
#[clap(long)]
address: SuiAddress,
#[clap(long)]
object_id: Option<ObjectID>,
#[clap(long)]
value: u64,
},

BuildUnsignedCheckpoint,

ExamineGenesisCheckpoint,
Expand Down Expand Up @@ -192,20 +182,6 @@ pub fn run(cmd: Ceremony) -> Result<()> {
}
}

CeremonyCommand::AddGasObject {
address,
object_id,
value,
} => {
let mut builder = Builder::load(&dir)?;

let object_id = object_id.unwrap_or_else(ObjectID::random);
let object = Object::with_id_owner_gas_for_testing(object_id, address, value);
builder = builder.add_object(object);

builder.save(dir)?;
}

CeremonyCommand::BuildUnsignedCheckpoint => {
let mut builder = Builder::load(&dir)?;
let UnsignedGenesis { checkpoint, .. } = builder.build_unsigned_genesis_checkpoint();
Expand Down

0 comments on commit 5411066

Please sign in to comment.