The testing guide is provided for Milestone-2 PoCS W3F Grant Delivery
pallet-staking has been integrated into pallet-contracts to enable Proof of Contract Stake (PoCS) functionality with Parity's Nominated Proof of Stake (NPoS). By following these steps, developers/reviewers can verify the correctness and reliability of the implemented features.
-
Developers deploy smart contracts with
stake_score
i.e., bond value. -
stake_score
derived from contract execution time (refTime) and reputation. -
Developers nominate a validator using
update_delegate()
extrinsic. -
Bonded contracts need minimum reputation to nominate.
-
min_reputation
is set at 10 for development, adjustable. -
stake_score
purges to 0 when contract's delegated validator changes. -
Validators need minimum delegates (nominators i.e., bonded contracts) to start validating.
-
min_delegates
set at 3 for development, adjustable. -
Extended details available in PoCS-Research Document.
- Building a local node is suitable to verify PoCS's unit & benchmarking tests locally, and further compile to run a Substrate-PoCSxNPoS node.
-
Clone the repository from GitHub
git clone https://github.com/auguth/pocs
-
Run the Rust Setup Script (Mandatory)
chmod +x setup.sh && ./setup.sh
-
Run Tests
cargo test
-
Run Specific Unit Tests (Optional)
pallets used :
pallet-contracts
,pallet_staking
cargo test -p [pallet-name]
-
Run Specific Benchmarking Tests (Optional)
cargo test -p [pallet-name] --features=runtime-benchmarks
-
Build the project in release mode
cargo build --release
-
Run the executable with the specified configuration:
./target/release/pocs --dev
- Using Docker, build and run a node shortly without requiring node specific dependencies, but unit & benchmarking tests cannot be verified manually.
- Regardless of the choice of any method, front-end tests can be conducted
Docker Compose
-
Build & Run using Docker Compose:
docker compose up --build -d
-
To Stop container
docker compose down
-
To Restart the container
docker compose up
Works in all hosts (Linux/Mac/Windows).
This is an optional extended test to check correctness of PoCS via
pallet_contracts
extrinsics on front-end, without attempting staking feature viapallet_staking
- Use Polkadot-JS and Contracts UI and configure it to Local/Development Node
- Use sample ink! contracts from auguth/ink-contracts-for-testing
- The examples below used flipper contract.
- For more advanced testing & scrutiny, use flipper and caller contracts to test automated
stake_score
update across delegate-calls between contracts.
After running the executable, the following tests using front-end can be done to verify the correctness mentioned in How PoCS Work Section.
- Use Polkadot-JS and Contracts UI and configure it to Local/Development Node
- Use sample ink! contracts from auguth/ink-contracts-for-testing
- The examples below used flipper contract.
- For more advanced testing & scrutiny, use flipper and caller contracts to test automated
stake_score
update across delegate-calls between contracts.
-
Deploying Contracts
- Upload a contract e.g., flipper contract using Contracts UI
- This uses function instantiate_with_code()
- instantiate_with_code() calls the bond() function in pallet-staking to bond the contract deployer address with default
stake_score
. - After deployment, should expect events - AccountStakeinfoevent & ContractStakeinfoevent with its default values
-
Executing Contracts
- When executing contract bond_extra() function is additionally called to increment the new
stake_score
- This emits ContractStakeinfoevent
- In validator list of bonds, the
stake_score
will be reflected
- When executing contract bond_extra() function is additionally called to increment the new
-
Nominating a Validator after minimum reputation achieved
- Construct an extrinsic via
contracts
pallet with update_delegate() function - update_delegate() calls nominate() and new_unbond() in pallet-staking to purge the
stake_score
(existing bond value) and ensures if the contract has required minimum reputation to nominate - In AccountStakeinfo,
delegateTo
anddelegateAt
will be updated and in ContractScarcityinfo, thestake_score
will be updated to 0 reflected in the validator list of bonds to zero.
- Construct an extrinsic via