daml/ledger/sandbox/BUILD.bazel
Gabor Aranyossy 8b9f2e5860
Sandbox - active contracts streaming + transaction validation (#197)
* draft of active contracts streaming - still WIP

dumping todos for Robert

Sandbox: fix getActiveContractSnapshot

Sandbox: Add comment on thread usage

Sandbox: Add jdbcuser and ledgerid CLI arguments

Sandbox: enable SQL ledger

Sandbox: fix ledgerEnd

Sandbox: Add postgres snapshot test

Sandbox: Refactor SQL ACS

Update ACS in the same transaction as updating ledger_entries

wip CommandTransactionIT

small refactoring of Postgres Ledger creation

removing jdbc user from CLI args as it should rather be part of the jdbc url

using a thread factory for the connection accessor thread

removing timestamps from contracts table

using Akka test helpers

handling failures as rejections

removing unnecessary fields from ActiveContractsCheck

minor cleanup

small optimisation in storing Anorm queries as constants

making ContractDataParser thinner

formatting

cleanup

PostgresLedger does not need initial contracts anymore

add docs to getStreamingConnection

configured streaming connection pool to grow and shrink dynamically

crashing on set jdbcUrl CLI arg

rolling back in case of an exception

adding some docs

adding some comments

minor renaming

Add runSQL comment

* wip ActiveContracts

* fixup

* creating class ActiveContractsManager to be explicit on responsibility

* cleanup

- Remove obsolete code introduced in this PR

* scalafmt

* changed wrong autoCommit behaviour

* formatting

* amended comment on denormalisation

* disabling failing assert for now
2019-04-08 11:56:14 +02:00

146 lines
4.3 KiB
Python

# Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
load(
'//bazel_tools:scala.bzl',
'da_scala_test_suite',
'da_scala_library',
'da_scala_binary',
)
load(
"//rules_daml:daml.bzl",
"daml_compile"
)
load("@os_info//:os_info.bzl", "is_darwin")
compileDependencies = [
# this has to come first other as somehow a different instance of grpc-core.jar
'//3rdparty/jvm/io/grpc:grpc_services',
'//daml-lf/scenario-interpreter',
'//daml-lf/transaction',
'//daml-lf/engine',
'//daml-lf/data',
'//daml-lf/lfpackage',
'//daml-lf/archive:daml_lf_java_proto',
'//daml-lf/archive:daml_lf_archive_scala',
'//daml-lf/interpreter',
'//daml-lf/transaction/src/main/protobuf:value_java_proto',
'//daml-lf/transaction/src/main/protobuf:transaction_java_proto',
'//ledger-api/rs-grpc-bridge',
'//ledger-api/rs-grpc-akka',
'//ledger/ledger-api-akka',
'//ledger/ledger-api-scala-logging',
'//language-support/scala/bindings',
'//ledger/ledger-api-domain:ledger-api-domain',
'//ledger/ledger-api-common:ledger-api-common',
'//ledger/ledger-api-client:ledger-api-client',
'//ledger/backend-api',
'//3rdparty/jvm/com/typesafe/scala_logging:scala_logging',
'//3rdparty/jvm/org/slf4j:slf4j_api',
'//3rdparty/jvm/org/scalaz:scalaz_core',
'//3rdparty/jvm/org/scalaz:scalaz_concurrent',
'//3rdparty/jvm/io/netty:netty_codec_http2',
'//3rdparty/jvm/io/netty:netty_tcnative_boringssl_static',
"//3rdparty/jvm/io/grpc:grpc_netty",
"//3rdparty/jvm/io/netty:netty_handler",
'//3rdparty/jvm/com/github/scopt:scopt',
'//3rdparty/jvm/com/typesafe/akka:akka_stream',
'//3rdparty/jvm/com/google/guava:guava',
'//3rdparty/jvm/org/postgresql:postgresql',
'//3rdparty/jvm/com/zaxxer:HikariCP',
'//3rdparty/jvm/org/flywaydb:flyway_core',
'//3rdparty/jvm/com/typesafe/play:anorm',
'//3rdparty/jvm/com/typesafe/play:anorm_akka'
]
da_scala_library(
name = 'sandbox',
srcs = glob(['src/main/scala/**/*.scala']),
resources = glob(['src/main/resources/**/*']) + [
'//:COMPONENT-VERSION'
],
deps = compileDependencies,
runtime_deps = [
'//3rdparty/jvm/ch/qos/logback:logback_core',
'//3rdparty/jvm/ch/qos/logback:logback_classic'
],
visibility = [
'//visibility:public',
]
)
da_scala_binary(
name = "sandbox-binary",
main_class = 'com.digitalasset.platform.sandbox.SandboxMain',
deps = [
":sandbox",
],
visibility = ['//visibility:public'],
)
genrule(
name = "sandbox-tarball",
srcs = [":sandbox-binary_deploy.jar", "//:component-version"],
outs = ["sandbox-tarball.tar.gz"],
cmd = """
VERSION=$$(cat $(location //:component-version))
mkdir -p sandbox
cp -L $(location :sandbox-binary_deploy.jar) sandbox/sandbox-$$VERSION.jar
tar zcf $@ sandbox
""",
visibility = [ '//visibility:public']
)
# The sole purpose of this rule is to get the sandbox.jar with version 0.0.0.
genrule(
name = "sandbox-head-tarball",
srcs = [":sandbox-binary_deploy.jar"],
outs = ["sandbox-head-tarball.tar.gz"],
cmd = """
mkdir -p sandbox
cp -L $(location :sandbox-binary_deploy.jar) sandbox/sandbox-0.0.0.jar
tar zcf $@ sandbox
""",
visibility = ['//visibility:public']
)
daml_compile(
name = "Test",
main_src = "src/test/resources/damls/Test.daml",
target = "1.3",
damlc = "//daml-foundations/daml-tools/da-hs-damlc-app:da-hs-damlc-app-deprecated",
visibility = ['//visibility:public'],
)
#TODO: generate dynamic BuildInfo.scala
testDependencies = [
':sandbox',
'//ledger-api/testing-utils',
'//3rdparty/jvm/org/scalatest:scalatest',
'//3rdparty/jvm/org/scalacheck:scalacheck',
'//3rdparty/jvm/org/awaitility:awaitility',
'//3rdparty/jvm/commons_io:commons_io'
] + compileDependencies
da_scala_library(
name = "sandbox-scala-tests-lib",
srcs = glob(['src/test/lib/**/*.scala']),
deps = testDependencies,
visibility = ['//visibility:public']
)
da_scala_test_suite(
name = "sandbox-scala-tests",
srcs = glob(
['src/test/suite/**/*.scala'],
),
resources = glob(['src/test/resources/**/*']),
data = ['//ledger/sandbox:Test.dalf', '//daml-foundations/daml-ghc/package-database/deprecated:daml-prim-1.3.dalf'],
deps = [
":sandbox-scala-tests-lib",
] + testDependencies,
)