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

Make BRI configurable by protocol version #4253

Merged
merged 11 commits into from Jan 25, 2024
Merged

Conversation

mitchelli
Copy link
Contributor

No description provided.

@mitchelli mitchelli self-assigned this Jan 22, 2024
@mitchelli mitchelli linked an issue Jan 22, 2024 that may be closed by this pull request
@mitchelli mitchelli changed the title Make BRI configurable Make BRI configurable by protocol version Jan 22, 2024
@@ -1797,8 +1797,8 @@
"protocol_beneficiaries" : {
"type" : "array",
"items" : {
"description" : "Public keys belonging to protocol maintainers with reward shares (100 is 10%). If not set testnet or mainnet beneficiaries and shares will be used based on network_id configuration value. IMPORTANT: The value of this setting is under governance, thus it should not be changed without previous agreement within the configured network on doing so.",
"pattern": "^ak_[1-9A-HJ-NP-Za-km-z]*:[0-9]+$"
"description" : "Public keys belonging to protocol maintainers with reward shares (100 is 10%), optionally a protocol version can be specified from and/or to this account will be rewarded, e.g. ak_2KAcA2Pp1nrR8Wkt3FtCkReGzAi8vJ9Snxa4PcmrthVx8AhPe8:109:6: specifies from Ceres onwards, ak_2KAcA2Pp1nrR8Wkt3FtCkReGzAi8vJ9Snxa4PcmrthVx8AhPe8:109::5 specifies to Iris. If not set testnet or mainnet beneficiaries and shares will be used based on network_id configuration value. IMPORTANT: The value of this setting is under governance, thus it should not be changed without previous agreement within the configured network on doing so.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason we need from-to spec? Usually protocol specific configuration requires just the protocol it kick s in, the from is somehow explicit?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The protocol_beneficiaries is a list of beneficiaries rather than a single beneficiary. If it was a single beneficiary then it would be implicit but with a list I don't think it is.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could just have a single protocol version there and get the same behavio I think 🤔 - but, this is perhaps clearer (and easier to work with). @dincho since a BRI account is normally(?) active for multiple protocols it is a bit different.

Still, changing BRI is probably not the common case, so normal usage would be singleton list with Addr:BRIAmount:: I guess?

Copy link
Contributor Author

@mitchelli mitchelli Jan 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, Addr:BRIAmount:: is the common case but you don't need to specify the to and from in this case, they are optional. You could just specify Addr:BRIAmount

From the code, it looks like it is possible to specify multi BRI accounts, it adds them together and makes sure they don't go above a certain limit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, if there is technical requirement that's fine

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling it a requirement is perhaps a bit strong, but I think this variant is slightly more fool-proof. Though I'm sure Nikita or Thomas would break it in a minute 😅

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how a fool would try to change the beneficiary

  1. Add NewAddr:1000 to config
    That fails, because the old beneficiary is there and now the total is more than 100% ???
  2. remove Addr:1000 from config....
    That fails, I guess, because synchronizing and validating old blocks would no longer work?
    Possibly not something one would notice straight away, but as soon as one starts that config on a new node to sync??
  3. Introduce a new protocol vsn 2 and then configure
    Addr:1000::1
    NewAddr:1000::
    Because someone said that that was the default use-case.
    But it is actually better to say
    NewAddr:1000:2:

Did I understand the documentation well?

apps/aecore/src/aec_dev_reward.erl Outdated Show resolved Hide resolved
apps/aecore/src/aec_dev_reward.erl Outdated Show resolved Hide resolved
Copy link
Member

@hanssv hanssv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

I've run (locally) my hacky system test - where I configured a new BRI account at Ceres. And accounts are awarded as expected 👍

@@ -20,34 +21,47 @@
-define(TOTAL_SHARES, 1000). % 100 shares == 10% of the reward
%%% weighted avg BRI voting result of 1% to 20% (yes) votes is 10.89869526640124746202%, 109 of 1000 shares will be the protocol reward
%%% for: "ak_2KAcA2Pp1nrR8Wkt3FtCkReGzAi8vJ9Snxa4PcmrthVx8AhPe8:109"
-define(MAINNET_BENEFICIARIES, [{<<172,241,128,85,116,104,119,143,197,105,4,192,224,207,200,138,230,84,111,38,89,33,239,21,201,183,185,209,19,60,109,136>>, 109}]).
%%%%%%%%% TODO update with real values
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a TO DO for later or something that was planned for this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for later, it should be before updated before Ceres goes live but we are waiting for a new BRI account from the foundation.

catch
error:Reason ->
{error, Reason}
end.

beneficiaries_at_protocol(ProtocolVsn, Beneficiaries) ->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feels overly careful to check for FromProtocol and TOProtocol to be undefined.
The places where you call this function already guarantee that these are integers.

I would add a type spec that they must be integers and possibly crash if not by a guard is_integer in the function clause

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that it is also called from the test function: set_beneficiaries which could include undefined as to or from parameters.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but that is test code... you don't need to expose this function from outside (only for testing) and therefore you can adapt the test to obtain clearer code and only export for test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The set_beneficiaries is only exported if TEST is set. It is used externally by the chain tests.

@@ -1797,8 +1797,8 @@
"protocol_beneficiaries" : {
"type" : "array",
"items" : {
"description" : "Public keys belonging to protocol maintainers with reward shares (100 is 10%). If not set testnet or mainnet beneficiaries and shares will be used based on network_id configuration value. IMPORTANT: The value of this setting is under governance, thus it should not be changed without previous agreement within the configured network on doing so.",
"pattern": "^ak_[1-9A-HJ-NP-Za-km-z]*:[0-9]+$"
"description" : "Public keys belonging to protocol maintainers with reward shares (100 is 10%), optionally a protocol version can be specified from and/or to this account will be rewarded, e.g. ak_2KAcA2Pp1nrR8Wkt3FtCkReGzAi8vJ9Snxa4PcmrthVx8AhPe8:109:6: specifies from Ceres onwards, ak_2KAcA2Pp1nrR8Wkt3FtCkReGzAi8vJ9Snxa4PcmrthVx8AhPe8:109::5 specifies to Iris. If not set testnet or mainnet beneficiaries and shares will be used based on network_id configuration value. IMPORTANT: The value of this setting is under governance, thus it should not be changed without previous agreement within the configured network on doing so.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how a fool would try to change the beneficiary

  1. Add NewAddr:1000 to config
    That fails, because the old beneficiary is there and now the total is more than 100% ???
  2. remove Addr:1000 from config....
    That fails, I guess, because synchronizing and validating old blocks would no longer work?
    Possibly not something one would notice straight away, but as soon as one starts that config on a new node to sync??
  3. Introduce a new protocol vsn 2 and then configure
    Addr:1000::1
    NewAddr:1000::
    Because someone said that that was the default use-case.
    But it is actually better to say
    NewAddr:1000:2:

Did I understand the documentation well?

@mitchelli mitchelli merged commit 2d5ce24 into master Jan 25, 2024
35 checks passed
@mitchelli mitchelli deleted the 4246-make-bri-configurable branch January 25, 2024 11:51
@dincho dincho added the kind/feature Issues or PRs related to a new feature label Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Issues or PRs related to a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make BRI configurable by protocol version
4 participants