Understanding Governance
In TAPLE Core, governance is a special type of subject that defines:- Schemas: The structure and validation rules for subjects
- Policies: Who can create, update, and validate events
- Quorum: Required number of approvals for operations
- Roles: Permissions assigned to network participants
core/src/governance/governance.rs:1 and provides the GovernanceAPI interface for interacting with governance data.
Creating a Governance Subject
To create a governance subject, you need to send aCreate event request with the special governance schema:
let create_subject_request = EventRequest::Create(StartRequest {
governance_id: DigestIdentifier::default(),
name: "".to_string(),
namespace: "".to_string(),
schema_id: "governance".to_string(),
public_key: governance_key,
});
The
governance_id is set to default (empty) because governance subjects are self-governing. The schema_id must be exactly "governance".let signed_request = Signed::<EventRequest> {
content: create_subject_request.clone(),
signature: Signature::new(&create_subject_request, &node_key_pair).unwrap(),
};
Retrieving Governance Data
Get Governance Subjects
Retrieve all governance subjects in the network:core/src/api/api.rs:207 and supports pagination through from and quantity parameters.
Get Schema Information
Retrieve the schema definition from governance:core/src/governance/governance.rs:289 and returns the schema as a ValueWrapper.
Get Governance Version
Check the current version of a governance:core/src/governance/governance.rs:393 for the implementation.
Working with Governance Policies
Get Signers for a Stage
Retrieve the set of authorized signers for a validation stage:ValidationStage enum defines different stages like Validate, Evaluate, and Approve.
Get Quorum Requirements
Determine the required quorum for a specific stage:core/src/governance/governance.rs:331.
Check Invoke Permissions
Verify if an invoker has permission to perform an operation:Governance Updates
When governance is updated, the system broadcasts update messages:core/src/governance/governance.rs:426.
Get Contracts
Retrieve the smart contracts associated with a governance:(Contract, String) tuples containing contract definitions and their identifiers.
Check if Subject is Governance
Determine whether a subject ID represents a governance:core/src/governance/governance.rs:413.
Best Practices
- Version Control: Always track governance versions to ensure compatibility
- Testing: Test governance changes in a development environment first
- Quorum Settings: Set appropriate quorum values to balance security and availability
- Schema Validation: Ensure schemas are well-defined before deployment
- Access Control: Carefully define roles and permissions in governance policies
Error Handling
Common governance errors include:GovernanceNotFound: The specified governance doesn’t existInvalidGovernanceID: The governance identifier is malformedSubjectNotFound: Referenced subject doesn’t existChannelClosed: Communication channel with governance module failed
