governance v1#47
Open
sumoshi21 wants to merge 1 commit into
Open
Conversation
Collaborator
|
Hi, If you are looking for my approval on this PR, please answer the questions relevant to protocol changes. |
Collaborator
|
@sumoshi21 do you want to fix the merge conflicts? |
There was a problem hiding this comment.
Pull request overview
Implements a new embedded governance contract (behind a new governance spork) that allows proposing actions, pillar voting, and executing approved actions to call administrative methods on other embedded contracts.
Changes:
- Added a new Governance embedded contract with
ProposeAction/ExecuteActionlogic and corresponding RPC API (embedded.governance). - Introduced a new governance spork enforcement gate and extended permission checks so the governance contract can call spork/bridge/liquidity administrative methods.
- Added an end-to-end governance test that creates and activates a spork through the governance workflow.
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| vm/vm_context/spork.go | Adds governance spork enforcement check to VM context. |
| vm/vm_context/interfaces.go | Extends AccountVmContext interface with governance spork enforcement method. |
| vm/embedded/tests/governance_test.go | Adds end-to-end governance proposal/vote/execute test coverage. |
| vm/embedded/implementation/governance.go | New embedded governance contract implementation (propose/execute + vote threshold logic). |
| vm/embedded/definition/governance.go | Governance ABI + storage definition for actions. |
| vm/embedded/embedded.go | Registers governance embedded contract and routes embedded method lookup based on governance spork. |
| rpc/apis.go | Exposes embedded.governance RPC namespace. |
| rpc/api/embedded/governance.go | Adds governance RPC API for listing/fetching actions + vote breakdown/expiry. |
| vm/embedded/implementation/spork.go | Permits governance contract to create/activate sporks. |
| vm/embedded/implementation/liquidity.go | Permits governance contract to call admin methods and spork-only methods. |
| vm/embedded/implementation/bridge.go | Permits governance contract to call admin methods. |
| vm/constants/embedded.go | Adds governance voting period/threshold constants. |
| vm/constants/errors.go | Adds governance-specific error for unknown action type. |
| common/types/spork.go | Introduces GovernanceSpork as an implemented spork (currently with a TODO placeholder id). |
| common/types/address.go | Adds Governance contract address to embedded contract registry. |
| go.mod / go.sum | Dependency tidying around protobuf modules. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
6
to
9
| BridgeAndLiquiditySpork = NewImplementedSpork("ddd43466769461c5b5d109c639da0f50a7eeb96ad6e7274b1928a35c431d7b1b") | ||
| // todo change it | ||
| GovernanceSpork = NewImplementedSpork("ddd43466769461c5b5d109c639da0f50a7eeb96ad6e7274b1928a35c431d7b1c") | ||
|
|
Comment on lines
+105
to
+107
| // Governance | ||
|
|
||
| ErrUnkownActionType = errors.New("unknown action type") |
Comment on lines
+156
to
+158
| } else { | ||
| return nil, constants.ErrUnkownActionType | ||
| } |
Comment on lines
+49
to
+52
| } else { | ||
| // todo just return the action? | ||
| return nil, constants.ErrUnkownActionType | ||
| } |
Comment on lines
+74
to
+78
| func (a *GovernanceApi) GetAllActions(pageIndex, pageSize uint32) (*ActionList, error) { | ||
| _, context, err := api.GetFrontierContext(a.chain, types.GovernanceContract) | ||
| if err != nil { | ||
| return nil, err | ||
| } |
Comment on lines
+537
to
539
| if sendBlock.Address.String() != bridgeInfo.Administrator.String() && sendBlock.Address.String() != types.GovernanceContract.String() { | ||
| return nil, constants.ErrPermissionDenied | ||
| } |
Comment on lines
+102
to
+105
| } else { | ||
| // todo just return the action? | ||
| return nil, constants.ErrUnkownActionType | ||
| } |
Comment on lines
+97
to
99
| if block.Address != *types.SporkAddress && block.Address.String() != types.GovernanceContract.String() { | ||
| return constants.ErrPermissionDenied | ||
| } |
Comment on lines
+122
to
124
| if block.Address != *types.SporkAddress && block.Address.String() != types.GovernanceContract.String() { | ||
| return constants.ErrPermissionDenied | ||
| } |
Comment on lines
+193
to
195
| if block.Address != *types.SporkAddress && block.Address.String() != types.GovernanceContract.String() { | ||
| return constants.ErrPermissionDenied | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement the governance logic that is able to create and activate sporks and call administrative methods of other embedded contract.