Skip to content
Merged
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
22 changes: 16 additions & 6 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ THEGRAPH_STORE_POSTGRES_DIESEL_URL="postgresql://graph:graph@127.0.0.1:5432/grap
# 🚨 MANDATORY: Format all code IMMEDIATELY after any .rs file edit
cargo fmt --all

# Check code without building
# 🚨 MANDATORY: Check code for warnings and errors - MUST have zero warnings
cargo check
```

🚨 **CRITICAL REMINDER**: `cargo fmt --all` is MANDATORY after editing ANY .rs file - NO EXCEPTIONS!
This must be done from the project root BEFORE any commit. Forgetting this means you failed to follow instructions.
🚨 **CRITICAL REQUIREMENTS for ANY implementation**:
1. **`cargo fmt --all`** is MANDATORY after editing ANY .rs file - NO EXCEPTIONS!
2. **`cargo check`** MUST show zero warnings before any commit - NO EXCEPTIONS!
3. **All tests** MUST pass before any commit
4. All requirements must be met from the project root BEFORE any commit
5. Forgetting any of these means you failed to follow instructions

## High-Level Architecture

Expand Down Expand Up @@ -91,12 +95,18 @@ Use format: `{crate-name}: {description}`
- Keep commits logical and atomic
- Use `git rebase -i` to clean up history before merging

### Testing Requirements
### Implementation Success Criteria
Before any commit or PR, ALL of the following MUST be satisfied:

1. **🚨 MANDATORY**: All tests MUST pass
2. **🚨 MANDATORY**: `cargo check` MUST show zero warnings
3. **🚨 MANDATORY**: `cargo fmt --all` MUST be run after editing ANY .rs file

**Testing Notes**:
- Unit tests inline with source code
- Integration tests require Docker Compose setup and additional environment dependencies
- Integration tests require Docker Compose setup and additional environment dependencies
- Claude cannot run integration tests due to missing environment dependencies
- Claude must set `THEGRAPH_STORE_POSTGRES_DIESEL_URL` before running any tests
- **🚨 MANDATORY**: Always run `cargo fmt --all` after editing .rs files, BEFORE committing

### Environment Variables
- `GRAPH_LOG=debug`: Enable debug logging
Expand Down
2 changes: 1 addition & 1 deletion graph/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ sqlparser = { workspace = true }
# stable-hash_legacy = { version = "0.3.3", package = "stable-hash" }
# stable-hash = { version = "0.4.2" }
stable-hash = { git = "https://github.com/graphprotocol/stable-hash", branch = "main" }
stable-hash_legacy = { git = "https://github.com/graphprotocol/stable-hash", branch = "old", package = "stable-hash", doc = false }
stable-hash_legacy = { git = "https://github.com/graphprotocol/stable-hash", branch = "old", package = "stable-hash" }
strum_macros = "0.27.1"
slog-async = "2.5.0"
slog-envlogger = "2.1.0"
Expand Down
4 changes: 2 additions & 2 deletions graph/src/components/store/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ impl EntityModification {

/// Return the details of the write if `self` is a write operation for a
/// new or an existing entity
fn as_write(&self) -> Option<EntityWrite> {
fn as_write(&self) -> Option<EntityWrite<'_>> {
EntityWrite::try_from(self).ok()
}

Expand Down Expand Up @@ -823,7 +823,7 @@ impl Batch {
&self,
entity_type: &EntityType,
at: BlockNumber,
) -> impl Iterator<Item = EntityOp> {
) -> impl Iterator<Item = EntityOp<'_>> {
self.mods
.group(entity_type)
.map(|group| group.effective_ops(at))
Expand Down
3 changes: 3 additions & 0 deletions graph/src/components/subgraph/proof_of_indexing/reference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,20 @@ use web3::types::{Address, H256};
/// well-implemented (without conflicting sequence numbers, or other oddities).
/// It's just way easier to check that this works, and serves as a kind of
/// documentation as a side-benefit.
#[allow(dead_code)]
pub struct PoI<'a> {
pub causality_regions: HashMap<String, PoICausalityRegion<'a>>,
pub subgraph_id: DeploymentHash,
pub block_hash: H256,
pub indexer: Option<Address>,
}

#[allow(dead_code)]
fn h256_as_bytes(val: &H256) -> AsBytes<&[u8]> {
AsBytes(val.as_bytes())
}

#[allow(dead_code)]
fn indexer_opt_as_bytes(val: &Option<Address>) -> Option<AsBytes<&[u8]>> {
val.as_ref().map(|v| AsBytes(v.as_bytes()))
}
Expand Down
8 changes: 4 additions & 4 deletions graph/src/util/timed_rw_lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl<T> TimedRwLock<T> {
}
}

pub fn write(&self, logger: &Logger) -> parking_lot::RwLockWriteGuard<T> {
pub fn write(&self, logger: &Logger) -> parking_lot::RwLockWriteGuard<'_, T> {
loop {
let mut elapsed = Duration::from_secs(0);
match self.lock.try_write_for(self.log_threshold) {
Expand All @@ -36,11 +36,11 @@ impl<T> TimedRwLock<T> {
}
}

pub fn try_read(&self) -> Option<parking_lot::RwLockReadGuard<T>> {
pub fn try_read(&self) -> Option<parking_lot::RwLockReadGuard<'_, T>> {
self.lock.try_read()
}

pub fn read(&self, logger: &Logger) -> parking_lot::RwLockReadGuard<T> {
pub fn read(&self, logger: &Logger) -> parking_lot::RwLockReadGuard<'_, T> {
loop {
let mut elapsed = Duration::from_secs(0);
match self.lock.try_read_for(self.log_threshold) {
Expand Down Expand Up @@ -73,7 +73,7 @@ impl<T> TimedMutex<T> {
}
}

pub fn lock(&self, logger: &Logger) -> parking_lot::MutexGuard<T> {
pub fn lock(&self, logger: &Logger) -> parking_lot::MutexGuard<'_, T> {
let start = Instant::now();
let guard = self.lock.lock();
let elapsed = start.elapsed();
Expand Down
2 changes: 1 addition & 1 deletion runtime/wasm/src/module/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl WasmInstance {
self.store.into_data()
}

pub(crate) fn instance_ctx(&mut self) -> WasmInstanceContext {
pub(crate) fn instance_ctx(&mut self) -> WasmInstanceContext<'_> {
WasmInstanceContext::new(&mut self.store)
}

Expand Down
1 change: 1 addition & 0 deletions runtime/wasm/src/to_from/external.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ where
}

#[derive(Debug, Clone, Eq, PartialEq, AscType)]
#[allow(dead_code)]
pub enum AscSubgraphEntityOp {
Create,
Modify,
Expand Down
2 changes: 1 addition & 1 deletion store/postgres/src/relational/dsl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl<'a> Table<'a> {
}

/// Reference a column in this table and use the correct SQL type `ST`
fn bind<ST>(&self, name: &str) -> Option<BoundColumn<ST>> {
fn bind<ST>(&self, name: &str) -> Option<BoundColumn<'_, ST>> {
self.column(name).map(|c| c.bind())
}

Expand Down
1 change: 1 addition & 0 deletions store/postgres/src/relational_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4976,6 +4976,7 @@ impl<'a, Conn> RunQueryDsl<Conn> for CountCurrentVersionsQuery<'a> {}
/// Helper struct for returning the id's touched by the RevertRemove and
/// RevertExtend queries
#[derive(QueryableByName, PartialEq, Eq, Hash)]
#[allow(dead_code)]
pub struct CopyVid {
#[diesel(sql_type = BigInt)]
pub vid: i64,
Expand Down
2 changes: 1 addition & 1 deletion store/postgres/src/subgraph_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ impl SubgraphStoreInner {
/// connections can deadlock the entire process if the pool runs out
/// of connections in between getting the first one and trying to get the
/// second one.
pub(crate) fn primary_conn(&self) -> Result<primary::Connection, StoreError> {
pub(crate) fn primary_conn(&self) -> Result<primary::Connection<'_>, StoreError> {
let conn = self.mirror.primary().get()?;
Ok(primary::Connection::new(conn))
}
Expand Down
2 changes: 1 addition & 1 deletion store/postgres/src/writable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ use crate::{primary, primary::Site, relational::Layout, SubgraphStore};
struct WritableSubgraphStore(SubgraphStore);

impl WritableSubgraphStore {
fn primary_conn(&self) -> Result<primary::Connection, StoreError> {
fn primary_conn(&self) -> Result<primary::Connection<'_>, StoreError> {
self.0.primary_conn()
}

Expand Down
Loading