Skip to content
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

Missing Limitation for Storage Size on Integration Testing for set_contract_storage() #1961

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

ramirez7358
Copy link

@ramirez7358 ramirez7358 commented Oct 30, 2023

Summary

Closes #1960

  • [n] y/n | Does it introduce breaking changes?
  • [n] y/n | Is it dependant on the specific version of cargo-contract or pallet-contracts?

Description

Issue Description

The storage in the integration environment does not have the same limitation as in the e2e environment. In the e2e environment, the storage size is limited by 16380 bytes.

Issue Documentation & Test Case

https://github.com/CoinFabrik/on-ink-integration-tests/tree/main/test-cases/set-contract-storage

Current Status

Missing Limitation Implemented. Test Cases Passed. Pull Request Performed to Corresponding Repository.

Implementation Notes

The function set_contract_storage() sets the storage in a contract. There was a missing validation in integration tests that was present in e2e. This validation checked that the size of the storage set did not exceed 16380 bytes.

We added a validation to the function set_contract_storage() in integration tests that checks the size of the input value against the same limit set in e2e test: 16380 bytes. In case this limit is exceeded, a panic is raised with the message: "Value too large to be stored in contract storage, maximum size is {} bytes".

Updated Documentation

We updated the original documentation of this issue in our repository, adding the section Update on Correcting this Issue and informing of the correction.

There is no necessary update to the associated documentation: ink_env set_contract_storage.

Testing Guide

In the directory integration-tests/set_contract_storage of the target directory, we include in our pull request a test case showing that the observed implementation difference has been corrected. Note that this test is different from the original test case in our repository, which showed the difference.

In order to run the integration tests run:
cargo test

In order to run the e2e tests run:
cargo test -–features e2e-tests

These tests are run separately because we do not need to compare their results.

Checklist before requesting a review

  • My code follows the style guidelines of this project
  • I have added an entry to CHANGELOG.md
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • Any dependent changes have been merged and published in downstream modules

bramirezcf and others added 8 commits November 3, 2023 12:02
Changed the limit to encoded_value.len() + encoded_key.len() > 2**14
try_insert() and try_set() were ignoring that insert() and set() increase the
length of the key by 4. After making the off-chain set_contract_storage()
respect the size limit, this was causing some tests to fail. The tests were
updated to test the correct limits.
@cmichi
Copy link
Collaborator

cmichi commented Nov 14, 2024

@ramirez7358 Could you merge master into your PR and resolve the conflicts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The function set_contract_storage in integration test it's missing a size check.
5 participants