-
Notifications
You must be signed in to change notification settings - Fork 2
feat: external API support, JS reference example implementation, symlink issue fix for "latest" #45
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
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 pull request adds external API support for exporting DevNet information to a stable JSON schema, along with JavaScript reference implementations for consuming this data. The primary goal is to provide a machine-readable interface for external tools and scripts to interact with a running FOC DevNet instance.
Changes:
- Introduced a versioned external API module that exports DevNet state (users, contracts, services) to
devnet-info.json - Added JavaScript examples demonstrating how to read DevNet info and check balances using ethers.js
- Modified step execution flow to return
SetupContextfor data extraction after successful cluster startup - Added CI validation to verify the exported JSON file exists, has correct schema, and is parseable by the JavaScript examples
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| src/external_api/mod.rs | New module defining public API and schema version constant |
| src/external_api/devnet_info.rs | Data structures for versioned DevNet information schema |
| src/external_api/export.rs | Logic to extract DevNet state from SetupContext and export to JSON |
| src/paths.rs | Added devnet_info_file() helper function for consistent path handling |
| src/lib.rs | Registered new external_api module |
| src/commands/start/mod.rs | Modified to return SetupContext and call export_devnet_info on success |
| src/commands/start/step/mod.rs | Changed execute_steps functions to return SetupContext instead of () |
| examples/read-devnet-info.js | JavaScript example showing how to parse and display DevNet info |
| examples/check-balances.js | JavaScript example demonstrating balance queries using ethers.js |
| examples/package.json | NPM package configuration with ethers.js dependency |
| examples/README.md | Documentation for using the JavaScript examples |
| examples/.gitignore | Ignore node_modules and package-lock.json |
| .github/workflows/ci.yml | Added validation steps to verify devnet-info.json export and JavaScript examples |
|
This looks like a duplication of existing data that's already in |
|
@rvagg the difference is intent of what's meant by each of the files. My defense against Or, only this file |
fair enough, as long as we clearly document it that way then that seems fine to me |
Co-authored-by: Rod Vagg <[email protected]>
|
@redpanda-f I've opened a new pull request, #46, to work on those changes. Once the pull request is ready, I'll request review from you. |
* Initial plan * Extract magic number 3 to USER_ACCOUNT_COUNT constant Co-authored-by: redpanda-f <[email protected]> * Improve USER_ACCOUNT_COUNT constant documentation Co-authored-by: redpanda-f <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: redpanda-f <[email protected]>
|
@copilot can you respond to rvagg's comments based on the new commits that were added by me? |
|
@redpanda-f I've opened a new pull request, #49, to work on those changes. Once the pull request is ready, I'll request review from you. |
Co-authored-by: Rod Vagg <[email protected]>
Co-authored-by: Rod Vagg <[email protected]>
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.
rm this file
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.
lgtm pending removal of that one file
Added usage instructions and examples section to README.
BigLep
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.
I haven't gone through all the the comments to the PR, so maybe everything I've said here was already covered, if so feel free to ignore.
I also updated the top level README with link to the examples: cf31642
|
|
||
| This directory contains examples demonstrating how to interact with a running FOC DevNet instance using the exported `devnet-info.json` file. | ||
|
|
||
| ## Files |
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.
I realize the building blocks are here, but is there a reason we don't have an exmaple of starting up synapse using the content from read-devnet-info.js (per #7 ) as that is a common usecase?
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.
I think that's part of a larger chunk of task, that in my opinion can be separated from this.
In any case, this API-providing PR has to be (by git workflow) merged into main separate from the actual use of it.
Would not want to do synapse work in this PR since now endorsements are part of mainline foc-devnet and synapse is in flux w.r.t endorsements.
What I would be able to agree to, is whether #7 should be closed by this PR or not (which it is only getting unblocked by, not being closed)
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.
Add External API for DevNet Info Export
Summary
Implements a versioned, stable JSON schema for exporting DevNet state to external tools and scripts. After a successful
foc-devnet start, adevnet-info.jsonfile is created containing all necessary information to interact with the running cluster.Changes
New Module:
src/external_api/VersionedDevnetInfowith schema version trackingDevnetInfoV1containing:Integration
~/.foc-devnet/run/<run_id>/devnet-info.json~/.foc-devnet/state/latest/devnet-info.jsonExamples
examples/read-devnet-info.js- Reads and displays DevNet infoexamples/check-balances.js- Queries on-chain balances using ethers.jsCI Validation
devnet-info.jsonis created after successful startread-devnet-info.jsto ensure examples workOutput Example
{ "version": 1, "info": { "run_id": "26jan20-1622_GoofyNubs", "start_time": "2026-01-27T...", "users": [{"name": "USER_1", "evm_addr": "0x...", ...}], "contracts": {"mockusdfc_addr": "0x...", "endorsements_addr": "0x...", ...}, "lotus": {"host_rpc_url": "http://localhost:5701/rpc/v1", ...} } }