Skip to content

Commit

Permalink
Merge branch 'fraccaman/remove-offline-governance' (#2803)
Browse files Browse the repository at this point in the history
* origin/fraccaman/remove-offline-governance:
  fmt
  changelog: add #2803
  fmt + clippy
  more tests
  added unit tests
  fix governance vp
  remove offline governance, refactor tally types

# Conflicts:
#	crates/apps/src/lib/client/tx.rs
  • Loading branch information
tzemanovic committed Apr 11, 2024
2 parents 8bef12f + 11ffc77 commit 63cb360
Show file tree
Hide file tree
Showing 29 changed files with 2,050 additions and 1,239 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Removes offline governance as a proposal option.
([\#2803](https://github.com/anoma/namada/pull/2803))
1 change: 0 additions & 1 deletion .github/workflows/scripts/e2e.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"e2e::ledger_tests::pos_bonds": 77,
"e2e::ledger_tests::implicit_account_reveal_pk": 30,
"e2e::ledger_tests::pos_init_validator": 40,
"e2e::ledger_tests::proposal_offline": 21,
"e2e::ledger_tests::rollback": 21,
"e2e::ledger_tests::pgf_governance_proposal": 320,
"e2e::ledger_tests::proposal_submission": 200,
Expand Down
3 changes: 1 addition & 2 deletions crates/apps/src/lib/bench_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,9 @@ impl Default for BenchShell {
let signed_tx = bench_shell.generate_tx(
TX_INIT_PROPOSAL_WASM,
InitProposalData {
id: 0,
content: content_section.get_hash(),
author: defaults::albert_address(),
r#type: ProposalType::Default(None),
r#type: ProposalType::Default,
voting_start_epoch,
voting_end_epoch: voting_start_epoch + 3_u64,
grace_epoch: voting_start_epoch + 9_u64,
Expand Down
111 changes: 11 additions & 100 deletions crates/apps/src/lib/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3189,7 +3189,6 @@ pub mod args {
pub const PROPOSAL_ETH: ArgFlag = flag("eth");
pub const PROPOSAL_PGF_STEWARD: ArgFlag = flag("pgf-stewards");
pub const PROPOSAL_PGF_FUNDING: ArgFlag = flag("pgf-funding");
pub const PROPOSAL_OFFLINE: ArgFlag = flag("offline");
pub const PROTOCOL_KEY: ArgOpt<WalletPublicKey> = arg_opt("protocol-key");
pub const PRE_GENESIS_PATH: ArgOpt<PathBuf> = arg_opt("pre-genesis-path");
pub const PUBLIC_KEY: Arg<WalletPublicKey> = arg("public-key");
Expand Down Expand Up @@ -4888,7 +4887,6 @@ pub mod args {
InitProposal::<SdkTypes> {
tx: self.tx.to_sdk(ctx),
proposal_data: std::fs::read(self.proposal_data).expect(""),
is_offline: self.is_offline,
is_pgf_stewards: self.is_pgf_stewards,
is_pgf_funding: self.is_pgf_funding,
tx_code_path: self.tx_code_path,
Expand All @@ -4900,7 +4898,6 @@ pub mod args {
fn parse(matches: &ArgMatches) -> Self {
let tx = Tx::parse(matches);
let proposal_data = DATA_PATH.parse(matches);
let is_offline = PROPOSAL_OFFLINE.parse(matches);
let is_pgf_stewards = PROPOSAL_PGF_STEWARD.parse(matches);
let is_pgf_funding = PROPOSAL_PGF_FUNDING.parse(matches);
let tx_code_path = PathBuf::from(TX_INIT_PROPOSAL);
Expand All @@ -4909,7 +4906,6 @@ pub mod args {
tx,
proposal_data,
tx_code_path,
is_offline,
is_pgf_stewards,
is_pgf_funding,
}
Expand All @@ -4920,19 +4916,6 @@ pub mod args {
.arg(DATA_PATH.def().help(
"The data path file (json) that describes the proposal.",
))
.arg(
PROPOSAL_OFFLINE
.def()
.help(
"Flag if the proposal should be serialized \
offline (only for default types).",
)
.conflicts_with_all([
PROPOSAL_PGF_FUNDING.name,
PROPOSAL_PGF_STEWARD.name,
PROPOSAL_ETH.name,
]),
)
.arg(
PROPOSAL_ETH
.def()
Expand Down Expand Up @@ -4975,12 +4958,9 @@ pub mod args {
tx: self.tx.to_sdk(ctx),
proposal_id: self.proposal_id,
vote: self.vote,
voter: ctx.borrow_chain_or_exit().get(&self.voter),
is_offline: self.is_offline,
proposal_data: self.proposal_data.map(|path| {
std::fs::read(path)
.expect("Should be able to read the file.")
}),
voter_address: ctx
.borrow_chain_or_exit()
.get(&self.voter_address),
tx_code_path: self.tx_code_path.to_path_buf(),
}
}
Expand All @@ -4989,54 +4969,26 @@ pub mod args {
impl Args for VoteProposal<CliTypes> {
fn parse(matches: &ArgMatches) -> Self {
let tx = Tx::parse(matches);
let proposal_id = PROPOSAL_ID_OPT.parse(matches);
let proposal_id = PROPOSAL_ID.parse(matches);
let vote = PROPOSAL_VOTE.parse(matches);
let voter = ADDRESS.parse(matches);
let is_offline = PROPOSAL_OFFLINE.parse(matches);
let proposal_data = DATA_PATH_OPT.parse(matches);
let voter_address = ADDRESS.parse(matches);
let tx_code_path = PathBuf::from(TX_VOTE_PROPOSAL);

Self {
tx,
proposal_id,
vote,
is_offline,
voter,
proposal_data,
voter_address,
tx_code_path,
}
}

fn def(app: App) -> App {
app.add_args::<Tx<CliTypes>>()
.arg(
PROPOSAL_ID_OPT
.def()
.help("The proposal identifier.")
.conflicts_with_all([
PROPOSAL_OFFLINE.name,
DATA_PATH_OPT.name,
]),
)
.arg(PROPOSAL_ID_OPT.def().help("The proposal identifier."))
.arg(PROPOSAL_VOTE.def().help(
"The vote for the proposal. Either yay, nay, or abstain.",
))
.arg(
PROPOSAL_OFFLINE
.def()
.help("Flag if the proposal vote should run offline.")
.conflicts_with(PROPOSAL_ID.name),
)
.arg(
DATA_PATH_OPT
.def()
.help(
"The data path file (json) that describes the \
proposal.",
)
.requires(PROPOSAL_OFFLINE.name)
.conflicts_with(PROPOSAL_ID.name),
)
.arg(ADDRESS.def().help("The address of the voter."))
}
}
Expand Down Expand Up @@ -5124,70 +5076,29 @@ pub mod args {
/// Common query args
pub query: Query<C>,
/// Proposal id
pub proposal_id: Option<u64>,
/// Flag if proposal result should be run on offline data
pub offline: bool,
/// The folder containing the proposal and votes
pub proposal_folder: Option<PathBuf>,
pub proposal_id: u64,
}

impl CliToSdk<QueryProposalResult<SdkTypes>> for QueryProposalResult<CliTypes> {
fn to_sdk(self, ctx: &mut Context) -> QueryProposalResult<SdkTypes> {
QueryProposalResult::<SdkTypes> {
query: self.query.to_sdk(ctx),
proposal_id: self.proposal_id,
offline: self.offline,
proposal_folder: self.proposal_folder,
}
}
}

impl Args for QueryProposalResult<CliTypes> {
fn parse(matches: &ArgMatches) -> Self {
let query = Query::parse(matches);
let proposal_id = PROPOSAL_ID_OPT.parse(matches);
let offline = PROPOSAL_OFFLINE.parse(matches);
let proposal_folder = DATA_PATH_OPT.parse(matches);
let proposal_id = PROPOSAL_ID.parse(matches);

Self {
query,
proposal_id,
offline,
proposal_folder,
}
Self { query, proposal_id }
}

fn def(app: App) -> App {
app.add_args::<Query<CliTypes>>()
.arg(
PROPOSAL_ID_OPT
.def()
.help("The proposal identifier.")
.conflicts_with_all([
PROPOSAL_OFFLINE.name,
DATA_PATH_OPT.name,
]),
)
.arg(
PROPOSAL_OFFLINE
.def()
.help(
"Flag if the proposal result should run on \
offline data.",
)
.conflicts_with(PROPOSAL_ID.name)
.requires(DATA_PATH_OPT.name),
)
.arg(
DATA_PATH_OPT
.def()
.help(
"The path to the folder containing the proposal \
and votes files in json format.",
)
.conflicts_with(PROPOSAL_ID.name)
.requires(PROPOSAL_OFFLINE.name),
)
.arg(PROPOSAL_ID.def().help("The proposal identifier."))
}
}

Expand Down

0 comments on commit 63cb360

Please sign in to comment.