Skip to content

Commit

Permalink
add --max-inbound-message-size flag to daml ledger export (#11087)
Browse files Browse the repository at this point in the history
Add support for `--max-inbound-message-size` flag to the [Ledger Export](https://docs.daml.com/tools/export/index.html) tool.

CHANGELOG_BEGIN

- [Daml Assistant] Add support for `--max-inbound-message-size` flag to the Ledger Export tool.

CHANGELOG_END
  • Loading branch information
sullivan-da authored Sep 30, 2021
1 parent 26d10b2 commit 7a4963b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 1 deletion.
4 changes: 3 additions & 1 deletion daml-assistant/daml-helper/src/DA/Daml/Helper/Ledger.hs
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,11 @@ runLedgerExport flags remainingArguments = do
pure []
else do
args <- getDefaultArgs flags
let maxSizeArgs size = ["--max-inbound-message-size", show size]
extras = maybe [] maxSizeArgs $ fMaxReceiveLengthM flags
-- TODO[AH]: Use parties from daml.yaml by default.
-- TODO[AH]: Use SDK version from daml.yaml by default.
pure ["--host", host args, "--port", show (port args)]
pure $ ["--host", host args, "--port", show (port args)] <> extras
withJar
damlSdkJar
[logbackArg]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ trait ReproducesTransactions
),
start = offset,
end = ledgerEnd,
maxInboundMessageSize = Config.DefaultMaxInboundMessageSize,
exportType = Some(
ExportScript(
outputPath = tmpDir,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ final case class Config(
start: LedgerOffset,
end: LedgerOffset,
exportType: Option[ExportType],
maxInboundMessageSize: Int,
)

sealed trait ExportType
Expand All @@ -39,6 +40,8 @@ final case class PartyConfig(
)

object Config {
val DefaultMaxInboundMessageSize: Int = 4194304

def parse(args: Array[String]): Option[Config] =
parser.parse(args, Empty)

Expand Down Expand Up @@ -100,6 +103,12 @@ object Config {
.text(
"The transaction offset (inclusive) for the end position of the export. Optional, by default the export includes the current end of the ledger."
)
opt[Int]("max-inbound-message-size")
.optional()
.action((x, c) => c.copy(maxInboundMessageSize = x))
.text(
s"Optional max inbound message size in bytes. Defaults to $DefaultMaxInboundMessageSize"
)
cmd("script")
.action((_, c) => c.copy(exportType = Some(EmptyExportScript)))
.text("Export ledger state in Daml script format")
Expand Down Expand Up @@ -172,5 +181,6 @@ object Config {
start = LedgerOffset(LedgerOffset.Value.Boundary(LedgerOffset.LedgerBoundary.LEDGER_BEGIN)),
end = LedgerOffset(LedgerOffset.Value.Boundary(LedgerOffset.LedgerBoundary.LEDGER_END)),
exportType = None,
maxInboundMessageSize = DefaultMaxInboundMessageSize,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,6 @@ object Main {
commandClient = CommandClientConfiguration.default,
sslContext = config.tlsConfig.client(),
token = config.accessToken.flatMap(_.token),
maxInboundMessageSize = config.maxInboundMessageSize,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,18 @@ class ConfigSpec extends AnyFreeSpec with Matchers with OptionValues {
optConfig.value.accessToken.value.token.value shouldBe token
}
}
"--max-inbound-message-size" - {
"unset" in {
val args = defaultRequiredArgs
val optConfig = Config.parse(args)
optConfig.value.maxInboundMessageSize shouldBe Config.DefaultMaxInboundMessageSize
}
"--max-inbound-message-size 9388608" in {
val args = defaultRequiredArgs ++ Array("--max-inbound-message-size", "9388608")
val optConfig = Config.parse(args)
optConfig.value.maxInboundMessageSize shouldBe 9388608
}
}
"Output type" - {
"missing" in {
val args = ledgerArgs ++ partyArgs
Expand Down

0 comments on commit 7a4963b

Please sign in to comment.