Skip to content

Add QubicSolanaBridge smart contract (QSB, index 27)#10

Open
SoufianeBenbah wants to merge 6 commits intoqubic:mainfrom
avicenne-studio:main
Open

Add QubicSolanaBridge smart contract (QSB, index 27)#10
SoufianeBenbah wants to merge 6 commits intoqubic:mainfrom
avicenne-studio:main

Conversation

@SoufianeBenbah
Copy link
Copy Markdown

@SoufianeBenbah SoufianeBenbah commented Mar 26, 2026

Add QubicSolanaBridge smart contract (QSB, index 27)

Copy link
Copy Markdown
Contributor

@fnordspace fnordspace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.


// 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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All kind of preprocessor directives are prohibited (character #), such as includes, pragmas, conditional compilation etc.

struct QSBOrderMessage
{
uint32 protocolNameLen; // 0: always 11
uint8 protocolName[11]; // 4: "QubicBridge"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

{
setMemory(msg, 0);
msg.protocolNameLen = 11;
msg.protocolName[0]='Q'; msg.protocolName[1]='u'; msg.protocolName[2]='b';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"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);

YazhuEth and others added 4 commits April 9, 2026 11:23
- 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
Copy link
Copy Markdown
Contributor

@fnordspace fnordspace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like some unwanted fragments are present.

<Filter>contracts</Filter>
 </ClInclude>

return;
}

state.mut().admin = input.newAdmin;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe block setting admin to NULL_ID to avoid mistake. (opt)

}

// Only non-zero values are updated
if (input.bpsFee != 0)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also mean fee can never be disabled. (opt)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants