@@ -22,9 +22,10 @@ import type {
2222 ComputeResourceRequest ,
2323 ComputeEnvFees ,
2424 ComputeResource ,
25- C2DEnvironmentConfig
25+ C2DEnvironmentConfig ,
26+ ComputeResourcesPricingInfo
2627} from '../../@types/C2D/C2D.js'
27- import { getConfiguration } from '../../utils/config.js'
28+ import { BENCHMARK_MONITORING_ADDRESS , getConfiguration } from '../../utils/config.js'
2829import { C2DEngine } from './compute_engine_base.js'
2930import { C2DDatabase } from '../database/C2DDatabase.js'
3031import { Escrow } from '../core/utils/escrow.js'
@@ -215,6 +216,54 @@ export class C2DEngineDocker extends C2DEngine {
215216 }
216217 const consumerAddress = this . getKeyManager ( ) . getEthAddress ( )
217218
219+ if ( config . enableBenchmark ) {
220+ const ramGB = this . physicalLimits . get ( 'ram' ) || 0
221+ const physicalDiskGB = this . physicalLimits . get ( 'disk' ) || 0
222+
223+ const gpuResources : ComputeResource [ ] = [ ]
224+ for ( const env of envConfig . environments ) {
225+ if ( env . resources ) {
226+ for ( const res of env . resources ) {
227+ if ( res . id !== 'cpu' && res . id !== 'ram' && res . id !== 'disk' ) {
228+ gpuResources . push ( res )
229+ }
230+ }
231+ }
232+ }
233+
234+ const benchmarkPrices : ComputeResourcesPricingInfo [ ] = gpuResources . map ( ( gpu ) => ( {
235+ id : gpu . id ,
236+ price : 1
237+ } ) )
238+
239+ const sepoliaChainId = '11155111' // TODO: add Sepolia chain ID
240+ const usdcToken = '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238' // TODO: add USDC token address on Sepolia
241+
242+ const benchmarkFees : ComputeEnvFeesStructure = {
243+ [ sepoliaChainId ] : [ { feeToken : usdcToken , prices : benchmarkPrices } ]
244+ }
245+
246+ const benchmarkEnv : C2DEnvironmentConfig = {
247+ description : 'Auto-generated benchmark environment' ,
248+ storageExpiry : 604800 ,
249+ maxJobDuration : 180 ,
250+ minJobDuration : 60 ,
251+ resources : [
252+ { id : 'cpu' , total : sysinfo . NCPU , min : 1 , max : sysinfo . NCPU } ,
253+ { id : 'ram' , total : ramGB , min : 1 , max : ramGB } ,
254+ { id : 'disk' , total : physicalDiskGB , min : 0 , max : physicalDiskGB } ,
255+ ...gpuResources
256+ ] ,
257+ access : {
258+ addresses : [ BENCHMARK_MONITORING_ADDRESS ] ,
259+ accessLists : null
260+ } ,
261+ fees : benchmarkFees
262+ }
263+
264+ envConfig . environments . push ( benchmarkEnv )
265+ }
266+
218267 for ( let envIdx = 0 ; envIdx < envConfig . environments . length ; envIdx ++ ) {
219268 const envDef : C2DEnvironmentConfig = envConfig . environments [ envIdx ]
220269
0 commit comments