How to figure out causal monotonicity inconsitency error in daml?

85 views Asked by At

I am continuously fetching the data and initiating new contracts and updating the templates if data is modified. I am getting the following error, which I am unable to figure out when it is occurring while updating or some other reasons.

Error: 3 INVALID_ARGUMENT: Inconsistent: Causal monotonicity violated
    at Object.callErrorFromStatus (/home/prachi/Documents/waste-water-management/trip_daml/contractService/node_modules/@grpc/grpc-js/build/src/call.js:31:26)
    at Object.onReceiveStatus (/home/prachi/Documents/waste-water-management/trip_daml/contractService/node_modules/@grpc/grpc-js/build/src/client.js:176:52)
    at Object.onReceiveStatus (/home/prachi/Documents/waste-water-management/trip_daml/contractService/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:342:141)
    at Object.onReceiveStatus (/home/prachi/Documents/waste-water-management/trip_daml/contractService/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:305:181)
    at /home/prachi/Documents/waste-water-management/trip_daml/contractService/node_modules/@grpc/grpc-js/build/src/call-stream.js:124:78
    at processTicksAndRejections (internal/process/task_queues.js:79:11) {
  code: 3,
  details: 'Inconsistent: Causal monotonicity violated',
  metadata: Metadata {
    internalRepr: Map { 'content-type' => [Array] },
    options: {}
  }
}
1

There are 1 answers

0
bame On BEST ANSWER

Causal Monotonicity ensures that Ledger Time follows causality. For example, it should not be possible that a fetch on a contract happens before its create in Ledger Time. The precise rule is explained here.

In earlier versions of DAML, the client application had to supply the Ledger Time via an API field called ledger_effective_time or some such. That time had to be set in such a way that the Ledger Time of the transaction was equal or later than the Ledger Time on any input contracts to that transaction. That's really quite difficult in practice because input contracts can be pulled in via ContractIds and Contract Keys.

For that reason, the model was changed in SDK 1.0 in such a way that a suitable Ledger Time is determined by the node to which the command is submitted. It's not only possible to give minimum bounds using the min_ledger_time_abs and min_ledger_time_rel parameters.

So, is you are on SDK < 1.0, you are running into a known difficulty with the old Ledger Time model. You'll either need to set ledger_effective_time very carefully, or upgrade to SDK >= 1.0.

If you are already on SDK >= 1.0, you have likely run into a bug, which you should report to the developers.