-
Notifications
You must be signed in to change notification settings - Fork 17
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
Conversation
d2cfc28
to
35d6ac3
Compare
@@ -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") |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
container/container_contract.go
Outdated
args.addrNNS = common.InferNNSHash() | ||
} | ||
if len(args.addrNetmap) != interop.Hash160Len { | ||
args.addrNetmap = common.ResolveFSContract("netmap") |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
container/container_contract.go
Outdated
@@ -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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// 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
35d6ac3
to
a9271a3
Compare
deada05
to
5e2a9cb
Compare
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>
5e2a9cb
to
b8745c8
Compare
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NeoFS.
There was a problem hiding this comment.
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
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") |
There was a problem hiding this comment.
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
No description provided.