Add QubicSolanaBridge smart contract (QSB, index 27)#10
Add QubicSolanaBridge smart contract (QSB, index 27)#10SoufianeBenbah wants to merge 6 commits intoqubic:mainfrom
Conversation
Add QubicSolanaBridge smart contract (QSB, index 27)
There was a problem hiding this comment.
Currently the SC does violate some of the restrictions of the Qubic SC System.
See https://github.com/qubic/core/blob/main/doc/contracts.md for all restrictions.
Also you can use https://github.com/Franziska-Mueller/qubic-contract-verify to verify your contract.
src/contracts/QubicSolanaBridge.h
Outdated
|
|
||
| // Serialized order message: domain prefix (52 bytes) + order fields (188 bytes) = 240 bytes. | ||
| // Layout matches the oracle's serializeBridgeOrder format exactly. | ||
| #pragma pack(push, 1) |
There was a problem hiding this comment.
All kind of preprocessor directives are prohibited (character #), such as includes, pragmas, conditional compilation etc.
src/contracts/QubicSolanaBridge.h
Outdated
| struct QSBOrderMessage | ||
| { | ||
| uint32 protocolNameLen; // 0: always 11 | ||
| uint8 protocolName[11]; // 4: "QubicBridge" |
There was a problem hiding this comment.
Low-level C arrays are not allowed in SC. Please use the qpi arrays, e.g., Array<uint8, 16>. N must be a power of 2 hence 16 and not 11.
src/contracts/QubicSolanaBridge.h
Outdated
| { | ||
| setMemory(msg, 0); | ||
| msg.protocolNameLen = 11; | ||
| msg.protocolName[0]='Q'; msg.protocolName[1]='u'; msg.protocolName[2]='b'; |
There was a problem hiding this comment.
"Strings " and chars ' are forbidden, because they can be used to jump to random memory fragments.
Also similar to above [x] indexing is not allowed. Probably should be something like msg.set(0,81);
- Replace #pragma pack and C-style arrays with QPI Array<uint8, N> - Replace char/string literals with ASCII codes - Replace [i] indexing with .set(i) / .get(i) - Change static const to static constexpr - Mark order filled before transfers to prevent replay on partial failure - Reorder transfers: recipient first, then relayer and fees - QSBOrderMessage layout changes from 240 to 245 bytes (protocolName padded to 16) - Contract verifier: PASSED
fix: resolve qubic sc compliance violations in QSBOrderMessage
fnordspace
left a comment
There was a problem hiding this comment.
Thanks for the update. Formal requirements seem to be all fulfilled. One small hick-up in the filter file left.
Additionally I pointed out two little things, marked with (opt), which just jumped to my eyes. These are by no mean necessary to change nor did I check if it would align with the specs!
Sidenote:
Before creating your official merge PR into the core, which probably happens at a later stage, please make sure the code also compiles in the core repo and that the tests are running in the core repo. PR target should will be the develop branch.
| <Filter>contracts</Filter> | ||
| </ClInclude> | ||
|
|
||
| <Filter>contracts</Filter> |
There was a problem hiding this comment.
Looks like some unwanted fragments are present.
<Filter>contracts</Filter>
</ClInclude>
| return; | ||
| } | ||
|
|
||
| state.mut().admin = input.newAdmin; |
There was a problem hiding this comment.
Maybe block setting admin to NULL_ID to avoid mistake. (opt)
| } | ||
|
|
||
| // Only non-zero values are updated | ||
| if (input.bpsFee != 0) |
There was a problem hiding this comment.
Also mean fee can never be disabled. (opt)
Add QubicSolanaBridge smart contract (QSB, index 27)