Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
538047d
feat: implement BLE swarm registry system with dual-chain support
aliXsed Feb 6, 2026
06e5a5f
chore: simplify architecture diagram
aliXsed Feb 10, 2026
6d95f61
feat(swarms): require bond on fleet id mints
aliXsed Feb 10, 2026
2b0d4de
feat(swarms): add regional registery feature
aliXsed Feb 12, 2026
f07c7d7
feat(swarms): different shard size for different geo level
aliXsed Feb 12, 2026
9e52897
Consolidate shard reassignment API
aliXsed Feb 12, 2026
55fc8ab
Refactor FleetIdentity to tiers
aliXsed Feb 12, 2026
f16f2c6
Fix FleetIdentity constants: MAX_TIERS=24, BOND_MULTIPLIER=2 (constant)
aliXsed Feb 13, 2026
1ba8514
Rename scanner APIs to EdgeBeaconScanner and highest-bonded terminology
aliXsed Feb 13, 2026
ba6ac56
Implement all-or-nothing tier collection in buildHighestBondedUUIDBundle
aliXsed Feb 16, 2026
f0a658f
Rename variable sc → tierCount for clarity
aliXsed Feb 16, 2026
70391f5
Reorder FleetBurned event parameters for better clarity
aliXsed Feb 16, 2026
024e814
feat(fleet): shared-cursor fair-stop algorithm for buildHighestBonded…
aliXsed Feb 17, 2026
2cc01ce
feat(fleet): add competitive intelligence views (competitiveLandscape…
aliXsed Feb 17, 2026
9664314
refactor(fleet): remove dead error, tierBond bit-shift, extract _addT…
aliXsed Feb 17, 2026
6cff00d
refactor: replace competitive hints with cheapest-inclusion hints
aliXsed Feb 17, 2026
31e1512
refactor: eliminate magic numbers, extract bundle helpers, split _fin…
aliXsed Feb 17, 2026
de71977
remove anyActive
aliXsed Feb 17, 2026
d27c48d
fix lints
aliXsed Feb 18, 2026
e63b9a3
Fix spellcheck typos and dictionary entries
aliXsed Feb 18, 2026
534cfc7
Simplify CI: remove zksync flag, fix lint warnings
aliXsed Feb 18, 2026
5a19bd4
Add edge case tests for _findCheapestInclusionTier
aliXsed Feb 18, 2026
4f2ef7d
feat(FleetIdentity): implement partial tier inclusion for bundle buil…
aliXsed Feb 18, 2026
f58f57c
refactor(FleetIdentity): remove redundant discovery functions
aliXsed Feb 18, 2026
22fa52a
add more test
aliXsed Feb 18, 2026
662394a
refactor(FleetIdentity): remove global level, 2-level system (Country…
aliXsed Feb 19, 2026
00c8a8b
remove public caller for tier cap
aliXsed Feb 19, 2026
45e6afb
remove public caller for tier cap
aliXsed Feb 19, 2026
07dedc1
register same uuid for different regions
aliXsed Feb 19, 2026
050564a
feat(FleetIdentity): enforce UUID ownership across multi-region regis…
aliXsed Feb 19, 2026
90b7d7c
feat(FleetIdentity): add level enforcement and migrateRegion()
aliXsed Feb 19, 2026
cf6faa0
correct the license
aliXsed Feb 19, 2026
dcb47a9
feat: Make country fleet cap flexible in buildHighestBondedUuidBundle
aliXsed Feb 23, 2026
edd5584
refactor: Separate validation from state mutation in tier management
aliXsed Feb 23, 2026
953a3b2
refactor: introduce RegistrationLevel enum and _isCountryRegion helper
aliXsed Feb 23, 2026
097a9fc
test: add comprehensive fairness analysis for PREFERRED_COUNTRY_SLOTS…
aliXsed Feb 23, 2026
7b64496
refactor: simplify tierBond signature to use bool isCountry
aliXsed Feb 23, 2026
ecacefe
refactor: remove auto-assign registerFleetLocal, use explicit tier pa…
aliXsed Feb 23, 2026
56160a6
chore: remove redundant fleetRegion mapping
aliXsed Feb 23, 2026
27067e2
docs: add ISO 3166-2 admin area mappings for 18 countries
aliXsed Feb 23, 2026
78b1a9c
Optimize region key encoding to 8-bit admin code
aliXsed Feb 23, 2026
ee56652
feat: Add owned-only UUID mode and fix ADMIN_SHIFT value
aliXsed Feb 24, 2026
e3d04bf
refactor: simplify bundle algorithm and remove soft-cap logic
aliXsed Feb 24, 2026
b7f9ef1
refactor loop
aliXsed Feb 24, 2026
efa5e32
refactor(FleetIdentity): maximize coupling between buildHighestBonded…
aliXsed Feb 25, 2026
6f7deba
refactor: restore None as default RegistrationLevel enum value
aliXsed Feb 25, 2026
f4327c9
refactor(FleetIdentity): extract helpers and simplify registration logic
aliXsed Feb 25, 2026
a8d8b15
docs: Update ISO 3166-2 admin area indices to 1-indexed
aliXsed Feb 25, 2026
56caf50
refactor: remove trivial countryRegionKey, make makeAdminRegion public
aliXsed Feb 25, 2026
2ba283c
feat(swarms): change country bond multiplier to 16
aliXsed Feb 25, 2026
f839da9
fix: exclude iso3166-2 docs from cspell
aliXsed Feb 25, 2026
77ce459
chore: remove local files
aliXsed Feb 25, 2026
f5dbd1c
chore: remove local files
aliXsed Feb 25, 2026
928db5b
docs: update swarm system documentation to reflect FleetIdentity geog…
aliXsed Feb 25, 2026
ba1e527
feat: add buildCountryOnlyBundle and fleet maintenance documentation
aliXsed Feb 26, 2026
48b02ae
refactor: make swarms UUID-based instead of token ID-based
aliXsed Feb 26, 2026
3be0d72
docs: update swarm documentation for UUID-based ownership
aliXsed Feb 26, 2026
941ea74
doc(swarms): remove ownership check for edge
aliXsed Feb 26, 2026
ad77108
minor doc correction
aliXsed Feb 26, 2026
3e80931
docs: restructure swarm documentation for Notion export
aliXsed Feb 26, 2026
7f59a6b
docs: formatting and accuracy corrections
aliXsed Feb 26, 2026
193424b
docs(swarms): revise privacy terminology to reflect iOS constraints
aliXsed Feb 26, 2026
dbaaf3a
feat: add operator delegation to FleetIdentity
aliXsed Feb 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .agent/rules/solidity_zksync.md
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).
20 changes: 18 additions & 2 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"deployments-zk",
"cache_hardhat-zk",
"zkout",
"clk-gateway/src/validators.test.ts"
"clk-gateway/src/validators.test.ts",
"src/swarms/doc/iso3166-2"
],
"ignoreWords": [
"NODL",
Expand Down Expand Up @@ -60,6 +61,21 @@
"Frontends",
"testuser",
"testhandle",
"douglasacost"
"douglasacost",
"IBEACON",
"AABBCCDD",
"SSTORE",
"Permissionless",
"Reentrancy",
"SFID",
"EXTCODECOPY",
"solady",
"SLOAD",
"Bitmask",
"mstore",
"MBOND",
"USCA",
"USNY",
"usca"
]
}
50 changes: 50 additions & 0 deletions .github/copilot-instructions.md
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
```
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ jobs:
run: yarn lint

- name: Run tests
run: forge test --zksync
run: forge test
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
[submodule "lib/era-contracts"]
path = lib/era-contracts
url = https://github.com/matter-labs/era-contracts
[submodule "lib/solady"]
path = lib/solady
url = https://github.com/vectorized/solady
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@
"editor.formatOnSave": true,
"[solidity]": {
"editor.defaultFormatter": "JuanBlanco.solidity"
},
"chat.tools.terminal.autoApprove": {
"forge": true
}
}
20 changes: 20 additions & 0 deletions foundry.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"lib/zksync-storage-proofs": {
"rev": "4b20401ce44c1ec966a29d893694f65db885304b"
},
"lib/openzeppelin-contracts": {
"rev": "e4f70216d759d8e6a64144a9e1f7bbeed78e7079"
},
"lib/solady": {
"tag": {
"name": "v0.1.26",
"rev": "acd959aa4bd04720d640bf4e6a5c71037510cc4b"
}
},
"lib/forge-std": {
"rev": "1eea5bae12ae557d589f9f0f0edae2faa47cb262"
},
"lib/era-contracts": {
"rev": "84d5e3716f645909e8144c7d50af9dd6dd9ded62"
}
}
1 change: 1 addition & 0 deletions lib/solady
Submodule solady added at acd959
32 changes: 32 additions & 0 deletions logs/deploy_l1_bridge.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Compiling 1 files with Solc 0.8.26
Solc 0.8.26 finished in 2.60s
Compiler run successful!
Script ran successfully.

== Logs ==
Deployed L1Bridge at 0x2D02b651Ea9630351719c8c55210e042e940d69a
Granted MINTER_ROLE on NodlL1(0x6dd0E17ec6fE56c5f58a0Fe2Bb813B9b5cc25990) to bridge

## Setting up 1 EVM.

==========================

Chain 1

Estimated gas price: 0.222068762 gwei

Estimated total gas used for script: 2685066

Estimated amount required: 0.000596269282508292 ETH

==========================


==========================

ONCHAIN EXECUTION COMPLETE & SUCCESSFUL.

Transactions saved to: /Users/alex/Documents/rollup/broadcast/DeployL1Bridge.s.sol/1/run-latest.json

Sensitive values saved to: /Users/alex/Documents/rollup/cache/DeployL1Bridge.s.sol/1/run-latest.json

29 changes: 29 additions & 0 deletions logs/deploy_l1_nodl.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
No files changed, compilation skipped
Script ran successfully.

== Logs ==
Deployed L1Nodl at 0x6dd0E17ec6fE56c5f58a0Fe2Bb813B9b5cc25990

## Setting up 1 EVM.

==========================

Chain 1

Estimated gas price: 0.251645298 gwei

Estimated total gas used for script: 4998146

Estimated amount required: 0.001257759939617508 ETH

==========================


==========================

ONCHAIN EXECUTION COMPLETE & SUCCESSFUL.

Transactions saved to: /Users/alex/Documents/rollup/broadcast/DeployL1Nodl.s.sol/1/run-latest.json

Sensitive values saved to: /Users/alex/Documents/rollup/cache/DeployL1Nodl.s.sol/1/run-latest.json

98 changes: 98 additions & 0 deletions logs/deploy_l2_bridge.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
Compiling 1 files with Solc 0.8.26
Solc 0.8.26 finished in 1.70s
Compiler run successful!

Compiling 1 files with zksolc and solc 0.8.26
zksolc and solc 0.8.26 finished in 4.05s
Compiler run successful with warnings:
Warning
ZKsync Era comes with native account abstraction support, and therefore the initiator of a
transaction might be different from the contract calling your code. It is highly recommended NOT
to rely on tx.origin, but use msg.sender instead.
Learn more about Account Abstraction at https://docs.zksync.io/build/developer-reference/account-abstraction/
You may disable this warning with:
a. `suppressedWarnings = ["txorigin"]` in standard JSON.
b. `--suppress-warnings txorigin` in the CLI.
--> lib/era-contracts/l1-contracts/contracts/vendor/AddressAliasHelper.sol:56:42 |
56 | _recipient = _prevMsgSender == tx.origin
| ^^^^^^^^^

Warning
EraVM does not use bytecode for contract deployment. Instead, it refers to contracts using their bytecode hashes.
In order to deploy a contract, please use the `new` operator in Solidity instead of raw 'create'/'create2' in assembly.
In Solidity v0.6 and older, it can be a false-positive warning if there is 'create(' or 'create2(' in comments within assembly.
Learn more about CREATE/CREATE2 EraVM limitations at https://docs.zksync.io/zksync-protocol/differences/evm-instructions#create-create2
You may disable this warning with:
1. `suppressedWarnings = ["assemblycreate"]` in standard JSON.
2. `--suppress-warnings assemblycreate` in the CLI.
--> lib/forge-std/src/StdCheats.sol:494:19 |
494 | addr := create(0, add(bytecode, 0x20), mload(bytecode))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Warning
EraVM does not use bytecode for contract deployment. Instead, it refers to contracts using their bytecode hashes.
In order to deploy a contract, please use the `new` operator in Solidity instead of raw 'create'/'create2' in assembly.
In Solidity v0.6 and older, it can be a false-positive warning if there is 'create(' or 'create2(' in comments within assembly.
Learn more about CREATE/CREATE2 EraVM limitations at https://docs.zksync.io/zksync-protocol/differences/evm-instructions#create-create2
You may disable this warning with:
1. `suppressedWarnings = ["assemblycreate"]` in standard JSON.
2. `--suppress-warnings assemblycreate` in the CLI.
--> lib/forge-std/src/StdCheats.sol:504:19 |
504 | addr := create(0, add(bytecode, 0x20), mload(bytecode))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Warning
EraVM does not use bytecode for contract deployment. Instead, it refers to contracts using their bytecode hashes.
In order to deploy a contract, please use the `new` operator in Solidity instead of raw 'create'/'create2' in assembly.
In Solidity v0.6 and older, it can be a false-positive warning if there is 'create(' or 'create2(' in comments within assembly.
Learn more about CREATE/CREATE2 EraVM limitations at https://docs.zksync.io/zksync-protocol/differences/evm-instructions#create-create2
You may disable this warning with:
1. `suppressedWarnings = ["assemblycreate"]` in standard JSON.
2. `--suppress-warnings assemblycreate` in the CLI.
--> lib/forge-std/src/StdCheats.sol:515:19 |
515 | addr := create(val, add(bytecode, 0x20), mload(bytecode))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Warning
EraVM does not use bytecode for contract deployment. Instead, it refers to contracts using their bytecode hashes.
In order to deploy a contract, please use the `new` operator in Solidity instead of raw 'create'/'create2' in assembly.
In Solidity v0.6 and older, it can be a false-positive warning if there is 'create(' or 'create2(' in comments within assembly.
Learn more about CREATE/CREATE2 EraVM limitations at https://docs.zksync.io/zksync-protocol/differences/evm-instructions#create-create2
You may disable this warning with:
1. `suppressedWarnings = ["assemblycreate"]` in standard JSON.
2. `--suppress-warnings assemblycreate` in the CLI.
--> lib/forge-std/src/StdCheats.sol:525:19 |
525 | addr := create(val, add(bytecode, 0x20), mload(bytecode))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

2025-10-15T00:35:52.095529Z ERROR backendhandler: failed to get block err=failed to get block; error sending request for url (https://mainnet.era.zksync.io/); operation timed out number=65260273
2025-10-15T00:35:52.096034Z ERROR sharedbackend: Failed to send/recv `block_hash` err=failed to get block hash for 65260273: failed to get block; error sending request for url (https://mainnet.era.zksync.io/); operation timed out number=65260273
Script ran successfully.

== Logs ==
Deployed L2Bridge at 0x2c1B65dA72d5Cf19b41dE6eDcCFB7DD83d1B529E
Granted MINTER_ROLE on NODL(0xBD4372e44c5eE654dd838304006E1f0f69983154) to bridge

## Setting up 1 EVM.

==========================

Chain 324

Estimated gas price: 0.090500001 gwei

Estimated total gas used for script: 209410861

Estimated amount required: 0.018951683129910861 ETH

==========================


==========================

ONCHAIN EXECUTION COMPLETE & SUCCESSFUL.

Transactions saved to: /Users/alex/Documents/rollup/broadcast/DeployL2Bridge.s.sol/324/run-latest.json

Sensitive values saved to: /Users/alex/Documents/rollup/cache/DeployL2Bridge.s.sol/324/run-latest.json

Expand Down
3 changes: 2 additions & 1 deletion remappings.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
@openzeppelin=lib/openzeppelin-contracts/
@openzeppelin=lib/openzeppelin-contracts/
solady/=lib/solady/src/
Loading
Loading