#603 Contract: Implement proposal execution in governance contract
ProposalExecutedEventexists butexecute_proposalfunction was incomplete- Proposals could not be executed
- Governance system was incomplete
- Decision implementation was missing
- Proposals cannot be executed
- Governance system is non-functional
Implemented complete proposal execution functionality by:
-
Extended Proposal Structure - Added action payload fields to store what should be executed
target: Address- Target contract to invokefunction: Symbol- Function to call on targetargs: Vec<soroban_sdk::Val>- Arguments to pass
-
Updated create_proposal - Now accepts action parameters
- Signature:
create_proposal(env, proposer, title, description, target, function, args) - Stores the complete action payload with the proposal
- Signature:
-
Implemented execute_proposal - Now actually executes the proposal
- Validates proposal has passed voting
- Invokes target contract with stored function and arguments
- Updates proposal status to Executed
- Emits ProposalExecutedEvent
-
Updated Helper Functions - Adapted propose_update_* functions
propose_update_interest_ratepropose_update_collateral_ratiopropose_update_liquidation_bonus
-
Updated Tests - Modified test helpers to work with new structure
- Updated
make_proposalhelper to include action parameters
- Updated
- Branch Name:
feat/603-proposal-execution - Base:
master
- 10c93f7 - Enhanced proposal execution with comprehensive documentation and safety checks
- 5c705af - Implemented complete proposal execution in governance contract
pub struct Proposal {
pub id: u32,
pub title: String,
pub description: String,
pub proposer: Address,
pub yes_votes: i128,
pub no_votes: i128,
pub abstain_votes: i128,
pub status: ProposalStatus,
pub created_at: u64,
pub expires_at: u64,
pub target: Address, // NEW
pub function: Symbol, // NEW
pub args: Vec<soroban_sdk::Val>, // NEW
}- Now accepts
target,function, andargsparameters - Stores action payload with proposal
- Enables proposals to carry their intended execution details
- Validates proposal has passed voting
- Invokes target contract:
env.invoke_contract(&proposal.target, &proposal.function, proposal.args) - Updates status to Executed
- Emits ProposalExecutedEvent
- Includes reentrancy protection and pause checks
- Updated to include action parameters
- Now passes target contract, function, and empty args
- Existing proposal tests updated to work with new structure
test_execute_proposal_after_voting_period- Verifies successful executiontest_execute_rejected_proposal_fails- Verifies rejected proposals cannot execute
Proposal struct now includes action payload fields. Any code creating proposals must be updated to provide:
target: Address- The contract to executefunction: Symbol- The function to callargs: Vec<soroban_sdk::Val>- The arguments
- Review and approve PR
- Merge to master
- Update any dependent code that creates proposals
- Deploy updated governance contract
To verify the implementation:
# Build the contract
cd contracts/governance-contract
cargo build --target wasm32-unknown-unknown
# Run tests
cargo testcontracts/governance-contract/src/lib.rs- Core implementationcontracts/governance-contract/src/test.rs- Test updates
The proposal execution functionality is now complete and functional. Proposals can be created with an intended action, voted on, and then executed to perform their intended function on target contracts. This completes the governance system implementation.