-
Notifications
You must be signed in to change notification settings - Fork 5
feat: implement BLE swarm registry system #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
540f23a
80c463e
4099ddf
a194c9e
2c662a7
6947340
37f0d09
d92fef1
e3e2343
2594567
4227ba7
0fca64c
a2d3950
359003f
5e59643
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # Solidity & ZkSync Development Standards | ||
|
|
||
| ## Toolchain & Environment | ||
| - **Primary Tool**: `forge` (ZkSync fork). Use for compilation, testing, and generic scripting. | ||
| - **Secondary Tool**: `hardhat`. Use only when `forge` encounters compatibility issues (e.g., complex deployments, specific plugin needs). | ||
| - **Network Target**: ZkSync Era (Layer 2). | ||
| - **Solidity Version**: `^0.8.20` (or `0.8.24` if strictly supported by the zk-compiler). | ||
|
|
||
| ## Modern Solidity Best Practices | ||
| - **Safety First**: | ||
| - **Checks-Effects-Interactions (CEI)** pattern must be strictly followed. | ||
| - When a contract requires an owner (e.g., admin-configurable parameters), prefer `Ownable2Step` over `Ownable`. Do **not** add ownership to contracts that don't need it — many contracts are fully permissionless by design. | ||
| - Prefer `ReentrancyGuard` for external calls where appropriate. | ||
| - **Gas & Efficiency**: | ||
| - Use **Custom Errors** (`error MyError();`) instead of `require` strings. | ||
| - Use `mapping` over arrays for membership checks where possible. | ||
| - Minimize on-chain storage; use events for off-chain indexing. | ||
|
|
||
| ## Testing Standards | ||
| - **Framework**: Foundry (Forge). | ||
| - **Methodology**: | ||
| - **Unit Tests**: Comprehensive coverage for all functions. | ||
| - **Fuzz Testing**: Required for arithmetic and purely functional logic. | ||
| - **Invariant Testing**: Define invariants for stateful system properties. | ||
| - **Naming Convention**: | ||
| - `test_Description` | ||
| - `testFuzz_Description` | ||
| - `test_RevertIf_Condition` | ||
|
|
||
| ## ZkSync Specifics | ||
| - **System Contracts**: Be aware of ZkSync system contracts (e.g., `ContractDeployer`, `L2EthToken`) when interacting with low-level features. | ||
| - **Gas Model**: Account for ZkSync's different gas metering if performing low-level optimization. | ||
| - **Compiler Differences**: Be mindful of differences between `solc` and `zksolc` (e.g., `create2` address derivation). |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # Solidity & ZkSync Development Standards | ||
|
|
||
| ## Toolchain & Environment | ||
|
|
||
| - **Primary Tool**: `forge` (ZkSync fork). Use for compilation, testing, and generic scripting. | ||
| - **Secondary Tool**: `hardhat`. Use only when `forge` encounters compatibility issues (e.g., complex deployments, specific plugin needs). | ||
| - **Network Target**: ZkSync Era (Layer 2). | ||
| - **Solidity Version**: `^0.8.20` (or `0.8.24` if strictly supported by the zk-compiler). | ||
|
|
||
| ## Modern Solidity Best Practices | ||
|
|
||
| - **Safety First**: | ||
| - **Checks-Effects-Interactions (CEI)** pattern must be strictly followed. | ||
| - Use `Ownable2Step` over `Ownable` for privileged access. | ||
| - Prefer `ReentrancyGuard` for external calls where appropriate. | ||
| - **Gas & Efficiency**: | ||
| - Use **Custom Errors** (`error MyError();`) instead of `require` strings. | ||
| - Use `mapping` over arrays for membership checks where possible. | ||
| - Minimize on-chain storage; use events for off-chain indexing. | ||
|
|
||
| ## Testing Standards | ||
|
|
||
| - **Framework**: Foundry (Forge). | ||
| - **Methodology**: | ||
| - **Unit Tests**: Comprehensive coverage for all functions. | ||
| - **Fuzz Testing**: Required for arithmetic and purely functional logic. | ||
| - **Invariant Testing**: Define invariants for stateful system properties. | ||
| - **Naming Convention**: | ||
| - `test_Description` | ||
| - `testFuzz_Description` | ||
| - `test_RevertIf_Condition` | ||
|
|
||
| ## ZkSync Specifics | ||
|
|
||
| - **System Contracts**: Be aware of ZkSync system contracts (e.g., `ContractDeployer`, `L2EthToken`) when interacting with low-level features. | ||
| - **Gas Model**: Account for ZkSync's different gas metering if performing low-level optimization. | ||
| - **Compiler Differences**: Be mindful of differences between `solc` and `zksolc` (e.g., `create2` address derivation). | ||
|
|
||
| ## L1-Only Contracts (No --zksync flag) | ||
|
|
||
| The following contracts use opcodes/patterns incompatible with ZkSync Era and must be built/tested **without** the `--zksync` flag: | ||
|
|
||
| - **SwarmRegistryL1**: Uses `SSTORE2` (relies on `EXTCODECOPY` which is unsupported on ZkSync). | ||
|
|
||
| For these contracts, use: | ||
|
|
||
| ```bash | ||
| forge build --match-path src/swarms/SwarmRegistryL1.sol | ||
| forge test --match-path test/SwarmRegistryL1.t.sol | ||
| ``` |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -13,5 +13,8 @@ | |||||||
| "editor.formatOnSave": true, | ||||||||
| "[solidity]": { | ||||||||
| "editor.defaultFormatter": "JuanBlanco.solidity" | ||||||||
| }, | ||||||||
| "chat.tools.terminal.autoApprove": { | ||||||||
| "forge": true | ||||||||
|
Comment on lines
+16
to
+18
|
||||||||
| }, | |
| "chat.tools.terminal.autoApprove": { | |
| "forge": true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The coverage-threshold condition is inverted: as written, it will fail when coverage is >= threshold and pass when coverage is below threshold. Flip the awk predicate/exit code so the job exits non-zero only when
COVERAGE < THRESHOLD(or compareCOVERAGE >= THRESHOLDfor the passing case).