-
-
Notifications
You must be signed in to change notification settings - Fork 112
Open
Labels
A-contractsArea: Contract runtime, SDK, and executionArea: Contract runtime, SDK, and executionA-developer-xpArea: developer experienceArea: developer experienceA-networkingArea: Networking, ring protocol, peer discoveryArea: Networking, ring protocol, peer discoveryE-mediumExperience needed to fix/implement: Medium / intermediateExperience needed to fix/implement: Medium / intermediateP-mediumMedium priorityMedium priorityS-needs-designStatus: Needs architectural design or RFCStatus: Needs architectural design or RFCT-featureType: New functionality requestType: New functionality request
Description
Parent: #2827
Summary
Allow delegates to create/store contracts via a PUT operation.
Proposed Implementation
1. Add to OutboundDelegateMsg (freenet-stdlib)
PutContractRequest {
contract: ContractContainer,
state: WrappedState,
related_contracts: RelatedContracts,
},2. Add to InboundDelegateMsg (freenet-stdlib)
PutContractResponse {
contract_id: ContractInstanceId,
result: Result<(), PutError>, // or a custom error type
},3. Handle in delegate runtime (freenet-core)
In delegate.rs, when processing OutboundDelegateMsg::PutContractRequest:
- Call
executor.perform_contract_put() - Package result as
InboundDelegateMsg::PutContractResponse - Call delegate again with the response
Design Questions
-
Who can PUT?
- Any delegate can PUT any contract (authorization is contract's responsibility)
- But should there be any rate limiting or resource controls?
-
Should the delegate be able to specify contract parameters?
- Parameters are part of
ContractContainer - Need to ensure the delegate can construct valid contract containers
- Parameters are part of
-
Related contracts handling
- What if related contracts aren't available?
- Should the delegate be notified of missing dependencies?
-
Network propagation
- In network mode, PUT broadcasts to peers
- Should the delegate be notified when propagation completes, or just when local commit succeeds?
Sender Attestation
When a delegate PUTs a contract, should the contract know who created it? This could be useful for:
- Initial authorization setup
- Audit trails
- Trust relationships
The delegate's key could be recorded as the contract's creator, though this may need design discussion.
Testing
- Unit test for new message types
- Integration test: delegate creates a contract via
freenet local - Test with related contracts
- Test error cases (invalid contract, resource limits)
Acceptance Criteria
-
OutboundDelegateMsg::PutContractRequestadded to stdlib -
InboundDelegateMsg::PutContractResponseadded to stdlib - Runtime handles the request and stores contract
- Works in both
freenet localandfreenet networkmodes - Example/test delegate demonstrates the capability
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-contractsArea: Contract runtime, SDK, and executionArea: Contract runtime, SDK, and executionA-developer-xpArea: developer experienceArea: developer experienceA-networkingArea: Networking, ring protocol, peer discoveryArea: Networking, ring protocol, peer discoveryE-mediumExperience needed to fix/implement: Medium / intermediateExperience needed to fix/implement: Medium / intermediateP-mediumMedium priorityMedium priorityS-needs-designStatus: Needs architectural design or RFCStatus: Needs architectural design or RFCT-featureType: New functionality requestType: New functionality request
Type
Projects
Status
Triage