Skip to content

Commit

Permalink
[main] Update 2024-07-10.10 (#194)
Browse files Browse the repository at this point in the history
Reference commit: 8582b999b8

Co-authored-by: Canton <[email protected]>
  • Loading branch information
canton-machine and Canton authored Jul 10, 2024
1 parent 85b4647 commit f0ddd4b
Show file tree
Hide file tree
Showing 262 changed files with 3,597 additions and 2,656 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import "scalapb/scalapb.proto";

// Schema definition for the exported ACS snapshot
message ActiveContract {
option (scalapb.message).companion_extends = "com.digitalasset.canton.version.UnstableProtoVersion";
option (scalapb.message).companion_extends = "com.digitalasset.canton.version.AlphaProtoVersion";

// The ID of the domain where the contract was assigned at the time of the export
// Required
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ service EnterpriseParticipantReplicationService {
message SetPassive {
message Request {}

message Response {}
message Response {
bool became_passive = 1;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ object ProtocolVersionAnnotation {
/** Type-level marker for whether a protocol version is stable */
sealed trait Status

/** Marker for unstable protocol versions */
sealed trait Unstable extends Status
/** Marker for alpha protocol versions */
sealed trait Alpha extends Status

/** Marker for stable protocol versions */
sealed trait Stable extends Status
Expand All @@ -19,17 +19,17 @@ object ProtocolVersionAnnotation {
* that are used in some stable protocol versions
*
* Implements both [[com.digitalasset.canton.version.ProtocolVersionAnnotation.Stable]] and
* [[com.digitalasset.canton.version.ProtocolVersionAnnotation.Unstable]] means that [[StableProtoVersion]]
* messages can be used in stable and unstable protocol versions.
* [[com.digitalasset.canton.version.ProtocolVersionAnnotation.Alpha]] means that [[StableProtoVersion]]
* messages can be used in stable and alpha protocol versions.
*/
trait StableProtoVersion
extends ProtocolVersionAnnotation.Stable
with ProtocolVersionAnnotation.Unstable
with ProtocolVersionAnnotation.Alpha

/** Marker trait for Protobuf messages generated by scalapb
* that are used only unstable protocol versions
* that are used only alpha protocol versions
*/
trait UnstableProtoVersion extends ProtocolVersionAnnotation.Unstable
trait AlphaProtoVersion extends ProtocolVersionAnnotation.Alpha

/** Marker trait for Protobuf messages generated by scalapb
* that are used only to persist data in node storage.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ import com.digitalasset.canton.domain.sequencing.admin.grpc.InitializeSequencerR
import com.digitalasset.canton.domain.sequencing.sequencer.SequencerSnapshot
import com.digitalasset.canton.sequencer.admin.v30
import com.digitalasset.canton.topology.{Member, SequencerId}
import com.digitalasset.canton.util.GrpcStreamingUtils
import com.google.protobuf.ByteString
import io.grpc.ManagedChannel
import io.grpc.Context.CancellableContext
import io.grpc.stub.StreamObserver
import io.grpc.{Context, ManagedChannel}

import scala.concurrent.Future

Expand Down Expand Up @@ -60,7 +63,12 @@ object EnterpriseSequencerAdminCommands {
service: v30.SequencerInitializationServiceGrpc.SequencerInitializationServiceStub,
request: v30.InitializeSequencerFromOnboardingStateRequest,
): Future[v30.InitializeSequencerFromOnboardingStateResponse] =
service.initializeSequencerFromOnboardingState(request)
GrpcStreamingUtils.streamToServer(
service.initializeSequencerFromOnboardingState,
(onboardingState: Array[Byte]) =>
v30.InitializeSequencerFromOnboardingStateRequest(ByteString.copyFrom(onboardingState)),
request.onboardingState,
)

override def createRequest()
: Either[String, v30.InitializeSequencerFromOnboardingStateRequest] =
Expand Down Expand Up @@ -92,7 +100,15 @@ object EnterpriseSequencerAdminCommands {
service: v30.SequencerInitializationServiceGrpc.SequencerInitializationServiceStub,
request: v30.InitializeSequencerFromGenesisStateRequest,
): Future[v30.InitializeSequencerFromGenesisStateResponse] =
service.initializeSequencerFromGenesisState(request)
GrpcStreamingUtils.streamToServer(
service.initializeSequencerFromGenesisState,
(topologySnapshot: Array[Byte]) =>
v30.InitializeSequencerFromGenesisStateRequest(
topologySnapshot = ByteString.copyFrom(topologySnapshot),
Some(domainParameters.toProtoV30),
),
request.topologySnapshot,
)

override def createRequest(): Either[String, v30.InitializeSequencerFromGenesisStateRequest] =
Right(
Expand Down Expand Up @@ -143,17 +159,20 @@ object EnterpriseSequencerAdminCommands {
override def timeoutType: TimeoutType = DefaultUnboundedTimeout
}

final case class OnboardingState(memberOrTimestamp: Either[SequencerId, CantonTimestamp])
extends BaseSequencerAdministrationCommand[
final case class OnboardingState(
observer: StreamObserver[v30.OnboardingStateResponse],
sequencerOrTimestamp: Either[SequencerId, CantonTimestamp],
) extends BaseSequencerAdministrationCommand[
v30.OnboardingStateRequest,
v30.OnboardingStateResponse,
ByteString,
CancellableContext,
CancellableContext,
] {
override def createRequest(): Either[String, v30.OnboardingStateRequest] = {
Right(
v30.OnboardingStateRequest(request =
memberOrTimestamp.fold[v30.OnboardingStateRequest.Request](
member => v30.OnboardingStateRequest.Request.SequencerId(member.toProtoPrimitive),
sequencerOrTimestamp.fold[v30.OnboardingStateRequest.Request](
sequencer =>
v30.OnboardingStateRequest.Request.SequencerUid(sequencer.uid.toProtoPrimitive),
timestamp => v30.OnboardingStateRequest.Request.Timestamp(timestamp.toProtoTimestamp),
)
)
Expand All @@ -163,22 +182,14 @@ object EnterpriseSequencerAdminCommands {
override def submitRequest(
service: v30.SequencerAdministrationServiceGrpc.SequencerAdministrationServiceStub,
request: v30.OnboardingStateRequest,
): Future[v30.OnboardingStateResponse] = service.onboardingState(request)
): Future[CancellableContext] = {
val context = Context.current().withCancellation()
context.run(() => service.onboardingState(request, observer))
Future.successful(context)
}

override def handleResponse(
response: v30.OnboardingStateResponse
): Either[String, ByteString] =
response.value match {
case v30.OnboardingStateResponse.Value
.Failure(v30.OnboardingStateResponse.Failure(reason)) =>
Left(reason)
case v30.OnboardingStateResponse.Value
.Success(
v30.OnboardingStateResponse.Success(onboardingState)
) =>
Right(onboardingState)
case _ => Left("response is empty")
}
override def handleResponse(response: CancellableContext): Either[String, CancellableContext] =
Right(response)

// command will potentially take a long time
override def timeoutType: TimeoutType = DefaultUnboundedTimeout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,23 @@
package com.digitalasset.canton.admin.api.client.commands

import com.digitalasset.canton.domain.sequencing.sequencer.block.bftordering.admin.EnterpriseSequencerBftAdminData.{
OrderingTopology,
PeerNetworkStatus,
endpointToProto,
}
import com.digitalasset.canton.networking.Endpoint
import com.digitalasset.canton.sequencer.admin.v30
import com.digitalasset.canton.sequencer.admin.v30.*
import com.digitalasset.canton.sequencer.admin.v30.SequencerBftAdministrationServiceGrpc.SequencerBftAdministrationServiceStub
import com.digitalasset.canton.sequencer.admin.v30.{
AddPeerEndpointRequest,
AddPeerEndpointResponse,
GetOrderingTopologyRequest,
GetOrderingTopologyResponse,
GetPeerNetworkStatusRequest,
GetPeerNetworkStatusResponse,
RemovePeerEndpointRequest,
RemovePeerEndpointResponse,
SequencerBftAdministrationServiceGrpc,
}
import io.grpc.ManagedChannel

import scala.concurrent.Future
Expand All @@ -19,11 +30,11 @@ object EnterpriseSequencerBftAdminCommands {
abstract class BaseSequencerBftAdministrationCommand[Req, Rep, Res]
extends GrpcAdminCommand[Req, Rep, Res] {
override type Svc =
v30.SequencerBftAdministrationServiceGrpc.SequencerBftAdministrationServiceStub
SequencerBftAdministrationServiceStub
override def createService(
channel: ManagedChannel
): v30.SequencerBftAdministrationServiceGrpc.SequencerBftAdministrationServiceStub =
v30.SequencerBftAdministrationServiceGrpc.stub(channel)
): SequencerBftAdministrationServiceStub =
SequencerBftAdministrationServiceGrpc.stub(channel)
}

final case class AddPeerEndpoint(endpoint: Endpoint)
Expand All @@ -38,7 +49,7 @@ object EnterpriseSequencerBftAdminCommands {
)

override def submitRequest(
service: v30.SequencerBftAdministrationServiceGrpc.SequencerBftAdministrationServiceStub,
service: SequencerBftAdministrationServiceStub,
request: AddPeerEndpointRequest,
): Future[AddPeerEndpointResponse] =
service.addPeerEndpoint(request)
Expand All @@ -61,7 +72,7 @@ object EnterpriseSequencerBftAdminCommands {
)

override def submitRequest(
service: v30.SequencerBftAdministrationServiceGrpc.SequencerBftAdministrationServiceStub,
service: SequencerBftAdministrationServiceStub,
request: RemovePeerEndpointRequest,
): Future[RemovePeerEndpointResponse] =
service.removePeerEndpoint(request)
Expand All @@ -84,7 +95,7 @@ object EnterpriseSequencerBftAdminCommands {
)

override def submitRequest(
service: v30.SequencerBftAdministrationServiceGrpc.SequencerBftAdministrationServiceStub,
service: SequencerBftAdministrationServiceStub,
request: GetPeerNetworkStatusRequest,
): Future[GetPeerNetworkStatusResponse] =
service.getPeerNetworkStatus(request)
Expand All @@ -94,4 +105,27 @@ object EnterpriseSequencerBftAdminCommands {
): Either[String, PeerNetworkStatus] =
PeerNetworkStatus.fromProto(response)
}

final case class GetOrderingTopology()
extends BaseSequencerBftAdministrationCommand[
GetOrderingTopologyRequest,
GetOrderingTopologyResponse,
OrderingTopology,
] {

override def createRequest(): Either[String, GetOrderingTopologyRequest] = Right(
GetOrderingTopologyRequest.of()
)

override def submitRequest(
service: SequencerBftAdministrationServiceStub,
request: GetOrderingTopologyRequest,
): Future[GetOrderingTopologyResponse] =
service.getOrderingTopology(request)

override def handleResponse(
response: GetOrderingTopologyResponse
): Either[String, OrderingTopology] =
OrderingTopology.fromProto(response)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,25 @@ object LedgerApiCommands {

}

final case class ValidateDarFile(darPath: String)
extends BaseCommand[ValidateDarFileRequest, ValidateDarFileResponse, Unit] {

override def createRequest(): Either[String, ValidateDarFileRequest] =
for {
bytes <- BinaryFileUtil.readByteStringFromFile(darPath)
} yield ValidateDarFileRequest(bytes)

override def submitRequest(
service: PackageManagementServiceStub,
request: ValidateDarFileRequest,
): Future[ValidateDarFileResponse] =
service.validateDarFile(request)
override def handleResponse(response: ValidateDarFileResponse): Either[String, Unit] =
Right(())

override def timeoutType: TimeoutType = DefaultUnboundedTimeout
}

final case class ListKnownPackages(limit: PositiveInt)
extends BaseCommand[ListKnownPackagesRequest, ListKnownPackagesResponse, Seq[
PackageDetails
Expand Down
Loading

0 comments on commit f0ddd4b

Please sign in to comment.