From 548debd5d9c1ecc97ca01160b1c2c7a63d628e86 Mon Sep 17 00:00:00 2001 From: Gianmarco Fraccaroli Date: Wed, 12 Jun 2024 17:54:39 +0200 Subject: [PATCH 1/8] ci: update antithesis workflow --- .github/workflows/triggerable-antithesis.yml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/triggerable-antithesis.yml b/.github/workflows/triggerable-antithesis.yml index 70bb66984d..1ef4f82abd 100644 --- a/.github/workflows/triggerable-antithesis.yml +++ b/.github/workflows/triggerable-antithesis.yml @@ -1,4 +1,4 @@ -name: Triggerable Antithesis workflow +name: Triggerable Antithesis on: workflow_dispatch: @@ -11,6 +11,10 @@ on: description: 'The docker tag of the scenario tester image' required: true type: string + with_instrumentation: + description: 'Use instrumented images' + required: true + type: boolean workload_type: type: choice description: The type of workload to use (namada__pr__customer 3h, namada__nightly__customer 8h) @@ -24,10 +28,20 @@ jobs: steps: - uses: antithesishq/antithesis-trigger-action@v0.2 + if: ${{ github.event.inputs.with_instrumentation }} + with: + notebook_name: ${{ github.event.inputs.workload_type }} + tenant: heliax + username: ${{ secrets.ANTITHESIS_USER_NAME }} + password: ${{ secrets.ANTITHESIS_PASSWORD }} + github_token: ${{ secrets.GITHUB_TOKEN }} + images: namada-config:${{ github.event.inputs.namada_docker_tag }},namada-genesis:${{ github.event.inputs.namada_docker_tag }},namada:${{ github.event.inputs.namada_docker_tag }}-inst,namada-scenario-tester:${{ github.event.inputs.scenario_tester_docker_tag }} + - uses: antithesishq/antithesis-trigger-action@v0.2 + if: ${{ !github.event.inputs.with_instrumentation }} with: notebook_name: ${{ github.event.inputs.workload_type }} tenant: heliax username: ${{ secrets.ANTITHESIS_USER_NAME }} password: ${{ secrets.ANTITHESIS_PASSWORD }} github_token: ${{ secrets.GITHUB_TOKEN }} - images: namada-config:${{ github.event.inputs.namada_docker_tag }},namada-genesis:${{ github.event.inputs.namada_docker_tag }},namada:${{ github.event.inputs.namada_docker_tag }},namada:${{ github.event.inputs.namada_docker_tag }}-inst,namada-scenario-tester:${{ github.event.inputs.scenario_tester_docker_tag }} \ No newline at end of file + images: namada-config:${{ github.event.inputs.namada_docker_tag }},namada-genesis:${{ github.event.inputs.namada_docker_tag }},namada:${{ github.event.inputs.namada_docker_tag }},namada-scenario-tester:${{ github.event.inputs.scenario_tester_docker_tag }} \ No newline at end of file From 0e7893278663a90883410923ed4cb0fb2fdc694c Mon Sep 17 00:00:00 2001 From: Gianmarco Fraccaroli Date: Wed, 12 Jun 2024 18:16:17 +0200 Subject: [PATCH 2/8] ci: update antithesis workflow --- .github/workflows/triggerable-antithesis.yml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/.github/workflows/triggerable-antithesis.yml b/.github/workflows/triggerable-antithesis.yml index 1ef4f82abd..d0c9d7746c 100644 --- a/.github/workflows/triggerable-antithesis.yml +++ b/.github/workflows/triggerable-antithesis.yml @@ -11,10 +11,6 @@ on: description: 'The docker tag of the scenario tester image' required: true type: string - with_instrumentation: - description: 'Use instrumented images' - required: true - type: boolean workload_type: type: choice description: The type of workload to use (namada__pr__customer 3h, namada__nightly__customer 8h) @@ -28,16 +24,6 @@ jobs: steps: - uses: antithesishq/antithesis-trigger-action@v0.2 - if: ${{ github.event.inputs.with_instrumentation }} - with: - notebook_name: ${{ github.event.inputs.workload_type }} - tenant: heliax - username: ${{ secrets.ANTITHESIS_USER_NAME }} - password: ${{ secrets.ANTITHESIS_PASSWORD }} - github_token: ${{ secrets.GITHUB_TOKEN }} - images: namada-config:${{ github.event.inputs.namada_docker_tag }},namada-genesis:${{ github.event.inputs.namada_docker_tag }},namada:${{ github.event.inputs.namada_docker_tag }}-inst,namada-scenario-tester:${{ github.event.inputs.scenario_tester_docker_tag }} - - uses: antithesishq/antithesis-trigger-action@v0.2 - if: ${{ !github.event.inputs.with_instrumentation }} with: notebook_name: ${{ github.event.inputs.workload_type }} tenant: heliax From 8363c34ae7f6abd995ea6c6ca185a1163b546fd8 Mon Sep 17 00:00:00 2001 From: Gianmarco Fraccaroli Date: Tue, 25 Jun 2024 17:29:34 +0200 Subject: [PATCH 3/8] added maximum amount of stewards as genesis parameter --- crates/apps_lib/src/config/genesis/chain.rs | 1 + .../apps_lib/src/config/genesis/templates.rs | 4 ++ crates/governance/src/pgf/parameters.rs | 11 ++++- crates/governance/src/pgf/storage/keys.rs | 8 ++++ crates/node/src/shell/governance.rs | 45 ++++++++++++++----- 5 files changed, 56 insertions(+), 13 deletions(-) diff --git a/crates/apps_lib/src/config/genesis/chain.rs b/crates/apps_lib/src/config/genesis/chain.rs index 690d67909f..5552623a4d 100644 --- a/crates/apps_lib/src/config/genesis/chain.rs +++ b/crates/apps_lib/src/config/genesis/chain.rs @@ -759,6 +759,7 @@ impl FinalizedParameters { stewards: pgf_params.stewards, pgf_inflation_rate: pgf_params.pgf_inflation_rate, stewards_inflation_rate: pgf_params.stewards_inflation_rate, + maximum_number_of_stewards: pgf_params.maximum_number_of_stewards, }; Self { parameters, diff --git a/crates/apps_lib/src/config/genesis/templates.rs b/crates/apps_lib/src/config/genesis/templates.rs index db5ac13772..15c05c08a1 100644 --- a/crates/apps_lib/src/config/genesis/templates.rs +++ b/crates/apps_lib/src/config/genesis/templates.rs @@ -474,6 +474,8 @@ pub struct PgfParams { pub pgf_inflation_rate: Dec, /// The pgf stewards inflation rate pub stewards_inflation_rate: Dec, + /// The pgf stewards inflation rate + pub maximum_number_of_stewards: u64, #[serde(default)] #[serde(skip_serializing)] #[cfg(test)] @@ -913,6 +915,8 @@ pub fn validate_parameters( stewards: pgf_params.stewards, pgf_inflation_rate: pgf_params.pgf_inflation_rate, stewards_inflation_rate: pgf_params.stewards_inflation_rate, + maximum_number_of_stewards: pgf_params + .maximum_number_of_stewards, valid: Default::default(), }, eth_bridge_params, diff --git a/crates/governance/src/pgf/parameters.rs b/crates/governance/src/pgf/parameters.rs index 171bc91200..c16c9e710a 100644 --- a/crates/governance/src/pgf/parameters.rs +++ b/crates/governance/src/pgf/parameters.rs @@ -34,6 +34,8 @@ pub struct PgfParameters { pub pgf_inflation_rate: Dec, /// The pgf stewards inflation rate pub stewards_inflation_rate: Dec, + /// The maximum number of pgf stewards at once + pub maximum_number_of_stewards: u64, } impl Default for PgfParameters { @@ -42,6 +44,7 @@ impl Default for PgfParameters { stewards: BTreeSet::default(), pgf_inflation_rate: Dec::new(10, 2).unwrap(), stewards_inflation_rate: Dec::new(1, 2).unwrap(), + maximum_number_of_stewards: 5, } } } @@ -56,6 +59,7 @@ impl PgfParameters { stewards, pgf_inflation_rate, stewards_inflation_rate, + maximum_number_of_stewards, } = self; for steward in stewards { @@ -71,6 +75,11 @@ impl PgfParameters { let steward_inflation_rate_key = pgf_storage::get_steward_inflation_rate_key(); - storage.write(&steward_inflation_rate_key, stewards_inflation_rate) + storage.write(&steward_inflation_rate_key, stewards_inflation_rate)?; + + let maximum_number_of_stewards_key = + pgf_storage::get_pgf_inflation_rate_key(); + storage + .write(&maximum_number_of_stewards_key, maximum_number_of_stewards) } } diff --git a/crates/governance/src/pgf/storage/keys.rs b/crates/governance/src/pgf/storage/keys.rs index dcdee44d83..846b5c95ad 100644 --- a/crates/governance/src/pgf/storage/keys.rs +++ b/crates/governance/src/pgf/storage/keys.rs @@ -14,6 +14,7 @@ struct Keys { fundings: &'static str, pgf_inflation_rate: &'static str, steward_inflation_rate: &'static str, + maximum_number_of_stewards: &'static str, } /// Obtain a storage key for stewards key @@ -94,6 +95,13 @@ pub fn get_pgf_inflation_rate_key() -> Key { .expect("Cannot obtain a storage key") } +/// Get key for maximum number of pgf stewards +pub fn get_maximum_number_of_pgf_steward_key() -> Key { + Key::from(ADDRESS.to_db_key()) + .push(&Keys::VALUES.maximum_number_of_stewards.to_owned()) + .expect("Cannot obtain a storage key") +} + /// Get key for inflation rate key pub fn get_steward_inflation_rate_key() -> Key { Key::from(ADDRESS.to_db_key()) diff --git a/crates/node/src/shell/governance.rs b/crates/node/src/shell/governance.rs index 758ec735d8..929ca86c31 100644 --- a/crates/node/src/shell/governance.rs +++ b/crates/node/src/shell/governance.rs @@ -461,18 +461,39 @@ fn execute_pgf_steward_proposal( where S: StorageRead + StorageWrite, { - for action in stewards { - match action { - AddRemove::Add(address) => { - pgf_storage::stewards_handle().insert( - storage, - address.to_owned(), - StewardDetail::base(address), - )?; - } - AddRemove::Remove(address) => { - pgf_storage::stewards_handle().remove(storage, &address)?; - } + let maximum_number_of_pgf_steward_key = + pgf_storage::get_maximum_number_of_pgf_steward_key(); + let maximum_number_of_pgf_steward = storage + .read::(&maximum_number_of_pgf_steward_key)? + .expect( + "Pgf parameter maximum_number_of_pgf_steward must be in storage", + ); + // first we remove + for address in stewards.iter().filter_map(|action| match action { + AddRemove::Add(_) => None, + AddRemove::Remove(address) => Some(address), + }) { + pgf_storage::stewards_handle().remove(storage, address)?; + } + // then we add + let mut steward_count = pgf_storage::stewards_handle().len(storage)?; + for address in stewards.iter().filter_map(|action| match action { + AddRemove::Add(address) => Some(address), + AddRemove::Remove(_) => None, + }) { + #[allow(clippy::arithmetic_side_effects)] + if steward_count + 1 > maximum_number_of_pgf_steward { + return Ok(false); + } + pgf_storage::stewards_handle().insert( + storage, + address.to_owned(), + StewardDetail::base(address.to_owned()), + )?; + + #[allow(clippy::arithmetic_side_effects)] + { + steward_count += 1; } } From ed9415fc730e303749581e2631f7c90ea9e52dbc Mon Sep 17 00:00:00 2001 From: Gianmarco Fraccaroli Date: Tue, 25 Jun 2024 17:38:08 +0200 Subject: [PATCH 4/8] improve logs --- crates/node/src/shell/governance.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/node/src/shell/governance.rs b/crates/node/src/shell/governance.rs index 929ca86c31..478b75fd8b 100644 --- a/crates/node/src/shell/governance.rs +++ b/crates/node/src/shell/governance.rs @@ -158,14 +158,19 @@ where GovernanceEvent::passed_proposal(id, true, result) } ProposalType::PGFSteward(stewards) => { - let _result = execute_pgf_steward_proposal( + let result = execute_pgf_steward_proposal( &mut shell.state, stewards, )?; tracing::info!( "Governance proposal (pgf stewards){} has been \ - executed and passed.", - id + executed and {}.", + id, + if result { + "applied the state changes successfully" + } else { + "didn't applied the state changes successfully" + } ); GovernanceEvent::passed_proposal(id, false, false) From 5fd8935cd81a12111fa4ad90c197ae1bdd2ddc99 Mon Sep 17 00:00:00 2001 From: Gianmarco Fraccaroli Date: Tue, 25 Jun 2024 17:55:34 +0200 Subject: [PATCH 5/8] fix genesis files --- genesis/localnet/parameters.toml | 2 ++ genesis/starter/parameters.toml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/genesis/localnet/parameters.toml b/genesis/localnet/parameters.toml index bef2c1ae2d..2fcb219af2 100644 --- a/genesis/localnet/parameters.toml +++ b/genesis/localnet/parameters.toml @@ -104,6 +104,8 @@ stewards = [ pgf_inflation_rate = "0.1" # The pgf stewards inflation rate stewards_inflation_rate = "0.01" +# The maximum number of pgf stewards +maximum_number_of_stewards = 5 # IBC parameters [ibc_params] diff --git a/genesis/starter/parameters.toml b/genesis/starter/parameters.toml index dfb01522d6..86ccdcedb2 100644 --- a/genesis/starter/parameters.toml +++ b/genesis/starter/parameters.toml @@ -99,6 +99,8 @@ stewards = [] pgf_inflation_rate = "0.1" # The pgf stewards inflation rate stewards_inflation_rate = "0.01" +# The maximum number of pgf stewards +maximum_number_of_stewards = 5 # IBC parameters [ibc_params] From 7aebfda46a038ce344947b17ce87f4699ad93961 Mon Sep 17 00:00:00 2001 From: brentstone Date: Wed, 26 Jun 2024 15:54:52 -0700 Subject: [PATCH 6/8] bug fix: get correct storage key --- crates/governance/src/pgf/parameters.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/governance/src/pgf/parameters.rs b/crates/governance/src/pgf/parameters.rs index c16c9e710a..533497ce12 100644 --- a/crates/governance/src/pgf/parameters.rs +++ b/crates/governance/src/pgf/parameters.rs @@ -78,7 +78,7 @@ impl PgfParameters { storage.write(&steward_inflation_rate_key, stewards_inflation_rate)?; let maximum_number_of_stewards_key = - pgf_storage::get_pgf_inflation_rate_key(); + pgf_storage::get_maximum_number_of_pgf_steward_key(); storage .write(&maximum_number_of_stewards_key, maximum_number_of_stewards) } From 8ac4fcede9f42bceea5cf86bd04fd619504aa589 Mon Sep 17 00:00:00 2001 From: brentstone Date: Wed, 26 Jun 2024 16:11:32 -0700 Subject: [PATCH 7/8] cleanup --- crates/apps_lib/src/config/genesis/templates.rs | 2 +- crates/node/src/shell/governance.rs | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/crates/apps_lib/src/config/genesis/templates.rs b/crates/apps_lib/src/config/genesis/templates.rs index 15c05c08a1..ed6608bb4a 100644 --- a/crates/apps_lib/src/config/genesis/templates.rs +++ b/crates/apps_lib/src/config/genesis/templates.rs @@ -474,7 +474,7 @@ pub struct PgfParams { pub pgf_inflation_rate: Dec, /// The pgf stewards inflation rate pub stewards_inflation_rate: Dec, - /// The pgf stewards inflation rate + /// The maximum allowed number of PGF stewards at any time pub maximum_number_of_stewards: u64, #[serde(default)] #[serde(skip_serializing)] diff --git a/crates/node/src/shell/governance.rs b/crates/node/src/shell/governance.rs index 478b75fd8b..9beb66d74e 100644 --- a/crates/node/src/shell/governance.rs +++ b/crates/node/src/shell/governance.rs @@ -163,13 +163,14 @@ where stewards, )?; tracing::info!( - "Governance proposal (pgf stewards){} has been \ - executed and {}.", + "Governance proposal #{} for PGF stewards has \ + been executed. {}.", id, if result { - "applied the state changes successfully" + "State changes have been applied successfully" } else { - "didn't applied the state changes successfully" + "FAILURE trying to apply the state changes - \ + no state change occurred" } ); @@ -473,14 +474,16 @@ where .expect( "Pgf parameter maximum_number_of_pgf_steward must be in storage", ); - // first we remove + + // First, remove the appropriate addresses for address in stewards.iter().filter_map(|action| match action { AddRemove::Add(_) => None, AddRemove::Remove(address) => Some(address), }) { pgf_storage::stewards_handle().remove(storage, address)?; } - // then we add + + // Then add new addresses let mut steward_count = pgf_storage::stewards_handle().len(storage)?; for address in stewards.iter().filter_map(|action| match action { AddRemove::Add(address) => Some(address), From 267eda23a21ed2fa3808e302f8c14138834f83c4 Mon Sep 17 00:00:00 2001 From: brentstone Date: Wed, 26 Jun 2024 16:19:50 -0700 Subject: [PATCH 8/8] changelog: add #3442 --- .changelog/unreleased/improvements/3442-limit-pgf-stewards.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .changelog/unreleased/improvements/3442-limit-pgf-stewards.md diff --git a/.changelog/unreleased/improvements/3442-limit-pgf-stewards.md b/.changelog/unreleased/improvements/3442-limit-pgf-stewards.md new file mode 100644 index 0000000000..35094192f6 --- /dev/null +++ b/.changelog/unreleased/improvements/3442-limit-pgf-stewards.md @@ -0,0 +1,2 @@ +- Enforce an upper limit on the number of PGF stewards allowed to exist at a + given time. ([\#3442](https://github.com/anoma/namada/pull/3442)) \ No newline at end of file