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

Drop most of deploy configs #370

Closed
wants to merge 15 commits into from
Closed

Drop most of deploy configs #370

wants to merge 15 commits into from

Conversation

roman-khimov
Copy link
Member

No description provided.

@@ -47,25 +46,23 @@ func _deploy(data any, isUpdate bool) {
switchToNotary(ctx)
}

// netmap is not used for quite some time and deleted in 0.19.0.
if version < 19_000 {
storage.Delete(ctx, "netmapScriptHash")
Copy link
Contributor

Choose a reason for hiding this comment

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

lets check this in migration test

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

if len(args.addrNetmap) != interop.Hash160Len || len(args.addrProxy) != interop.Hash160Len {
panic("incorrect length of contract script hash")
if len(args.addrNetmap) != interop.Hash160Len {
args.addrNetmap = common.ResolveFSContract("netmap")
Copy link
Contributor

Choose a reason for hiding this comment

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

this looks OK if len(args.addrNetmap) == 0, otherwise, if it is not interop.Hash160Len, i suggest to panic (set correct address or completely omit, do not pass garbage)

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 behavior now is to derive address from NNS, so in most cases it will just get a proper hash. In the future non-NNS logic can be omitted completely. I'd leave it as is for now, tools that care pass correct things and we resolve from NNS otherwise.

Copy link
Member

Choose a reason for hiding this comment

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

i would say that check is better for me too. but if we know that it is kinda overriding now and NNS gonna be the only true way soon, i am OK with this change


// ResolveFSContract returns contract hash by name as registered in NNS or
// panics if it can't be resolved.
func ResolveFSContract(name string) interop.Hash160 {
Copy link
Contributor

Choose a reason for hiding this comment

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

nice candidate to be tested

Copy link
Member Author

Choose a reason for hiding this comment

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

It is tested in deployment scenarios.

Copy link
Contributor

Choose a reason for hiding this comment

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

fault conditions too? E.g. hello world instead of hash

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not a part of any public contract API, so a unit-test would require creating a specific contract to test just this thing. Push garbage in the deployment tests... Can be done, but I doubt it's useful. "hello world" is to be tried as an address and it will fail decoding miserably.

args.addrNNS = common.InferNNSHash()
}
if len(args.addrNetmap) != interop.Hash160Len {
args.addrNetmap = common.ResolveFSContract("netmap")
Copy link
Contributor

Choose a reason for hiding this comment

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

we've already resolved args.addrNNS and do this again in each common.ResolveFSContract. I'd add func common.ResolveNeoFSContractWithNNS(addrNNS, name) and call it in common.ResolveNeoFSContract and 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.

I'm not sure I like the resulting code, but OK.

@@ -166,6 +169,9 @@ func _deploy(data any, isUpdate bool) {
if len(args.addrID) != interop.Hash160Len {
args.addrID = common.ResolveFSContract("neofsid")
}
if len(args.nnsRoot) == 0 {
args.nnsRoot = nnsDefaultTLD
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be documented somewhere

addrNetmap, addrBalance, addrNNS = &ctrNetmap.Hash, &ctrBalance.Hash, &nnsHash
deployContainerContract(t, e, &ctrNetmap.Hash, &ctrBalance.Hash, &nnsHash)
} else {
_ = deployNeoFSIDContract(t, e) // Needed in this case to autoresolve.
Copy link
Contributor

Choose a reason for hiding this comment

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

easy to forget, so lets do inside deployContainerContractInt or at least write comment

Copy link
Member Author

Choose a reason for hiding this comment

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

deployContainerContractInt deploys container only, it doesn't care about dependencies. Dependencies are handled here.

Copy link
Contributor

Choose a reason for hiding this comment

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

this doesnt change my request

what Int stays for in deployContainerContractInt? Internal? Integer?

Copy link
Member Author

Choose a reason for hiding this comment

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

Internal.

common/nns.go Outdated
// ContractTLD is the default domain used by NeoFS contracts.
const ContractTLD = "neofs"

// InferNNSHash returns NNS contract hash by its well-known ID or panics if
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// InferNNSHash returns NNS contract hash by its well-known ID or panics if
// InferNNSHash returns NNS contract hash by [NNSID] or panics if

it's not well-known enough

common/nns.go Show resolved Hide resolved
common/nns.go Outdated Show resolved Hide resolved
neofsid/neofsid_contract.go Show resolved Hide resolved
@roman-khimov roman-khimov force-pushed the drop-deploy-configs branch 2 times, most recently from deada05 to 5e2a9cb Compare November 27, 2023 21:42
Signed-off-by: Roman Khimov <roman@nspcc.ru>
Proxy doesn't need them and it doesn't have any deploy parameters.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
Signed-off-by: Roman Khimov <roman@nspcc.ru>
Make them somewhat closer in style to RPC bindings.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
They're still there to override/keep compatibility, but they're not mandatory
now. Closes #325.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
Many contracts no longer have any deploy flags and while we've kept them for
update during transition this is no longer needed, there is no non-notary mode.
Make them completely parameterless.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
They're no longer needed.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
There is a nice well-known default.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
These still have parameters, but we can forget about the notary flag.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
Signed-off-by: Roman Khimov <roman@nspcc.ru>
Signed-off-by: Roman Khimov <roman@nspcc.ru>
Signed-off-by: Roman Khimov <roman@nspcc.ru>
We have a relatively stable set of configs now and this is just not needed,
updates can and should work with an empty config.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
Don't try interpreting data when there is no need to.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
41e483f was a bit more correct, we can't use
std.Atoi since it's intended for C#-compatible integers which means they will
be interpreted as integers for input and output (including signedness) and the
resulting byte set can differ from the input one leading to failed calls.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
tests/neofsid_test.go Show resolved Hide resolved
common/nns.go Outdated
// Contract name should be lowercased, should not include [ContractTLD]. Example
// values: "netmap", "container", etc. Relies on NeoFS-specific NNS setup, see
// [NNSID].
func ResolveFSContract(contractName string) interop.Hash160 {
Copy link
Member

Choose a reason for hiding this comment

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

what does FS stand for 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.

NeoFS.

Copy link
Member

Choose a reason for hiding this comment

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

but there is no Neo in the method's name. i can understand and accept it but do not think it is a good name

common/nns.go Show resolved Hide resolved
common/nns.go Show resolved Hide resolved
if len(args.addrNetmap) != interop.Hash160Len || len(args.addrProxy) != interop.Hash160Len {
panic("incorrect length of contract script hash")
if len(args.addrNetmap) != interop.Hash160Len {
args.addrNetmap = common.ResolveFSContract("netmap")
Copy link
Member

Choose a reason for hiding this comment

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

i would say that check is better for me too. but if we know that it is kinda overriding now and NNS gonna be the only true way soon, i am OK with this change

tests/container_test.go Show resolved Hide resolved
netmap/netmap_contract.go Outdated Show resolved Hide resolved
common/nns.go Show resolved Hide resolved
@roman-khimov roman-khimov deleted the drop-deploy-configs branch November 28, 2023 14:51
@roman-khimov roman-khimov mentioned this pull request Nov 28, 2023
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.

None yet

4 participants