-
Notifications
You must be signed in to change notification settings - Fork 18
ci: Add CI workflow to verify ABI consistency #114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@hugomrdias I think this will resolve your issue -- at least with this contract. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements a CI workflow to ensure ABI files in the subgraph stay synchronized with smart contract source code. The workflow automatically regenerates ABIs and fails if they differ from committed files, preventing integration issues.
- Added a GitHub Actions workflow that verifies ABI consistency on push/PR to main
- Created a new
make abitarget that generates ABIs for all contracts (excluding libraries) - Added a bash script to extract ABIs from Solidity contracts using forge and jq
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
.github/workflows/check-abi-consistency.yml |
New CI workflow that checks ABI consistency by regenerating ABIs and comparing with committed files |
service_contracts/Makefile |
Added abi target to generate ABI files for all contracts in src/ directory |
service_contracts/tools/generate-abi.sh |
New script that extracts ABIs from compiled contracts using forge and jq |
subgraph/abis/FilecoinWarmStorageService.json |
Updated ABI file reflecting changes to the FilecoinWarmStorageService contract |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| # Extract ABI for each contract in the source directory | ||
| for contract in "${contracts[@]}"; do | ||
| mkdir -p ${OUTPUT_DIR}/ | ||
| jq '.abi' "${SRC_DIR}/../out/${contract}.sol/${contract}.json" > "${OUTPUT_DIR}/${contract}.json" |
Copilot
AI
Aug 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The path construction assumes the contract filename matches the contract name exactly (${contract}.sol), but Solidity files can contain multiple contracts or have different naming conventions. This could fail if the contract name doesn't match the file name.
| jq '.abi' "${SRC_DIR}/../out/${contract}.sol/${contract}.json" > "${OUTPUT_DIR}/${contract}.json" | |
| mkdir -p "${OUTPUT_DIR}/" | |
| abi_file=$(find "${SRC_DIR}/../out" -type f -name "${contract}.json" | head -n 1) | |
| if [[ -z "$abi_file" ]]; then | |
| echo "ABI file for contract $contract not found in ${SRC_DIR}/../out" | |
| continue | |
| fi | |
| jq '.abi' "$abi_file" > "${OUTPUT_DIR}/${contract}.json" |
rvagg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
love it
|
needs merge conflict resolution though -- I think if I were you I'd rebase, re-gen and force push over the top of whatever the conflict is in that .json, up to you how you handle it as long as it results in a correct .json |
d837190 to
2d50788
Compare
|
Hey @pali101! 👋 I'm not sure why this never got merged before conflicts arose again. I think if I read the code and history correct, it looks like the ABI consistency workflow was ultimately implemented in PR #180 which added the check-abi
Even though this PR wasn't the one that got merged, thank you so much for your contribution @pali101! 🙏 Your work here clearly helped shape the thinking around ABI consistency, I can see similar patterns and approaches in what ultimately got implemented in PR #180. Will make sure this gets reflected in the PLDG impact rating, your contribution was valuable even if the timing and merge conflicts didn't work out perfectly. CC: @rvagg if there is anything else from this PR that we want to salvage before closing it out. |
Summary
This PR adds a GitHub Actions workflow that checks if smart contract ABIs in
subgraph/abis/match the Solidity source. It regenerates ABIs usingmake abiand fails if differences with committed files are found, ensuring ABI updates accompany contract changes and preventing integration issues.Changes
abithat generates ABIs for all contracts in service_contracts/src (excluding libraries)service_contracts/tools/generate-abi.shused both in CI and the Makefile for ABI generation