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 · 6 comments
Closed

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

zone117x opened this issue Dec 11, 2023 · 6 comments
Assignees

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 friedger moved this from Status: 🆕 New to Status: In Review in Stacks Core Eng Jan 10, 2024
@friedger
Copy link
Collaborator

yes, it should fail.

@friedger
Copy link
Collaborator

fixed in #4157

@github-project-automation github-project-automation bot moved this from Status: In Review to Status: ✅ Done in Stacks Core Eng Jan 24, 2024
@blockstack-devops
Copy link
Contributor

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@stacks-network stacks-network locked as resolved and limited conversation to collaborators Oct 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Archived in project
Development

No branches or pull requests

4 participants