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

Prohibit governance voting from jailed and inactive validators #3004

Merged
merged 22 commits into from
Apr 12, 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Fix client bug that now ensures that a validator with
delegations but no self-bonds can vote in governance.
([\#2877](https://github.com/anoma/namada/pull/2877))
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))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Prohibit jailed or inactive validators from voting in governance.
([\#3004](https://github.com/anoma/namada/pull/3004))
1 change: 0 additions & 1 deletion .github/workflows/scripts/e2e.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,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 @@ -249,10 +249,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 @@ -3217,7 +3217,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 @@ -4906,7 +4905,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 @@ -4918,7 +4916,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 @@ -4927,7 +4924,6 @@ pub mod args {
tx,
proposal_data,
tx_code_path,
is_offline,
is_pgf_stewards,
is_pgf_funding,
}
Expand All @@ -4938,19 +4934,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 @@ -4993,12 +4976,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 @@ -5007,54 +4987,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 @@ -5142,70 +5094,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
Loading
Loading