morph: Remove name transformer in morph policy client #32

Merged
fyrchik merged 1 commits from aarifullin/policy-engine:fix/remove_container_name_transformer into master 2023-12-14 12:22:55 +00:00
Collaborator

It is not required to transform long names because container chains will be added by container ID but not by a resource name.
Adding chains by converted CID to a resource name was a mistake left after first prototype implementations.

It is not required to transform long names because container chains will be added by container ID but not by a resource name. Adding chains by converted CID to a resource name was a mistake left after first prototype implementations.
aarifullin requested review from storage-services-committers 2023-12-12 15:54:09 +00:00
aarifullin requested review from storage-services-developers 2023-12-12 15:54:11 +00:00
aarifullin requested review from storage-core-committers 2023-12-12 15:54:14 +00:00
aarifullin requested review from storage-core-developers 2023-12-12 15:54:18 +00:00
aarifullin force-pushed fix/remove_container_name_transformer from e2573c563e to def9032615 2023-12-12 18:56:57 +00:00 Compare
dstepanov-yadro approved these changes 2023-12-13 08:06:13 +00:00
fyrchik approved these changes 2023-12-13 09:19:51 +00:00
Poster
Collaborator

@TrueCloudLab/storage-core-developers

@TrueCloudLab/storage-services-developers

The maximum key length for a contract storage is 64 and storageKey is <'n'/'c'/'i'> + <cid> + <name>

Entity kind is 1 byte long
CID can have 45 characters in base58: GCrGDRmQL4xTFnt2R5byeCiQX4fTbJ7ZR1xyV7hXGPZT
So, 46 bytes are already reserved

-> 18 can be used to name a chain in the policy contract.

Let's look at prefixedChainName.

func prefixedChainName(name chain.Name, chainID chain.ID) []byte {
	return []byte(strings.ToLower(fmt.Sprintf("%s:%s", name, chainID)))
}

So, chains are named with prefix like ingress:some_chain_id and we list chains for a target with prefix ingress.

It means we can use only 10 characters to name chains. WDYT?

@TrueCloudLab/storage-core-developers @TrueCloudLab/storage-services-developers The maximum key length for a contract storage is `64` and [storageKey](https://git.frostfs.info/TrueCloudLab/frostfs-contract/src/branch/master/policy/policy_contract.go#L77) is `<'n'/'c'/'i'> + <cid> + <name>` Entity kind is `1` byte long `CID` can have `45` characters in base58: `GCrGDRmQL4xTFnt2R5byeCiQX4fTbJ7ZR1xyV7hXGPZT` So, `46` bytes are already reserved `-> 18` can be used to name a chain in the policy contract. Let's look at [prefixedChainName](https://git.frostfs.info/TrueCloudLab/policy-engine/src/branch/master/pkg/morph/policy/policy_contract_storage.go#L86). ```go func prefixedChainName(name chain.Name, chainID chain.ID) []byte { return []byte(strings.ToLower(fmt.Sprintf("%s:%s", name, chainID))) } ``` So, chains are named with prefix like `ingress:some_chain_id` and we [list](https://git.frostfs.info/TrueCloudLab/policy-engine/src/branch/master/pkg/morph/policy/policy_contract_storage.go#L100) chains for a target with prefix `ingress`. It means we can use only **10** characters to name chains. WDYT?

For CID we may use raw byte array, there is no requirement to have human-readable keys in contract.
Another possibility to increase useful key size is to add indirection: store CID -> 4-byte ID mapping and start all keys with 4-byte ID.
This can be done without changing contract interface.

For CID we may use raw byte array, there is no requirement to have human-readable keys in contract. Another possibility to increase useful key size is to add indirection: store `CID -> 4-byte ID` mapping and start all keys with 4-byte ID. This can be done without changing contract interface.
Poster
Collaborator

For CID we may use raw byte array, there is no requirement to have human-readable keys in contract.
Another possibility to increase useful key size is to add indirection: store CID -> 4-byte ID mapping and start all keys with 4-byte ID.
This can be done without changing contract interface.

Could you clarify your idea, please:

"start all keys with" sounds like you suggest to cut the prefix from CID. Am I right?

> For CID we may use raw byte array, there is no requirement to have human-readable keys in contract. > Another possibility to increase useful key size is to add indirection: store `CID -> 4-byte ID` mapping and start all keys with 4-byte ID. > This can be done without changing contract interface. Could you clarify your idea, please: "start all keys with" sounds like you suggest to cut the prefix from CID. Am I right?
acid-ant approved these changes 2023-12-14 06:20:35 +00:00

@aarifullin cutting prefix is an option, but in contract we can have u32 numbers incrementing from 0, so that they will definitely be different.

@aarifullin cutting prefix is an option, but in contract we can have u32 numbers incrementing from 0, so that they will definitely be different.
dkirillov approved these changes 2023-12-14 07:56:54 +00:00
fyrchik approved these changes 2023-12-14 12:22:43 +00:00
fyrchik merged commit 62ea96b82c into master 2023-12-14 12:22:54 +00:00
Sign in to join this conversation.
There is no content yet.