[#768] adm: Do not change frostfsid admin on update
Behave similarly to the netmap contract. Close #768 Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
d2d850786d
commit
d13e37f70b
1 changed files with 40 additions and 1 deletions
|
@ -550,7 +550,17 @@ func (c *initializeContext) getContractDeployData(ctrName string, keysParam []an
|
|||
nnsCs.Hash,
|
||||
"container")
|
||||
case frostfsIDContract:
|
||||
h, found, err := getFrostfsIDAdmin(viper.GetViper())
|
||||
var (
|
||||
h util.Uint160
|
||||
found bool
|
||||
err error
|
||||
)
|
||||
if method == updateMethodName {
|
||||
h, found, err = c.getFrostfsIDAdminFromContract()
|
||||
}
|
||||
if method != updateMethodName || err == nil && !found {
|
||||
h, found, err = getFrostfsIDAdmin(viper.GetViper())
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -588,6 +598,35 @@ func (c *initializeContext) getContractDeployData(ctrName string, keysParam []an
|
|||
return items, nil
|
||||
}
|
||||
|
||||
func (c *initializeContext) getFrostfsIDAdminFromContract() (util.Uint160, bool, error) {
|
||||
r := management.NewReader(c.ReadOnlyInvoker)
|
||||
cs, err := r.GetContractByID(1)
|
||||
if err != nil {
|
||||
return util.Uint160{}, false, fmt.Errorf("get nns contract: %w", err)
|
||||
}
|
||||
fidHash, err := nnsResolveHash(c.ReadOnlyInvoker, cs.Hash, domainOf(frostfsIDContract))
|
||||
if err != nil {
|
||||
return util.Uint160{}, false, fmt.Errorf("resolve frostfsid contract hash: %w", err)
|
||||
}
|
||||
item, err := unwrap.Item(c.ReadOnlyInvoker.Call(fidHash, "getAdmin"))
|
||||
if err != nil {
|
||||
return util.Uint160{}, false, fmt.Errorf("getAdmin: %w", err)
|
||||
}
|
||||
if _, ok := item.(stackitem.Null); ok {
|
||||
return util.Uint160{}, false, nil
|
||||
}
|
||||
|
||||
bs, err := item.TryBytes()
|
||||
if err != nil {
|
||||
return util.Uint160{}, true, fmt.Errorf("getAdmin: decode result: %w", err)
|
||||
}
|
||||
h, err := util.Uint160DecodeBytesBE(bs)
|
||||
if err != nil {
|
||||
return util.Uint160{}, true, fmt.Errorf("getAdmin: decode result: %w", err)
|
||||
}
|
||||
return h, true, nil
|
||||
}
|
||||
|
||||
func (c *initializeContext) getNetConfigFromNetmapContract() ([]stackitem.Item, error) {
|
||||
r := management.NewReader(c.ReadOnlyInvoker)
|
||||
cs, err := r.GetContractByID(1)
|
||||
|
|
Loading…
Reference in a new issue