-
Notifications
You must be signed in to change notification settings - Fork 15
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
feat: [PRO-823] bind-nodes-executor-to-address #3987
Merged
Janislav
merged 6 commits into
main
from
feature/PRO-823/bind-nodes-executor-to-address
Sep 18, 2023
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
cb7fdb8
feat: :sparkles: added benchmarks
Janislav 56786f4
fix: :bug: fixed clippy
Janislav cafde7b
test: :test_tube: added tests
Janislav de1bae1
refactor: :recycle: renaming
Janislav 8b13e03
docs: :memo: updated comment
Janislav 91f331c
Merge branch 'main' into feature/PRO-823/bind-nodes-executor-to-address
dandanlen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,7 +136,7 @@ pub mod pallet { | |
|
||
/// Registered addresses for an executor. | ||
#[pallet::storage] | ||
pub type ExecutorAddressBinding<T: Config> = | ||
pub type BoundExecutorAddress<T: Config> = | ||
StorageMap<_, Blake2_128Concat, AccountId<T>, EthereumAddress, OptionQuery>; | ||
|
||
/// List of restricted addresses | ||
|
@@ -156,7 +156,7 @@ pub mod pallet { | |
|
||
/// Map of bound addresses for accounts. | ||
#[pallet::storage] | ||
pub type BoundAddress<T: Config> = | ||
pub type BoundRedeemAddress<T: Config> = | ||
StorageMap<_, Blake2_128Concat, AccountId<T>, EthereumAddress>; | ||
|
||
/// The fee levied for every redemption request. Can be updated by Governance. | ||
|
@@ -298,7 +298,7 @@ pub mod pallet { | |
StopBiddingDisabled, | ||
|
||
/// Wrong executor address | ||
InvalidExecutorAddress, | ||
ExecutorBindingRestrictionViolated, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: please update the comment too - it's included in the type metadata and displayed to users, it should be useful. Something like |
||
|
||
/// The account is already bound to an executor address. | ||
ExecutorAddressAlreadyBound, | ||
|
@@ -377,10 +377,10 @@ pub mod pallet { | |
) -> DispatchResultWithPostInfo { | ||
let account_id = ensure_signed(origin)?; | ||
|
||
if let Some(executor_addr) = ExecutorAddressBinding::<T>::get(&account_id) { | ||
if let Some(executor_addr) = BoundExecutorAddress::<T>::get(&account_id) { | ||
ensure!( | ||
executor_addr == executor.unwrap_or_default(), | ||
Error::<T>::InvalidExecutorAddress | ||
Error::<T>::ExecutorBindingRestrictionViolated | ||
); | ||
} | ||
|
||
|
@@ -400,7 +400,7 @@ pub mod pallet { | |
let mut restricted_balances = RestrictedBalances::<T>::get(&account_id); | ||
let redemption_fee = RedemptionTax::<T>::get(); | ||
|
||
if let Some(bound_address) = BoundAddress::<T>::get(&account_id) { | ||
if let Some(bound_address) = BoundRedeemAddress::<T>::get(&account_id) { | ||
ensure!( | ||
bound_address == address || | ||
restricted_balances.keys().any(|res_address| res_address == &address), | ||
|
@@ -681,8 +681,11 @@ pub mod pallet { | |
address: EthereumAddress, | ||
) -> DispatchResultWithPostInfo { | ||
let account_id = ensure_signed(origin)?; | ||
ensure!(!BoundAddress::<T>::contains_key(&account_id), Error::<T>::AccountAlreadyBound); | ||
BoundAddress::<T>::insert(&account_id, address); | ||
ensure!( | ||
!BoundRedeemAddress::<T>::contains_key(&account_id), | ||
Error::<T>::AccountAlreadyBound | ||
); | ||
BoundRedeemAddress::<T>::insert(&account_id, address); | ||
Self::deposit_event(Event::BoundRedeemAddress { account_id, address }); | ||
Ok(().into()) | ||
} | ||
|
@@ -722,10 +725,10 @@ pub mod pallet { | |
) -> DispatchResultWithPostInfo { | ||
let account_id = ensure_signed(origin)?; | ||
ensure!( | ||
!ExecutorAddressBinding::<T>::contains_key(&account_id), | ||
!BoundExecutorAddress::<T>::contains_key(&account_id), | ||
Error::<T>::ExecutorAddressAlreadyBound, | ||
); | ||
ExecutorAddressBinding::<T>::insert(account_id.clone(), executor_address); | ||
BoundExecutorAddress::<T>::insert(account_id.clone(), executor_address); | ||
Self::deposit_event(Event::BoundExecutorAddress { | ||
account_id, | ||
address: executor_address, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Unfortunately this will require a storage migration (if it's not empty) 🙈
I don't mind leaving it out until we release - right now the storage is empty on perseverance.
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.
Mhhh.... Well that's bad :D. But I think we will release from scratch anyway and if it's empty on perseverance I don't think it should be an issue or?
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.
Yes that's what I mean - no need to migrate unless we use this in perseverance (and I don't think we will).