-
Notifications
You must be signed in to change notification settings - Fork 447
feat: instant alloc delay from dm #1646
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
base: release-dev/slashing-ux-improvements
Are you sure you want to change the base?
feat: instant alloc delay from dm #1646
Conversation
54b756c
to
68e1331
Compare
* @param allocationConfigurationDelay The delay after which the allocation delay takes effect. 0 if the operator is newly registered, otherwise ALLOCATION_CONFIGURATION_DELAY. | ||
*/ | ||
function _setAllocationDelay(address operator, uint32 delay) internal { | ||
function _setAllocationDelay(address operator, uint32 delay, uint32 allocationConfigurationDelay) internal { |
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.
Rather than passing in an arbitrary uint32
, which we expect to be constrained to either 0 or ALLOCATION_CONFIGURATION_DELAY
based on whether this is an operator's first registration or subsequent registration respectively, I recommend instead using existing storage within this function to determine what effectBlock
to set.
info.effectBlock
is 0
before registration, and non-zero after registration. By checking within this function if info.effectBlock == 0
, we can then set the new effectBlock
accordingly: uint32(block.number) + 1
if true
, uint32(block.number) + ALLOCATION_CONFIGURATION_DELAY + 1
if false
. This constrains the function inputs to as few as possible, and allows the internal function to figure out the correct delay for the operator.
Side question: is having the delay activate on the block following this call a consequence of the implementation, or is there a safety or other concern meriting it?
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.
Good points. I think we cannot do the effectBlock == 0
check because we only want newly registered operators (in core) to be able to allocate after a single block. However, if we checked effectBlock==0
, then both newly registered operators and operators that have previously registered, but not used slashing, could allocate instantly, which we don't want. Thoughts on passing in a bool instead?
I kept +1 for consistency with the old implementation. Though, it remains to be seen if we want an immediate allocation (same block)
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.
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.
Good callout on already existing operators requiring a different flow! The boolean approach makes total sense.
There's a slight optimization you can do for codesize by removing the newlyRegistered = false
statement (since it'll already be false by default). But other than that, looks solid.
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.
True, will remove
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.
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.
Looked over it again, here's what I think the cleanest implementation is, for most clarity and least codesize:
function setAllocationDelay(address operator, uint32 delay) external {
/// If the caller is the delegationManager, the operator is newly registered
/// This results in *newly-registered* operators in the core protocol to have their allocation delay effective after 1 block
bool newlyRegistered = (msg.sender != address(delegation));
if (!newlyRegistered) {
require(_checkCanCall(operator), InvalidCaller());
require(delegation.isOperator(operator), InvalidOperator());
}
_setAllocationDelay(operator, delay, newlyRegistered);
}
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.
Cleaner! Updated: 3850113
Motivation:
Newly created operators in core have to wait 17.5 days to begin allocating. This is a UX painpoint for new AVSs to onboard their operators.
Modifications:
Update the
AllocationManager
so that the allocation delay for a newly created operator is active at the next block. This allows operators to make an allocation at the very next block.Result:
Easier onboarding