fix: fix: protocol activity statistics stay zero — ponder watches wrong contract addresses (#4) #6
No reviewers
Labels
No labels
action
backlog
blocked
in-progress
priority
tech-debt
underspecified
vision
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: johba/harb#6
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/issue-4"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #4
Changes
AI Review
Summary
This PR fixes protocol activity stats staying zero by making ponder watch the correct contract addresses. It adds pool address discovery via the Uniswap factory to bootstrap, passes
LM_ADDRESS,POOL_ADDRESS, andMINIMUM_BLOCKS_FOR_RINGBUFFERto the ponder env, and makes the ring-buffer minimum blocks threshold configurable via env so local dev doesn't have to wait 100 blocks.The TypeScript change and the
MINIMUM_BLOCKS_FOR_RINGBUFFER=0override inbootstrap.share both correct. The pool address discovery logic inbootstrap-common.shhas one bug that will abort the bootstrap script in certain failure conditions.Issues
bug
scripts/bootstrap-common.sh:113:POOL_ADDRESSis never initialised before the discovery block. Whenfactoryis empty or0x(factory call fails, returns empty, or returns a zero address), theifbranch that setsPOOL_ADDRESSis skipped, leaving the variable unbound. The immediately following check[[ -z "$POOL_ADDRESS" ... ]]then triggers aPOOL_ADDRESS: unbound variableerror and aborts the script underset -euo pipefail.Fix: initialise the variable to empty before the discovery block:
Non-issues
POOL_ADDRESS=$POOL_ADDRESSin the heredoc incontainers/bootstrap.sh:108looks like a self-reference but is correct: the unquoted heredoc terminator causes shell expansion, so the actual address value is written into the file.10000ingetPoolcall is consistent with the rest of bootstrap (seed swap uses the same tier).parseInt(process.env.MINIMUM_BLOCKS_FOR_RINGBUFFER || '100')is fine; env var is always set to a valid integer by bootstrap.Verdict
REQUEST_CHANGES — POOL_ADDRESS unbound variable will abort bootstrap when factory call returns empty
Reviewed at
e20b451| AGENTS.mdAI Review: REQUEST_CHANGES — POOL_ADDRESS unbound variable will abort bootstrap when factory call returns empty
AI Review
Summary
This PR correctly identifies and fixes the root cause of zero protocol activity statistics: ponder was not receiving the
LM_ADDRESSorPOOL_ADDRESSit needed to watch the right contracts, and the 100-block ring buffer guard was preventing stats from accumulating on fresh local chains. The three-part fix is well-scoped and the approach is sound.Findings
scripts/bootstrap-common.sh:106-116: Unbound variable crash underset -u.POOL_ADDRESSis never initialized before the conditional block. Ifcast callfor the factory fails (network hiccup, swap router not deployed), theifblock on line 110 is skipped andPOOL_ADDRESSremains unset. The subsequent check[[ -z "$POOL_ADDRESS" || ... ]]then triggers bash'snounseterror and aborts the entire bootstrap — the opposite of the graceful fallback intended. Fix: addPOOL_ADDRESS=""immediately beforedetect_swap_routeron line 107.Rest of the diff
containers/bootstrap.sh:107-109— WritingPOOL_ADDRESS=$POOL_ADDRESSin the heredoc is correct; the outer variable is expanded before the heredoc is written.services/ponder/src/helpers/stats.ts:10—parseIntwithout a radix is fine here; input is always"0"(local) or the string default"100".MINIMUM_BLOCKS_FOR_RINGBUFFER=0hardcoded inwrite_ponder_envis intentional and correct — fresh local chains have far fewer than 100 blocks at bootstrap time.Verdict
REQUEST_CHANGES — POOL_ADDRESS unbound variable in bootstrap-common.sh will crash bootstrap under set -u when factory lookup fails
Reviewed at
e20b451| AGENTS.mdAI Review: REQUEST_CHANGES — POOL_ADDRESS unbound variable in bootstrap-common.sh will crash bootstrap under set -u when factory lookup fails
AI Re-review (round 3)
Previous Findings
scripts/bootstrap-common.sh:106— FIXED:POOL_ADDRESS=""added immediately beforedetect_swap_router, exactly as requested. The graceful fallback now works correctly underset -u.New Issues
None.
Verdict
APPROVE — Previous finding fixed: POOL_ADDRESS initialized before conditional block
Reviewed at
caabcde| Previous:e20b451| AGENTS.mdAI Re-review (round 3)
Previous Findings
POOL_ADDRESSunderset -u(scripts/bootstrap-common.sh:107) → FIXED:POOL_ADDRESS=""added immediately beforedetect_swap_router, matching the suggested fix exactly.New Issues
None.
Verdict
APPROVE — Previous finding fixed: POOL_ADDRESS initialised before conditional block
Reviewed at
caabcde| Previous:e20b451| AGENTS.mdAI Re-review (round 3): APPROVE — Previous finding fixed: POOL_ADDRESS initialized before conditional block
AI Re-review (round 3): APPROVE — Previous finding fixed: POOL_ADDRESS initialised before conditional block
Pull request closed