AppLayerLabs / bdk-cpp

MIT License
7 stars 12 forks source link

Implement SafeBytes and SnailTracer benchmark #129

Closed Jean-Lessa closed 3 months ago

Jean-Lessa commented 3 months ago

This PR adds a new C++ contract and benchmark based on the SnailTracer Solidity contract, as well as a new SafeVar type for the bytes Solidity type (SafeBytes), derived directly from SafeVector (basically using a fixed std::vector<uint8_t> type instead of templates) and required as a return by some of the functions on SnailTracer.

There are two different SnailTracer contracts: the "original" one, using (u)int256 integers as per the Solidity original code (int = int256), and an "optimized" version that uses (u)int136 instead ((u)int128 and below seem to not be enough for the original contract's math logic, over/underflows happen every time).

Due to practical reasons, there's also a new raw() function on SafeTuple which does the same as get() on other vars (return the raw type beneath the class, since SafeTuple already has a get() that has its own functionality). This was implemented mostly because of SnailTracer, but can be used anywhere just like the other vars' get() wrappers.

bdk-cpp-sonarqube-app[bot] commented 3 months ago

Quality Gate failed Quality Gate failed

Failed conditions
97 New issues
17.8% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube

Catch issues before they fail your Quality Gate with our IDE extension SonarLint SonarLint