-
Notifications
You must be signed in to change notification settings - Fork 9
Development and testing guide
Before testing, make sure to get your system ready using the Running your QDAO node (dev release) guide.
Substrate Frontend Template - you can access QDAO node through the template frontend
Polkadot JS - Send signed extrinsics, test execution and auditor signup/challenges. List below.
pub fn tool_exec_req // Request audit tool execution
pub fn tool_exec_cancel_invalid // Cancel request - to be improved in Milestone 2
pub fn tool_exec_auto_report // Record the automated tool's output - to be improved in Milestone 2
pub fn challenge_report // Allows challenging an audit report - to be improved in Milestone 2
pub fn sign_up // Signs up as auditor
pub fn update_profile // Update the profile
pub fn cancel_account // Cancel account
pub fn approve_auditor // Approve auditor (otherwise they are not allowed to work)
pub fn game_result // Return ELO game's result
Generating keccak256 hash on linux for auditor pallet testing
$ cat exotestflipper.tar|keccak256
Convert URL from ASCII to HEX for auditor pallet testing
bindechexascii --a2h "https://qrucial.io/"
Online tool: https://www.asciitohex.com/
A new user can obtain an auditor status by:
- The user signs up by calling the
sign_up
extrinsic which involves locking a certain amount of tokens. Every user which is not already signed up can do this. - The
AuditorData
struct which is assigned to every user holds the auditor'sscore
, which is aOption<u32>
and set toNone
until the auditor is approved. - Every user which already has an auditor score which is larger then
MinimalApproverScore
, a configuralbe runtime constant, can approve new members. - As soon as an auditor received approvals from three different existing auditors, his or her
score
changes toSome(InitialAuditorScore)
, whereInitialAuditorScore
is a configurable runtime constant.
At the current point of development, the onboarding/signup workflow of new auditors is primarily tested through extensive unit tests which are defined in: ./qdao-node/audit-pallet/src/tests.rs
. These tests cover all aspects of the described onboarding process and prove that our implemented business logic for the extrinsics behaves as expected.
For on-chain testing after compiling and running qdao-node and communicating with it through Substrate Frontend template, we need to start with an existing pre-defined set of auditors which are already capable of approving new auditors. These initial auditors and their initial scores are now provided through the genesis config of qdao-node. The users Alice
, Bob
and Charlie
and Dave
are capable of approving the sign-up of new auditors. To test this on chain with the runnning qdao-node
, we suggest to call the extrinsics through the Substrate Frontend Template:
- Try to approve
Ferdie
byapprove_auditor
throughAlice
. Call should fail, sinceFerdie
did not sign up. -
Ferdie
callssign_up
extrinsic. Should work. - Try to approve
Ferdie
byapprove_auditor
throughAlice
. Call should be successful, sinceFerdie
has signed up now. Second call byAlice
should fail, since every applicant can't receive two approvals by the same user. - Approval by
Bob
andCharlie
should work. - Since now
Ferdie
obtained auditor status, further attempts to approveFerdie
should fail. EspeciallyDave
will not be able to approveFerdie
, sinceFerdie
already received three approvals.
After the full node is running, you can test the execution of tools by calling the tool_exec_req
function. You can use https://v-space.hu/s/exotestflipper.tar and https://v-space.hu/s/exotest.tar files for testing. Hashes are the following:
$ keccak256 < exotest.tar
0x3e2d46f07bb14bab9d623e426246ee8115f2669fa04745e51a00e18446e47df7
$ keccak256 < exotestflipper.tar
0xa03f6ba3eb8141f0f8daee4ea016d4144f44fc4cba9e7477a4c1f041aaeb6c38
- Exosysd monitors the execution of
tool_exec_req
extrinsic. When it is called successfully, the off-chain tool execution gets requested by exosysd. The url parameter is the file provided for audit and the hash it the keccak256 hash of it. If you send this extrinsic two times, the second should fail as the security audit's unique identifier is the audit file's keccak256 hash itself. - After successful call of
tool_exec_req
, Exosysd passes the url and the hash toexotool.sh
. -
exotool.sh
runsexec_audit
takes the output, executes the default toolcargo audit
(this tool will be replaced in M2). -
lar.py
sends a notification extrinsic to QDAO blockchain throughnotify_logger
call. This includes the hash and the result of the tool execution. With this the execution logic finishes.
The extrinsics tool_exec_cancel_invalid
will be used to cancel invalid executions, but this extrinsic might be removed as the blockchain itself doesn't have direct control over the execution (exosysd and exotool do). We will test it in M2 for the best possible solution.
The tool_exec_auto_report
extrinsic is used by lar.py
to report on the status of audits. At this moment this can be called manually as well from the frontend.
The challenge_report
provides option for the auditors to challenge each other. This is a feature to be improved in M2.
Overall, the execution flow is the following:
ExoSysD is monitoring continously and lar.py is running as the logger.
Flow:
Audit request success --> ExoSysD calls ExoTool for execution of automated audit
ExoTool handles the automated execution and reports the status to lar.py
lar.py logs the event and sends an extrinsic to the blockchain about the status.
by QDAO