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

governance: update migration logic in GovernanceDelegation #342

Merged
merged 6 commits into from
Aug 23, 2024

Conversation

cairoeth
Copy link
Contributor

@cairoeth cairoeth commented Aug 16, 2024

Description & Context

For interop, the governor will have to be updated use the L1 block number instead of the OP L2 block number as networks in their superchain will have their own cadence of blocks.

Proposed by @smartcontracts, the interop update introduces breaking changes so it's better to have the delegation state separated: the legacy state in the GovernanceToken (with L2 block number), and the new state in the GovernanceDelegation contract. This means that the GovernanceToken doens't call the GovernanceDelegation in its getter functions, and vice versa.

@cairoeth cairoeth marked this pull request as ready for review August 21, 2024 20:03
@cairoeth cairoeth changed the title governance: remove migration from GovernanceDelegation governance: update migration logic in GovernanceDelegation Aug 21, 2024
@tynes
Copy link
Contributor

tynes commented Aug 21, 2024

I'd like a review from @smartcontracts given he has the most context here

## Migration

All write functions in the `GovernanceDelegation` MUST check if the users interacting with it have been migrated by
checking the `migrated` mapping from its [storage](#storage). If a user has not been migrated, the `GovernanceDelegation`
MUST copy the delegation and checkpoint data from the token contract to its own state. After copying the data, the
`GovernanceDelegation` MUST update the `migrated` mapping to reflect that the address has been migrated.
`GovernanceDelegation` MUST update the `migrated` mapping to reflect that the address has been migrated, and remove the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually don't think we need the migrated mapping anymore? Since we're not forwarding stuff to the original contract.

Copy link
Contributor Author

@cairoeth cairoeth Aug 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah the GovernanceDelegation contract doesn't really need it, but it could be a helper for external contracts like governor: if migrated is true, get data from GovernanceDelegation, otherwise from GovernanceToken.

if these contracts check delegates[_addr] only in GovernanceToken, they won't be able to know if there's a delegation in GovernanceDelegation, so they will always have to call both. wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah since we maintain the invariant that you can't have a delegation in both contracts then what you can do is just check if delegates[_addr] inside GovernanceToken is address(0)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, updated in eee936c

## Migration
The `GovernanceDelegation` MUST enforce the following invariants for the migration logic:

1. A user MUST NOT have an active delegation in both `GovernanceToken` and `GovernanceDelegation` at the same time.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically some of these statements are implied by the other statements but I think it's good enough to just be explicit and list all of the statements

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i think it helps to have some redundancy in this specific case

@tynes tynes merged commit f93bfdc into main Aug 23, 2024
1 check passed
@tynes tynes deleted the migration-gov-delegation branch August 23, 2024 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants