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

container: add object meta notification support #448

Merged
merged 1 commit into from
Dec 3, 2024

Conversation

carpawell
Copy link
Member

Containers now can be created with new put method with one more bool parameter for meta-on-chain feature (TX must still be signed by the Alphabet, and it also must check that container was created with this feature, see nspcc-dev/neofs-api#309). If enabled, new PutObject method allows checking object meta information's signature and producing corresponding notification. Closes #414.

contracts/container/contract.go Show resolved Hide resolved
contracts/container/contract.go Outdated Show resolved Hide resolved
contracts/container/contract.go Outdated Show resolved Hide resolved
contracts/container/contract.go Show resolved Hide resolved
estimatePostfixSize = 10
singleEstimatePrefix = "est"
estimateKeyPrefix = "cnr"
containersWithMetaPrefix = 'm'
Copy link
Contributor

Choose a reason for hiding this comment

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

just a remark

i very like (no) how gofmt makes a 10-line change when one is actually added/changed. Takin bout why linebreaks are good sometimes, and const/var blocks aint

// PutObject registers successful object PUT operation and notifies about
// it. metaInformation must be signed by container nodes according to
// container's placement, see [VerifyPlacementSignatures]. metaInformation
// must contain information about an object placed to a container that was
Copy link
Contributor

Choose a reason for hiding this comment

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

must contain information in what form? Lets describe, []byte is hard to guess

Copy link
Member Author

Choose a reason for hiding this comment

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

what form

i think this will somehow appear somewhere. at least it should appear before node's 0.44.0 release and contract's 0.21. however, currently node also uses it as is and the format is not fixed or described

contracts/container/contract.go Outdated Show resolved Hide resolved
tests/container_test.go Outdated Show resolved Hide resolved
require.NoError(t, err)

c.Invoke(t, stackitem.Null{}, "put", cnt.value, cnt.sig, cnt.pub, cnt.token, true)
c.Invoke(t, stackitem.Null{}, "putObject", metaInfo, nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

why is it OK w/o signatures?

Copy link
Member Author

Choose a reason for hiding this comment

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

for test purposes, container was added without any nodes (again, IMO signature verification should not be tested in this PR), so no nodes can add its signature but also no nodes are quired to do it, every iterator over node's put keys does nothing

require.NoError(t, err)

c.Invoke(t, stackitem.Null{}, "put", cnt.value, cnt.sig, cnt.pub, cnt.token, true)
c.Invoke(t, stackitem.Null{}, "putObject", metaInfo, nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

if we have tools to test whether notification event is expectedly thrown, lets do it. If no, suggest to create an issue for this. Suppose other methods/contracts need this too

Copy link
Member Author

Choose a reason for hiding this comment

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

we use neo-go's test framework. i tried my best, @roman-khimov, check if there is more optimal way to test events

// PutMeta is the same as [Put] (and exposed as put from the contract via
// overload), but allows container's meta-information be handled and notified
// using the chain.
func PutMeta(container []byte, signature interop.Signature, publicKey interop.PublicKey, token []byte, metaOnChain bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

we put container and just configure meta support, with this PutMeta name can confuse. I can suggest PutWithTunedMeta, but not very against ur proposal

Copy link
Member Author

Choose a reason for hiding this comment

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

i have adopted @roman-khimov's approach with method overloading. no one will call it putMeta, it is the same put but with one more arg. i really liked it

Copy link
Contributor

Choose a reason for hiding this comment

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

put but with one more arg - putWithMeta to me

@@ -238,6 +239,42 @@ func Update(script []byte, manifest []byte, data any) {
runtime.Log("container contract updated")
}

// PutObject registers successful object PUT operation and notifies about
Copy link
Contributor

Choose a reason for hiding this comment

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

what meaning do u put into registers here? In proposed implementation it verifies and notifies only

Copy link
Member Author

Choose a reason for hiding this comment

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

what meaning do u put

dont remember, maybe i meant how it really will be used: some meta service will wait for this notification. this is like the proof that an object exists. until this method is called it is not guaranteed

contracts/container/contract.go Outdated Show resolved Hide resolved
Containers now can be created with new `put` method with one more bool parameter
for meta-on-chain feature (TX must still be signed by the Alphabet, and it also
must check that container was created with this feature, see nspcc-dev/neofs-api#309).
If enabled, new `PutObject` method allows checking object meta information's
signature and producing corresponding notification. Closes #414.

Signed-off-by: Pavel Karpy <[email protected]>
Copy link
Member

@roman-khimov roman-khimov left a comment

Choose a reason for hiding this comment

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

OK for now.

@roman-khimov roman-khimov merged commit a49b3d7 into master Dec 3, 2024
8 checks passed
@roman-khimov roman-khimov deleted the feat/container-events branch December 3, 2024 18:45
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.

Per-container event feed
3 participants