Shorten policy contract keys #61

Closed
opened 2023-12-15 10:11:35 +00:00 by alexvanin · 1 comment
Owner

Contract storage key has 65 byte limit. Proxy contract store CID and namespaces in the key. Both are almost hitting key limit and therefore reducing possible useful information that can be stored here.

Note


Length of AWS account name is up to 50 symbols: link. Namespaces are briefly matched with AWS accounts.

Describe the solution you'd like

In TrueCloudLab/policy-engine#32 (comment) @fyrchik suggested to use numerical ID to encode and decode Container IDs. This approach can be applied for namespaces as well.

  1. Create numerical index variables for Container IDs and Namespace during contract deployment
  2. On every write operation, find Container ID and Namespace in the policy contract storage
  3. If no value found, update contract storage and update indices.

Describe alternatives you've considered

Store useful metadata in the storage value instead of the storage key.

Additional context

Issue: multiple transaction with same new CID or namespace potentially can produce FAULT state due to invalid GAS calculation. However this should not be the case here, because first transaction is always more expensive, so in the worst case scenario secondary transactions will pay a bit more than they should, but execution will not fail.

## Is your feature request related to a problem? Please describe. Contract storage key has 65 byte limit. Proxy contract store CID and namespaces in the key. Both are almost hitting key limit and therefore reducing possible useful information that can be stored here. > **Note** > Length of AWS account name is up to 50 symbols: [link](https://docs.aws.amazon.com/organizations/latest/APIReference/API_CreateAccount.html#API_CreateAccount_RequestSyntax). Namespaces are briefly matched with AWS accounts. ## Describe the solution you'd like In https://git.frostfs.info/TrueCloudLab/policy-engine/pulls/32#issuecomment-29034 @fyrchik suggested to use numerical ID to encode and decode Container IDs. This approach can be applied for namespaces as well. 1) Create numerical index variables for Container IDs and Namespace during contract deployment 2) On every write operation, find Container ID and Namespace in the policy contract storage 3) If no value found, update contract storage and update indices. ## Describe alternatives you've considered Store useful metadata in the storage value instead of the storage key. ## Additional context Issue: multiple transaction with same *new* CID or namespace potentially can produce FAULT state due to invalid GAS calculation. However this should not be the case here, because first transaction is always more expensive, so in the worst case scenario secondary transactions will pay a bit more than they should, but execution will not fail.
aarifullin self-assigned this 2023-12-15 12:19:47 +00:00
Member

Solved by #71

Solved by https://git.frostfs.info/TrueCloudLab/frostfs-contract/pulls/71
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-contract#61
No description provided.