Support divulged contracts in a distributed ledger
See original GitHub issueDivulged 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:
- Split the current
contracts
table intocontracts_data
andcontracts
.contracts_data
only holds the relation(ContractId, ContractInstance)
contracts
only holds the metadata (i.e. what it currently holds minus the contract instance data)
- The type of
TransactionAccepted#referenceContracts
is changed toList[(AbsoluteContractId, VersionValue[AbsoluteContractInst)]
PersistenceEntry.Transaction
is extended with the list of referenced contracts fromTransactionAccepted
.- The class
c.d.p.s.s.l.s.d.Contract
needs to change the fieldslet
,transactionId
to be of typeOption
. - Stop using
ActiveContract
internally inActiveContractsManager
, but only useContract
. - Rename
LedgerDao#lookupActiveContract
toLedgerDao#lookupPotentiallyActiveContract
. - 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.
- When adding contracts coming from a
TransactionAccepted
state update, a “divulged” contract can be upgraded to a disclosed contract by:- checking that the existing
ContractInst
value incontracts_data
is exactly the same as the to be inserted value from the transaction - additional metadata to the already known entry in
contracts_data
is written to thecontracts
table.
- checking that the existing
- 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
, whereTx(N)
isTransaction at offset N
.
Issue Analytics
- State:
- Created 4 years ago
- Comments:20 (19 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks @gerolf-da .
Potential typo in Point 2: should be
List[NodeCreate[AbsoluteContractId, VersionValue[AbsoluteContractInst]]]
On point to think about:
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