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

Add state getter in TimelockController using OperationState enum #4316

Closed
ernestognw opened this issue Jun 5, 2023 · 6 comments · Fixed by #4358
Closed

Add state getter in TimelockController using OperationState enum #4316

ernestognw opened this issue Jun 5, 2023 · 6 comments · Fixed by #4358
Labels
breaking change Changes that break backwards compatibility of the public API. feature New contracts, functions, or helpers.
Milestone

Comments

@ernestognw
Copy link
Member

Description

We introduced an enum of OperationStates for custom errors in #4261. However, it feels weird that such enum is only used for custom errors.

We should use the same enum for retrieving the state. We might also want to replace the state getters with this new state(bytes32 id) getter.

@clauBv23
Copy link
Contributor

clauBv23 commented Jun 16, 2023

Hi there,

I have been taking a look at this task and, have some concerns regarding it.
Currently, the states are not restrictive, I mean, an operation could be in both the pending and ready state. Due to that, there are some places where this is taken as an advantage to check the minimal needed restrictions like in

} else if (_timelock.isOperationPending(queueid)) {
return ProposalState.Queued;
where with a single check covers the pending and the ready state.

A solution for that case using a state-getter could be to check if the operation is either pending or ready like is being done in the proposed PR, but by doing it more checks will be needed to do the same.
Also to check a specific operation state, will be needed to ensure it is not in other ones (to know if is ready should check if is not pending or vice-versa).

So in general, Even though I agree it will be more descriptive and clean, it will likely increase the amount of checks needed to do the same that is being done at this time.

@Amxx
Copy link
Collaborator

Amxx commented Jun 16, 2023

We could rename "Pending" into "Waiting" in the enum, and consider that Pending == Waiting || Ready. We would keepn the isOperationPending getter for compatibility (governor uses that)

@ernestognw WDYT?

@clauBv23
Copy link
Contributor

clauBv23 commented Jun 19, 2023

That will definitely work, but due to "Ready" and "Pending" being opposite it could sound contradictory. Maybe going with Active == Pending || Ready?

@Amxx
Copy link
Collaborator

Amxx commented Jun 19, 2023

Active == Pending || Ready sounds great, but then what would isOperationPending return ?

Remember that the governor does a isOperationPending lookup to check is the operation was queued. With the change you propose the governor should look if the operation is active...

So again, either isOperationPending returns true is the operation is Active (and that doesn't sound right) ... or the govenor does an isOperationActive on the timelock controller ... but that reverts for old instances of the timelock

an option would be for the governor to do

function isOperationActiveWithFallback(bytes32 queueId) private view returns (bool) {
  try _timelock.isOperationActive(queueId) returns (bool isActive) {
    return isActive;
  } catch {
    // assume old governor
    return _timelock.isOperationPending(queueId);
  }
}

Before any decision is made, we should discuss that with the team

@clauBv23
Copy link
Contributor

Yeap, you are right, changing to Active will break the previous instances, and even though it could be solved as you mentioned, it might not be worth it. And pending being ready has worked so far.

@RenanSouza2
Copy link
Contributor

The current documentation says this

** *Unset:* An operation that is not part of the timelock mechanism.
** *Pending:* An operation that has been scheduled, before the timer expires.
** *Ready:* An operation that has been scheduled, after the timer expires.
** *Done:* An operation that has been executed.

So whatever is the final decision on the names I will update the documents as wel

@Amxx Amxx added feature New contracts, functions, or helpers. breaking change Changes that break backwards compatibility of the public API. labels Jun 27, 2023
@Amxx Amxx added this to the 5.0 milestone Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Changes that break backwards compatibility of the public API. feature New contracts, functions, or helpers.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants