-
Notifications
You must be signed in to change notification settings - Fork 597
refactor!: prohibiting static calls via non-static interface #18398
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -827,13 +827,27 @@ pub contract AvmTest { | |
| arg_a: Field, | ||
| arg_b: Field, | ||
| ) -> Field { | ||
| AvmTest::at(address).add_args_return(arg_a, arg_b).view(context) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test here relies on the static call but in other places another ugly stale monstrosity expects the called function to b e non-view so I hack around this by directly using the context thingy. |
||
| let selector = | ||
| comptime { FunctionSelector::from_signature("add_args_return(Field,Field)") }; | ||
| context.static_call_public_function( | ||
| address, | ||
| selector, | ||
| [arg_a, arg_b].as_slice(), | ||
| GasOpts::default(), | ||
| )[0] | ||
| } | ||
|
|
||
| // Indirectly call_static `set_storage_single`. Should revert since it's accessing self.storage. | ||
| #[external("public")] | ||
| fn nested_static_call_to_set_storage() { | ||
| AvmTest::at(self.address).set_storage_single(20).view(self.context); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test here relies on the static call but in other places another ugly stale monstrosity expects the called function to b e non-view so I hack around this by directly using the context thingy. |
||
| let selector = comptime { FunctionSelector::from_signature("set_storage_single(Field)") }; | ||
| let args = [20 as Field]; | ||
| let _ = self.context.static_call_public_function( | ||
| self.address, | ||
| selector, | ||
| args.as_slice(), | ||
| GasOpts::default(), | ||
| ); | ||
| } | ||
|
|
||
| #[external("public")] | ||
|
|
||
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.
Not closing this issue with this PR as there are more subtasks TODO