-
Notifications
You must be signed in to change notification settings - Fork 10
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(avs):implement whitelist feature for AVS #262
base: develop
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,7 @@ interface IAVSManager { | |
/// @param slashAddr The slash address of AVS. | ||
/// @param rewardAddr The reward address of AVS. | ||
/// @param avsOwnerAddress The owners who have permission for AVS. | ||
/// @param whitelistAddress The whitelist address of the operator. | ||
/// @param assetIds The basic asset information of AVS. | ||
/// @param avsUnbondingPeriod The unbonding duration of AVS. | ||
/// @param minSelfDelegation The minimum delegation amount for an operator. | ||
|
@@ -65,6 +66,7 @@ interface IAVSManager { | |
address slashAddr, | ||
address rewardAddr, | ||
string[] memory avsOwnerAddress, | ||
string[] memory whitelistAddress, | ||
trestinlsd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
string[] memory assetIds, | ||
uint64 avsUnbondingPeriod, | ||
uint64 minSelfDelegation, | ||
|
@@ -80,6 +82,7 @@ interface IAVSManager { | |
/// @param slashAddr The slash address of AVS. | ||
/// @param rewardAddr The reward address of AVS. | ||
/// @param avsOwnerAddress The owners who have permission for AVS. | ||
/// @param whitelistAddress The whitelist address of the operator. | ||
/// @param assetIds The basic asset information of AVS. | ||
/// @param avsUnbondingPeriod The unbonding duration of AVS. | ||
/// @param minSelfDelegation The minimum delegation amount for an operator. | ||
|
@@ -96,6 +99,7 @@ interface IAVSManager { | |
address slashAddr, | ||
address rewardAddr, | ||
string[] memory avsOwnerAddress, | ||
string[] memory whitelistAddress, | ||
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. Why choose |
||
string[] memory assetIds, | ||
uint64 avsUnbondingPeriod, | ||
uint64 minSelfDelegation, | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -129,7 +129,8 @@ func (k Keeper) UpdateAVSInfo(ctx sdk.Context, params *types.AVSRegisterOrDeregi | |||||||||||||||||||
// #nosec G115 | ||||||||||||||||||||
AvsSlash: sdk.NewDecWithPrec(int64(params.AvsSlash), 2), | ||||||||||||||||||||
// #nosec G115 | ||||||||||||||||||||
AvsReward: sdk.NewDecWithPrec(int64(params.AvsReward), 2), | ||||||||||||||||||||
AvsReward: sdk.NewDecWithPrec(int64(params.AvsReward), 2), | ||||||||||||||||||||
WhitelistAddress: params.WhitelistAddress, | ||||||||||||||||||||
trestinlsd marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
return k.SetAVSInfo(ctx, avs) | ||||||||||||||||||||
|
@@ -185,6 +186,9 @@ func (k Keeper) UpdateAVSInfo(ctx sdk.Context, params *types.AVSRegisterOrDeregi | |||||||||||||||||||
if params.AvsOwnerAddress != nil { | ||||||||||||||||||||
avs.AvsOwnerAddress = params.AvsOwnerAddress | ||||||||||||||||||||
} | ||||||||||||||||||||
if params.WhitelistAddress != nil { | ||||||||||||||||||||
avs.WhitelistAddress = params.WhitelistAddress | ||||||||||||||||||||
} | ||||||||||||||||||||
Comment on lines
+189
to
+191
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. Add validation for WhitelistAddress during AVS updates Similar to the registration flow, the update flow also lacks address validation for WhitelistAddress. Add validation before updating WhitelistAddress: if params.WhitelistAddress != nil {
+ if err := k.validateAddresses(params.WhitelistAddress); err != nil {
+ return err
+ }
avs.WhitelistAddress = params.WhitelistAddress
} 📝 Committable suggestion
Suggested change
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. Please consider this comment from the AI. 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. @MaxMustermann2, here's an example of how you could incorporate address validation for the WhitelistAddress before updating: // helper function to validate a list of Bech32 addresses
func (k Keeper) validateAddresses(addresses []string) error {
for _, addr := range addresses {
if _, err := sdk.AccAddressFromBech32(addr); err != nil {
return errorsmod.Wrap(types.ErrInvalidAddr, fmt.Sprintf("Invalid whitelist address: %s", addr))
}
}
return nil
}
// snippet inside UpdateAVSInfo
if params.WhitelistAddress != nil {
if err := k.validateAddresses(params.WhitelistAddress); err != nil {
return err
}
avs.WhitelistAddress = params.WhitelistAddress
} This ensures each address is checked for validity prior to updating the whitelist. |
||||||||||||||||||||
if params.AssetID != nil { | ||||||||||||||||||||
avs.AssetIDs = params.AssetID | ||||||||||||||||||||
if err := k.ValidateAssetIDs(ctx, params.AssetID); err != nil { | ||||||||||||||||||||
|
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.
Have you verified that this file compiles? Too many local variables (within a function) can cause Solidity to complain "stack too deep"