@@ -26,10 +26,9 @@ import type {
2626 ComputeResourcesPricingInfo
2727} from '../../@types/C2D/C2D.js'
2828import {
29- BENCHMARK_MONITORING_ADDRESS ,
29+ BASE_CHAIN_ID ,
3030 getConfiguration ,
31- SEPOLIA_CHAIN_ID ,
32- USDC_TOKEN
31+ USDC_TOKEN_ADDRESS_BASE
3332} from '../../utils/config.js'
3433import { C2DEngine } from './compute_engine_base.js'
3534import { C2DDatabase } from '../database/C2DDatabase.js'
@@ -64,7 +63,8 @@ import { Service } from '@oceanprotocol/ddo-js'
6463import { getOceanTokenAddressForChain } from '../../utils/address.js'
6564import { dockerRegistrysAuth , dockerRegistryAuth } from '../../@types/OceanNode.js'
6665import { EncryptMethod } from '../../@types/fileObject.js'
67- import { ZeroAddress } from 'ethers'
66+ import { getAddress , ZeroAddress } from 'ethers'
67+ import { AccessList } from '../../@types/AccessList.js'
6868
6969const C2D_CONTAINER_UID = 1000
7070const C2D_CONTAINER_GID = 1000
@@ -91,7 +91,6 @@ export class C2DEngineDocker extends C2DEngine {
9191 private trivyCachePath : string
9292 private cpuAllocations : Map < string , number [ ] > = new Map ( )
9393 private envCpuCoresMap : Map < string , number [ ] > = new Map ( )
94- private enableNetwork : boolean
9594
9695 public constructor (
9796 clusterConfig : C2DClusterInfo ,
@@ -115,7 +114,7 @@ export class C2DEngineDocker extends C2DEngine {
115114 this . paymentClaimInterval = clusterConfig . connection . paymentClaimInterval || 3600 // 1 hour
116115 this . scanImages = clusterConfig . connection . scanImages || false // default is not to scan images for now, until it's prod ready
117116 this . scanImageDBUpdateInterval = clusterConfig . connection . scanImageDBUpdateInterval
118- this . enableNetwork = clusterConfig . connection . enableNetwork ?? false
117+
119118 if (
120119 clusterConfig . connection . protocol &&
121120 clusterConfig . connection . host &&
@@ -210,16 +209,11 @@ export class C2DEngineDocker extends C2DEngine {
210209 }
211210 const gpuResources : ComputeResource [ ] = Array . from ( gpuMap . values ( ) )
212211
213- const benchmarkPrices : ComputeResourcesPricingInfo [ ] = gpuResources . map ( ( gpu ) => ( {
214- id : gpu . id ,
215- price : 1
216- } ) )
217-
218- const sepoliaChainId = SEPOLIA_CHAIN_ID
219- const usdcToken = USDC_TOKEN
212+ const benchmarkPrices : ComputeResourcesPricingInfo [ ] =
213+ gpuResources . length > 0 ? [ { id : gpuResources [ 0 ] . id , price : 1 } ] : [ ]
220214
221215 const benchmarkFees : ComputeEnvFeesStructure = {
222- [ sepoliaChainId ] : [ { feeToken : usdcToken , prices : benchmarkPrices } ]
216+ [ BASE_CHAIN_ID ] : [ { feeToken : USDC_TOKEN_ADDRESS_BASE , prices : benchmarkPrices } ]
223217 }
224218
225219 const benchmarkEnv : C2DEnvironmentConfig = {
@@ -234,10 +228,13 @@ export class C2DEngineDocker extends C2DEngine {
234228 ...gpuResources
235229 ] ,
236230 access : {
237- addresses : [ BENCHMARK_MONITORING_ADDRESS ] ,
238- accessLists : null
231+ addresses : [ ] ,
232+ accessLists : [
233+ { [ BASE_CHAIN_ID ] : [ getAddress ( '0xcb7Db55Ca9Aa9C3b25F5Bc266da63317fa02086a' ) ] }
234+ ]
239235 } ,
240- fees : benchmarkFees
236+ fees : benchmarkFees ,
237+ enableNetwork : true
241238 }
242239
243240 envConfig . environments . push ( benchmarkEnv )
@@ -286,7 +283,13 @@ export class C2DEngineDocker extends C2DEngine {
286283 const consumerAddress = this . getKeyManager ( ) . getEthAddress ( )
287284
288285 if ( config . enableBenchmark ) {
289- this . createBenchmarkEnvironment ( sysinfo , envConfig )
286+ if ( supportedChains . includes ( parseInt ( BASE_CHAIN_ID ) ) ) {
287+ this . createBenchmarkEnvironment ( sysinfo , envConfig )
288+ } else {
289+ CORE_LOGGER . warn (
290+ `Skipping benchmark environment: Base chain (${ BASE_CHAIN_ID } ) is not in supportedNetworks`
291+ )
292+ }
290293 }
291294
292295 for ( let envIdx = 0 ; envIdx < envConfig . environments . length ; envIdx ++ ) {
@@ -362,7 +365,8 @@ export class C2DEngineDocker extends C2DEngine {
362365 queMaxWaitTime : 0 ,
363366 queMaxWaitTimeFree : 0 ,
364367 runMaxWaitTime : 0 ,
365- runMaxWaitTimeFree : 0
368+ runMaxWaitTimeFree : 0 ,
369+ enableNetwork : envDef . enableNetwork
366370 }
367371
368372 if ( envDef . storageExpiry !== undefined ) env . storageExpiry = envDef . storageExpiry
@@ -403,9 +407,16 @@ export class C2DEngineDocker extends C2DEngine {
403407 for ( const env of this . envs ) {
404408 const cpuRes = this . getResource ( env . resources ?? [ ] , 'cpu' )
405409 if ( cpuRes && cpuRes . total > 0 ) {
406- const isBenchmarkEnv = env . access ?. addresses ?. includes (
407- BENCHMARK_MONITORING_ADDRESS
408- )
410+ let isBenchmarkEnv = false
411+ if ( env . access ?. accessLists ) {
412+ const baseAccessList = env . access ?. accessLists ?. [ 0 ] as AccessList
413+ if ( baseAccessList && baseAccessList [ BASE_CHAIN_ID ] ) {
414+ isBenchmarkEnv = baseAccessList [ BASE_CHAIN_ID ] . includes (
415+ getAddress ( '0xcb7Db55Ca9Aa9C3b25F5Bc266da63317fa02086a' )
416+ )
417+ }
418+ }
419+
409420 if ( isBenchmarkEnv ) {
410421 const total = physicalCpuCount > 0 ? physicalCpuCount : cpuRes . total
411422 const cores = Array . from ( { length : total } , ( _ , i ) => i )
@@ -1824,7 +1835,7 @@ export class C2DEngineDocker extends C2DEngine {
18241835 }
18251836 ]
18261837 }
1827- if ( ! this . enableNetwork ) {
1838+ if ( ! env . enableNetwork ) {
18281839 hostConfig . NetworkMode = 'none' // no network inside the container
18291840 }
18301841 // disk
0 commit comments