Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] GetUpdatesRequest #20000

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1074,8 +1074,8 @@ object LedgerApiCommands {

override def createRequest(): Either[String, GetUpdatesRequest] = Right {
GetUpdatesRequest(
beginExclusive = beginExclusive,
endInclusive = endInclusive,
beginExclusive = ApiOffset.assertFromStringToLong(beginExclusive),
endInclusive = ApiOffset.assertFromStringToLongO(endInclusive),
verbose = verbose,
filter = Some(filter),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,11 @@ trait TopologyClientApi[+T] { this: HasFutureSupervision =>
timestamp: CantonTimestamp
)(implicit traceContext: TraceContext): Option[FutureUnlessShutdown[Unit]]

/** Finds the transaction with maximum effective time that has been sequenced before `sequencedTime` and
* yields the sequenced and effective time of that transaction, if necessary after waiting for a timestamp
* at or after `sequencedTime.immediatePredecessor` that the topology processor has fully processed.
/** Finds the topology transaction with maximum effective time whose effects would be visible,
* at earliest i.e. if delay is 0, in a topology snapshot at `effectiveTime`, and yields
* the sequenced and actual effective time of that topology transaction, if necessary after waiting
* to observe a timestamp at or after sequencing time `effectiveTime.immediatePredecessor`
* that the topology processor has fully processed.
*/
def awaitMaxTimestampUS(sequencedTime: CantonTimestamp)(implicit
traceContext: TraceContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,21 @@

public final class ActiveContracts<Ct> {

public final Optional<String> offset;

public final List<Ct> activeContracts;

public final String workflowId;

public ActiveContracts(
@NonNull Optional<String> offset,
@NonNull List<Ct> activeContracts,
@NonNull String workflowId) {
this.offset = offset;
this.activeContracts = activeContracts;
this.workflowId = workflowId;
}

@Override
public String toString() {
return "ActiveContracts{"
+ "offset='"
+ offset
+ '\''
+ ", activeContracts="
+ "activeContracts="
+ activeContracts
+ ", workflowId="
+ workflowId
Expand All @@ -43,13 +36,12 @@ public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ActiveContracts<?> that = (ActiveContracts<?>) o;
return offset.equals(that.offset)
&& Objects.equals(activeContracts, that.activeContracts)
return Objects.equals(activeContracts, that.activeContracts)
&& Objects.equals(workflowId, that.workflowId);
}

@Override
public int hashCode() {
return Objects.hash(offset, activeContracts, workflowId);
return Objects.hash(activeContracts, workflowId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,12 @@

public final class GetActiveContractsResponse implements WorkflowEvent {

private final String offset;

private final Optional<ContractEntry> contractEntry;

private final String workflowId;

public GetActiveContractsResponse(
@NonNull String offset, @NonNull Optional<ContractEntry> contractEntry, String workflowId) {
this.offset = offset;
@NonNull Optional<ContractEntry> contractEntry, String workflowId) {
this.contractEntry = contractEntry;
this.workflowId = workflowId;
}
Expand All @@ -29,22 +26,18 @@ public static GetActiveContractsResponse fromProto(
switch (response.getContractEntryCase()) {
case ACTIVE_CONTRACT:
return new GetActiveContractsResponse(
response.getOffset(),
Optional.of(ActiveContract.fromProto(response.getActiveContract())),
response.getWorkflowId());
case INCOMPLETE_UNASSIGNED:
return new GetActiveContractsResponse(
response.getOffset(),
Optional.of(IncompleteUnassigned.fromProto(response.getIncompleteUnassigned())),
response.getWorkflowId());
case INCOMPLETE_ASSIGNED:
return new GetActiveContractsResponse(
response.getOffset(),
Optional.of(IncompleteAssigned.fromProto(response.getIncompleteAssigned())),
response.getWorkflowId());
case CONTRACTENTRY_NOT_SET:
return new GetActiveContractsResponse(
response.getOffset(), Optional.empty(), response.getWorkflowId());
return new GetActiveContractsResponse(Optional.empty(), response.getWorkflowId());
default:
throw new ProtoContractEntryUnknown(response);
}
Expand All @@ -53,7 +46,6 @@ public static GetActiveContractsResponse fromProto(
public StateServiceOuterClass.GetActiveContractsResponse toProto() {
var builder =
StateServiceOuterClass.GetActiveContractsResponse.newBuilder()
.setOffset(this.offset)
.setWorkflowId(this.workflowId);
if (contractEntry.isPresent()) {
ContractEntry ce = contractEntry.get();
Expand All @@ -66,12 +58,6 @@ else if (ce instanceof IncompleteAssigned)
return builder.build();
}

@NonNull
public Optional<String> getOffset() {
// Empty string indicates that the field is not present in the protobuf.
return Optional.of(offset).filter(off -> !offset.equals(""));
}

public Optional<ContractEntry> getContractEntry() {
return contractEntry;
}
Expand All @@ -84,10 +70,7 @@ public String getWorkflowId() {
@Override
public String toString() {
return "GetActiveContractsResponse{"
+ "offset='"
+ offset
+ '\''
+ ", contractEntry="
+ "contractEntry="
+ contractEntry
+ ", workflowId="
+ workflowId
Expand All @@ -99,14 +82,13 @@ public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
GetActiveContractsResponse that = (GetActiveContractsResponse) o;
return Objects.equals(offset, that.offset)
&& Objects.equals(contractEntry, that.contractEntry)
return Objects.equals(contractEntry, that.contractEntry)
&& Objects.equals(workflowId, that.workflowId);
}

@Override
public int hashCode() {
return Objects.hash(offset, contractEntry, workflowId);
return Objects.hash(contractEntry, workflowId);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@

public final class GetUpdatesRequest {

@NonNull private final String beginExclusive;
@NonNull private final Long beginExclusive;

@NonNull private final String endInclusive;
@NonNull private final Optional<Long> endInclusive;

@NonNull private final TransactionFilter transactionFilter;

private final boolean verbose;

public GetUpdatesRequest(
@NonNull String beginExclusive,
@NonNull String endInclusive,
@NonNull Long beginExclusive,
@NonNull Optional<Long> endInclusive,
@NonNull TransactionFilter transactionFilter,
boolean verbose) {
this.beginExclusive = beginExclusive;
Expand All @@ -34,25 +34,30 @@ public static GetUpdatesRequest fromProto(UpdateServiceOuterClass.GetUpdatesRequ
TransactionFilter filters = TransactionFilter.fromProto(request.getFilter());
boolean verbose = request.getVerbose();
return new GetUpdatesRequest(
request.getBeginExclusive(), request.getEndInclusive(), filters, verbose);
request.getBeginExclusive(),
request.hasEndInclusive() ? Optional.of(request.getEndInclusive()) : Optional.empty(),
filters,
verbose);
}

public UpdateServiceOuterClass.GetUpdatesRequest toProto() {
return UpdateServiceOuterClass.GetUpdatesRequest.newBuilder()
.setBeginExclusive(beginExclusive)
.setEndInclusive(endInclusive)
.setFilter(this.transactionFilter.toProto())
.setVerbose(this.verbose)
.build();
UpdateServiceOuterClass.GetUpdatesRequest.Builder builder =
UpdateServiceOuterClass.GetUpdatesRequest.newBuilder()
.setBeginExclusive(beginExclusive)
.setFilter(this.transactionFilter.toProto())
.setVerbose(this.verbose);

endInclusive.ifPresent(builder::setEndInclusive);
return builder.build();
}

@NonNull
public String getBeginExclusive() {
public Long getBeginExclusive() {
return beginExclusive;
}

@NonNull
public String getEndInclusive() {
public Optional<Long> getEndInclusive() {
return endInclusive;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,12 +507,10 @@ object Generators {

def getActiveContractResponseGen: Gen[v2.StateServiceOuterClass.GetActiveContractsResponse] =
for {
offset <- Arbitrary.arbString.arbitrary
workflowId <- Arbitrary.arbString.arbitrary
entryGen <- contractEntryBuilderGen
} yield v2.StateServiceOuterClass.GetActiveContractsResponse
.newBuilder()
.setOffset(offset)
.setWorkflowId(workflowId)
.pipe(entryGen)
.build()
Expand Down Expand Up @@ -820,8 +818,8 @@ object Generators {
def getUpdatesRequestGen: Gen[v2.UpdateServiceOuterClass.GetUpdatesRequest] = {
import v2.UpdateServiceOuterClass.GetUpdatesRequest as Request
for {
beginExclusive <- Arbitrary.arbString.arbitrary
endInclusiveO <- Gen.option(Arbitrary.arbString.arbitrary)
beginExclusive <- Arbitrary.arbLong.arbitrary
endInclusiveO <- Gen.option(Arbitrary.arbLong.arbitrary)
filter <- transactionFilterGen
verbose <- Arbitrary.arbBool.arbitrary
} yield {
Expand All @@ -831,15 +829,10 @@ object Generators {
.setFilter(filter)
.setVerbose(verbose)

endInclusiveO match {
case Some(endInclusive) =>
partialBuilder
.setEndInclusive(endInclusive)
.build()
case None =>
partialBuilder
.build()
}
val builder =
endInclusiveO.fold(partialBuilder)(partialBuilder.setEndInclusive)

builder.build()
}
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import com.digitalasset.canton.console.ParticipantReference
import com.digitalasset.canton.discard.Implicits.DiscardOps
import com.digitalasset.canton.logging.{NamedLoggerFactory, NamedLogging}
import com.digitalasset.canton.networking.grpc.ClientChannelBuilder
import com.digitalasset.canton.platform.ApiOffset
import com.digitalasset.canton.topology.UniqueIdentifier
import com.digitalasset.canton.tracing.{NoTracing, TraceContext}
import com.digitalasset.canton.util.LoggerUtil.clue
Expand Down Expand Up @@ -362,7 +363,7 @@ class ParticipantTab(

val partyId = UniqueIdentifier.tryCreate(party, uid.namespace).toProtoPrimitive
val req = new GetUpdatesRequest(
beginExclusive = offset,
beginExclusive = ApiOffset.assertFromStringToLong(offset),
filter = Some(TransactionFilter(filtersByParty = Map(partyId -> Filters()))),
verbose = true,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,9 @@ private[update] final class BlockChunkProcessor(
// and we don't need to add a `Deliver` for the tick.

logger.debug(
s"Block $height: emitting a topology tick at least at $tickAtLeastAt (actually at $tickSequencingTimestamp) " +
s"as requested by the block orderer"
s"Emitting topology tick: after processing block $height, the last sequenced timestamp is ${state.lastChunkTs} and " +
s"the block orderer requested to tick at least at $tickAtLeastAt, so " +
s"ticking topology at $tickSequencingTimestamp"
)
// We bypass validation here to make sure that the topology tick is always received by the sequencer runtime.
for {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,6 @@ message GetActiveContractsRequest {
}

message GetActiveContractsResponse {
// Included only in the last message.
// The client should start consuming the transactions endpoint with this offset.
// On a participant that is not aware of any events in the ledger the offset returned could be the empty string.
// The empty string signifies that the offset returned is before the first transaction.
// The details of the offset field are described in ``community/ledger-api/README.md``.
string offset = 1;

// The workflow ID used in command submission which corresponds to the contract_entry. Only set if
// the ``workflow_id`` for the command was set.
// Must be a valid LedgerString (as described in ``value.proto``).
Expand Down
Loading