Skip to content

Commit 8e45127

Browse files
committed
Merge branch 'fraccaman/refactor-governance' (#1803)
* origin/fraccaman/refactor-governance: added changelog feat: introduce pgf, refactor governance
2 parents d262be6 + 516dfbc commit 8e45127

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+4518
-3270
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Introduce a simplified version of Public Good Fundings.
2+
([\#1803](https://github.com/anoma/namada/pull/1803))

.github/workflows/scripts/e2e.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"e2e::ledger_tests::pos_init_validator": 40,
1313
"e2e::ledger_tests::proposal_offline": 21,
1414
"e2e::ledger_tests::pgf_governance_proposal": 100,
15-
"e2e::ledger_tests::eth_governance_proposal": 100,
1615
"e2e::ledger_tests::proposal_submission": 200,
1716
"e2e::ledger_tests::run_ledger": 5,
1817
"e2e::ledger_tests::run_ledger_load_state_and_reset": 23,

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/src/lib/cli.rs

Lines changed: 131 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ pub mod cmds {
246246
.subcommand(QueryProposal::def().display_order(4))
247247
.subcommand(QueryProposalResult::def().display_order(4))
248248
.subcommand(QueryProtocolParameters::def().display_order(4))
249+
.subcommand(QueryPgf::def().display_order(4))
249250
.subcommand(QueryValidatorState::def().display_order(4))
250251
// Actions
251252
.subcommand(SignTx::def().display_order(5))
@@ -297,6 +298,7 @@ pub mod cmds {
297298
Self::parse_with_ctx(matches, QueryProposalResult);
298299
let query_protocol_parameters =
299300
Self::parse_with_ctx(matches, QueryProtocolParameters);
301+
let query_pgf = Self::parse_with_ctx(matches, QueryPgf);
300302
let query_validator_state =
301303
Self::parse_with_ctx(matches, QueryValidatorState);
302304
let add_to_eth_bridge_pool =
@@ -333,6 +335,7 @@ pub mod cmds {
333335
.or(query_proposal)
334336
.or(query_proposal_result)
335337
.or(query_protocol_parameters)
338+
.or(query_pgf)
336339
.or(query_validator_state)
337340
.or(query_account)
338341
.or(sign_tx)
@@ -405,6 +408,7 @@ pub mod cmds {
405408
QueryProposal(QueryProposal),
406409
QueryProposalResult(QueryProposalResult),
407410
QueryProtocolParameters(QueryProtocolParameters),
411+
QueryPgf(QueryPgf),
408412
QueryValidatorState(QueryValidatorState),
409413
SignTx(SignTx),
410414
}
@@ -1185,6 +1189,28 @@ pub mod cmds {
11851189
}
11861190
}
11871191

1192+
#[derive(Clone, Debug)]
1193+
pub struct QueryPgf(pub args::QueryPgf<args::CliTypes>);
1194+
1195+
impl SubCmd for QueryPgf {
1196+
const CMD: &'static str = "query-pgf";
1197+
1198+
fn parse(matches: &ArgMatches) -> Option<Self>
1199+
where
1200+
Self: Sized,
1201+
{
1202+
matches
1203+
.subcommand_matches(Self::CMD)
1204+
.map(|matches| QueryPgf(args::QueryPgf::parse(matches)))
1205+
}
1206+
1207+
fn def() -> App {
1208+
App::new(Self::CMD)
1209+
.about("Query pgf stewards and continous funding.")
1210+
.add_args::<args::QueryPgf<args::CliTypes>>()
1211+
}
1212+
}
1213+
11881214
#[derive(Clone, Debug)]
11891215
pub struct TxCustom(pub args::TxCustom<args::CliTypes>);
11901216

@@ -2496,6 +2522,9 @@ pub mod args {
24962522
"port-id",
24972523
DefaultFn(|| PortId::from_str("transfer").unwrap()),
24982524
);
2525+
pub const PROPOSAL_ETH: ArgFlag = flag("eth");
2526+
pub const PROPOSAL_PGF_STEWARD: ArgFlag = flag("pgf-stewards");
2527+
pub const PROPOSAL_PGF_FUNDING: ArgFlag = flag("pgf-funding");
24992528
pub const PROPOSAL_OFFLINE: ArgFlag = flag("offline");
25002529
pub const PROTOCOL_KEY: ArgOpt<WalletPublicKey> = arg_opt("protocol-key");
25012530
pub const PRE_GENESIS_PATH: ArgOpt<PathBuf> = arg_opt("pre-genesis-path");
@@ -3677,26 +3706,15 @@ pub mod args {
36773706
))
36783707
}
36793708
}
3680-
#[derive(Clone, Debug)]
3681-
pub struct InitProposal<C: NamadaTypes = SdkTypes> {
3682-
/// Common tx arguments
3683-
pub tx: Tx<C>,
3684-
/// The proposal file path
3685-
pub proposal_data: PathBuf,
3686-
/// Flag if proposal should be run offline
3687-
pub offline: bool,
3688-
/// Native token address
3689-
pub native_token: C::NativeAddress,
3690-
/// Path to the TX WASM code file
3691-
pub tx_code_path: PathBuf,
3692-
}
36933709

36943710
impl CliToSdk<InitProposal<SdkTypes>> for InitProposal<CliTypes> {
36953711
fn to_sdk(self, ctx: &mut Context) -> InitProposal<SdkTypes> {
36963712
InitProposal::<SdkTypes> {
36973713
tx: self.tx.to_sdk(ctx),
3698-
proposal_data: self.proposal_data,
3699-
offline: self.offline,
3714+
proposal_data: std::fs::read(self.proposal_data).expect(""),
3715+
is_offline: self.is_offline,
3716+
is_pgf_stewards: self.is_pgf_stewards,
3717+
is_pgf_funding: self.is_pgf_funding,
37003718
native_token: ctx.native_token.clone(),
37013719
tx_code_path: self.tx_code_path,
37023720
}
@@ -3707,15 +3725,19 @@ pub mod args {
37073725
fn parse(matches: &ArgMatches) -> Self {
37083726
let tx = Tx::parse(matches);
37093727
let proposal_data = DATA_PATH.parse(matches);
3710-
let offline = PROPOSAL_OFFLINE.parse(matches);
3728+
let is_offline = PROPOSAL_OFFLINE.parse(matches);
3729+
let is_pgf_stewards = PROPOSAL_PGF_STEWARD.parse(matches);
3730+
let is_pgf_funding = PROPOSAL_PGF_FUNDING.parse(matches);
37113731
let tx_code_path = PathBuf::from(TX_INIT_PROPOSAL);
37123732

37133733
Self {
37143734
tx,
37153735
proposal_data,
3716-
offline,
37173736
native_token: (),
37183737
tx_code_path,
3738+
is_offline,
3739+
is_pgf_stewards,
3740+
is_pgf_funding,
37193741
}
37203742
}
37213743

@@ -3727,45 +3749,66 @@ pub mod args {
37273749
.arg(
37283750
PROPOSAL_OFFLINE
37293751
.def()
3730-
.help("Flag if the proposal vote should run offline."),
3752+
.help(
3753+
"Flag if the proposal should be serialized \
3754+
offline (only for default types).",
3755+
)
3756+
.conflicts_with_all([
3757+
PROPOSAL_PGF_FUNDING.name,
3758+
PROPOSAL_PGF_STEWARD.name,
3759+
PROPOSAL_ETH.name,
3760+
]),
3761+
)
3762+
.arg(
3763+
PROPOSAL_ETH
3764+
.def()
3765+
.help("Flag if the proposal is of type eth.")
3766+
.conflicts_with_all([
3767+
PROPOSAL_PGF_FUNDING.name,
3768+
PROPOSAL_PGF_STEWARD.name,
3769+
]),
3770+
)
3771+
.arg(
3772+
PROPOSAL_PGF_STEWARD
3773+
.def()
3774+
.help(
3775+
"Flag if the proposal is of type pgf-stewards. \
3776+
Used to elect/remove stewards.",
3777+
)
3778+
.conflicts_with_all([
3779+
PROPOSAL_ETH.name,
3780+
PROPOSAL_PGF_FUNDING.name,
3781+
]),
3782+
)
3783+
.arg(
3784+
PROPOSAL_PGF_FUNDING
3785+
.def()
3786+
.help(
3787+
"Flag if the proposal is of type pgf-funding. \
3788+
Used to control continous/retro pgf fundings.",
3789+
)
3790+
.conflicts_with_all([
3791+
PROPOSAL_ETH.name,
3792+
PROPOSAL_PGF_STEWARD.name,
3793+
]),
37313794
)
37323795
}
37333796
}
37343797

3735-
#[derive(Clone, Debug)]
3736-
pub struct VoteProposal<C: NamadaTypes = SdkTypes> {
3737-
/// Common tx arguments
3738-
pub tx: Tx<C>,
3739-
/// Proposal id
3740-
pub proposal_id: Option<u64>,
3741-
/// The vote
3742-
pub vote: String,
3743-
/// The address of the voter
3744-
pub voter_address: C::Address,
3745-
/// PGF proposal
3746-
pub proposal_pgf: Option<String>,
3747-
/// ETH proposal
3748-
pub proposal_eth: Option<String>,
3749-
/// Flag if proposal vote should be run offline
3750-
pub offline: bool,
3751-
/// The proposal file path
3752-
pub proposal_data: Option<PathBuf>,
3753-
/// Path to the TX WASM code file
3754-
pub tx_code_path: PathBuf,
3755-
}
3756-
37573798
impl CliToSdk<VoteProposal<SdkTypes>> for VoteProposal<CliTypes> {
37583799
fn to_sdk(self, ctx: &mut Context) -> VoteProposal<SdkTypes> {
37593800
VoteProposal::<SdkTypes> {
37603801
tx: self.tx.to_sdk(ctx),
37613802
proposal_id: self.proposal_id,
37623803
vote: self.vote,
3763-
voter_address: ctx.get(&self.voter_address),
3764-
offline: self.offline,
3765-
proposal_data: self.proposal_data,
3804+
voter: ctx.get(&self.voter),
3805+
is_offline: self.is_offline,
3806+
proposal_data: self.proposal_data.map(|path| {
3807+
println!("Not able to read {}.", path.to_string_lossy());
3808+
std::fs::read(path)
3809+
.expect("Should be able to read the file.")
3810+
}),
37663811
tx_code_path: self.tx_code_path.to_path_buf(),
3767-
proposal_pgf: self.proposal_pgf,
3768-
proposal_eth: self.proposal_eth,
37693812
}
37703813
}
37713814
}
@@ -3774,22 +3817,18 @@ pub mod args {
37743817
fn parse(matches: &ArgMatches) -> Self {
37753818
let tx = Tx::parse(matches);
37763819
let proposal_id = PROPOSAL_ID_OPT.parse(matches);
3777-
let proposal_pgf = PROPOSAL_VOTE_PGF_OPT.parse(matches);
3778-
let proposal_eth = PROPOSAL_VOTE_ETH_OPT.parse(matches);
37793820
let vote = PROPOSAL_VOTE.parse(matches);
3780-
let voter_address = ADDRESS.parse(matches);
3781-
let offline = PROPOSAL_OFFLINE.parse(matches);
3821+
let voter = ADDRESS.parse(matches);
3822+
let is_offline = PROPOSAL_OFFLINE.parse(matches);
37823823
let proposal_data = DATA_PATH_OPT.parse(matches);
37833824
let tx_code_path = PathBuf::from(TX_VOTE_PROPOSAL);
37843825

37853826
Self {
37863827
tx,
37873828
proposal_id,
37883829
vote,
3789-
proposal_pgf,
3790-
proposal_eth,
3791-
offline,
3792-
voter_address,
3830+
is_offline,
3831+
voter,
37933832
proposal_data,
37943833
tx_code_path,
37953834
}
@@ -3809,29 +3848,7 @@ pub mod args {
38093848
.arg(
38103849
PROPOSAL_VOTE
38113850
.def()
3812-
.help("The vote for the proposal. Either yay or nay"),
3813-
)
3814-
.arg(
3815-
PROPOSAL_VOTE_PGF_OPT
3816-
.def()
3817-
.help(
3818-
"The list of proposed councils and spending \
3819-
caps:\n$council1 $cap1 $council2 $cap2 ... \
3820-
(council is bech32m encoded address, cap is \
3821-
expressed in microNAM",
3822-
)
3823-
.requires(PROPOSAL_ID.name)
3824-
.conflicts_with(PROPOSAL_VOTE_ETH_OPT.name),
3825-
)
3826-
.arg(
3827-
PROPOSAL_VOTE_ETH_OPT
3828-
.def()
3829-
.help(
3830-
"The signing key and message bytes (hex encoded) \
3831-
to be signed: $signing_key $message",
3832-
)
3833-
.requires(PROPOSAL_ID.name)
3834-
.conflicts_with(PROPOSAL_VOTE_PGF_OPT.name),
3851+
.help("The vote for the proposal. Either yay or nay."),
38353852
)
38363853
.arg(
38373854
PROPOSAL_OFFLINE
@@ -3846,6 +3863,7 @@ pub mod args {
38463863
"The data path file (json) that describes the \
38473864
proposal.",
38483865
)
3866+
.requires(PROPOSAL_OFFLINE.name)
38493867
.conflicts_with(PROPOSAL_ID.name),
38503868
)
38513869
.arg(ADDRESS.def().help("The address of the voter."))
@@ -3938,24 +3956,34 @@ pub mod args {
39383956

39393957
fn def(app: App) -> App {
39403958
app.add_args::<Query<CliTypes>>()
3941-
.arg(PROPOSAL_ID_OPT.def().help("The proposal identifier."))
3959+
.arg(
3960+
PROPOSAL_ID_OPT
3961+
.def()
3962+
.help("The proposal identifier.")
3963+
.conflicts_with_all([
3964+
PROPOSAL_OFFLINE.name,
3965+
DATA_PATH_OPT.name,
3966+
]),
3967+
)
39423968
.arg(
39433969
PROPOSAL_OFFLINE
39443970
.def()
39453971
.help(
39463972
"Flag if the proposal result should run on \
39473973
offline data.",
39483974
)
3949-
.conflicts_with(PROPOSAL_ID.name),
3975+
.conflicts_with(PROPOSAL_ID.name)
3976+
.requires(DATA_PATH_OPT.name),
39503977
)
39513978
.arg(
39523979
DATA_PATH_OPT
39533980
.def()
39543981
.help(
39553982
"The path to the folder containing the proposal \
3956-
json and votes",
3983+
and votes files in json format.",
39573984
)
3958-
.conflicts_with(PROPOSAL_ID.name),
3985+
.conflicts_with(PROPOSAL_ID.name)
3986+
.requires(PROPOSAL_OFFLINE.name),
39593987
)
39603988
}
39613989
}
@@ -3985,6 +4013,26 @@ pub mod args {
39854013
}
39864014
}
39874015

4016+
impl CliToSdk<QueryPgf<SdkTypes>> for QueryPgf<CliTypes> {
4017+
fn to_sdk(self, ctx: &mut Context) -> QueryPgf<SdkTypes> {
4018+
QueryPgf::<SdkTypes> {
4019+
query: self.query.to_sdk(ctx),
4020+
}
4021+
}
4022+
}
4023+
4024+
impl Args for QueryPgf<CliTypes> {
4025+
fn parse(matches: &ArgMatches) -> Self {
4026+
let query = Query::parse(matches);
4027+
4028+
Self { query }
4029+
}
4030+
4031+
fn def(app: App) -> App {
4032+
app.add_args::<Query<CliTypes>>()
4033+
}
4034+
}
4035+
39884036
impl CliToSdk<Withdraw<SdkTypes>> for Withdraw<CliTypes> {
39894037
fn to_sdk(self, ctx: &mut Context) -> Withdraw<SdkTypes> {
39904038
Withdraw::<SdkTypes> {
@@ -4076,9 +4124,10 @@ pub mod args {
40764124

40774125
fn def(app: App) -> App {
40784126
app.add_args::<Query<CliTypes>>().arg(
4079-
BALANCE_OWNER
4127+
OWNER
40804128
.def()
4081-
.help("The substorage space address to query."),
4129+
.help("The substorage space address to query.")
4130+
.required(true),
40824131
)
40834132
}
40844133
}

0 commit comments

Comments
 (0)