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

[DPP-1022] ACS active_at_offset #15764

Merged
merged 4 commits into from
Dec 15, 2022
Merged

[DPP-1022] ACS active_at_offset #15764

merged 4 commits into from
Dec 15, 2022

Conversation

pbatko-da
Copy link
Contributor

changelog_begin
Ledger API: Add active_at_offset to the GetActiveContractsRequest request
changelog_end

@pbatko-da pbatko-da self-assigned this Dec 1, 2022
@pbatko-da pbatko-da force-pushed the pbatko/acs-request-offset branch 3 times, most recently from dfea01b to d81ada0 Compare December 2, 2022 19:34
@pbatko-da pbatko-da marked this pull request as ready for review December 2, 2022 19:34
Copy link
Contributor

@meiersi-da meiersi-da left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @pbatko-da . This is great functionality to have!

I'm not approving, as I'd like one of your team to review Scala code.

FYI: @arne-da @cocreature : note that this enables us to ingest audit-logs backed by historical ACS snapshots.

@@ -38,23 +38,26 @@ message GetActiveContractsRequest {
// In particular, setting the verbose flag to true triggers the ledger to include labels for record fields.
// Optional
bool verbose = 3;

// The offset at which the snapshot of the active contracts will be computed.
// Must be no greater than the current ledger end offset.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume it has to be greater than the latest pruning offset? Otherwise it seems like you'll omit contracts that have been active at the specified offset but have been archived before the pruning interval.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current implementation allows active_at offset that is greater than or equal to the pruning offset.

Added conformance tests verifying that and a note in the proto file

changelog_begin
Ledger API: Add active_at_offset to the GetActiveContractsRequest request
changelog_end
@pbatko-da pbatko-da force-pushed the pbatko/acs-request-offset branch from e4c8b2b to 767b11c Compare December 13, 2022 11:25
@lucianojoublanc-da
Copy link

Is there any chance we would be able to get the active_at_offset field added to the response message?

As discussed here, we currently have to wait until the last GRPC message to know the offset (if we requested LEDGEREND). This can be really resource intensive, as we need to cache the entire ACS before performing any action that depends on knowing the ledger position.

@pbatko-da
Copy link
Contributor Author

@lucianojoublanc-da My instinct would be to modify the behavior of the already existing offset such that it is populated in every response message. @cocreature pointed out that it would be breaking change though.

@cocreature Why would it be a breaking change? Current description [1] leaves it unspecified what is the content of the offset field in every but the last message. If anything, it hints that this field is not empty with the "Required" note.

If wonder if we could lose any useful semantics if we start populating offset in every message.
I thought about detecting the stream end but it seems useless because the stream should end by itself just after the last message.

[1] Current description of the offset field:

  // Included in the last message.
  // The client should start consuming the transactions endpoint with this offset.
  // The format of this field is described in ``ledger_offset.proto``.
  // Required
  string offset = 1;

@meiersi-da
Copy link
Contributor

Is there any chance we would be able to get the active_at_offset field added to the response message?

As discussed here, we currently have to wait until the last GRPC message to know the offset (if we requested LEDGEREND). This can be really resource intensive, as we need to cache the entire ACS before performing any action that depends on knowing the ledger position.

@lucianojoublanc-da : why do you need to see the offset in the response at all with this change? I am under the assumption that with this change the caller chooses the offset up front (e.g., using a call to GetLedgerEnd) and submits it to the ledger-api server, so the offset is already known to the caller before receiving any message. Isn't that so @pbatko-da ?

@lucianojoublanc-da
Copy link

I am under the assumption that with this change the caller chooses the offset up front (e.g., using a call to GetLedgerEnd)

If you submit a call to getActiveContracts with LEDGEREND, that's not the case. This would save you one extra round-trip.

There's also the fact that the spec is somewhat ambiguous in this regard : I don't think it actually says that you'll get back the same offset that you set in the request ..

@lucianojoublanc-da
Copy link

@lucianojoublanc-da My instinct would be to modify the behavior of the already existing offset such that it is populated in every response message. @cocreature pointed out that it would be breaking change though.

@cocreature Why would it be a breaking change? Current description [1] leaves it unspecified what is the content of the offset field in every but the last message. If anything, it hints that this field is not empty with the "Required" note.

I agree with you, that would be my preference, but I think that in practice there will be people who have coded up their client based on what they observe when e.g. calling the sandbox, and this would break that behaviour.

@mziolekda
Copy link
Contributor

Code from this PR combined with the getLedgerEnd call is fixing the UX that Luciano has pointed out.
Therefore, we should not make a breaking change and start sending the offset on every message batch. We can leave that chestnut for later. It is a client-app performance optimization that I am not convinced really brings much to the table.

Copy link
Contributor

@mziolekda mziolekda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left few minor comments, otherwise LGTM

@pbatko-da
Copy link
Contributor Author

@lucianojoublanc-da : why do you need to see the offset in the response at all with this change? I am under the assumption that with this change the caller chooses the offset up front (e.g., using a call to GetLedgerEnd) and submits it to the ledger-api server, so the offset is already known to the caller before receiving any message. Isn't that so @pbatko-da ?

@meiersi-da - correct

@pbatko-da pbatko-da enabled auto-merge (squash) December 15, 2022 16:28
@pbatko-da pbatko-da merged commit 566b564 into main Dec 15, 2022
@pbatko-da pbatko-da deleted the pbatko/acs-request-offset branch December 15, 2022 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants