WIP: example class hash forward.#10163
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
| impl CounterClassHash = | ||
| super::counter_contract::__class_hash__::ForwardingClassHashImpl<ContractState>; | ||
|
|
||
| #[abi(embed_v0)] | ||
| impl ForwardedImpl = super::ICounterContractForwardImpl<ContractState>; |
There was a problem hiding this comment.
ideally we'd like not to have to specify both of those - would that be possible?
There was a problem hiding this comment.
you would ALWAYS have to state both - these are completely independent concepts.
you could (and mostly should) do it in a oneliner.
#[abi(embed_v0)]
impl ForwardedImpl =
// The forwarded trait.
super::ICounterContractForwardImpl<
ContractState,
// Where is it forwarded to.
super::counter_contract::__class_hash__::ForwardingClassHashImpl<ContractState>,
>;
orizi
left a comment
There was a problem hiding this comment.
@orizi made 1 comment.
Reviewable status: 0 of 2 files reviewed, 1 unresolved discussion (waiting on Arcticae).
| impl CounterClassHash = | ||
| super::counter_contract::__class_hash__::ForwardingClassHashImpl<ContractState>; | ||
|
|
||
| #[abi(embed_v0)] | ||
| impl ForwardedImpl = super::ICounterContractForwardImpl<ContractState>; |
There was a problem hiding this comment.
you would ALWAYS have to state both - these are completely independent concepts.
you could (and mostly should) do it in a oneliner.
#[abi(embed_v0)]
impl ForwardedImpl =
// The forwarded trait.
super::ICounterContractForwardImpl<
ContractState,
// Where is it forwarded to.
super::counter_contract::__class_hash__::ForwardingClassHashImpl<ContractState>,
>;

Summary
Adds a test and accompanying test data for static interface forwarding via the compile-time class-hash feature. A new
static_forwarding_contract.cairoexample demonstrates astatic_proxycontract that forwards allICounterContractcalls as library calls tocounter_contract's class using the compile-time-injectedForwardingClassHashImpl— requiring no stored class hash and no constructor. The newstatic_forwarding_compilestest verifies that the proxy compiles successfully and exposes exactly the two forwarded external entry points.Type of change
Please check one:
Why is this change needed?
The compile-time class-hash /
forward-implfeature lacked test coverage for the static forwarding pattern. Without a test, regressions in the two-pass Sierra injection or theForwardingClassHashImplgeneration could go undetected.What was the behavior or documentation before?
There was no test exercising static proxy forwarding using
counter_contract::__class_hash__::ForwardingClassHashImpl. Only the dynamic proxy pattern (with a stored class hash and constructor) was covered.What is the behavior or documentation after?
A
static_forwarding_compilestest compiles thestatic_proxycontract and asserts that:ICounterContract).sanity_check().Related issue or discussion (if any)
N/A
Additional context
The
static_proxycontract uses the#[feature("forward-impl")]attribute and delegates tocounter_contract's class hash, which is injected by the two-pass compilation incompile_path. This is distinct from the existingclass_hash_injection_compilestest, which only verifies deterministic recompilation of the injected hash, not the forwarding behavior itself.