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

Feat/add big objects support for meta on chain #3063

Merged
merged 6 commits into from
Dec 28, 2024

Conversation

carpawell
Copy link
Member

@carpawell carpawell commented Dec 23, 2024

Blocked by #3044.

Copy link

codecov bot commented Dec 23, 2024

Codecov Report

Attention: Patch coverage is 64.10256% with 14 lines in your changes missing coverage. Please review.

Project coverage is 21.96%. Comparing base (7ac9947) to head (8ebd425).
Report is 19 commits behind head on master.

Files with missing lines Patch % Lines
pkg/services/object/put/distributed.go 0.00% 10 Missing ⚠️
pkg/network/transport/object/grpc/replication.go 66.66% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3063      +/-   ##
==========================================
- Coverage   22.36%   21.96%   -0.40%     
==========================================
  Files         793      797       +4     
  Lines       58713    59852    +1139     
==========================================
+ Hits        13130    13149      +19     
- Misses      44682    45800    +1118     
- Partials      901      903       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

carpawell added a commit to nspcc-dev/neofs-contract that referenced this pull request Dec 23, 2024
Follows nspcc-dev/neofs-node#3063.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
carpawell added a commit to nspcc-dev/neofs-contract that referenced this pull request Dec 23, 2024
Follows nspcc-dev/neofs-node#3063.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
carpawell added a commit to nspcc-dev/neofs-contract that referenced this pull request Dec 23, 2024
Follows nspcc-dev/neofs-node#3063.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
carpawell added a commit to nspcc-dev/neofs-contract that referenced this pull request Dec 23, 2024
Follows nspcc-dev/neofs-node#3063.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
@@ -206,6 +206,12 @@ func objectFromMessage(gMsg *objectGRPC.Object) (*object.Object, error) {
}

