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 Governor documentation #1235

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

ericnordelo
Copy link
Member

Fixes #1234

Copy link

codecov bot commented Nov 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.26%. Comparing base (493a4d1) to head (17fc3e6).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1235   +/-   ##
=======================================
  Coverage   92.26%   92.26%           
=======================================
  Files          59       59           
  Lines        1811     1811           
=======================================
  Hits         1671     1671           
  Misses        140      140           
Files with missing lines Coverage Δ
.../governor/extensions/governor_core_execution.cairo 77.77% <ø> (ø)
...governor/extensions/governor_counting_simple.cairo 100.00% <ø> (ø)
...ce/src/governor/extensions/governor_settings.cairo 100.00% <ø> (ø)
...ernor/extensions/governor_timelock_execution.cairo 98.41% <ø> (ø)
...or/extensions/governor_votes_quorum_fraction.cairo 96.87% <ø> (ø)
packages/governance/src/governor/governor.cairo 92.50% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 493a4d1...17fc3e6. Read the comment docs.

Copy link
Collaborator

@andrew-fleming andrew-fleming left a comment

Choose a reason for hiding this comment

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

Looking good, Eric! Phew...the governor is a big addition. Sorry for the 32423402340923 comments 😅

docs/modules/ROOT/pages/governance/governor.adoc Outdated Show resolved Hide resolved
docs/modules/ROOT/pages/governance/governor.adoc Outdated Show resolved Hide resolved
docs/modules/ROOT/pages/governance/governor.adoc Outdated Show resolved Hide resolved
docs/modules/ROOT/pages/governance/governor.adoc Outdated Show resolved Hide resolved
docs/modules/ROOT/pages/governance/governor.adoc Outdated Show resolved Hide resolved
docs/modules/ROOT/pages/api/governance.adoc Outdated Show resolved Hide resolved
docs/modules/ROOT/pages/api/governance.adoc Outdated Show resolved Hide resolved
docs/modules/ROOT/pages/api/governance.adoc Outdated Show resolved Hide resolved
docs/modules/ROOT/pages/api/governance.adoc Show resolved Hide resolved
docs/modules/ROOT/pages/api/governance.adoc Show resolved Hide resolved
@ericnordelo
Copy link
Member Author

I added the right interface id cc @andrew-fleming. All I needed to do was to add the empty type to the enum variants in ProposalState, and the src5_rs did the trick without issues. I double checked that every Extended Function Selector looked right.

Copy link
Collaborator

@andrew-fleming andrew-fleming left a comment

Choose a reason for hiding this comment

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

Improvements look great! I left a few more suggestions and comments, but I think we're super close. And nice work with src5 workaround solution!

Comment on lines +218 to +229

pub trait IGovernor2 {
fn name() -> felt252;

fn version() -> felt252;

fn COUNTING_MODE() -> ByteArray;

fn hash_proposal(calls: Span<Call>, description_hash: felt252) -> felt252;

// fn state(proposal_id: felt252) -> ProposalState;

Copy link
Collaborator

Choose a reason for hiding this comment

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

:)


/// Interface for a contract that implements the ERC-6372 standard.
#[starknet::interface]
pub trait IERC6372<TState> {
/// Clock used for flagging checkpoints.
/// Can be overridden to implement timestamp based checkpoints (and voting).
/// Can be overridden to implement block number based checkpoints (and voting).
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// Can be overridden to implement block number based checkpoints (and voting).

I think we can remove this sentence because it's just the interface and not the impl

Comment on lines -215 to 220
/// Returns the token that voting power is sourced from.
/// Returns the timelock controller address.
fn timelock(self: @ComponentState<TContractState>) -> ContractAddress {
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

[[GovernorComponent-cast_vote_with_reason_and_params_by_sig]]
==== `[.contract-item-name]#++cast_vote_with_reason_and_params_by_sig++#++(proposal_id: felt252, support: u8, voter: ContractAddress, reason: ByteArray, params: Span<felt252>, signature: Span<felt252>) → u256++` [.item-kind]#external#

Cast a vote with a `reason` and additional serialized `params` using the `voter`'s
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Cast a vote with a `reason` and additional serialized `params` using the `voter`'s
Cast a vote with a `reason` and additional serialized `params` using the ``voter``'s

[[IGovernor-cast_vote_with_reason_and_params_by_sig]]
==== `[.contract-item-name]#++cast_vote_with_reason_and_params_by_sig++#++(proposal_id: felt252, support: u8, voter: ContractAddress, reason: ByteArray, params: Span<felt252>, signature: Span<felt252>) → u256++` [.item-kind]#external#

Cast a vote on a proposal with a reason and additional encoded parameters using the voter's signature.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Cast a vote on a proposal with a reason and additional encoded parameters using the voter's signature.
Cast a vote on a proposal with a reason and additional encoded parameters using the ``voter``'s signature.

To match the component description

[[GovernorTimelockExecutionComponent-timelock_salt]]
==== `[.contract-item-name]#++timelock_salt++#++(self: @ContractState, description_hash: felt252) → felt252++` [.item-kind]#internal#

Computes the `TimelockController` operation salt.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Computes the `TimelockController` operation salt.
Computes the `TimelockController` operation salt as the XOR of the governor address and `description_hash`.

In case users are curious 🤷‍♂️

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.

Add Governor documentation
2 participants