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

[release-builder] local simulation of governance proposals #13949

Merged
merged 1 commit into from
Jul 23, 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
9 changes: 9 additions & 0 deletions Cargo.lock

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

9 changes: 9 additions & 0 deletions aptos-move/aptos-release-builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,26 @@ aptos-gas-schedule-updator = { workspace = true }
aptos-genesis = { workspace = true }
aptos-infallible = { workspace = true }
aptos-keygen = { workspace = true }
aptos-language-e2e-tests = { workspace = true }
aptos-move-debugger = { workspace = true }
aptos-rest-client = { workspace = true }
aptos-temppath = { workspace = true }
aptos-types = { workspace = true }
aptos-vm = { workspace = true }
aptos-vm-logging = { workspace = true }
bcs = { workspace = true }
clap = { workspace = true }
futures = { workspace = true }
git2 = { workspace = true }
handlebars = { workspace = true }
hex = { workspace = true }
move-binary-format = { workspace = true }
move-bytecode-verifier = { workspace = true }
move-core-types = { workspace = true }
move-model = { workspace = true }
move-vm-types = { workspace = true }
once_cell = { workspace = true }
parking_lot = { workspace = true }
reqwest = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
Expand All @@ -45,6 +53,7 @@ strum = { workspace = true }
strum_macros = { workspace = true }
tokio = { workspace = true }
url = { workspace = true }
walkdir = { workspace = true }

[[bin]]
name = "aptos-release-builder"
Expand Down
18 changes: 7 additions & 11 deletions aptos-move/aptos-release-builder/data/release.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
---
remote_endpoint: ~
name: "v1.14"
remote_endpoint: https://fullnode.mainnet.aptoslabs.com
name: "TBD"
proposals:
- name: step_1_upgrade_framework
- name: proposal_1_upgrade_framework
metadata:
title: "Multi-step proposal to upgrade mainnet framework to v1.14"
description: "This includes changes in https://github.com/aptos-labs/aptos-core/commits/aptos-release-v1.13"
title: "Multi-step proposal to upgrade mainnet framework, version TBD"
description: "This includes changes in (TBA: URL to changes)"
execution_mode: MultiStep
update_sequence:
- Gas:
new: current
- Framework:
bytecode_version: 6
git_hash: ~
- Gas:
new: current
- FeatureFlag:
enabled:
- disallow_user_native

1 change: 1 addition & 0 deletions aptos-move/aptos-release-builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

pub mod components;
pub mod simulate;
mod utils;
pub mod validate;

Expand Down
68 changes: 68 additions & 0 deletions aptos-move/aptos-release-builder/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use aptos_gas_schedule::LATEST_GAS_FEATURE_VERSION;
use aptos_release_builder::{
components::fetch_config,
initialize_aptos_core_path,
simulate::simulate_all_proposals,
validate::{DEFAULT_RESOLUTION_TIME, FAST_RESOLUTION_TIME},
};
use aptos_types::{
Expand All @@ -17,6 +18,7 @@ use aptos_types::{
};
use clap::{Parser, Subcommand};
use std::{path::PathBuf, str::FromStr};
use url::Url;

#[derive(Parser)]
pub struct Argument {
Expand All @@ -26,6 +28,43 @@ pub struct Argument {
aptos_core_path: Option<PathBuf>,
}

// TODO(vgao1996): unify with `ReplayNetworkSelection` in the `aptos` crate.
#[derive(Clone, Debug)]
pub enum NetworkSelection {
Mainnet,
Testnet,
Devnet,
RestEndpoint(String),
}

impl FromStr for NetworkSelection {
type Err = anyhow::Error;

fn from_str(s: &str) -> Result<Self, anyhow::Error> {
Ok(match s {
"mainnet" => Self::Mainnet,
"testnet" => Self::Testnet,
"devnet" => Self::Devnet,
_ => Self::RestEndpoint(s.to_owned()),
})
}
}

impl NetworkSelection {
fn to_url(&self) -> anyhow::Result<Url> {
use NetworkSelection::*;

let s = match &self {
Mainnet => "https://fullnode.mainnet.aptoslabs.com",
Testnet => "https://fullnode.testnet.aptoslabs.com",
Devnet => "https://fullnode.devnet.aptoslabs.com",
RestEndpoint(url) => url,
};

Ok(Url::parse(s)?)
}
}

#[derive(Subcommand, Debug)]
pub enum Commands {
/// Generate sets of governance proposals based on the release_config file passed in
Expand All @@ -34,6 +73,24 @@ pub enum Commands {
release_config: PathBuf,
#[clap(short, long)]
output_dir: PathBuf,

#[clap(long)]
simulate: Option<NetworkSelection>,
},
/// Simulate a multi-step proposal on the specified network, using its current states.
/// The simulation will execute the governance scripts, as if the proposal is already
/// approved.
Simulate {
/// Directory that may contain one or more proposals at any level
/// within its sub-directory hierarchy.
#[clap(short, long)]
path: PathBuf,

/// The network to simulate on.
///
/// Possible values: devnet, testnet, mainnet, <url to rest endpoint>
#[clap(long)]
network: NetworkSelection,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! validate proposal also has an "endpoint" arguement, it would be great could replace its usage of URL with network so we dont have to specify the testnet / mainnet / devnet url all the time there either

},
/// Generate sets of governance proposals with default release config.
WriteDefault {
Expand Down Expand Up @@ -126,12 +183,23 @@ async fn main() -> anyhow::Result<()> {
Commands::GenerateProposals {
release_config,
output_dir,
simulate,
} => {
aptos_release_builder::ReleaseConfig::load_config(release_config.as_path())
.with_context(|| "Failed to load release config".to_string())?
.generate_release_proposal_scripts(output_dir.as_path())
.await
.with_context(|| "Failed to generate release proposal scripts".to_string())?;

if let Some(network) = simulate {
let remote_endpoint = network.to_url()?;
simulate_all_proposals(remote_endpoint, output_dir.as_path()).await?;
}

Ok(())
},
Commands::Simulate { network, path } => {
simulate_all_proposals(network.to_url()?, &path).await?;
Ok(())
},
Commands::WriteDefault { output_path } => {
Expand Down
Loading
Loading