Conversation
|
ok |
|
please use |
There was a problem hiding this comment.
Please make sure you keep the existing format of the files. The new lines introduce a lot of noise in the changes.
There was a problem hiding this comment.
Also please make sure you leave the #include order as is.
|
|
||
| #endif | ||
|
|
||
| // new contracts should be added above this line |
There was a problem hiding this comment.
Please keep these guards as is as they will be removed in the development branch when we update it.
src/contract_core/contract_def.h
Outdated
|
|
||
| #endif | ||
|
|
||
| #define QSURV_CONTRACT_INDEX 25 |
There was a problem hiding this comment.
You miss the #undef, see the other contracts above for the correct schema.
fnordspace
left a comment
There was a problem hiding this comment.
Overall a good start but there some major points that need to be addressed:
- Please do not change the formating of files
- Use the style described in https://github.com/qubic/core/blob/main/doc/contributing.md#style-guidelines for your Contract
- The PR description should clearly describe the SC functionality or link to the proposal with the description.
src/Qubic.vcxprojandsrc/Qubic.vcxproj.filters: Adding the SC header file to the Qubic project in the VS Solution.test/test.vcxprojandtest/test.vcxproj.filters: Adding the SC test file to the test project in the VS Solution.- Make sure the UEFI and test build run without Errors and use the develop branch as base branch
- Also make sure you check your contract with the Contract Verify tool https://github.com/qubic/core/blob/main/doc/contracts.md#review-and-tests, at the moment there are no problems in this regards.
src/contract_core/contract_def.h
Outdated
| #define CONTRACT_STATE2_TYPE QSURV2 | ||
| #include "contracts/QSurv.h" | ||
|
|
||
| #endif |
There was a problem hiding this comment.
This #endif has no coresponding #if probably a copy paste error from pulse. Leave the compile time switch away for the moment.
There was a problem hiding this comment.
Also please make sure you leave the #include order as is.
src/contracts/QSurv.h
Outdated
| } | ||
|
|
||
| // Verify invocation reward matches rewardPool | ||
| if (qpi.invocationReward() < input.rewardPool) { |
There was a problem hiding this comment.
If the user send more Qus than needed, everything is kept. Can be ok but worth thinking about refund the excess back to the user.
|
|
||
| PUBLIC_PROCEDURE(setOracle) { | ||
| // Only allow setting oracle if not already set, or by current oracle | ||
| if (state._oracleAddress == NULL_ID || |
There was a problem hiding this comment.
The first caller to this procedures can set the oracleAddress. Probably better to set the inital _oracleAddress in INITIALIZE so that no one can try to be faster and 'steal' the oracleAddress by setting it.
src/contracts/QSurv.h
Outdated
|
|
||
| // Calculate reward splits using QPI::div (no / operator allowed) | ||
| locals.totalReward = locals.tempSurvey.rewardPerRespondent; | ||
| locals.baseReward = |
There was a problem hiding this comment.
Would be nice to see a bit more detail how the payout is planned. At the moment the total amount only accounts for 90% (60% Base, 25% Referral, 5% Platform) but 100% are deducted from the survey balance.
Also it is not clear to me how the bonus system works, in its current form it might deplete the contracts Qus over time.
There was a problem hiding this comment.
Maybe worth to check if you want to have a way to cancel surveys if not enough people are answering. Also at the moment there will be a maximum of 1024 contracts ever before the contract is rendered useless completed surveys are never cleaned and the slot remains occupied.
Please also make sure your contract follows the style guide https://github.com/qubic/core/blob/main/doc/contributing.md#style-guidelines
There was a problem hiding this comment.
Great that you test, test could be more thorough tho. Some ideas on top of my mind:
- Verify the expected survey and contract balance after payout
- Survey competition works as expected e.g., isActive => 0
- createSurvey with maxRespondents = 0 or rewardPool = 0
- Set oracle from non oracle id (should fail)
- Payout when currentRespondents >= maxRespondents (should fail)
|
Hi @fnordspace, I have updated the PR to address the feedback. I've patched the potential vulnerabilities in setOracle, updated the exact payout logic to prevent deflation/division issues, thoroughly expanded the test suites in contract_qsurv.cpp, and adhered to the Allman formatting guidelines. I also resolved the recent merge conflicts |
|
@IanLaFlair Thanks for the update. I'll take a look later. However the last commit also includes your build directory and hence adds around 200 files. Please do not commit these. Also see my other comments about changing the format of, for example, contract_def.h. |
fnordspace
left a comment
There was a problem hiding this comment.
The PR is not in a state for a proper review. The code will not compile in it current version and style restrictions are not followed. Please first fix all the issues, make sure it compiles with MSVC (not cmake/clang) and that all tests runs.
I strongly suggest you test your SC functionality thoroughly as in the moment I don't think it is doing what you expect. To test your SC you can use the Qubic Core-Lite https://github.com/qubic/core-lite. This node you can run in single node mode and test your SC in a ticking network.
src/contract_core/contract_def.h
Outdated
| "Size of contract state " #contractName " is too large!"); \ | ||
| } | ||
|
|
||
| <<<<<<< HEAD static void initializeContracts() { |
There was a problem hiding this comment.
These are git conflict marker, should not be here
src/contract_core/contract_def.h
Outdated
| #endif | ||
| REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(QSURV); | ||
| // new contracts should be added above this line | ||
| == == == = |
src/contract_core/contract_def.h
Outdated
| REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(QTF); | ||
| REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(QDUEL); | ||
| // new contracts should be added above this line | ||
| >>>>>>> upstream/develop |
src/contracts/QSurv.h
Outdated
| // ============================================ | ||
| public: | ||
| INITIALIZE() { | ||
| state._oracleAddress = qpi.invocator(); |
There was a problem hiding this comment.
INITIALIZE() has no invocator hence it probably will set the oracleAddress to null leaving the same problem open.
af183a3 to
60fa7c4
Compare
|
@IanLaFlair Do not force-push after we've started reviewing/writing comments. The force-push destroys the association of the comments with the code and we're unable to see the changes you introduce with new commits. |
…ract_def.h formatting
…and contract_def.h registration
|
@Franziska-Mueller Hi Franziska, thanks for the guidance! |
…ain pristine CRLF line endings
Description
This PR introduces QSurv (Qubic Survey), a decentralized and verifiable survey smart contract integrated into the Qubic Core.
QSurv enables entities to create and fund surveys directly on the Qubic network. Respondents are then rewarded autonomously upon successful survey completion. Central to the contract is its Oracle integration, ensuring that off-chain survey data or respondent verification is securely bridged on-chain.
Key Features
rewardPool, defining a maxtargetRespondents, and providing an IPFS hash containing the survey metadata/questions.MAX_SURVEYSlimits in mind, the contract actively reuses inactive slots to prevent indefinite storage creep.Updates (Addressing PR Feedback)
_surveysbalance._oracleAddressduring the contract's INITIALIZE() routine.