Skip to content

Commit

Permalink
[upgrade] get actual git head for framework on upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
0o-de-lally committed Nov 4, 2023
1 parent 8a824fb commit acab3c0
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
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.

1 change: 1 addition & 0 deletions framework/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ diem-build-info = { workspace = true }
diem-crypto = { workspace = true }
diem-framework = { workspace = true }
diem-types = { workspace = true }
git2 = { workspace = true }
hex = { workspace = true }
move-command-line-common = { workspace = true }
move-model = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module diem_framework::diem_governance {
const ENOT_DELEGATED_VOTER: u64 = 2;
/// The specified stake pool does not have long enough remaining lockup to create a proposal or vote
const EINSUFFICIENT_STAKE_LOCKUP: u64 = 3;
/// The specified stake pool has already been used to vote on the same proposal
/// The specified address already been used to vote on the same proposal
const EALREADY_VOTED: u64 = 4;
/// The specified stake pool must be part of the validator set
const ENO_VOTING_POWER: u64 = 5;
Expand Down
15 changes: 14 additions & 1 deletion framework/src/builder/framework_generate_upgrade_proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ pub fn make_framework_upgrade_artifacts(
framework_local_dir: &Path,
core_modules: &Option<Vec<String>>,
) -> Result<Vec<(String, String)>> {
let framework_git_hash = &get_framework_git_head(framework_local_dir).unwrap_or("none".to_owned());

let deploy_to_account = AccountAddress::from_hex_literal(CORE_MODULE_ADDRESS)?;

let mut next_execution_hash = vec![];
Expand Down Expand Up @@ -99,6 +101,7 @@ pub fn make_framework_upgrade_artifacts(
deploy_to_account,
this_mod_gov_script_path.clone(),
next_execution_hash,
framework_git_hash,
)?;

// We need transaction execution hashes OF THE GOVERNANCE SCRIPT for the governance ceremony.
Expand Down Expand Up @@ -211,6 +214,16 @@ pub fn save_build(
"success: governance script built at: {:?}",
script_package_dir
);
println!("hash: {:?}", hash.to_hex_literal());
println!("tx script hash: {:?}", hash.to_hex_literal());
Ok(())
}


fn get_framework_git_head(path: &Path) -> anyhow::Result<String> {
let r = git2::Repository::discover(path).unwrap();
let id = r.head()?
.peel_to_commit()?
.id();

Ok(id.to_string())
}
12 changes: 5 additions & 7 deletions framework/src/builder/framework_release_bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ fn generate_blob(writer: &CodeWriter, data: &[u8]) {
}

pub fn libra_author_script_file(
//////// 0L //////// turn an MRB into a script proposal
//////// 0L //////// turn a compiled framework package into a script proposal
release_package: &ReleasePackage,
for_address: AccountAddress,
out: PathBuf,
next_execution_hash: Vec<u8>, // metadata: Option<PackageMetadata>,
// is_testnet: bool,
// is_multi_step: bool,
// next_execution_hash: Vec<u8>,
next_execution_hash: Vec<u8>,
framework_git_hash: &str,
) -> anyhow::Result<()> {
println!("autogenerating .move governance script file");
let metadata = &release_package.metadata;
Expand All @@ -41,7 +39,7 @@ pub fn libra_author_script_file(
emitln!(
writer,
"// Framework commit hash: {}\n// Builder commit hash: {}\n",
diem_build_info::get_git_hash(),
framework_git_hash,
diem_build_info::get_git_hash(),
);
emitln!(
Expand Down Expand Up @@ -104,7 +102,7 @@ pub fn libra_author_script_file(
emitln!(
writer,
"version::upgrade_set_git(&framework_signer, x\"{}\")",
diem_build_info::get_git_hash()
framework_git_hash
);

writer.unindent();
Expand Down

0 comments on commit acab3c0

Please sign in to comment.