Skip to content

Commit

Permalink
Merge branch 'grarco/fix-pgf-stewards-funding' (#1999)
Browse files Browse the repository at this point in the history
  • Loading branch information
grarco committed Oct 20, 2023
2 parents 454b3f6 + 05fbe1f commit 738fb61
Show file tree
Hide file tree
Showing 26 changed files with 78 additions and 61 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Fixed the pgf stewards reward to be constant regardless of the number of
stewards. ([\#1999](https://github.com/anoma/namada/pull/1999))
2 changes: 2 additions & 0 deletions .changelog/v0.23.1/bug-fixes/1991-fix-pgf-payment-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Fixed a bug that would cause the ledger to crash on a failed PGF payment.
([\#1991](https://github.com/anoma/namada/pull/1991))
1 change: 1 addition & 0 deletions .changelog/v0.23.1/summary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Namada 0.23.1 is a patch release fixing a potential ledger crash on the pgf module.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# CHANGELOG

## v0.23.1

Namada 0.23.1 is a patch release fixing a potential ledger crash on the pgf module.

### BUG FIXES

- Fixed a bug that would cause the ledger to crash on a failed PGF payment.
([\#1991](https://github.com/anoma/namada/pull/1991))

## v0.23.0

Namada is a minor release that improves the ethereum bridge, the IBC mechanism, and fixes some general protocol bugs.
Expand Down
26 changes: 13 additions & 13 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ keywords = ["blockchain", "privacy", "crypto", "protocol", "network"]
license = "GPL-3.0"
readme = "README.md"
repository = "https://github.com/anoma/namada"
version = "0.23.0"
version = "0.23.1"

[workspace.dependencies]
ark-bls12-381 = {version = "0.3"}
Expand Down
16 changes: 5 additions & 11 deletions apps/src/lib/node/ledger/shell/finalize_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -801,13 +801,16 @@ where
pgf_parameters.pgf_inflation_rate / Dec::from(epochs_per_year);
let pgf_inflation = Dec::from(total_tokens) * pgf_pd_rate;

let stewards = pgf::get_stewards(&self.wl_storage)?;
let pgf_stewards_pd_rate =
pgf_parameters.stewards_inflation_rate / Dec::from(epochs_per_year);
let pgf_steward_inflation =
Dec::from(total_tokens) * pgf_stewards_pd_rate;
let total_pgf_stewards_inflation =
pgf_steward_inflation * Dec::from(stewards.len());

let pgf_inflation_amount =
token::Amount::from(pgf_inflation + pgf_steward_inflation);
token::Amount::from(pgf_inflation + total_pgf_stewards_inflation);

credit_tokens(
&mut self.wl_storage,
Expand Down Expand Up @@ -850,18 +853,9 @@ where
}

// Pgf steward inflation
let stewards = pgf::get_stewards(&self.wl_storage)?;

let pgf_steward_reward = match stewards.len() {
0 => Dec::zero(),
_ => pgf_steward_inflation
.trunc_div(&Dec::from(stewards.len()))
.unwrap_or_default(),
};

for steward in stewards {
for (address, percentage) in steward.reward_distribution {
let pgf_steward_reward = pgf_steward_reward
let pgf_steward_reward = pgf_steward_inflation
.checked_mul(&percentage)
.unwrap_or_default();
let reward_amount = token::Amount::from(pgf_steward_reward);
Expand Down
25 changes: 17 additions & 8 deletions apps/src/lib/node/ledger/shell/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,19 +378,28 @@ where
}
},
PGFAction::Retro(target) => {
token::transfer(
match token::transfer(
storage,
token,
&ADDRESS,
&target.target,
target.amount,
)?;
tracing::info!(
"Execute RetroPgf from proposal id {}: sent {} to {}.",
proposal_id,
target.amount.to_string_native(),
target.target
);
) {
Ok(()) => tracing::info!(
"Execute RetroPgf from proposal id {}: sent {} to {}.",
proposal_id,
target.amount.to_string_native(),
target.target
),
Err(e) => tracing::warn!(
"Error in RetroPgf transfer from proposal id {}, \
amount {} to {}: {}",
proposal_id,
target.amount.to_string_native(),
target.target,
e
),
}
}
}
}
Expand Down
26 changes: 13 additions & 13 deletions wasm/Cargo.lock

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

2 changes: 1 addition & 1 deletion wasm/tx_template/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ edition = "2021"
license = "GPL-3.0"
name = "tx_template"
resolver = "2"
version = "0.23.0"
version = "0.23.1"

[lib]
crate-type = ["cdylib"]
Expand Down
2 changes: 1 addition & 1 deletion wasm/vp_template/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ edition = "2021"
license = "GPL-3.0"
name = "vp_template"
resolver = "2"
version = "0.23.0"
version = "0.23.1"

[lib]
crate-type = ["cdylib"]
Expand Down
2 changes: 1 addition & 1 deletion wasm/wasm_source/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ edition = "2021"
license = "GPL-3.0"
name = "namada_wasm"
resolver = "2"
version = "0.23.0"
version = "0.23.1"

[lib]
crate-type = ["cdylib"]
Expand Down
Binary file modified wasm_for_tests/tx_memory_limit.wasm
Binary file not shown.
Binary file modified wasm_for_tests/tx_mint_tokens.wasm
Binary file not shown.
Binary file modified wasm_for_tests/tx_no_op.wasm
Binary file not shown.
Binary file modified wasm_for_tests/tx_proposal_code.wasm
Binary file not shown.
Binary file modified wasm_for_tests/tx_read_storage_key.wasm
Binary file not shown.
Binary file modified wasm_for_tests/tx_write.wasm
Binary file not shown.
Binary file modified wasm_for_tests/tx_write_storage_key.wasm
Binary file not shown.
Binary file modified wasm_for_tests/vp_always_false.wasm
Binary file not shown.
Binary file modified wasm_for_tests/vp_always_true.wasm
Binary file not shown.
Binary file modified wasm_for_tests/vp_eval.wasm
Binary file not shown.
Binary file modified wasm_for_tests/vp_memory_limit.wasm
Binary file not shown.
Binary file modified wasm_for_tests/vp_read_storage_key.wasm
Binary file not shown.
Loading

0 comments on commit 738fb61

Please sign in to comment.