Software Architecture For Dynamic Contract Composability#48
Software Architecture For Dynamic Contract Composability#48JosephDenman wants to merge 1 commit intomainfrom
Conversation
Plugin Test Results 1 files 3 suites 1s ⏱️ Results for commit 2ebb622. ♻️ This comment has been updated with latest results. |
Compactc E2E Tests Results2 707 tests - 12 293 2 707 ✅ - 12 292 5m 13s ⏱️ - 22m 24s Results for commit 2ebb622. ± Comparison against base commit ade0471. This pull request removes 15000 and adds 2707 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
E2E test resultsbuild: Run #180
🎉 All tests passed! |
Flaky Rate
No current tests have flaky rates to display ✨ Github Test Reporter by CTRF 💚 Flaky Rate
No current tests have flaky rates to display ✨ Github Test Reporter by CTRF 💚 |
|
Please remove CoIP-1 from this PR, it logically belongs to the CoIP-1 PR and not some other CoIP. If you are proposing changes to CoIP-1, please do it in the CoIP-1 PR, otherwise it's impossible to tell what's going on. The TSC will approve CoIP-1 before we begin the CoIP process. The proposed CoIP should be file name |
|
A few high-level comments:
|
Signed-off-by: JosephDenman <joseph.denman@iohk.io>
33c62b2 to
2ebb622
Compare
E2E test resultsbuild: Run #182
🎉 All tests passed! |
|
"Cross-contract call" might more clearly distinguish these kinds of calls from ordinary calls within a contract, especially in distinguishing a call to another instance of the same contract from a call within the same contract. Don't we already have contract interfaces? Isn't that what the existing contract types are? |
| The ZKIR format changes from v3.0 to v3.1 (minor version bump): | ||
|
|
||
| - `IrSource` adds `arg_alignment` and `return_val_alignment` fields (already present in current code, now required) | ||
| - `Impact` instruction changes from `inputs: Vec<Fr>` to `ops: Vec<SymbolicOp>` plus `field_count: u64` |
There was a problem hiding this comment.
Doesn't this change require a major version bump?
There was a problem hiding this comment.
Adding specific fields to specific structs is out of scope for a CoIP feature design proposal. If we want to we can provide a reference implementation as a separate artifact that goes along with the proposal.
As a practical matter, a proposal accepted by the Minokawa TSC can't actually mandate a specific implementation in another component anyway.
So this should be removed from the proposal, I think.
| - `Impact` instruction changes from `inputs: Vec<Fr>` to `ops: Vec<SymbolicOp>` plus `field_count: u64` | ||
| - New `ContractCall` instruction added | ||
|
|
||
| Existing v3.0 ZKIR files will fail to parse with the v3.1 interpreter. This is acceptable because ZKIR is not stored on-chain today—it lives in the compiled JavaScript bundle. When users upgrade the compiler, they get new ZKIR. No migration needed. |
There was a problem hiding this comment.
That is a concern, because it renders contracts implemented with the ZKIR v3.0 entirely incompatible with the new model with no path for enablement. Providing a backwards compatibility in the ZKIR would still enable adding missing information in the future by means of contract maintenance actions.
|
|
||
| * A malicious contract could implement an interface correctly but behave unexpectedly. Callers should only interact with trusted or audited contracts. Interfaces provide type safety, not behavioral safety. | ||
| * Reentrancy shouldn't be any more of a concern than it was when we planned on implementing only static contract calls. | ||
| * How are costs attributed across caller and callee? Who pays? |
There was a problem hiding this comment.
Pays the user or a some other fee-paying entity. Fee payment almost always happens after all contract calls are wrapped in a transaction.
There was a problem hiding this comment.
The good news is that transaction fees are really outside the language's control so we don't need to have a solution to this, just raise the question for the people who can solve it.
| * Reentrancy shouldn't be any more of a concern than it was when we planned on implementing only static contract calls. | ||
| * How are costs attributed across caller and callee? Who pays? | ||
| * What happens when the ZKIR format changes? How do old contracts interoperate with new ones? | ||
| * How do we handle maintenance updates for contracts? These can modify circuits and therefore ZKIR. |
There was a problem hiding this comment.
They need to enable changing whole triplet of verifier key, prover key hash and ZKIR at once
|
|
||
| The ZKIR interpreter currently has two modes: `preprocess` (verify witness consistency) and `circuit` (generate ZK constraints). These will be updated to handle `ContractCall` and symbolic Impact, but their core logic stays the same. | ||
|
|
||
| The main addition is a new **interpret mode** (rehearsal). This mode actually executes the circuit to compute witnesses, `Effects`, and proof pre-images: |
There was a problem hiding this comment.
While it makes perfect sense from a purely functional perspective - do we know if the interpretation mode would be fast enough to not become an obstacle from UX/performance standpoint?
There was a problem hiding this comment.
We don't know, but I don't believe it will. It's a separate linear pass over the ZKIR representation, in addition to the one needed to make the proof (we might actually be able to combine the two passes), and I suspect that the proving time dominates the interpretation time (barring time spent executing witnesses, which might not even terminate :) but we have to do that anyway).
We could use that term, as well.
Yes, I think so. They're probably missing features and have some open questions around subtyping (structural or nominal) and explicit vs. implicit "implementation" of a contract type by a contract. I'll try to write this up using contract types. |
Adds CoIP 1 to replace #36 and facilitate discussion.