From 82534f9155c777c7f533d71e5d3faf2d091b61a5 Mon Sep 17 00:00:00 2001 From: mziolekda Date: Wed, 19 Jan 2022 14:46:50 +0100 Subject: [PATCH] Remove the reset service from the ledger api and the documentation [DPP-804] (#12472) * Remove reset service from grpc and documentation [DPP-804] CHANGELOG_BEGIN Remove reset service from the ledger api protocol and the documentation CHANGELOG_END * remove reset service from two left-over places * remove reset service from the protobuf structure test --- docs/source/app-dev/authorization.rst | 2 - docs/source/app-dev/grpc/error-codes.rst | 3 -- docs/source/app-dev/ledger-api.rst | 1 - docs/source/app-dev/services.rst | 11 ---- .../hs/bindings/src/DA/Ledger/Services.hs | 1 - .../src/DA/Ledger/Services/ResetService.hs | 22 -------- .../hs/bindings/test/DA/Ledger/Tests.hs | 30 ----------- ledger-api/grpc-definitions/BUILD.bazel | 22 +++----- .../ledger/api/v1/testing/reset_service.proto | 50 ------------------- .../self-service-error-codes-migration.yml | 2 - ...-error-codes-sandbox-classic-migration.yml | 10 ---- .../sandbox/auth/ServiceCallAuthTests.scala | 3 -- .../sandbox/services/LegacyServiceIT.scala | 18 ------- release/test-protobuf-structure.sh | 1 - 14 files changed, 8 insertions(+), 168 deletions(-) delete mode 100644 language-support/hs/bindings/src/DA/Ledger/Services/ResetService.hs delete mode 100644 ledger-api/grpc-definitions/com/daml/ledger/api/v1/testing/reset_service.proto diff --git a/docs/source/app-dev/authorization.rst b/docs/source/app-dev/authorization.rst index 0fc8deb024e..c7ffefebdf5 100644 --- a/docs/source/app-dev/authorization.rst +++ b/docs/source/app-dev/authorization.rst @@ -102,8 +102,6 @@ The following table summarizes what kind of claim is required to access each Led +-------------------------------------+----------------------------+------------------------------------------+ | PruningService | All | admin | +-------------------------------------+----------------------------+------------------------------------------+ -| ResetService | All | admin | -+-------------------------------------+----------------------------+------------------------------------------+ | TimeService | GetTime | public | | +----------------------------+------------------------------------------+ | | SetTime | admin | diff --git a/docs/source/app-dev/grpc/error-codes.rst b/docs/source/app-dev/grpc/error-codes.rst index 27d0802bbe2..6ea86c4b73f 100644 --- a/docs/source/app-dev/grpc/error-codes.rst +++ b/docs/source/app-dev/grpc/error-codes.rst @@ -292,9 +292,6 @@ The following gRPC status codes have changed for submission rejections in Sandbo |INVALID_ARGUMENT |NOT_FOUND |PARTY_NOT_KNOWN_ON_LEDGER is now returned on transaction rejections on unallocated parties. |PARTY_NOT_KNOWN_ON_LEDGER | +-----------------------------------+---------------------------------------+--------------------------------------------------------------------------------------------+----------------------------------------+ -**NOTE**: Additionally, UNAVAILABLE is now returned when trying to reset the Sandbox server during an ongoing re-initialization (was FAILED_PRECONDITION). - - Daml Sandbox and VMBC ====================================== diff --git a/docs/source/app-dev/ledger-api.rst b/docs/source/app-dev/ledger-api.rst index c14d8cbc225..b4b2135c8cc 100644 --- a/docs/source/app-dev/ledger-api.rst +++ b/docs/source/app-dev/ledger-api.rst @@ -45,7 +45,6 @@ all cases, the Ledger API exposes the same services: - Testing services (on Sandbox only, *not* for production ledgers) - Use the :ref:`time service ` to obtain the time as known by the ledger. - - Use the :ref:`reset service ` to reset the ledger state, as a quicker alternative to restarting the whole ledger application. For full information on the services see :doc:`/app-dev/services`. diff --git a/docs/source/app-dev/services.rst b/docs/source/app-dev/services.rst index f86265790a3..7ff91334b9c 100644 --- a/docs/source/app-dev/services.rst +++ b/docs/source/app-dev/services.rst @@ -262,17 +262,6 @@ Use the **time service** to obtain the time as known by the ledger server. For full details, see :ref:`the proto documentation for the service `. -.. _reset-service: - -Reset service -============= - -Use the **reset service** to reset the ledger state, as a quicker alternative to restarting the whole ledger application. - -This resets all state in the ledger, *including the ledger ID*, so clients will have to re-fetch the ledger ID from the identity service after hitting this endpoint. - -For full details, see :ref:`the proto documentation for the service `. - Services diagram **************** diff --git a/language-support/hs/bindings/src/DA/Ledger/Services.hs b/language-support/hs/bindings/src/DA/Ledger/Services.hs index 882d9d18c0d..d3133147ca7 100644 --- a/language-support/hs/bindings/src/DA/Ledger/Services.hs +++ b/language-support/hs/bindings/src/DA/Ledger/Services.hs @@ -12,6 +12,5 @@ import DA.Ledger.Services.LedgerIdentityService as X import DA.Ledger.Services.PackageManagementService as X import DA.Ledger.Services.PartyManagementService as X import DA.Ledger.Services.PackageService as X -import DA.Ledger.Services.ResetService as X import DA.Ledger.Services.TimeService as X import DA.Ledger.Services.TransactionService as X diff --git a/language-support/hs/bindings/src/DA/Ledger/Services/ResetService.hs b/language-support/hs/bindings/src/DA/Ledger/Services/ResetService.hs deleted file mode 100644 index ec933382386..00000000000 --- a/language-support/hs/bindings/src/DA/Ledger/Services/ResetService.hs +++ /dev/null @@ -1,22 +0,0 @@ --- Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module DA.Ledger.Services.ResetService (reset) where - -import Com.Daml.Ledger.Api.V1.Testing.ResetService -import DA.Ledger.GrpcWrapUtils -import DA.Ledger.LedgerService -import DA.Ledger.Types -import Google.Protobuf.Empty -import Network.GRPC.HighLevel.Generated - -reset :: LedgerId -> LedgerService () -reset lid = - makeLedgerService $ \timeout config mdm -> do - withGRPCClient config $ \client -> do - service <- resetServiceClient client - let ResetService {resetServiceReset=rpc} = service - let request = ResetRequest (unLedgerId lid) - response <- rpc (ClientNormalRequest request timeout mdm) - Empty{} <- unwrap response - return () diff --git a/language-support/hs/bindings/test/DA/Ledger/Tests.hs b/language-support/hs/bindings/test/DA/Ledger/Tests.hs index bf95d7ece12..7467dd1fc6b 100644 --- a/language-support/hs/bindings/test/DA/Ledger/Tests.hs +++ b/language-support/hs/bindings/test/DA/Ledger/Tests.hs @@ -46,10 +46,6 @@ type SandboxTest = WithSandbox -> TestTree sharedSandboxTests :: FilePath -> TestTree sharedSandboxTests testDar = testGroupWithSandbox testDar Nothing "shared sandbox" [ tGetLedgerIdentity - -- The reset service causes a bunch of issues so for now - -- we disable these tests. - -- , tReset - -- , tMultipleResets , tListPackages , tGetPackage , tGetPackageBad @@ -103,24 +99,6 @@ tGetLedgerIdentity withSandbox = testCase "getLedgerIdentity" $ run withSandbox lid <- getLedgerIdentity liftIO $ assertEqual "ledger-id" lid (LedgerId "my-ledger-id") -{- -tReset :: SandboxTest -tReset withSandbox = testCase "reset" $ run withSandbox $ \_ _ -> do - lid1 <- getLedgerIdentity - Ledger.reset lid1 - lid2 <- getLedgerIdentity - liftIO $ assertBool "lid1 /= lid2" (lid1 /= lid2) - -tMultipleResets :: SandboxTest -tMultipleResets withSandbox = testCase "multipleResets" $ run withSandbox $ \_pid _testId -> do - let resetsCount = 20 - lids <- forM [1 .. resetsCount] $ \_ -> do - lid <- getLedgerIdentity - Ledger.reset lid - pure lid - liftIO $ assertEqual "Ledger IDs are unique" resetsCount (Set.size $ Set.fromList lids) --} - tListPackages :: SandboxTest tListPackages withSandbox = testCase "listPackages" $ run withSandbox $ \DarMetadata{mainPackageId,manifest} _testId -> do lid <- getLedgerIdentity @@ -682,14 +660,6 @@ makeSignedJwt' :: Secret -> TestId -> String makeSignedJwt' secret tid = makeSignedJwt (getSecret secret) [TL.unpack $ unParty $ p tid | p <- [alice, bob]] - --- resetSandbox :: Sandbox-> IO () --- resetSandbox sandbox = runWithSandbox sandbox $ do --- lid <- getLedgerIdentity --- Ledger.reset lid --- lid2 <- getLedgerIdentity --- unless (lid /= lid2) $ fail "resetSandbox: reset did not change the ledger-id" - ---------------------------------------------------------------------- -- misc expectation combinators diff --git a/ledger-api/grpc-definitions/BUILD.bazel b/ledger-api/grpc-definitions/BUILD.bazel index 80e7948ab27..bc1a260314b 100644 --- a/ledger-api/grpc-definitions/BUILD.bazel +++ b/ledger-api/grpc-definitions/BUILD.bazel @@ -141,11 +141,6 @@ filegroup( visibility = ["//visibility:private"], ) -ledger_api_haskellpb_sources_testing = [ - "ResetService.hs", - "TimeService.hs", -] - genrule( name = "ledger-api-haskellpb-sources-testing", srcs = [ @@ -153,16 +148,15 @@ genrule( "@go_googleapis//google/rpc:status.proto", ":ledger-api-protos-fg-testing", ], - outs = ["Com/Daml/Ledger/Api/V1/Testing/" + b for b in ledger_api_haskellpb_sources_testing], + outs = ["Com/Daml/Ledger/Api/V1/Testing/TimeService.hs"], cmd = """ - for src in $(locations :ledger-api-protos-fg-testing); do - $(location @proto3-suite//:compile-proto-file) \ - --includeDir """ + google_protobuf_src + """ \ - --includeDir """ + google_rpc_src + """ \ - --includeDir """ + ledger_api_proto_source_root + """ \ - --proto com/daml/ledger/api/v1/testing/$$(basename $$src) \ - --out $(@D) - done + $(location @proto3-suite//:compile-proto-file) \ + --includeDir """ + google_protobuf_src + """ \ + --includeDir """ + google_rpc_src + """ \ + --includeDir """ + ledger_api_proto_source_root + """ \ + --proto com/daml/ledger/api/v1/testing/time_service.proto \ + --out $$(dirname $$(dirname $$(dirname $$(dirname $$(dirname $$(dirname $(@D))))))) + #6x dirname because @D works differently for a single output """, tools = [ "@proto3-suite//:compile-proto-file", diff --git a/ledger-api/grpc-definitions/com/daml/ledger/api/v1/testing/reset_service.proto b/ledger-api/grpc-definitions/com/daml/ledger/api/v1/testing/reset_service.proto deleted file mode 100644 index 98d7ad99260..00000000000 --- a/ledger-api/grpc-definitions/com/daml/ledger/api/v1/testing/reset_service.proto +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -syntax = "proto3"; - -package com.daml.ledger.api.v1.testing; - -import "google/protobuf/empty.proto"; - - -option java_outer_classname = "ResetServiceOuterClass"; -option java_package = "com.daml.ledger.api.v1.testing"; -option csharp_namespace = "Com.Daml.Ledger.Api.V1.Testing"; - -// Service to reset the ledger state. The goal here is to be able to reset the state in a way -// that's much faster compared to restarting the whole ledger application (be it a sandbox -// or the real ledger server). -// -// Note that *all* state present in the ledger implementation will be reset, most importantly -// including the ledger ID. This means that clients will have to re-fetch the ledger ID -// from the identity service after hitting this endpoint. -// -// The semantics are as follows: -// -// * When the reset service returns the reset is initiated, but not completed; -// * While the reset is performed, the ledger will not accept new requests. In fact we guarantee -// that ledger stops accepting new requests by the time the response to Reset is delivered; -// * In-flight requests might be aborted, we make no guarantees on when or how quickly this -// happens; -// * The ledger might be unavailable for a period of time before the reset is complete. -// -// Given the above, the recommended mode of operation for clients of the reset endpoint is to -// call it, then call the ledger identity endpoint in a retry loop that will tolerate a brief -// window when the ledger is down, and resume operation as soon as the new ledger ID is delivered. -// -// Note that this service will be available on the sandbox and might be available in some other testing -// environments, but will *never* be available in production. -service ResetService { - - // Resets the ledger state. Note that loaded DARs won't be removed -- this only rolls back the - // ledger to genesis. - rpc Reset (ResetRequest) returns (google.protobuf.Empty); -} - -message ResetRequest { - // Must correspond to the ledger ID reported by the Ledger Identification Service. - // Must be a valid LedgerString (as describe in ``value.proto``). - // Optional - string ledger_id = 1; -} diff --git a/ledger/participant-integration-api/src/docs/resources/com/daml/platform/docs/self-service-error-codes-migration.yml b/ledger/participant-integration-api/src/docs/resources/com/daml/platform/docs/self-service-error-codes-migration.yml index a20ab0ac3ae..9db4b422f25 100644 --- a/ledger/participant-integration-api/src/docs/resources/com/daml/platform/docs/self-service-error-codes-migration.yml +++ b/ledger/participant-integration-api/src/docs/resources/com/daml/platform/docs/self-service-error-codes-migration.yml @@ -50,8 +50,6 @@ ledgerIdMismatch: changeExplanation: "The ledger id from the request does match the participant's ledger id." selfServiceErrorCodeId: LEDGER_ID_MISMATCH services: - SandboxResetService: - - reset TimeService: - getTimeSource - setTime diff --git a/ledger/participant-integration-api/src/docs/resources/com/daml/platform/docs/self-service-error-codes-sandbox-classic-migration.yml b/ledger/participant-integration-api/src/docs/resources/com/daml/platform/docs/self-service-error-codes-sandbox-classic-migration.yml index 4abf590602e..b3d2ab59d9c 100644 --- a/ledger/participant-integration-api/src/docs/resources/com/daml/platform/docs/self-service-error-codes-sandbox-classic-migration.yml +++ b/ledger/participant-integration-api/src/docs/resources/com/daml/platform/docs/self-service-error-codes-sandbox-classic-migration.yml @@ -62,13 +62,3 @@ SandboxClassicRejections.#invalidLedgerTime: services: SandboxClassic.CommandCompletionService: - CompletionStream - -SandboxClassic.resetService: - change: - - FAILED_PRECONDITION - - UNAVAILABLE - changeExplanation: "UNAVAILABLE is now returned when trying to reset the Sandbox server during an ongoing re-initialization." - selfServiceErrorCodeId: SERVICE_NOT_RUNNING - services: - SandboxClassic: - - Reset diff --git a/ledger/sandbox-classic/src/test/lib/scala/platform/sandbox/auth/ServiceCallAuthTests.scala b/ledger/sandbox-classic/src/test/lib/scala/platform/sandbox/auth/ServiceCallAuthTests.scala index e04c23ab91c..d992aad84e7 100644 --- a/ledger/sandbox-classic/src/test/lib/scala/platform/sandbox/auth/ServiceCallAuthTests.scala +++ b/ledger/sandbox-classic/src/test/lib/scala/platform/sandbox/auth/ServiceCallAuthTests.scala @@ -54,9 +54,6 @@ trait ServiceCallAuthTests protected def expectInvalidArgument(f: Future[Any]): Future[Assertion] = expectFailure(f, Status.Code.INVALID_ARGUMENT) - protected def expectUnimplemented(f: Future[Any]): Future[Assertion] = - expectFailure(f, Status.Code.UNIMPLEMENTED) - protected def expectFailure(f: Future[Any], code: Status.Code): Future[Assertion] = f.failed.collect { case GrpcException(GrpcStatus(`code`, _), _) => succeed diff --git a/ledger/sandbox-classic/src/test/suite/scala/platform/sandbox/services/LegacyServiceIT.scala b/ledger/sandbox-classic/src/test/suite/scala/platform/sandbox/services/LegacyServiceIT.scala index 334d002584a..001f283da55 100644 --- a/ledger/sandbox-classic/src/test/suite/scala/platform/sandbox/services/LegacyServiceIT.scala +++ b/ledger/sandbox-classic/src/test/suite/scala/platform/sandbox/services/LegacyServiceIT.scala @@ -40,7 +40,6 @@ import com.daml.ledger.api.v1.ledger_identity_service.{ LedgerIdentityServiceGrpc, } import com.daml.ledger.api.v1.package_service.{ListPackagesRequest, PackageServiceGrpc} -import com.daml.ledger.api.v1.testing.reset_service.{ResetRequest, ResetServiceGrpc} import com.daml.ledger.api.v1.testing.time_service.{GetTimeRequest, TimeServiceGrpc} import com.daml.ledger.api.v1.transaction_service.{GetLedgerEndRequest, TransactionServiceGrpc} import io.grpc @@ -85,15 +84,6 @@ class LegacyServiceIT } } - private def expectUnimplemented[A](block: => A): Assertion = { - inside(Try(block)) { - case Success(_) => fail() - case Failure(exc: StatusRuntimeException) => - exc.getStatus.getCode shouldBe Status.Code.UNIMPLEMENTED - case Failure(otherwise) => fail(otherwise) - } - } - "Ledger API Server" should { "offer com.digitalasset.ledger.api.v1.ActiveContractsService" in { expectNotUnimplemented { @@ -159,14 +149,6 @@ class LegacyServiceIT } } - "offer com.digitalasset.ledger.api.v1.testing.ResetService" in { - expectUnimplemented { - val testingReset = - ResetServiceGrpc.blockingStub(channel).withInterceptors(legacyCallInterceptor) - testingReset.reset(ResetRequest(randomLedgerId)) - } - } - "offer com.digitalasset.ledger.api.v1.testing.TimeService" in { expectNotUnimplemented { val testingTime = diff --git a/release/test-protobuf-structure.sh b/release/test-protobuf-structure.sh index fb86508739e..fcb1987bcea 100755 --- a/release/test-protobuf-structure.sh +++ b/release/test-protobuf-structure.sh @@ -55,7 +55,6 @@ com/daml/ledger/api/v1/ledger_configuration_service.proto com/daml/ledger/api/v1/ledger_identity_service.proto com/daml/ledger/api/v1/ledger_offset.proto com/daml/ledger/api/v1/package_service.proto -com/daml/ledger/api/v1/testing/reset_service.proto com/daml/ledger/api/v1/testing/time_service.proto com/daml/ledger/api/v1/transaction.proto com/daml/ledger/api/v1/transaction_filter.proto