We have entered a 6 week beta period during which we will build more C++ smart contracts and put things to the test. Target production release is July 17.
We just released version 2.4.0, which supports update calls in addition to the already supported query calls.
During the beta period, we’re also experimenting with some ideas to use the IC’s unique capabilities for a Freemium style software licensing. It is not there yet though, so please just DM me, and I will ship you a .whl for icpp-pro that you can install and get access to all the good stuff that will make you super productive.
If you do not want to code anything up yourself, but have ideas or suggestions for a demo C++ Smart Contract, please comment in this thread, or just open an issue.
After a lot of trial & error, we figured out how to get orthogonal persistence to work for all std containers, like vector, list, deque, map, etc.
Still a lot testing to do, but this is a big enabler for the C++ Smart Contracts we’re building.
You can check out an example here, where we control multiple counters using a CandidTypeVecNat64, which maps onto std::vector<uint64_t>.
The hard part in all of this was to figure out what Orthogonal Persistence actually persists, and we found that only data that is globally managed works. So, we provide a set of functions to store & retrieve data from global storage for all the container types. The helper functions are also provided for std::string, in case you want to persist text between calls.
FYI: Initially we thought that it was sufficient to simply store the container objects on the heap, and point to them from a global pointer, and all would be honky dory for orthogonal persistence to do it’s thing. It turned out that this does not work. The update calls always work, but then during the next call, doesn’t matter if it is a query call or another update call, we get the error “IC0502: Canister trapped: unknown”. I understand that this is a runtime error on the IC and usually indicates a problem with memory allocation, out-of-bounds access, or null pointer dereference. Perhaps, we’re guessing here, since the container object on the heap is managing it’s own internal dynamic memory, it is de-allocating it’s internal data storage after the call is done, and then during the next call, we get an error that the canister is no longer good if we’re trying to access memory that is no longer there.
Hey! Is icpp open source? I’m looking for the repo. I’d like to open an issue/start a discussion around conventions for some cdk Wasm metadata so that we can track cdk stats live on the IC.
@lastmjs ,
I had a look a the different ways this could be done, and I believe the only option in my case is to implement it as a post build step, by modifying the wasm file.
There is capability for custom sections at the LLVM level, but not at the C++ frontend level.
So, I want to use a pure python module to do the injection of the custom sections and am currently looking for the best options.
I assume you plan to use a similar approach for Kybra?
If so, have you settled yet on the python package to use for the wasm file manipulation?
The metadata section makes adding this functionality relatively trivial. dfx extensions will allow you to create an extension for your cdk and produce the dfx.json automatically. We’re probably a few weeks out from a beta that would allow us to test out dfx extensions.