mit-dci / opencbdc-tx

A transaction processor for a hypothetical, general-purpose, central bank digital currency
Other
898 stars 198 forks source link

Parsec atomic commit fix #246

Closed maurermi closed 8 months ago

maurermi commented 8 months ago

Fixes a bug which occurs when a smart contract does not request locks on all update keys, resulting in undesirable behavior.

Aborts a transaction where the agent does not have tickets associated with all update keys. In the case that a contract does not prompt for all update keys to be locked, enforces that the transaction aborts (+ rolls back) and no updates are written, rather than those which are locked. Does not abort if the smart contract correctly requested locks and is still waiting on them, but still rolls back and retries.

maurermi commented 8 months ago

Thanks to @ayeshaali and @madars for identifying this

maurermi commented 8 months ago

This PR also contains a new util called get_row which is also included in #241 to enable the integration tests included with this PR. If this is not wanted, we can keep only the commit which fixes this behavior.

HalosGhost commented 8 months ago

utACK, clear and simple fix (core fix in 1e51249) to throw a reasonable error in the agent if a change-set includes modifications to keys which don't have tickets.

I also want to call out how easy it is to review this PR because of the pleasant separation of the commits. CI passed, and the output for the added integration tests looks good:

Running integration tests...
Running main() from /build/googletest-j5yxiC/googletest-1.10.0/googletest/src/gtest_main.cc
[==========] Running 23 tests from 11 test suites.
[----------] Global test environment set-up.
[----------] 2 tests from parsec_smart_contract_updates_test
[ RUN      ] parsec_smart_contract_updates_test.valid_updates
[       OK ] parsec_smart_contract_updates_test.valid_updates (1038 ms)
[ RUN      ] parsec_smart_contract_updates_test.invalid_updates
Error: 1-13 16:47:58.584] [ERROR] Update map contains keys not associated with tickets. Aborting.
Error: 1-13 16:47:58.585] [ERROR] Broker error for commit for 14
[2024-01-13 16:47:58.585] [WARN ] Exec failed
[       OK ] parsec_smart_contract_updates_test.invalid_updates (1036 ms)
[----------] 2 tests from parsec_smart_contract_updates_test (2074 ms total)