Conversation
update_contract_meta already required admin authorization: it calls require_auth() on the caller and compares it against the stored admin, panicking with OnlyAdmin otherwise, and test_update_contract_meta_non_admin covered that. The issue's premise that any caller can rewrite the staking position metadata does not hold against the current code, so the authorization check is left as it is and covered by additional tests rather than reimplemented. What was genuinely missing is any bound on what the admin can store. The description, icon_url, and website strings were written to instance storage at whatever length was supplied, so a single update could commit the contract to unbounded storage rental. Reject any field longer than MAX_METADATA_LEN (256 bytes) with a new MetadataUriTooLong error. The bound is inclusive, so a URI of exactly 256 bytes is accepted. The emitted event carried only the ContractMetadata struct, so a subscriber wanting the new URI had to destructure it. Lead the event data with icon_url, keeping the full struct behind it so existing consumers continue to work. Also add the missing `Events` import to the test module, without which the crate's tests did not compile at all. Tests cover a non-admin update being rejected and leaving prior metadata intact, a URI at exactly the limit being accepted, each of the three fields being rejected one byte over, an oversized update leaving state untouched, and the update emitting an event. 25 tests pass (17 pre-existing, 8 new).
|
@0xDeon Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
Author
|
Superseded by #1068, which combines this with the other three Soroban contract PRs into a single branch. Commit and tests carried over unchanged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #987
The authorization check already exists
update_contract_metaalready required admin authorization onmain: it callsrequire_auth()on the caller and compares against the stored admin, panicking withOnlyAdminotherwise.test_update_contract_meta_non_adminalready covered it.The issue's premise that any caller can rewrite staking position metadata does not hold against the current code, so the authorization check is left as-is and covered by additional tests rather than reimplemented. Flagging this explicitly in case the issue was written against an older revision.
What was genuinely missing
description,icon_url, andwebsitewere written to instance storage at whatever length was supplied, so a single update could commit the contract to unbounded storage rental. Any field longer thanMAX_METADATA_LEN(256 bytes) is now rejected with a newMetadataUriTooLongerror. The bound is inclusive, so exactly 256 bytes is accepted.ContractMetadatastruct, so a subscriber wanting the new URI had to destructure it. The data now leads withicon_url, keeping the full struct behind it so existing consumers continue to work.Eventsimport to the test module, without which the crate's test target failed to build.Test evidence
25 tests pass (17 pre-existing, 8 new), covering a non-admin update being rejected and leaving prior metadata intact, a URI at exactly the limit, each field rejected one byte over, an oversized update leaving state untouched, and the event being emitted.
Note on the
contracts/workspaceThis workspace has a pre-existing, unrelated dependency break:
soroban-env-host 22.1.3fails to compile againsted25519-dalek 3.0.0(an unpinned transitive bump), which blocks all test builds there. I pinned dalek to 2.2.0 locally to run the tests but deliberately did not commit that lockfile change, since it is a separate concern from this issue. Worth its own PR.The issue body says
Closes #83, but this repo's issue is #987; the template number appears stale.