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

PoX-4 revoke-delegate-stx calls should fail if no state is changed #4146

Closed
zone117x opened this issue Dec 11, 2023 · 5 comments
Closed

PoX-4 revoke-delegate-stx calls should fail if no state is changed #4146

zone117x opened this issue Dec 11, 2023 · 5 comments
Assignees
Labels

Comments

@zone117x
Copy link
Member

zone117x commented Dec 11, 2023

There's a discussion in PR #4094 around the behavior of revoke-delegate-stx. Right now the function always returns (ok) even if no state was changed:

(define-public (revoke-delegate-stx)
(begin
;; must be called directly by the tx-sender or by an allowed contract-caller
(asserts! (check-caller-allowed)
(err ERR_STACKING_PERMISSION_DENIED))
(ok (map-delete delegation-state { stacker: tx-sender }))))

This means A) the new synthetic event for revoke-delegate-stx can be triggered repeatedly for no valid/useful reason, and B) the event has empty data:

"revoke-delegate-stx" => {
format!(
r#"
{{
data: {{ }}
}}
"#,

Ideally the event would at least include the delegate-to address so that the event can be associated with the prior delegation. And ideally the call would return an error and not emit repeated events if called repeatedly.

@friedger
Copy link
Collaborator

Could you clarify the use case.
Revoking implies that the user does not delegate anymore after the tx was successful.

Users have to check the stacking state nevertheless to learn about the stacking state.

@zone117x
Copy link
Member Author

zone117x commented Dec 11, 2023

If an event observer receives a revoke-delegate-stx event with no data and possibly repeated, then it has to:

  1. Scan through past revoke-delegate-stx and delegate-stx events to check if this one actually changed state and is not a redundant no-op event.
  2. Scan through past delegation events to find the associated delegate-to address and stx amounts.

Or, if you don't handle this during event ingestion, you just push off the complexity to read queries. E.g. a query for "as a delegate, what are the last X revocations that I should act on?".

Why require event observers to handle more stacking state complexity when It seems trivial to improve this on the pox/stacks-node side?

@friedger
Copy link
Collaborator

Should revoke-delegate-stx fail if the delegation expired?

@friedger friedger self-assigned this Dec 13, 2023
@friedger
Copy link
Collaborator

yes, it should fail.

@friedger
Copy link
Collaborator

fixed in #4157

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

No branches or pull requests

3 participants