Description
Implement structured audit logging for critical escrow and NFT mutation operations to improve observability, debugging, and compliance tracking across the platform.
Problem Statement
Currently, tracking escrow transactions and NFT mutations across the system is challenging due to:
- Lack of centralized, structured logging for critical operations
- Difficulty correlating related operations across different services/components
- Limited visibility into the lifecycle of escrow and NFT state changes
- Potential compliance and audit trail gaps
Requirements
Must Have
- Structured Log Format: Use a consistent JSON format for all audit logs
- Correlation IDs: Assign unique correlation IDs to track related operations across the system
- No PII: Ensure no Personally Identifiable Information is logged (use user IDs, wallet addresses in hashed form if needed)
- Critical Operations Coverage:
- Escrow creation, funding, release, and cancellation
- NFT minting, transfers, and state mutations
- Any state changes affecting escrow or NFT ownership
Log Fields
Each audit log entry should include:
timestamp: ISO 8601 format
correlationId: Unique identifier for tracking related operations
operation: Action being performed (e.g., "escrow.created", "nft.transferred")
resourceType: Type of resource ("escrow" or "nft")
resourceId: Identifier of the resource being mutated
actorId: Hashed/anonymized identifier of the actor
status: Operation status ("success", "failure", "pending")
metadata: Additional context (amounts, addresses in anonymized form, etc.)
errorCode: If applicable, error code for failed operations
Suggested Implementation
1. Create Audit Logger Service
// services/auditLogger.ts
interface AuditLogEntry {
timestamp: string;
correlationId: string;
operation: string;
resourceType: 'escrow' | 'nft';
resourceId: string;
actorId: string;
status: 'success' | 'failure' | 'pending';
metadata?: Record<string, any>;
errorCode?: string;
}
class AuditLogger {
log(entry: AuditLogEntry): void {
// Implement structured logging
}
}
2. Correlation ID Propagation
- Generate correlation IDs at API entry points
- Propagate through async context or request headers
- Include in all downstream operations
3. Integration Points
- Wrap escrow mutation functions with audit logging
- Add audit logging to NFT contract interaction handlers
- Ensure database transaction boundaries align with audit log entries
4. Storage & Retention
- Consider log aggregation service (e.g., CloudWatch, Datadog, ELK stack)
- Define retention policies based on compliance requirements
- Ensure logs are immutable and tamper-proof
Acceptance Criteria
Additional Context
This is a foundational observability improvement that will:
- Enable better debugging of production issues
- Provide audit trails for compliance
- Support future monitoring and alerting features
- Improve incident response capabilities
Related Issues
Help Wanted
Looking for contributors who can help with:
- Designing the structured log schema
- Implementing the audit logger service
- Integrating logging into existing escrow and NFT mutation flows
- Setting up log aggregation and monitoring infrastructure
- Writing comprehensive tests
Description
Implement structured audit logging for critical escrow and NFT mutation operations to improve observability, debugging, and compliance tracking across the platform.
Problem Statement
Currently, tracking escrow transactions and NFT mutations across the system is challenging due to:
Requirements
Must Have
Log Fields
Each audit log entry should include:
timestamp: ISO 8601 formatcorrelationId: Unique identifier for tracking related operationsoperation: Action being performed (e.g., "escrow.created", "nft.transferred")resourceType: Type of resource ("escrow" or "nft")resourceId: Identifier of the resource being mutatedactorId: Hashed/anonymized identifier of the actorstatus: Operation status ("success", "failure", "pending")metadata: Additional context (amounts, addresses in anonymized form, etc.)errorCode: If applicable, error code for failed operationsSuggested Implementation
1. Create Audit Logger Service
2. Correlation ID Propagation
3. Integration Points
4. Storage & Retention
Acceptance Criteria
Additional Context
This is a foundational observability improvement that will:
Related Issues
Help Wanted
Looking for contributors who can help with: