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

KV: do not use "Inputs" part of InputsAndEffects #9429

Merged
merged 9 commits into from
Apr 19, 2021
Merged

Conversation

remyhaemmerle-da
Copy link
Collaborator

CHANGELOG_BEGIN
CHANGELOG_END

Pull Request Checklist

  • Read and understand the contribution guidelines
  • Include appropriate tests
  • Set a descriptive title and thorough description
  • Add a reference to the issue this PR will solve, if appropriate
  • Include changelog additions in one or more commit message bodies between the CHANGELOG_BEGIN and CHANGELOG_END tags
  • Normal production system change, include purpose of change in description

NOTE: CI is not automatically run on non-members pull-requests for security
reasons. The reviewer will have to comment with /AzurePipelines run to
trigger the build.

Copy link
Contributor

@miklos-da miklos-da left a comment

Choose a reason for hiding this comment

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

@remyhaemmerle-da If you merge #9361 you won't need this PR. Am I missing something?

@remyhaemmerle-da
Copy link
Collaborator Author

@remyhaemmerle-da If you merge #9361 you won't need this PR. Am I missing something?

I think it is better to go this way. Review #9361 and make it only about Effect and make this PR about Inputs only.

In the concrete case we do not need a special computation of Input because almost everything (expect contract key) is already in GenTransaction.

I tried to address some of the comment you make in #9361, here.

(tx.informees ++ submitterInfo.actAs).toList.map(Conversions.partyStateKey)
val contractIdStates =
tx.inputContracts[ContractId].map(Conversions.contractIdToStateKey)
val contractKeyStates =
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we treat contract keys created with the transaction as inputs but don’t do the same for contract ids? That seems a bit inconsistent. I assume it has something to do with duplicate key detection or something along those lines?

Copy link
Collaborator Author

@remyhaemmerle-da remyhaemmerle-da Apr 16, 2021

Choose a reason for hiding this comment

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

As far I understand, for validation, KV has to collect beforehand all the info needed to replay the transaction. For created contract, it need to know the contract key does not exists.

Copy link
Contributor

Choose a reason for hiding this comment

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

alright so the input is the “non-existence of the key” or something like that, makes sense 👍

@remyhaemmerle-da remyhaemmerle-da changed the title KV: refactor transactionToSubmission to not use InputsAndEffects KV: do not use "Inputs" part of InputsAndEffects Apr 16, 2021
remyhaemmerle-da added a commit that referenced this pull request Apr 16, 2021
The PR is based #9429.

CHANGELOG_BEGIN
CHANGELOG_END
remyhaemmerle-da added a commit that referenced this pull request Apr 16, 2021
The PR is based #9429.

CHANGELOG_BEGIN
CHANGELOG_END
@cocreature cocreature self-assigned this Apr 16, 2021
final def contractKeys(implicit
ev: HasTxNodes[Nid, Cid] <:< HasTxNodes[_, Value.ContractId]
): Set[GlobalKey] = {
ev(this).fold(Set.empty[GlobalKey]) {
Copy link

Choose a reason for hiding this comment

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

I'd find this a little prettier with some kind of foldMap. Is it worth implementing that?

Copy link
Contributor

Choose a reason for hiding this comment

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

Could be sensible but I’d prefer keeping it for a separate PR.

cocreature and others added 2 commits April 19, 2021 09:38
…ansaction/TransactionSpec.scala

Co-authored-by: Samir Talwar <samir.talwar@digitalasset.com>
changelog_begin
changelog_end
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

I'm happy but if I were you, I'd wait for @miklos-da or @fabiotudone-da to verify. I am not too familiar with this part of the code.

cocreature pushed a commit that referenced this pull request Apr 19, 2021
The PR is based #9429.

CHANGELOG_BEGIN
CHANGELOG_END
cocreature and others added 2 commits April 19, 2021 11:14
Co-authored-by: fabiotudone-da <fabio.tudone@digitalasset.com>
changelog_begin
changelog_end
@mergify mergify bot merged commit 1cb907c into main Apr 19, 2021
@mergify mergify bot deleted the remy-kv-input branch April 19, 2021 11:11
cocreature pushed a commit that referenced this pull request Apr 19, 2021
The PR is based #9429.

CHANGELOG_BEGIN
CHANGELOG_END

.

changelog_begin
changelog_end

.

changelog_begin
changelog_end

.

changelog_begin
changelog_end
cocreature pushed a commit that referenced this pull request Apr 19, 2021
The PR is based #9429.

changelog_begin
changelog_end
cocreature pushed a commit that referenced this pull request Apr 19, 2021
The PR is based #9429.

changelog_begin
changelog_end
* that refer transient contracts or that appear under a rollback node.
*/
final def contractKeys(implicit
ev: HasTxNodes[Nid, Cid] <:< HasTxNodes[_, Value.ContractId]
Copy link
Contributor

Choose a reason for hiding this comment

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

What is an ev? Can you use meaningful parameter names, please?

Copy link

Choose a reason for hiding this comment

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

ev is pretty conventional in Scala-ese for "evidence".

I prefer the latter, but I think it's quite common (kind of like "i" for an iterator or "e" for an exception).

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the explanation, @SamirTalwar-DA.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The method Iterable#toMap is the standard example of method using such implicit (and syntax)

cocreature added a commit that referenced this pull request Apr 20, 2021
* KV: do not use "Effects" part of InputsAndEffects

The PR is based #9429.

changelog_begin
changelog_end

* Factor out helpers

changelog_begin
changelog_end

* Apply suggestions from code review

Co-authored-by: Miklos <57664299+miklos-da@users.noreply.github.com>

* review comments

changelog_begin
changelog_end

* fmt

changelog_begin
changelog_end

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
Co-authored-by: Miklos <57664299+miklos-da@users.noreply.github.com>
azure-pipelines bot pushed a commit that referenced this pull request Apr 21, 2021
This PR has been created by a script, which is not very smart
and does not have all the context. Please do double-check that
the version prefix is correct before merging.

@remyhaemmerle-da is in charge of this release.

Commit log:
```
cf2be78 Support rollback nodes in BlindingInfo (#9445)
adde90b KV: do not use "Effects" part of InputsAndEffects (#9433)
75fa86a Additional metrics for mutable contract state cache (#9444)
d8c34a4 Rename normalization-related params in the integrity checker config (#9455)
e335244 Hash submitters in the deduplication key [DPP-347] (#9417)
43ffa42 Test for duplicate contracts when querying on behalf of multiple parties (#9443)
7644844 Document daml ledger export script (#9446)
3193027 DPP-334 Manually partition the event table (#9394)
14661a8 Clearer variable name for subtype evidence (#9442)
40c85d8 Release v1.13.0-snapshot.20210419.6730.0.8c3a8c04 (#9439)
1cb907c KV: do not use "Inputs" part of InputsAndEffects (#9429)
```
Changelog:
```
- [Integration Kit] - deduplication key will contain hashed submitters instead of concatenated submitters
* [Daml export] Refer to the "Ledger Export" chapter under the "Early
  Access Features" for a description of the new Daml ledger export
  command. This is an early access feature.
```

CHANGELOG_BEGIN
CHANGELOG_END
Copy link
Collaborator Author

@remyhaemmerle-da remyhaemmerle-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

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.

4 participants