We are currently working on integrating the Ledger Sync Service in our Cordapp: https://github.com/corda/corda-solutions/tree/master/bn-apps/ledger-sync
During our own tests, we experienced that in certain circumstances the ledger is not successfully synchronized/repaired after a crash.
Our test does the following:
- Node
A
andB
transact with each other, creating a StateS
. - Node
B
crashes and recovers to a state, where it does not knowS
. - Node
A
creates a new transaction, that consumes stateS
- Node
B
uses the ledger sync service to recover all states.
In the background, the following happens: When node A
creates the Tx that consumes the state S
, node B
will also receive the old Tx that created state S
as dependency. From that point, the Tx is recorded in the database of node B
and can be retrieved by calling serviceHub.validatedTransactions.getTransaction(txId)
.
However, querying the vault for CONSUMED
or ALL
states will not return the old state S
. Running the ledger sync will report that the node is out of sync, saying that the transaction that created state S
is missing.
Calling the repair will not successfully repair and consecutive runs of RequestLedgersSyncFlow
will keep reporting missing transactions.
I am not sure that this use case is actually supported (creating Txs while the ledger is out of sync) but I think if it is not a supported use case, it is hard to make sure that nodes are not transacting with each other when one of the nodes is out of sync.
I hope the issue is clear, otherwise I can also prepare and provide a test for it.
Update: Upon request, here I created a fork of the Corda Solutions repo and added a test that showcases the error: https://github.com/marioschlipf/corda-solutions/commit/fe1ab5917c971fcf9732bf8af7d0f2c1800b5e37
assertEquals(0, ledgerSyncResult2[node1.fromNetwork().identity()]!!.missingAtRequester.size)
. Because you ran recovery before? – mritz_p