From c91b27071f7027d7ff362752a68c8da34fa3b6c7 Mon Sep 17 00:00:00 2001 From: Marcin Gordel Date: Mon, 2 Sep 2024 10:15:47 +0200 Subject: [PATCH 1/4] fix(demand): defined minimum expiration value for demand --- src/market/market.module.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/market/market.module.ts b/src/market/market.module.ts index 3ed0d2277..3b61382f8 100644 --- a/src/market/market.module.ts +++ b/src/market/market.module.ts @@ -285,9 +285,26 @@ export class MarketModuleImpl implements MarketModule { ? await this.applyLocalGVMIServeSupport(demandOptions.workload) : demandOptions.workload; + /** + * We need to publish a demand with a minimum expiration time of no less than 5 minutes. + * + * When negotiating an offer and sending a counter proposal, providers (on default settings) + * reject offers with an expirationSec of less than 5 minutes. + * By default, the expirationSec in CounterProposal value is copied from the value defined in the demand. + * + * Additionally, we want to avoid a situation when the demand expires before finding and signing + * an agreement with the provider. Therefore, we assume a minimum time of 15 minutes, + * if the value calculated based on the user-defined rentHourse is less. + */ + const MIN_EXPIRATION_SEC = 15; + + const expirationSecBasedOnRentTime = orderOptions.rentHours * 3600; + const expirationSec = + expirationSecBasedOnRentTime < MIN_EXPIRATION_SEC ? MIN_EXPIRATION_SEC : expirationSecBasedOnRentTime; + const workloadConfig = new WorkloadDemandDirectorConfig({ ...workloadOptions, - expirationSec: orderOptions.rentHours * 60 * 60, // hours to seconds + expirationSec, }); const workloadDirector = new WorkloadDemandDirector(workloadConfig); await workloadDirector.apply(builder); From 310a25082d1ecdb65b7316d192bcc619ff53a547 Mon Sep 17 00:00:00 2001 From: Marcin Gordel Date: Mon, 2 Sep 2024 10:35:03 +0200 Subject: [PATCH 2/4] chore: fixed min_expiration sec valu --- src/market/market.module.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/market/market.module.ts b/src/market/market.module.ts index 3b61382f8..cab259af0 100644 --- a/src/market/market.module.ts +++ b/src/market/market.module.ts @@ -296,7 +296,7 @@ export class MarketModuleImpl implements MarketModule { * an agreement with the provider. Therefore, we assume a minimum time of 15 minutes, * if the value calculated based on the user-defined rentHourse is less. */ - const MIN_EXPIRATION_SEC = 15; + const MIN_EXPIRATION_SEC = 15 * 60; const expirationSecBasedOnRentTime = orderOptions.rentHours * 3600; const expirationSec = From 5526db4b039f4cdd44358cfcac678feaf8bcd658 Mon Sep 17 00:00:00 2001 From: Marcin Gordel Date: Mon, 2 Sep 2024 10:36:20 +0200 Subject: [PATCH 3/4] chore: fixed min_expiration sec valu --- src/market/market.module.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/market/market.module.ts b/src/market/market.module.ts index cab259af0..0b803e09d 100644 --- a/src/market/market.module.ts +++ b/src/market/market.module.ts @@ -298,7 +298,7 @@ export class MarketModuleImpl implements MarketModule { */ const MIN_EXPIRATION_SEC = 15 * 60; - const expirationSecBasedOnRentTime = orderOptions.rentHours * 3600; + const expirationSecBasedOnRentTime = orderOptions.rentHours * 60 * 60; const expirationSec = expirationSecBasedOnRentTime < MIN_EXPIRATION_SEC ? MIN_EXPIRATION_SEC : expirationSecBasedOnRentTime; From 1c48145f7ffc731ba40b16bbb536f7a496cb79e9 Mon Sep 17 00:00:00 2001 From: Marcin Gordel Date: Tue, 3 Sep 2024 14:00:24 +0200 Subject: [PATCH 4/4] refactor(demand): added warning when rentHours is less than 5 min --- src/market/market.module.ts | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/market/market.module.ts b/src/market/market.module.ts index 0b803e09d..2a66a9d52 100644 --- a/src/market/market.module.ts +++ b/src/market/market.module.ts @@ -285,22 +285,20 @@ export class MarketModuleImpl implements MarketModule { ? await this.applyLocalGVMIServeSupport(demandOptions.workload) : demandOptions.workload; + const expirationSec = orderOptions.rentHours * 60 * 60; + /** - * We need to publish a demand with a minimum expiration time of no less than 5 minutes. - * - * When negotiating an offer and sending a counter proposal, providers (on default settings) - * reject offers with an expirationSec of less than 5 minutes. - * By default, the expirationSec in CounterProposal value is copied from the value defined in the demand. - * - * Additionally, we want to avoid a situation when the demand expires before finding and signing - * an agreement with the provider. Therefore, we assume a minimum time of 15 minutes, - * if the value calculated based on the user-defined rentHourse is less. + * Default value on providers for MIN_AGREEMENT_EXPIRATION = 5min. + * This means that if the user declares a rentHours time of less than 5 min, + * offers will be rejected during negotiations with these providers. */ - const MIN_EXPIRATION_SEC = 15 * 60; + const MIN_EXPIRATION_SEC_WARN = 5 * 60; - const expirationSecBasedOnRentTime = orderOptions.rentHours * 60 * 60; - const expirationSec = - expirationSecBasedOnRentTime < MIN_EXPIRATION_SEC ? MIN_EXPIRATION_SEC : expirationSecBasedOnRentTime; + if (expirationSec < MIN_EXPIRATION_SEC_WARN) { + this.logger.warn( + "The declared value of rentHours is less than 5 min. This may cause offers to be rejected during negotiations.", + ); + } const workloadConfig = new WorkloadDemandDirectorConfig({ ...workloadOptions,