Security Considerations
DoS Prevention
// Constants (not tunable parameters)
MaxBatchSize = 100 // Max items per batch operation
MaxAddressesPerMint = 100 // Max addresses per mint call
MaxMarketCapHistory = 100 // Max market cap snapshots per AI
// Parameters (if defined in Params)
MaxTensorRowsPerBlock // Max tensor rows per transaction
MaxAisForRewards // Max AIs processed per blockArithmetic Safety
// Example: Safe accumulation with overflow check
func (k Keeper) CalculateOresToMint(aiTensors []*types.AITensor) (map[string]uint64, error) {
oresToMint := make(map[string]uint64)
for _, aiTensor := range aiTensors {
for _, row := range aiTensor.Tensor {
totalContributions, err := types.SumContributions(row.Contributions)
if err != nil {
return nil, fmt.Errorf("overflow while summing: %w", err)
}
current := math.NewIntFromUint64(oresToMint[row.Address])
updated := current.Add(math.NewIntFromUint64(totalContributions))
if !updated.IsUint64() {
return nil, fmt.Errorf("total cores exceed uint64 limit")
}
oresToMint[row.Address] = updated.Uint64()
}
}
return oresToMint, nil
}Two-Phase Validation
Credential Security
Next Steps
Last updated