func (s *Server) metaInfoSignature(o object.Object) ([]byte, error) {
firstObj, _ := o.FirstID()
if firstObj.IsZero() && o.HasParent() && o.SplitID() == nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

last operand is inobvious to me. How about create a helper func for this? U check this condition twice here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this differs split V1. in the engine it is required to be possible handle both schemes. in fact, it should be impossible to meet it here, since meta-on-chain containers are new containers, so not V1 is expected but still i would like to see this check

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check is OK, i just suggest to share and doc it. Again, if i'd need to check whether object is first or not, i'd miss split ID check

Copy link
Member Author

@carpawell carpawell Dec 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd miss split ID check

as i said, this check is the only thing that differs v1 from v2. but if a drop code is requested i usually support it, dropped

@@ -38,14 +38,46 @@ const (
// "validuntil": last valid block number for meta information
//
// Last valid epoch is object's creation epoch + 10.
func EncodeReplicationMetaInfo(cID cid.ID, oID, firstPart oid.ID, pSize uint64,
deleted, locked []oid.ID, vub uint64, magicNumber uint32) []byte {
func EncodeReplicationMetaInfo(o object.Object, vub uint64, magicNumber uint32) ([]byte, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

callers aint happy about this change. One was completely okay w/o an error, while the second forced to do multiple decoding. If u wanna decrease prm num, typedef a structure

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typedef a structure

object.Object is such a struct, why not?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

object has no deleted, locked []oid.ID fields

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

object has no deleted, locked []oid.ID fields

yes, but object.Object is enough to get this information and it will be always gotten like this

this commit was already dropped anyway

if err != nil {
return nil, fmt.Errorf("encoding metadata")
}
secondMeta, _ := objectcore.EncodeReplicationMetaInfo(o, secondBlock, s.mNumber)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one more proof of the refactoring dubiousness

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just a context of this func: you need to repeat the same encoding 3 times, error happens for all or does not happen at all

ok, it is easier to drop this commit

deleted, locked []oid.ID, vub uint64, magicNumber uint32) []byte {
kvs := []stackitem.MapElement{
kv(networkMagicKey, magicNumber),
kv(cidKey, cID[:]),
kv(oidKey, oID[:]),
kv(firstPartKey, firstPart[:]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont suggest to push missing firstPart as zero ID, it's a reserved invalid value. Push emptiness instead: this will match the zero length condition from ur contract change nspcc-dev/neofs-contract@416936f

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added optional fields support. firstPart is now one of them

@carpawell carpawell changed the title Feat/add first object in meta data Feat/add big objects support for meta on chain Dec 25, 2024
Not sure what made me go this way, there is no reason for it.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
@carpawell carpawell force-pushed the feat/add-first-object-in-meta-data branch from 3a07bdd to 0265840 Compare December 25, 2024 16:32
Should have been done in ae6e37d.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
@carpawell carpawell force-pushed the feat/add-first-object-in-meta-data branch from 0265840 to 983b38b Compare December 25, 2024 16:42
carpawell added a commit to nspcc-dev/neofs-contract that referenced this pull request Dec 25, 2024
Follows nspcc-dev/neofs-node#3063.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
carpawell added a commit to nspcc-dev/neofs-contract that referenced this pull request Dec 25, 2024
Follows nspcc-dev/neofs-node#3063.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
// "validUntil": last valid block number for meta information
// "network": network magic
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better keep them alphabetically sorted (in optional/non-optional groups).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in optional/non-optional groups)

👍

alphabetically sorted

👎. Excessive load to the dev brain "where to place new key?". And i like how they are grouped by type currently

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better keep them alphabetically sorted

well, my suggestion is not a random order, it was an intention. i grouped it like "logically" or as @cthulhu-rider said, currently, it is by type too. do you have any pros as to why it is better to sort them? new value will be harder to add, and alphabet sorting has no advantages (or change my mind)

pkg/core/object/replicate.go Show resolved Hide resolved
@@ -59,6 +62,9 @@ func EncodeReplicationMetaInfo(cID cid.ID, oID, firstPart, previousPart oid.ID,
if len(locked) > 0 {
kvs = append(kvs, oidsKV(lockedKey, locked))
}
if typ != objectsdk.TypeRegular {
kvs = append(kvs, kv(typeKey, uint32(typ)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notice that tombstone/lock can be detected by deleted/locked already. But this covers more things, so OK.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean lock type with some non-empy deleted should be an error (panic in fact) in this func?

validUntilKey = "validUntil"
networkMagicKey = "network"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

motivated movement?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the same as in #3063 (comment)

ok-ok, waste of time, more code to review, etc. but i feel better this way

// "validUntil": last valid block number for meta information
// "network": network magic
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in optional/non-optional groups)

👍

alphabetically sorted

👎. Excessive load to the dev brain "where to place new key?". And i like how they are grouped by type currently

kv(networkMagicKey, magicNumber),
}

if len(deleted) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd split unit tests into min and full cases. And include fields added in the following commits

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -59,6 +62,9 @@ func EncodeReplicationMetaInfo(cID cid.ID, oID, firstPart, previousPart oid.ID,
if len(locked) > 0 {
kvs = append(kvs, oidsKV(lockedKey, locked))
}
if typ != objectsdk.TypeRegular {
kvs = append(kvs, kv(typeKey, uint32(typ)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

although typ is uint32, lets to cast to int32. It will be int32 soon (im also unhappy bout this, but wcyd). We'll most likely forget to change conversion later

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Map type allows to be flexible and not rely on positional data interpretation,
so there is no need to put empty `deleted` or `locked` arrays for objects that
do not delete or lock anything.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
@carpawell carpawell force-pushed the feat/add-first-object-in-meta-data branch 2 times, most recently from fb4685d to 858354c Compare December 28, 2024 14:52
@carpawell carpawell force-pushed the feat/add-first-object-in-meta-data branch from 858354c to ce1096b Compare December 28, 2024 15:47
@carpawell carpawell force-pushed the feat/add-first-object-in-meta-data branch from ce1096b to fb345bf Compare December 28, 2024 16:30
@carpawell carpawell force-pushed the feat/add-first-object-in-meta-data branch from fb345bf to cde8332 Compare December 28, 2024 16:33
A first object has its own OID to simplify detection of such objects by indexed
meta-information. Closes #2935.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
It is optional since one of the types (REGULAR) is the most expected, and its
missing can be recognizable.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
An omission from ae6e37d: check all 3
signatures and slice them correctly.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
@carpawell carpawell force-pushed the feat/add-first-object-in-meta-data branch from cde8332 to 8ebd425 Compare December 28, 2024 16:36
@roman-khimov roman-khimov merged commit b39e7b8 into master Dec 28, 2024
19 of 22 checks passed
@roman-khimov roman-khimov deleted the feat/add-first-object-in-meta-data branch December 28, 2024 17:50
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.

3 participants