nspcc-dev / neofs-contract

NeoFS smart-contract
GNU General Public License v3.0
10 stars 17 forks source link

Register contract's NNS domain record in deployment transaction #339

Open cthulhu-rider opened 1 year ago

cthulhu-rider commented 1 year ago

Currently management of NeoFS contracts on the Sidechain completely relies on NNS: addresses (hashes) are set in corresponding domain record and used by the whole system. However, now the procedure for deploying a contract and registering domain names is not an atomic operation, because executed in separate transactions. This complicates synchronization, and also puts at risk the use of NNS as a source of up-to-date information on the status of contracts.

Proposal

Register (set) contract NNS domain in deployment transaction via _deploy callback. Fail deployment if contract domain can't be registered.

I would make this a deployment option (extra parameter). But maybe it's worth to do by default or even always.

Pls share ur Thoughts @roman-khimov @AnnaShaleva

cthulhu-rider commented 1 year ago

currently NeoFS contracts are not destructured, but if suddenly - then it's worth processing the domain name back to deploy

roman-khimov commented 1 year ago

(extra parameter).

No parameters, please, my dream is zero _deploy parameters (at least in most of the cases).

But this makes sense otherwise. The only problem I see is ownership (contract owns a name of its own?) and renewals (it's the contract who will have to do it). But this can be solved.

AnnaShaleva commented 1 year ago

The overall idea LGTM.

ownership (contract owns a name of its own?) and renewals (it's the contract who will have to do it)

We can add a domain owner as a signer to the transaction at the specified fixed place in the signers list. After that during the contract's deployment inside _deploy method we can retrieve the transaction's signers using System.Runtime.GetScriptContainer and Ledger's getTransactionSigners APIs and provide that signer as an owner argument to the NNS's registration method. If the domain owner has a proper scope, then this scheme allows to preserve the old ownership scheme and doesn't use additional arguments on _deploy.