resolves #67 Co-authored-by: johba <johba@harb.eth> Reviewed-on: https://codeberg.org/johba/harb/pulls/70
9 KiB
Changelog: Version Validation System & Tax Rate Index Refactoring
Date: 2025-10-07
Summary
This release implements a comprehensive version validation system to ensure contract-indexer-frontend compatibility and completes the tax rate index refactoring to eliminate fragile decimal lookups.
Major Features
1. Version Validation System
Contract Changes:
onchain/src/Kraiken.sol: AddedVERSION = 1constant (line 28)- Public constant for runtime validation
- Must be incremented for breaking changes to TAX_RATES, events, or data structures
kraiken-lib:
kraiken-lib/src/version.ts(NEW): Central version trackingKRAIKEN_LIB_VERSION = 1COMPATIBLE_CONTRACT_VERSIONS = [1]isCompatibleVersion()validation functiongetVersionMismatchError()for detailed error reporting
kraiken-lib/package.json: Added./versionexport
Ponder Indexer:
services/ponder/src/helpers/version.ts(NEW): Contract version validation- Reads
VERSIONfrom deployed contract at startup - Validates against
COMPATIBLE_CONTRACT_VERSIONS - Fails hard (exit 1) on mismatch to prevent indexing wrong data
- Reads
services/ponder/src/kraiken.ts: Integrated version check on first Transfer eventservices/ponder/ponder-env.d.ts: Fixed permissions (chmod 666)
Frontend:
web-app/src/composables/useVersionCheck.ts(NEW): Version validation composable- Validates
KRAIKEN_LIB_VERSIONloads correctly - Placeholder for future GraphQL-based 3-way validation
- Warns (doesn't fail) on mismatch
- Validates
CI/CD:
.github/workflows/validate-version.yml(NEW): Automated version validation- Validates contract VERSION is in COMPATIBLE_CONTRACT_VERSIONS
- Runs on PRs and pushes to master/main
- Prevents merging incompatible versions
Documentation:
VERSION_VALIDATION.md(NEW): Complete architecture and workflows- System architecture diagram
- Version bump workflow
- Troubleshooting guide
- Maintenance guidelines
2. Podman Orchestration Fix
Problem: Podman's dependency graph validator fails with "container not found in input list" errors when containers have depends_on metadata.
Solution:
-
podman-compose.yml: Removed ALLdepends_ondeclarations from:- bootstrap
- ponder
- webapp
- landing
- txn-bot
- caddy
-
scripts/dev.sh: Implemented phased startup with explicit health checks:- Create all containers (
podman-compose up --no-start) - Start anvil & postgres, wait for healthy
- Start bootstrap, wait for completion
- Start ponder, wait for healthy
- Start webapp/landing/txn-bot
- Start caddy
- Create all containers (
Result: Stack starts reliably without dependency graph errors.
3. Tax Rate Index Refactoring (Completion)
Web App:
-
web-app/src/composables/useSnatchSelection.ts:- Replaced
position.taxRate >= maxTaxRateDecimalwithposIndex >= selectedTaxRateIndex - Fixed test data to match index-based logic
- Replaced
-
web-app/src/composables/usePositions.ts:- Replaced decimal-based sorting with index-based sorting
- Changed threshold calculation from average percentage to average index
-
web-app/src/components/collapse/CollapseActive.vue:- Changed low tax detection from decimal to index comparison
-
web-app/src/views/GraphView.vue: DELETED (dead code, 63 lines)
Ponder:
-
services/ponder/ponder.schema.ts:- CRITICAL FIX: Import
TAX_RATE_OPTIONSfrom kraiken-lib instead of hardcoded array - Added
taxRateIndexcolumn to positions table - Added index on
taxRateIndexcolumn
- CRITICAL FIX: Import
-
services/ponder/src/stake.ts:- Extract and store
taxRateIndexfrom contract events
- Extract and store
Tests:
kraiken-lib/src/tests/taxRates.test.ts: Fixed Jest ES module compatibilitykraiken-lib/jest.config.js→kraiken-lib/jest.config.cjs: Renamed for CommonJSweb-app/src/composables/__tests__/useSnatchSelection.spec.ts: Fixed test data inconsistencies
File Changes
Added Files (7)
.github/workflows/validate-version.yml- CI/CD validationVERSION_VALIDATION.md- Documentationkraiken-lib/src/version.ts- Version trackingkraiken-lib/jest.config.cjs- Jest configservices/ponder/src/helpers/version.ts- Ponder validationweb-app/src/composables/useVersionCheck.ts- Frontend validationscripts/sync-tax-rates.mjs- Tax rate sync script
Deleted Files (2)
web-app/src/views/GraphView.vue- Dead codekraiken-lib/jest.config.js- Replaced with .cjs
Modified Files (29)
.gitignore- Added test artifacts, logs, ponder stateCLAUDE.md- Added Version Validation and Podman Orchestration sectionskraiken-lib/AGENTS.md- Added version.ts to Key Moduleskraiken-lib/package.json- Added ./version exportkraiken-lib/src/index.ts- Export version validation functionskraiken-lib/src/taxRates.ts- Generated tax rates with checksumskraiken-lib/src/tests/taxRates.test.ts- Fixed Jest compatibilityonchain/src/Kraiken.sol- Added VERSION constantpodman-compose.yml- Removed all depends_on declarationsscripts/build-kraiken-lib.sh- Updated build processscripts/dev.sh- Implemented phased startupservices/ponder/AGENTS.md- Updated documentationservices/ponder/ponder-env.d.ts- Fixed permissionsservices/ponder/ponder.schema.ts- Import from kraiken-lib, add taxRateIndexservices/ponder/src/kraiken.ts- Added version validationservices/ponder/src/stake.ts- Store taxRateIndextests/e2e/01-acquire-and-stake.spec.ts- Test updatesweb-app/README.md- Documentation updatesweb-app/env.d.ts- Type updatesweb-app/src/components/StakeHolder.vue- Index-based logicweb-app/src/components/collapse/CollapseActive.vue- Index comparisonweb-app/src/components/fcomponents/FSelect.vue- Index handlingweb-app/src/composables/__tests__/useSnatchSelection.spec.ts- Fixed testsweb-app/src/composables/useAdjustTaxRates.ts- Index-based adjustmentsweb-app/src/composables/usePositions.ts- Index-based sorting and thresholdweb-app/src/composables/useSnatchSelection.ts- Index-based filteringweb-app/src/composables/useStake.ts- Index handling 28-29. Various documentation and configuration updates
Breaking Changes
For Contract Deployments
- New VERSION constant must be present in Kraiken.sol
- Ponder will fail to start if VERSION is missing or incompatible
For Ponder
- Schema migration required: Add
taxRateIndexcolumn to positions table - Database reset recommended: Delete
.ponder/directory before starting - New import required: Import TAX_RATE_OPTIONS from kraiken-lib
For kraiken-lib Consumers
- New export:
kraiken-lib/versionmust be built - Run
./scripts/build-kraiken-lib.shto regenerate dist/
Migration Guide
Updating to This Version
-
Stop the stack:
./scripts/dev.sh stop -
Clean Ponder state:
rm -rf services/ponder/.ponder/ -
Rebuild kraiken-lib:
./scripts/build-kraiken-lib.sh -
Rebuild contracts (if needed):
cd onchain && forge build -
Start the stack:
./scripts/dev.sh start -
Verify version validation:
podman logs harb_ponder_1 | grep "version validated"Should output:
✓ Contract version validated: v1 (kraiken-lib v1)
Future Version Bumps
When making breaking changes to TAX_RATES, events, or data structures:
-
Increment VERSION in Kraiken.sol:
uint256 public constant VERSION = 2; -
Update COMPATIBLE_CONTRACT_VERSIONS in kraiken-lib/src/version.ts:
export const KRAIKEN_LIB_VERSION = 2; export const COMPATIBLE_CONTRACT_VERSIONS = [2]; // Or [1, 2] for backward compat -
Rebuild and redeploy:
./scripts/build-kraiken-lib.sh rm -rf services/ponder/.ponder/ cd onchain && forge script script/Deploy.s.sol
Validation
Unit Tests
- ✅ kraiken-lib tests pass
- ✅ web-app tests pass
- ✅ Ponder codegen succeeds
- ✅ onchain tests pass
Integration Tests
- ✅ Stack starts without dependency errors
- ✅ Ponder validates contract version successfully
- ✅ Ponder indexes events with taxRateIndex
- ✅ GraphQL endpoint responds
- ✅ Version validation logs appear in Ponder output
Manual Verification
# Check Ponder logs for version validation
podman logs harb_ponder_1 | grep "version validated"
# Output: ✓ Contract version validated: v1 (kraiken-lib v1)
# Check contract VERSION
cast call $KRAIKEN_ADDRESS "VERSION()" --rpc-url http://localhost:8545
# Output: 1
# Query positions with taxRateIndex
curl -X POST http://localhost:42069/graphql \
-d '{"query":"{ positions { id taxRateIndex taxRate } }"}'
Known Issues
None. All blocking issues resolved.
Contributors
- Claude Code (Anthropic)
References
- Full architecture:
VERSION_VALIDATION.md - Podman orchestration:
CLAUDE.md§ Podman Orchestration - Tax rate system:
kraiken-lib/src/taxRates.ts