-
Notifications
You must be signed in to change notification settings - Fork 122
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
Access Controller Fee Vault. #1785
Conversation
…ts' into feature/access-controller-vault
Docker tags |
Benchmark for 02c8b84Click to view benchmark
|
…ts' into feature/access-controller-vault
@@ -428,7 +428,7 @@ pub enum TypedMainModuleSubstateValue { | |||
NonFungibleVault(NonFungibleVaultTypedSubstateValue), | |||
ConsensusManager(ConsensusManagerTypedSubstateValue), | |||
Validator(ValidatorTypedSubstateValue), | |||
AccessController(AccessControllerTypedSubstateValue), | |||
AccessController(AccessControllerV2TypedSubstateValue), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need both AccessControllerV1
and AccessControllerV2
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think that v1 is needed here since both v1 and v2 substates can be represented as AccessControllerV2TypedSubstateValue
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we decode the V1 sbor payload into AccessControllerV2TypedSubstateValue
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup should be possible since the main change is that we added a new version (enum variant) so we should be able to decode v1 as v2, I've just added a test for that: access_controller_state_v1_can_be_decoded_as_v2
.
Also, this is implicitly tested in test_all_scenario_commit_receipts_should_have_substate_changes_which_can_be_typed
since our scenarios use AccessControllerV1 and their state can be typed.
@@ -153,7 +153,7 @@ pub enum TypedMainModuleSubstateKey { | |||
NonFungibleVault(NonFungibleVaultTypedSubstateKey), | |||
ConsensusManager(ConsensusManagerTypedSubstateKey), | |||
ValidatorField(ValidatorTypedSubstateKey), | |||
AccessController(AccessControllerTypedSubstateKey), | |||
AccessController(AccessControllerV2TypedSubstateKey), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If v1 and v2 are the same, we should keep AccessControllerTypedSubstateKey
? or we should have AccessControllerV1
and AccessControllerV2
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this is similar to the other discussion, I believe that blueprint updates that extend the state (adding fields as an example) we can use latest versions.
Summary
This PR adds an XRD vault to the state of access controllers and methods for depositing, withdrawing, and locking XRD from that vault for fees. Anyone is allowed to deposit into the vault. Only the primary role is allowed to withdraw from the vault and any three of the roles are allowed to lock XRD from the vault for fees.
Details
An
AccessControllerV2
blueprint is added with this PR which has an updates state structure that contains an XRD whose primary usage is for locking fees for recoveries. The addition of this field pushed the state to v2. The update from the v1 state (that doesn't have the vault) to v2 (which has a field for an optional vault) is done lazily, any method call to the access controller updates the state after the protocol update. This means that it is possible to have some access controller on v1 while others are on v2 after the protocol update.Alongside the above state changes, the following methods have been added to the access controller blueprint:
A
DepositRecoveryXrdEvent
is emitted when XRD is deposited into the vault via thecontribute_recovery_fee
method and aWithdrawRecoveryXrdEvent
method is emitted when XRD is withdrawn from the vault via thewithdraw_recovery_fee
method.Testing
All of the testing done for this PR can be found in the
radix-engine-tests/tests/flash/access_controller.rs
file.Update Recommendations
For Internal Integrators
Be aware that this introduces a protocol update that updates the access controller blueprint from v1 to v2 by doing the following:
Additionally, the following changes were made that you should be aware of: