Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
35 changes: 35 additions & 0 deletions .github/workflows/storage-collision-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Storage Key Collision Check

on:
push:
branches: [ main, issue-150 ]
pull_request:
branches: [ main ]

jobs:
check-storage-collision:
name: Check Storage Key Collision & Namespacing
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown

- name: Cache Cargo
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
contracts/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Run Storage Key Collision Check
run: |
chmod +x scripts/check-storage-keys.sh
./scripts/check-storage-keys.sh
27 changes: 27 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Dependencies & Build Outputs
node_modules/
target/
contracts/target/
dist/
build/
.next/

# Environment variables
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

# Logs & Temporary files
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.DS_Store
*.swp
*.swo

# IDE & Editor files
.vscode/
.idea/
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: up down build logs ps clean staging
.PHONY: up down build logs ps clean staging check-storage-keys

## Start the full local stack
up:
Expand Down Expand Up @@ -27,3 +27,8 @@ ps:
## Start staging stack
staging:
docker compose -f docker-compose.yml -f docker-compose.staging.yml up --build

## Check for storage key collisions across contracts
check-storage-keys:
./scripts/check-storage-keys.sh

5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ Handles:
- Yield verification
- Fund distribution

### Storage Key Namespacing & Collision Detection
- All contracts use tuple namespacing `(Symbol, DataKey)` with unique `CONTRACT_PREFIX` identifiers
- Collision detection script: `./scripts/check-storage-keys.sh` (or `make check-storage-keys`)
- Documentation: [docs/storage-namespacing.md](docs/storage-namespacing.md)

---

## Project Structure
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
{
"generators": {
"address": 3,
"nonce": 0
},
"auth": [
[],
[],
[],
[],
[],
[]
],
"ledger": {
"protocol_version": 22,
"sequence_number": 0,
"timestamp": 0,
"network_id": "0000000000000000000000000000000000000000000000000000000000000000",
"base_reserve": 0,
"min_persistent_entry_ttl": 4096,
"min_temp_entry_ttl": 16,
"max_entry_ttl": 6312000,
"ledger_entries": [
[
{
"contract_data": {
"contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM",
"key": {
"vec": [
{
"symbol": "access_control"
},
{
"vec": [
{
"symbol": "Admin"
}
]
}
]
},
"durability": "persistent"
}
},
[
{
"last_modified_ledger_seq": 0,
"data": {
"contract_data": {
"ext": "v0",
"contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM",
"key": {
"vec": [
{
"symbol": "access_control"
},
{
"vec": [
{
"symbol": "Admin"
}
]
}
]
},
"durability": "persistent",
"val": {
"address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4"
}
}
},
"ext": "v0"
},
4095
]
],
[
{
"contract_data": {
"contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM",
"key": {
"vec": [
{
"symbol": "access_control"
},
{
"vec": [
{
"symbol": "Role"
},
{
"symbol": "operator"
},
{
"address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M"
}
]
}
]
},
"durability": "persistent"
}
},
[
{
"last_modified_ledger_seq": 0,
"data": {
"contract_data": {
"ext": "v0",
"contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM",
"key": {
"vec": [
{
"symbol": "access_control"
},
{
"vec": [
{
"symbol": "Role"
},
{
"symbol": "operator"
},
{
"address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M"
}
]
}
]
},
"durability": "persistent",
"val": {
"bool": true
}
}
},
"ext": "v0"
},
4095
]
],
[
{
"contract_data": {
"contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM",
"key": "ledger_key_contract_instance",
"durability": "persistent"
}
},
[
{
"last_modified_ledger_seq": 0,
"data": {
"contract_data": {
"ext": "v0",
"contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM",
"key": "ledger_key_contract_instance",
"durability": "persistent",
"val": {
"contract_instance": {
"executable": {
"wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
},
"storage": null
}
}
}
},
"ext": "v0"
},
4095
]
],
[
{
"contract_code": {
"hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
}
},
[
{
"last_modified_ledger_seq": 0,
"data": {
"contract_code": {
"ext": "v0",
"hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"code": ""
}
},
"ext": "v0"
},
4095
]
]
]
},
"events": []
}
2 changes: 1 addition & 1 deletion contracts/financing-pool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,4 +609,4 @@ mod test;
#[cfg(test)]
mod reentrancy_tests;
#[cfg(test)]
mod upgrade_tests;
mod upgrade_tests;
Loading
Loading