Repository navigation
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
|
/run-e2e |
|
E2E status was updated. Follow the current E2E and merge checks on this PR. Detailed diagnostics are available internally. |
danieljrc888
left a comment
There was a problem hiding this comment.
Reviewed at ea97a81. Two things: a merge gate that no code change resolves, and a short list of design points to settle while it waits.
Merge gate (blocking)
Same situation as #123: the base is v0.19-dev, frozen for the v0.6 train until 0.19.0 stable is tagged as part of the Studio v0.123 release in progress. A new top-level export (generate_contract_types) is public API that would ship in 0.19.0 without an rc cycle. It also changes ContractMethod in genlayer_py/types/contracts.py from a plain class to a TypedDict; the fix is right, but it is a behaviour change to an existing exported type on a frozen line. Hold until the next development branch exists and retarget there, or until the repo owner explicitly decides to include it in 0.19.0. The PR body says E2E is advisory and not a merge gate; the freeze is the gate.
What I verified
- Generated bindings forward to
read_contractwith the argument shapes it expects (genlayer_py/contracts/actions.py), and result types match the Python decoder (no JSON-safe conversion exists in this SDK, soCalldataAddress,bytes,dict,listare right). - Names reach the generated source only after
isidentifier/iskeyword/ leading-underscore checks, and keys only throughrepr, so a hostile schema cannot inject code. This matters more here than in the JS generator because the output is imported and executed. _typing.Neverand the rest are fine forrequires-python >= 3.12.
Design points to settle
- Inconsistent with the JS implementation of the same feature (genlayer-js#248, DXP-538). There keyword parameters are optional and write methods are included; here keyword parameters are all required and only views are generated. A contract method with a defaulted keyword argument is callable without it through
client.read_contractbut not through the generated binding. Pick one rule for both SDKs. Since the schema does not expose defaults, optional keyword arguments (omitted from the call when not passed) is the choice that never rejects a valid call. $$key unescaping. The generator treats$$nameas an escaped$namefield and rejects other$keys. I could not find that convention anywhere in this repo. Link the GenVM schema source that defines it, or drop it; inventing an escape rule here means silently mistyping a field if GenVM does something else.- One unsupported name fails the whole contract. A single view method or parameter that fails
_identifierraises for the entire schema. Skipping that method with a comment in the output, or raising only in a strict mode, keeps the generator usable on contracts the author does not control. - Conflict with #123. Both PRs edit
genlayer_py/__init__.py; whichever lands second needs a rebase.
Minor
- The README section is appended after
## License; move it next to the other contract usage docs.
|
Legatus audit: Changes requested (commit ea97a81) Audit of PR #124 (DXP-537): typed contract reads generated from the schemaHead reviewed: The PR adds Checks I ran
Findings (most serious first)
What must change before merge
|
|
Update on design point 1: genlayer-js#248 now makes keyword parameters required as well (558c5fa3), so the two SDKs agree on that rule and the kwargs part of the point is settled. The remaining difference is scope (JS generates writes, this generates reads only), which is fine if the README says so, and it does. Points 2 and 3 and the merge gate are unchanged. |
|
/run-e2e |
|
E2E status was updated. Follow the current E2E and merge checks on this PR. Detailed diagnostics are available internally. |
|
/run-e2e |
|
E2E status was updated. Follow the current E2E and merge checks on this PR. Detailed diagnostics are available internally. |
|
Re-checked at 192b75d. The requested-changes state stays, and this commit widens the scope in a way that makes the freeze concern stronger. New in this commit: New test does network installs inside the unit suite Resolved
Still open
|
|
Legatus audit: Approved (commit 192b75d) Re-audit of PR #124 (DXP-537): typed contract reads generated from the schemaI approve commit Previous findings
Tests
Notes (not blocking)
LEGATUS-TICKET |
|
/run-e2e all |
|
E2E status was updated. Follow the current E2E and merge checks on this PR. Detailed diagnostics are available internally. |
|
/run-e2e |
|
E2E status was updated. Follow the current E2E and merge checks on this PR. Detailed diagnostics are available internally. |
|
Re-reviewed at 2aab8ff. The three code points from my review are addressed:
My review stays as changes requested for two reasons that are not about this code: the base is the frozen One small thing: |
Merge hold
Do not merge into frozen
v0.19-dev/ 0.19.0. Passing tests and advisory E2E do not override this release freeze. Hold until the next development branch exists and retarget there, or until the repository owner explicitly approves inclusion. The currently declared active branch is stillv0.19-dev.Package-wide typing enablement is now separately proposed in #125, with an unreleased compatibility note and a package-wide strict audit/known-issues list. This feature depends on that independently reviewed change. The identical marker/package-data/ContractMethod prerequisite edits remain in this branch so the feature can be tested; merge the prerequisite only when authorized, then rebase this PR so those edits disappear from its diff before merging this feature. The prerequisite reports 373 existing strict errors in 33 SDK files, not a strict-clean SDK. Neither PR is authorized to bypass the freeze.
PR #123 remains open and this PR currently reports MERGEABLE. Both touch
genlayer_py/__init__.py; rebase the second to land and preserve both exports when that happens. There is no current conflict to resolve.Summary
Contract reads currently return generic calldata values even when a schema describes their structure. Add
generate_contract_types(schema, class_name="Contract", strict=False), which emits an importable Python module with typed view methods, public result aliases, and nestedTypedDictrecords. A generatedStorage(client, address).get_balance(owner)exposes schema argument and result types while forwarding through the existing SDK read path.Support GenVM primitive types, records, unions, dictionaries, repeated and fixed arrays. Preserve record field names literally. GenVM's
_repr_typedataclass branch copies field names directly;_escape_dict_propis used for keyword parameters, not these records. Removed the inferred record$$unescaping, so$$namestays$$name.Unsupported method or parameter names now skip only that method, with a safely escaped comment in the generated source.
strict=Truepreserves fail-fast behavior. Invalid class names and unsupported schema types still raiseValueError. Tests cover method, positional-parameter and keyword-parameter names, including newline-containing hostile names.Generated imports use defining modules for strict-compatible exports. The README usage section is alongside the other contract examples, before Key Features and License.
Ticket: https://linear.app/genlayer-labs/issue/DXP-537/generate-contract-types-from-schema
Assumptions
TypedDict, addresses useCalldataAddress, arrays use lists. Fixed-array length is not enforced; element types form a union.client.read_contract.<Class>_<method>_Resultaliases; internal aliases prevent generated-name collisions. Output is deterministic.Validation
uv run pytest tests/unit --disable-warnings -q -m "not testnet": 282 passed, 17 deselected. No wheel builds, network installs, or mypy invocation occur in this unit suite.uv run pytest tests/packaging -m packaging -q: 1 passed. This explicitly builds the wheel, installs it in isolation, verifies the marker is packaged, runs strict mypy on generated code and valid usage, and verifies rejection of an invalid address argument, missing keyword argument, and unknown result field.tests/unitand behind the registeredpackagingmarker. Default pytest runs exclude them; the explicit check fails rather than skips ifuvis absent. README documents its network/uv requirements and command.uv run pytest --collect-only -q: 334 selected, 1 packaging check deselected by default.git diff --checkpass.Advisory E2E is requested separately. The release freeze and prerequisite review are merge gates regardless of its result.