diff --git a/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/committer/transaction/validation/LedgerTimeValidatorSpec.scala b/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/committer/transaction/validation/LedgerTimeValidatorSpec.scala index 9829e9029c..0b218f1277 100644 --- a/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/committer/transaction/validation/LedgerTimeValidatorSpec.scala +++ b/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/committer/transaction/validation/LedgerTimeValidatorSpec.scala @@ -85,8 +85,12 @@ class LedgerTimeValidatorSpec extends AnyWordSpec with Matchers { aDamlTransactionEntrySummaryWithSubmissionAndLedgerEffectiveTimes, ) - context.minimumRecordTime shouldEqual Some(Instant.ofEpochSecond(-28)) - context.maximumRecordTime shouldEqual Some(Instant.ofEpochSecond(31)) + context.minimumRecordTime shouldEqual Some( + Instant.ofEpochSecond(2).minus(theDefaultConfig.timeModel.minSkew) + ) + context.maximumRecordTime shouldEqual Some( + Instant.ofEpochSecond(1).plus(theDefaultConfig.timeModel.maxSkew) + ) context.deduplicateUntil shouldBe empty context.outOfTimeBoundsLogEntry should not be empty context.outOfTimeBoundsLogEntry.foreach { actualOutOfTimeBoundsLogEntry => @@ -106,7 +110,9 @@ class LedgerTimeValidatorSpec extends AnyWordSpec with Matchers { context.minimumRecordTime shouldEqual Some( Instant.ofEpochSecond(3).plus(Timestamp.Resolution) ) - context.maximumRecordTime shouldEqual Some(Instant.ofEpochSecond(31)) + context.maximumRecordTime shouldEqual Some( + Instant.ofEpochSecond(1).plus(theDefaultConfig.timeModel.maxSkew) + ) context.deduplicateUntil shouldEqual Some( Instant.ofEpochSecond(aDeduplicateUntil.getSeconds) ) diff --git a/ledger/sandbox-common/src/main/scala/platform/sandbox/cli/CommonCliBase.scala b/ledger/sandbox-common/src/main/scala/platform/sandbox/cli/CommonCliBase.scala index 5f4973250f..b77d59ef8d 100644 --- a/ledger/sandbox-common/src/main/scala/platform/sandbox/cli/CommonCliBase.scala +++ b/ledger/sandbox-common/src/main/scala/platform/sandbox/cli/CommonCliBase.scala @@ -11,7 +11,6 @@ import com.daml.ledger.api.auth.AuthServiceJWT import com.daml.ledger.api.domain.LedgerId import com.daml.ledger.api.tls.TlsVersion.TlsVersion import com.daml.ledger.api.tls.{SecretsUrl, TlsConfiguration} -import com.daml.ledger.configuration.LedgerTimeModel import com.daml.lf.data.Ref import com.daml.platform.apiserver.SeedService.Seeding import com.daml.platform.common.LedgerIdMode @@ -312,7 +311,7 @@ class CommonCliBase(name: LedgerName) { config.copy(timeModel = config.timeModel.copy(minSkew = duration, maxSkew = duration)) } .text( - s"Maximum skew (in seconds) between the ledger time and the record time. Default is ${LedgerTimeModel.reasonableDefault.maxSkew.getSeconds}." + s"Maximum skew (in seconds) between the ledger time and the record time. Default is ${SandboxConfig.defaultConfig.timeModel.maxSkew.getSeconds}." ) opt[Duration]("management-service-timeout") diff --git a/ledger/sandbox-common/src/main/scala/platform/sandbox/config/SandboxConfig.scala b/ledger/sandbox-common/src/main/scala/platform/sandbox/config/SandboxConfig.scala index 9d39f5022c..328e8e67b4 100644 --- a/ledger/sandbox-common/src/main/scala/platform/sandbox/config/SandboxConfig.scala +++ b/ledger/sandbox-common/src/main/scala/platform/sandbox/config/SandboxConfig.scala @@ -119,7 +119,14 @@ object SandboxConfig { configurationLoadTimeout = Duration.ofSeconds(10), maxDeduplicationDuration = None, delayBeforeSubmittingLedgerConfiguration = Duration.ofSeconds(1), - timeModel = LedgerTimeModel.reasonableDefault, + // Sandbox is a slow ledger, use a big skew to avoid failing commands under load. + // If sandbox ever gets fast enough not to cause flakes in our tests, + // this can be reverted to LedgerTimeModel.reasonableDefault. + timeModel = LedgerTimeModel( + avgTransactionLatency = Duration.ofSeconds(0L), + minSkew = Duration.ofSeconds(120L), + maxSkew = Duration.ofSeconds(120L), + ).get, commandConfig = CommandConfiguration.default, submissionConfig = SubmissionConfiguration.default, tlsConfig = None,