kroma-network / kroma

A developer-friendly, rollup-based Ethereum Layer 2 solution that offers low fees and EVM equivalence.
Other
161 stars 82 forks source link

feat: implement governance token minting and distribution #333

Closed seolaoh closed 3 months ago

seolaoh commented 3 months ago

Description

Implemented GovernanceToken and MintManager contracts. GovernanceToken will be minted and distributed on both L1 and L2 in TGE. GovernanceToken is KromaMintableERC20, which can be bridged between both chains via standard bridge. MintManager is the owner of GovernanceToken which can mint tokens, and it has mint and distribute function to automate the minting and distribution to several recipients. MintManager also has an owner who has the permission to call mint and distribute.

Note that GovernanceToken is proxy contract but MintManager is not. Additionally, GovernanceTokenProxy is deployed using CREATE2 to fix the same token address across multi-chains.

Process to Follow in TGE

Test Contracts on Holesky

coderabbitai[bot] commented 3 months ago

Walkthrough

The recent changes involve adding and modifying functionalities related to governance token management, minting, and deployment across both L1 and L2 networks. Key updates include the introduction of new deployment scripts, governance modifications in configurations, storage layout changes for GovernanceToken and MintManager contracts, and updates to testing functions. The changes aim to enhance minting processes, streamline token governance, and improve testing frameworks.

Changes

Files/Paths Change Summary
kroma-bindings/bindings/mintmanager_more.go Introduced a new file for MintManager contract binding, setting up storage layout and deployed bytecode.
kroma-chain-ops/genesis/config.go Added and modified governance token fields, mint managers, and proxies configurations in DeployConfig struct.
kroma-chain-ops/genesis/layer_two_test.go Adjusted isProxy condition in tests and added governance checks.
op-e2e/bridge_test.go Refined bridge functionality tests, updated logging levels, adjusted variable assignments, transaction handling, and assertions for GovernanceToken bridging between L1 and L2.
op-e2e/setup.go Added functions for minting and setting up governance tokens on L1, alongside new imports.
packages/contracts/.gas-snapshot Updated gas cost details for GovernanceToken_Test and MintManagerTest cases.
packages/contracts/.storage-layout Detailed the changes in the storage layout for GovernanceToken.sol and MintManager.sol.
packages/contracts/contracts/governance/GovernanceToken.sol Applied various changes for minting and burning logic, owner initialization, and several function overrides.
packages/contracts/contracts/governance/MintManager.sol Added functions and constants for token minting and distribution, and renouncing ownership.
packages/contracts/contracts/libraries/Predeploys.sol Removed the constant address declaration for the GOVERNANCE_TOKEN.
packages/contracts/deploy/L1/001-Proxies.ts Removed L1GovernanceTokenProxy from the PROXY_NAMES array.
packages/contracts/deploy/L1/017-L1GovernanceTokenProxy.ts Introduced a deployment function for L1GovernanceTokenProxy using deployDeterministicProxy.
packages/contracts/deploy/L1/018-L1MintManager.ts Added a deployment script for L1MintManager with specific configurations.
packages/contracts/deploy/L1/019-L1GovernanceToken.ts Updated deployment details, removed isProxyImpl, and adjusted tags.
packages/contracts/deploy/L2/011-GovernanceTokenProxy.ts Added a new deployment function for GovernanceTokenProxy on L2 using hardhat-deploy.
packages/contracts/deploy/L2/012-MintManager.ts Introduced a deployment function for MintManager on L2 with specific configuration settings.
packages/contracts/deploy/L2/013-GovernanceToken.ts Adjusted deployment for GovernanceToken, refactoring argument passing and updating deployment tags.
packages/contracts/scripts/rename-deploy-scripts.ts Renamed deployment script entries for L1GovernanceToken to L1GovernanceTokenProxy and L1MintManager.

Sequence Diagrams

Mint and Governance Token Flow

sequenceDiagram
    participant User
    participant L1Client
    participant L2Client
    participant DeployConfig
    participant L1Deployments
    participant L2Deployments
    participant GovernanceToken
    participant MintManager

    User->>L1Client: MintGovernanceTokenOnL1
    L1Client->>DeployConfig: Get MintManager address
    L1Client->>GovernanceToken: Mint tokens
    GovernanceToken-->>L1Client: Tokens minted
    L1Client-->>User: Token Mint Success

    User->>L2Client: SetupGovernanceTokenOnL2
    L2Client->>DeployConfig: Get MintManager address
    L2Client->>GovernanceToken: Setup tokens
    GovernanceToken-->>L2Client: Tokens setup complete
    L2Client-->>User: Token Setup Success

Updated Token Governance and Proxy Setup

sequenceDiagram
    participant User
    participant ConfigScript
    participant DeployScript
    participant Proxy
    participant GovernanceToken
    participant MintManager

    User->>ConfigScript: Deploy Configurations
    ConfigScript->>DeployScript: Initialize Proxies and Managers
    DeployScript->>Proxy: Deploy GovernanceTokenProxy
    Proxy-->>DeployScript: GovernanceTokenProxy Deployed
    DeployScript->>MintManager: Set up MintManager
    MintManager-->>DeployScript: MintManager Set up
    DeployScript-->>User: Configuration Deployed

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai generate interesting stats about this repository and render them as a table.` - `@coderabbitai show all the console.log statements in this repository.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` - `@coderabbitai help me debug CodeRabbit configuration file.` Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. ### CodeRabbit Commands (invoked as PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai full review` to do a full review from scratch and review all the files again. - `@coderabbitai summary` to regenerate the summary of the PR. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@coderabbitai help` to get help. Additionally, you can add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. ### CodeRabbit Configration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.