WIP: Store hashed entity name in policy contract #87

Closed
alexvanin wants to merge 3 commits from alexvanin/frostfs-contract:after-ug into master
Owner
No description provided.
alexvanin added 3 commits 2024-04-15 06:13:50 +00:00
[#xxxx] policy: Add constants for more targets
Some checks failed
DCO action / DCO (pull_request) Failing after 59s
Tests / Tests (1.21) (pull_request) Successful in 1m43s
Tests / Tests (1.22) (pull_request) Successful in 1m45s
5b0ea5e0a8
Signed-off-by: Alex Vanin <a.vanin@yadro.com>
Namespace is a part of entity name, so it should be hashed
in order to fit neo-go storage key.

Signed-off-by: Alex Vanin <a.vanin@yadro.com>
[#xxxx] policy: Test very large entity name
Some checks failed
DCO action / DCO (pull_request) Failing after 1m1s
Tests / Tests (1.21) (pull_request) Successful in 1m19s
Tests / Tests (1.22) (pull_request) Successful in 1m23s
4022e3b6c3
Signed-off-by: Alex Vanin <a.vanin@yadro.com>
fyrchik reviewed 2024-04-15 06:34:14 +00:00
@ -105,6 +108,9 @@ func storageKey(prefix Kind, counter int, name []byte) []byte {
}
func mapKey(kind Kind, name []byte) []byte {
if len(name) > 0 {
Owner

Why do we need this check, can it be false?

Why do we need this check, can it be false?
Author
Owner

Yes, ListTargets uses mapKey with empty name to iterate all storage keys based on kind prefix.

Yes, `ListTargets` uses `mapKey` with empty name to iterate all storage keys based on kind prefix.
Author
Owner

We've decided to avoid this change for v0.19.X releases.
I see an issue with proposed approach: ListTargets method becomes useless. It returns hashed sha256(entityName), and this info cannot be reused later. So I see couple of options:

  1. Remove ListTargets and all use-cases with this method (are there any?)
  2. Rework this PR and store tuple of entityKind and entityName as a value in contract, so it can be returned in ListTargets
  3. Something else?
We've decided to avoid this change for `v0.19.X` releases. I see an issue with proposed approach: `ListTargets` method becomes useless. It returns hashed `sha256(entityName)`, and this info cannot be reused later. So I see couple of options: 1) Remove `ListTargets` and all use-cases with this method (are there any?) 2) Rework this PR and store tuple of `entityKind` and `entityName` as a value in contract, so it can be returned in `ListTargets` 3) Something else?
Owner

Option 2 looks ok to me
So we have mappings:

'v' + entityKind +  sha256(name) -> name
'k' + sha256(name) -> 8-byte id

We can iterate over the first to get a list.
Frankly, I would remove ListTargets unless it is really needed.

Option 2 looks ok to me So we have mappings: ``` 'v' + entityKind + sha256(name) -> name 'k' + sha256(name) -> 8-byte id ``` We can iterate over the first to get a list. Frankly, I would remove `ListTargets` unless it is really needed.
Owner

Closing stale PR, feel free to reeopen.

Closing stale PR, feel free to reeopen.
fyrchik closed this pull request 2024-12-12 12:39:57 +00:00
Some checks failed
DCO action / DCO (pull_request) Failing after 1m1s
Required
Details
Tests / Tests (1.21) (pull_request) Successful in 1m19s
Required
Details
Tests / Tests (1.22) (pull_request) Successful in 1m23s
Required
Details

Pull request closed

Sign in to join this conversation.
No description provided.