question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support divulged contracts in a distributed ledger

See original GitHub issue

Divulged contracts in a distributed ledger (i.e. multi-participant topology) are currently not supported. This is witnessed by a foreign key constraint error in the Ledger API Server, when it tries to insert entries into the contract_divulgences table. After a discussion with @oliverse-da and @meiersi-da, we propose the following steps to support divulged contracts:

  1. Split the current contracts table into contracts_data and contracts.
    1. contracts_data only holds the relation (ContractId, ContractInstance)
    2. contracts only holds the metadata (i.e. what it currently holds minus the contract instance data)
  2. The type of TransactionAccepted#referenceContracts is changed to List[(AbsoluteContractId, VersionValue[AbsoluteContractInst)]
  3. PersistenceEntry.Transaction is extended with the list of referenced contracts from TransactionAccepted.
  4. The class c.d.p.s.s.l.s.d.Contract needs to change the fields let, transactionId to be of type Option.
  5. Stop using ActiveContract internally in ActiveContractsManager, but only use Contract.
  6. Rename LedgerDao#lookupActiveContract to LedgerDao#lookupPotentiallyActiveContract.
  7. Only perform the LET contract check if the LET is actually available. For divulged contracts, we can only assume that it is active, as we don’t have any further information.
  8. When adding contracts coming from a TransactionAccepted state update, a “divulged” contract can be upgraded to a disclosed contract by:
    1. checking that the existing ContractInst value in contracts_data is exactly the same as the to be inserted value from the transaction
    2. additional metadata to the already known entry in contracts_data is written to the contracts table.
  9. A new migration script for postgres must be added to split the contracts table into two tables.

Points to think about:

  • If a contract is disclosed AFTER it has been divulged (i.e. more metadata like LET and ledger offset is now available), does this have an effect on consistency assumptions? For example, it is possible that Tx(N).LET < Tx(N-1).LET, where Tx(N) is Transaction at offset N.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:20 (19 by maintainers)

github_iconTop GitHub Comments

1reaction
meiersi-dacommented, Aug 12, 2019

Thanks @gerolf-da .

Potential typo in Point 2: should be List[NodeCreate[AbsoluteContractId, VersionValue[AbsoluteContractInst]]]

On point to think about:

  • this is a ledger consistency violation that can have been detected by the signatories of the divulged contract. We expect ledger implementations to avoid such consistency violations as part of the process of committing a transaction.
0reactions
oliverse-dacommented, Nov 5, 2019

Fwiw, at the time we implemented multi-domain divulgence, we could not identify a scenario for item 8 (for a previously divulged contract to become fully known to a participant). Multi-domain scenarios will at some point have such a scenario as contracts are transferred in an out of domains, but we will follow up on that separately (#3334) once multi-domain requirements are sufficiently understood and formalized. (Just thought I’d point this out here as fyi.)

cc @andreaslochbihler-da

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Distributed Ledger: Blockchain, Digital Assets and Smart ...
In this issue of The Distributed Ledger, we describe these ... sanctions on the decentralized cryptocurrency mixing service Tornado Cash and ...
Read more >
Chapter 1, Fundamental Concepts of Blockchain - O'Reilly
This chapter will help you understand the following: The architecture and core design components of blockchain. How ledger databases and world state ...
Read more >
Part 2 - Smart contracts, blockchain and distributed ledger ...
The evolving smart contracts, blockchain and distributed ledger technologies bring a number of potential risks (including governance, deployment ...
Read more >
Upgrading blockchains: Smart contract use cases in industry
Blockchains provide a single ledger as the source of truth, and smart contracts offer the ability to automate approval workflows and clearing ...
Read more >
Distributed Ledger Technologies in IoT - GSMA
Smart contracts. Considerations in the application of distributed ledgers for the IoT ... 5.2.1 Supporting compliance (smart contracts). 5.2.2 Micropayments.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found