-
Notifications
You must be signed in to change notification settings - Fork 72
feat: add Proxy-UUPS #729
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
feat: add Proxy-UUPS #729
Conversation
✅ Deploy Preview for contracts-stylus canceled.
|
Blocked by OpenZeppelin/stylus-test-helpers#104 |
This isn't a blocker per se, we can still test proxies with e2e tests; we can even consider e2e tests to be more reliable, given how fragile proxy logic is. |
Co-authored-by: Daniel Bigos <[email protected]>
added a couple of missing constructor-related unit tests necessary for #729
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.
Great job @0xNeshi 👏
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.
Good job @0xNeshi !
I feel we're good to merge as it is while addressing todo's later.
Just a few notes I have
contracts/src/proxy/erc1967/utils.rs
Outdated
// TODO: enable this test when we have a way to test for unknown selector | ||
// errors | ||
// | ||
// #[motsu::test] | ||
// fn upgrade_to_and_call_with_delegate_call_failure( |
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 this one should work:
#[motsu::test]
fn upgrade_to_and_call_with_delegate_call_failure(
contract: Contract<TestContract>,
implementation: Contract<Implementation>,
alice: Address,
) {
let data = function_selector!("nonExistentFunction").to_vec();
let err = contract
.sender(alice)
.test_upgrade_to_and_call(
implementation.address(),
data.clone().into(),
)
.expect_err("should fail when delegate call fails");
let vec = format!(
"function not found for selector '{0}' and no fallback defined",
u32::from_be_bytes(TryInto::try_into(data).unwrap())
)
.as_bytes()
.to_vec();
assert_eq!(
err,
Error::FailedCallWithReason(address::FailedCallWithReason {
reason: stylus_sdk::call::Error::Revert(vec).encode().into()
})
.encode(),
);
}
And we should do it cause of this change in motsu. We replace default stylus-sdk vec![]
error (when selector not found) with ours. We need to think how to change motsu to make this test look better
Resolves #14 Implementing `StorageSlot` requires our library depend directly on `stylus-test` feature flag to properly instantiate [VM](https://docs.rs/stylus-sdk/0.9.0/stylus_sdk/host/struct.VM.html) (see [source code](https://github.com/OffchainLabs/stylus-sdk-rs/blob/b7310ef87d05182a946555ae8754f13c97c21c8b/stylus-sdk/src/host/mod.rs)). But due to how this feature is enabled and what `cargo-stylus` operations depend on it, it causes great difficulty in synchronizing all of the requirements to make everything work as expected (and as before). This it made it necessary to make some changes to make our CI pass, but it unfortunately still made `export-abi` not work at all. We may find a way to address this in a maintainable way that makes export-abi work before SDK v0.10.0, but for now this will do. <!-- Before merging the pull request all of the following must be completed. Feel free to submit a PR or Draft PR even if some items are pending. Some of the items may not apply. --> - [x] Tests - [x] Documentation - [x] Changelog --------- Co-authored-by: Nenad <[email protected]>
Resolves #14
Implementing
StorageSlot
requires our library depend directly onstylus-test
feature flag to properly instantiate VM (see source code). But due to how this feature is enabled and whatcargo-stylus
operations depend on it, it causes great difficulty in synchronizing all of the requirements to make everything work as expected (and as before).This it made it necessary to make some changes to make our CI pass, but it unfortunately still made
export-abi
not work at all.We may find a way to address this in a maintainable way that makes export-abi work before SDK v0.10.0, but for now this will do.
PR Checklist