Roman Zajic f5fff5cdc2
chore: fuzz test expansion (#40)
* test: register invalid

* test: multiple registers

* fix: increase max rejects

* test: erasure with fullErase idCommitments

* fix: reduce cyclomatic complexity

* fix: reduce complexity one step less

* fix: run tests in parallel

* fix: undo run tests in parallel - default already

* test: invalid extension with extreme values

* fix: line length

* test: set MaxTotalRateLimit

* test: set ActiveDuration

* test: Merkle inserts

* test: Merkle erasures

* test: GetRateCommitmentsRange

* test: GetMerkleProof

* fix: optimized MerkleInsert MerkleErasures

* fix: update gas snapshot

* test: malicious upgrade drains funds

* fix: formatting

* test: show success when unauthorized upgrade after malicious

* test: offchain proof post lazy erase
- multi-user erase reuse race

* fix: line length

* fix: remove offchain lazy erase test - rate limit still applies

* fix: remove fuzz tests from CI run

* fix: formatting

* fix: formatting coverage

* test: timestamp manipulation

* fix: rename tests

* test: front running for registration

* fix: unused variables

* test: register during spam conditions

* fix: delete failing tests
- test_MaliciousUpgradeDrainsFunds
- testFrontrunning_RegistrationRevertsForVictim
- testFrontrunning_SetFillingSpam

* fix: delete MaliciousImplementation

* fix: formatting with a new Foundry version

* test: testEraseAndReuse with Echidna

* fix: remove limit check

* fix: remove test_MultiUserEraseReuseRace
- test_TimestampManipulationRaces

* fix: skip Echidna contract during forge test

* test: Echidna contract with invariants
- registerMembership
- attemptExtensionRace
- attemptErasureRace

* fix: tune config file

* fix: run and cleanup scripts for echidna

* test: Echidna test replay

* fix: Solidity version

* fix: test_attemptExtensionRace_WakuRLN

* fix: invalid commitment in test_attemptExtensionRace_WakuRLN

* fix: invalid commitments in
test_attemptErasureRace_WakuRLN

* fix: line length

* fix: skip all Echidna tests in CI

* test: register invalid

* test: multiple registers

* fix: increase max rejects

* test: erasure with fullErase idCommitments

* fix: reduce cyclomatic complexity

* fix: reduce complexity one step less

* test: invalid extension with extreme values

* fix: line length

* test: set MaxTotalRateLimit

* test: set ActiveDuration

* test: Merkle inserts

* test: Merkle erasures

* test: GetRateCommitmentsRange

* test: GetMerkleProof

* fix: optimized MerkleInsert MerkleErasures

* fix: update gas snapshot

* fix: formatting

* fix: remove tests with high overlap

* fix: remove all tests originally meant for fuzzing

* fix: rename merged Echidna tests

* fix: formatting

* test: fuzzing for essential invariants

* test: EchidnaTest contract

* fix: remove unnecessary imports

* fix: remove unnecessary helpers

* fix: remove bounds from invariants

* fix: change test mode to property

* fix: update run script

* fix: max_test_rejects back to the original value

* fix: remove unused local variables
2025-11-07 09:20:49 +08:00
2025-11-07 09:20:49 +08:00
2024-11-01 10:23:28 -04:00
2025-11-07 09:20:49 +08:00
2024-05-21 00:46:20 +00:00
2024-05-30 19:21:55 +05:30
2024-05-22 00:04:00 +05:30
2025-11-07 09:20:49 +08:00
2024-05-21 00:46:20 +00:00
2024-05-21 00:46:20 +00:00
2024-11-01 10:23:28 -04:00
2024-05-21 00:46:20 +00:00
2024-05-21 00:46:20 +00:00
2024-05-21 00:46:20 +00:00
2024-05-21 00:46:20 +00:00
2024-05-21 00:46:20 +00:00
2024-05-30 19:21:55 +05:30
2024-11-01 10:23:28 -04:00
2024-05-21 00:46:20 +00:00
2024-11-01 10:23:28 -04:00
2024-10-23 12:22:32 -04:00
2024-05-21 00:46:20 +00:00
2024-11-01 10:23:28 -04:00
2024-05-21 00:46:20 +00:00

waku-rlnv2-contract Github Actions Foundry License: MIT

Waku's RLNv2 contracts, which include -

  • LazyIMT, which allows the root of the chain to be accessible on-chain.

What's Inside

  • Forge: compile, test, fuzz, format, and deploy smart contracts
  • Forge Std: collection of helpful contracts and cheatcodes for testing
  • Solhint Community: linter for Solidity code

Prerequisites

Usage

Install dependencies before first run:

pnpm install

This is a list of the most frequently needed commands.

Build

Build the contracts:

$ forge build

Clean

Delete the build artifacts and cache directories:

$ forge clean

Compile

Compile the contracts:

$ forge build

Coverage

Get a test coverage report:

$ forge coverage

Deploy

Deploy to Anvil:

$ TOKEN_ADDRESS=0x1122334455667788990011223344556677889900 forge script script/Deploy.s.sol --broadcast --rpc-url localhost --tc Deploy

Replace the TOKEN_ADDRESS value by a token address you have deployed on anvil. A TestToken is available in test/TestToken.sol and can be deployed with

forge script test/TestToken.sol --broadcast --rpc-url localhost --tc TestTokenFactory

For this script to work, you need to have a MNEMONIC environment variable set to a valid BIP39 mnemonic.

Deploy to Sepolia:

Ensure that you use the cast wallet to store private keys that will be used in deployments.

$ export RPC_URL=<rpc-url>
$ export ACCOUNT=<account name in foundry keystore>
$ pnpm deploy:sepolia

Format

Format the contracts:

$ forge fmt

Gas Usage

Get a gas report:

$ forge test --gas-report

Lint

Lint the contracts:

$ pnpm lint

Fixing linting issues

For any errors in solidity files, run forge fmt. For errors in any other file type, run pnpm prettier:write.

Test

Run the tests:

$ forge test

Notes

  1. Foundry uses git submodules to manage dependencies. For detailed instructions on working with dependencies, please refer to the guide in the book
  2. You don't have to create a .env file, but filling in the environment variables may be useful when debugging and testing against a fork.

Owner privileges

The contract implementation aims to follow the specification that also describes ownership (see Governance and upgradability section).

As of commit afb858, the Owner privileges are assigned to the msg.sender of the membership registration transaction. The Owner has the following privileges:

  • set the token and price of one message published per epoch (link);
  • authorize upgrades to a new implementation contract (link);
  • set the price calculator contract address (link);
  • set the maximum total rate limit of all memberships in the membership set (link);
  • set the minimum (link) and maximum (link) rate limit of one membership;
  • set the duration of the active period (link) and grace period (link) of new memberships (see the state transition diagram of a membership).

The pause functionality for contract functions is not yet implemented.

License

This project is licensed under MIT.

Description
rln-v2 Contracts for Waku
Readme
Languages
Shell 100%