From f268a770ddac705e623fda870fa9e96e15394ba0 Mon Sep 17 00:00:00 2001 From: ghostant-1017 Date: Mon, 13 Nov 2023 15:52:48 +0800 Subject: [PATCH 1/3] Enable to set beneficiary for validator --- arc-0035/README.md | 89 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 arc-0035/README.md diff --git a/arc-0035/README.md b/arc-0035/README.md new file mode 100644 index 0000000..7293cd2 --- /dev/null +++ b/arc-0035/README.md @@ -0,0 +1,89 @@ +--- +arc: 0034 +title: Enable to set beneficiary for validator +authors: Ghostant1017 +discussion: +topic: Protocol +status: Draft +created: 13/11/2023 +--- + +## Abstract + +In AleoBFT, validators benefit from bonding `credits.aleo/credits` into the program `credits.aleo`. Others can delegate to bond `credits.aleo/credits` to one of the `credits.aleo/committee` to get reward by staking. However, the validators can call `credits.aleo/unbond_delegator_as_validator` to unbond any delegator that is bonded to them. If validators allow other people to bond with them , their own rewards are diluted, which does not incentivize validators to accept other people's pledges. + +In this ARC, we propose to add a beneficiary for validator, which means that, the PoS rewards will not be directly sent to the bonded address.All rewards will go to an external account or a contract account. And if the beneficiary is set as a contract account, the validator could customize the logic distribute the rewards.It enables the validator to charge service fee from users and incentive validators to attract users to delegate credits to them. + + + + +## Specification + + + +1.Add a extra field in `credits.aleo/struct committee_state` + +```aleo +struct committee_state: + // The beneficiary of the validator where the PoS rewards will be distributed to. + beneficiary as address; + // The amount of microcredits bonded to the validator, by the validator and its delegators. + microcredits as u64; + // The boolean flag indicating if the validator is open to stakers. + is_open as boolean; +``` + +2.Change the logic in `fn staking_rewards` + +```rust +let beneficiaries: HashMap:: = HashMap::new(); +cfg_iter!(stakers) + .map(|(staker, (beneficiary, validator, stake))| { + if beneficiary != validator { + // Distribute the rewards to the `beneficiary` + } +} +``` + +3.Update the logic in `fn ensure_stakers_matches` + +### Test Cases + +1.Test the reward distribution when `beneficiary == validator` + +2.Test the reward distribution when `beneficiary != validator` + +- Check the committee map +- Check the bond map +- Check the balance map + + + + +## Reference Implementations + +Not yet + +## Dependencies + +This proposal will only affect the snarkVM. + + + +### Backwards Compatibility + +We need to think carefully about the incentive-economy model of PoS to avoid implications for backward compatibility + + + + +## Security & Compliance + +There should be no regulatory concerns. + + + + +## References + + From 1666ba48403d609384733a3e07963a3c7487d0aa Mon Sep 17 00:00:00 2001 From: ghost ant <53888545+ghostant-1017@users.noreply.github.com> Date: Mon, 13 Nov 2023 15:55:26 +0800 Subject: [PATCH 2/3] Update README.md Signed-off-by: ghost ant <53888545+ghostant-1017@users.noreply.github.com> --- arc-0035/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arc-0035/README.md b/arc-0035/README.md index 7293cd2..ba5c7ed 100644 --- a/arc-0035/README.md +++ b/arc-0035/README.md @@ -25,8 +25,8 @@ In this ARC, we propose to add a beneficiary for validator, which means that, th ```aleo struct committee_state: - // The beneficiary of the validator where the PoS rewards will be distributed to. - beneficiary as address; + // The beneficiary of the validator where the PoS rewards will be distributed to. + beneficiary as address; // The amount of microcredits bonded to the validator, by the validator and its delegators. microcredits as u64; // The boolean flag indicating if the validator is open to stakers. From d3232b9911d2579d2863ba9536fc83120f10132e Mon Sep 17 00:00:00 2001 From: ghost ant <53888545+ghostant-1017@users.noreply.github.com> Date: Mon, 13 Nov 2023 15:57:44 +0800 Subject: [PATCH 3/3] Update README.md Signed-off-by: ghost ant <53888545+ghostant-1017@users.noreply.github.com> --- arc-0035/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arc-0035/README.md b/arc-0035/README.md index ba5c7ed..ddf860b 100644 --- a/arc-0035/README.md +++ b/arc-0035/README.md @@ -1,5 +1,5 @@ --- -arc: 0034 +arc: 0035 title: Enable to set beneficiary for validator authors: Ghostant1017 discussion: