hyperledger-labs / convector

Smart Contract Systems the easy way. Open source development framework.
Other
146 stars 45 forks source link

fix: preserve context with cls-hooked #142

Open diestrin opened 3 years ago

diestrin commented 3 years ago

Proposed changes

Use a context data library, cls-hooked to fix a context issue reported in #105.

Previously, convector had problems with concurrent transaction, because it was setting a global variable BaseStorage.current on each chaincode @Invoke. This variable contains a reference to the Fabric STUB object, where operations (reads and writes to the ledger) get written for each transaction. So when a second @Invoke is received, the STUB gets overwritten, and all the operations of the first transaction still pending to run (because asynchronicity) end up being registered in the incorrect STUB. This causes all sorts of wrong behaviors, like trying to write in a transaction STUB that has already finished, or simply putting the reads and writes in different blocks, which is not accurate at all.

Types of changes

Checklist